diff --git a/data/dynos.cpp.h b/data/dynos.cpp.h index 8ab23bc89..9e267c81b 100644 --- a/data/dynos.cpp.h +++ b/data/dynos.cpp.h @@ -736,6 +736,7 @@ void Print(const char *aFmt, Args... aArgs) { template void PrintConsole(const char *aFmt, Args... aArgs) { snprintf(gDjuiConsoleTmpBuffer, CONSOLE_MAX_TMP_BUFFER, aFmt, aArgs...); + sys_swap_backslashes(gDjuiConsoleTmpBuffer); djui_console_message_create(gDjuiConsoleTmpBuffer); } diff --git a/src/pc/djui/djui_console.h b/src/pc/djui/djui_console.h index 0186dba49..79d39d24d 100644 --- a/src/pc/djui/djui_console.h +++ b/src/pc/djui/djui_console.h @@ -7,7 +7,7 @@ struct DjuiConsole { bool scrolling; }; -#define CONSOLE_MAX_TMP_BUFFER 256 +#define CONSOLE_MAX_TMP_BUFFER 512 extern struct DjuiConsole* gDjuiConsole; extern bool gDjuiConsoleFocus; extern char gDjuiConsoleTmpBuffer[]; diff --git a/src/pc/loading.c b/src/pc/loading.c index 439e36ef4..4dc8d7e25 100644 --- a/src/pc/loading.c +++ b/src/pc/loading.c @@ -81,13 +81,7 @@ static bool loading_screen_on_render(struct DjuiBase* base) { snprintf(buffer, 256, "%s...", gCurrLoadingSegment.str); } - // swap around the backslashes - bool inColor = false; - for (u32 i = 0; i < length; i++) { - if (buffer[i] == '\\' && buffer[MIN(i+1,length)] == '#') { inColor = true; } - if (buffer[i] == '\\' && !inColor) { buffer[i] = '/'; } - if (buffer[i] == '\\' && inColor && buffer[MIN(i+1,length)] != '#') { inColor = false; } - } + sys_swap_backslashes(buffer); } djui_text_set_text(sLoading->loadingDesc, buffer); djui_base_set_location(&sLoading->loadingDesc->base, 0, windowHeight - 250); diff --git a/src/pc/platform.c b/src/pc/platform.c index 8a02fc271..5a2b5675b 100644 --- a/src/pc/platform.c +++ b/src/pc/platform.c @@ -66,6 +66,16 @@ const char *sys_file_name(const char *fpath) { return sep + 1; } +void sys_swap_backslashes(char* buffer) { + size_t length = strlen(buffer); + bool inColor = false; + for (u32 i = 0; i < length; i++) { + if (buffer[i] == '\\' && buffer[MIN(i + 1, length)] == '#') { inColor = true; } + if (buffer[i] == '\\' && !inColor) { buffer[i] = '/'; } + if (buffer[i] == '\\' && inColor && buffer[MIN( i + 1, length)] != '#') { inColor = false; } + } +} + /* this calls a platform-specific impl function after forming the error message */ static void sys_fatal_impl(const char *msg) __attribute__ ((noreturn)); diff --git a/src/pc/platform.h b/src/pc/platform.h index 3ee1bdb34..2a1dc3421 100644 --- a/src/pc/platform.h +++ b/src/pc/platform.h @@ -22,6 +22,7 @@ const char *sys_user_path(void); const char *sys_exe_path(void); const char *sys_file_extension(const char *fpath); const char *sys_file_name(const char *fpath); +void sys_swap_backslashes(char* buffer); // shows an error message in some way and terminates the game void sys_fatal(const char *fmt, ...) __attribute__ ((noreturn));