diff --git a/arm9/source/common/ui.c b/arm9/source/common/ui.c index 104e1f0..57c6fd4 100644 --- a/arm9/source/common/ui.c +++ b/arm9/source/common/ui.c @@ -309,6 +309,26 @@ u32 GetFontHeight(void) { return font_height; } +void MultiLineString(char* dest, const char* orig, int llen, int maxl) { + char* ptr_o = (char*) orig; + char* ptr_d = (char*) dest; + for (int l = 0; l < maxl; l++) { + int len = strnlen(ptr_o, llen+1); + snprintf(ptr_d, llen+1, "%.*s", llen, ptr_o); + ptr_o += min(len, llen); + ptr_d += min(len, llen); + if (len <= llen) break; + *(ptr_d++) = '\n'; + } + + // string too long? + if (!maxl) *dest = '\0'; + else if (*ptr_o) { + if (llen >= 3) snprintf(ptr_d - 4, 4, "..."); + else *(ptr_d-1) = '\0'; + } +} + void WordWrapString(char* str, int llen) { char* last_brk = str - 1; char* last_spc = str - 1; diff --git a/arm9/source/common/ui.h b/arm9/source/common/ui.h index 36def5c..626ae7d 100644 --- a/arm9/source/common/ui.h +++ b/arm9/source/common/ui.h @@ -67,6 +67,7 @@ u32 GetDrawStringWidth(const char* str); u32 GetFontWidth(void); u32 GetFontHeight(void); +void MultiLineString(char* dest, const char* orig, int llen, int maxl); void WordWrapString(char* str, int llen); void ResizeString(char* dest, const char* orig, int nsize, int tpos, bool align_right); void TruncateString(char* dest, const char* orig, int nsize, int tpos); diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c index ebcc534..29f3df1 100644 --- a/arm9/source/godmode.c +++ b/arm9/source/godmode.c @@ -952,12 +952,12 @@ u32 StandardCopy(u32* cursor, u32* scroll) { u32 DirFileAttrMenu(const char* path, const char *name) { bool drv = (path[2] == '\0'); bool vrt = (!drv); // will be checked below - char namestr[32], datestr[32], attrstr[128], sizestr[192]; + char namestr[128], datestr[32], attrstr[128], sizestr[192]; FILINFO fno; u8 new_attrib; - // create truncated name string - TruncateString(namestr, name, 31, 8); + // create mutiline name string + MultiLineString(namestr, name, 31, 4); // preparations: create file info, date string if (!drv) {