From d38a33de8fbc57a4c20a5e811da4492b0fb8749b Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 24 Mar 2024 15:45:20 +0100 Subject: [PATCH] Update to 35cdadf74d39e03b59c153d7df7653a5bce7bd99 --- src/Misc.gd | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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