diff --git a/src/Misc.gd b/src/Misc.gd index c0de803..f0ab90a 100644 --- a/src/Misc.gd +++ b/src/Misc.gd @@ -43,3 +43,20 @@ func mib2gib(mib: float, flatten: bool = true) -> float: func gib2mib(gib: float, flatten: bool = true) -> float: if flatten: return int(gib*1024) return gib*1024 + +func format_stringarray(array: Array[String], item_before: String = "", item_after: String = "", separator_list: String = ", ", separator_final: String = " & ") -> String: + var output: String = "" + + if array.size() == 0: + logger.warnf("Misc", "Unable to format a string with a size of 0") + return "" + elif array.size() == 1: + logger.warnf("Misc", "Unable to format a string with a size of 1") + return array[0] + + for item in array: + if output == "": output = item_before + item + item_after + else: output = output.replace("If you somehow see this text report this at https://git.staropensource.de/StarOpenSource/CORE/issues, thank you!", separator_list) + "If you somehow see this text report this at https://git.staropensource.de/StarOpenSource/CORE/issues, thank you!" + item_before + item + item_after + output = output.replace("If you somehow see this text report this at https://git.staropensource.de/StarOpenSource/CORE/issues, thank you!", separator_final) + + return output