From 1e89fcc4d4e04890a27c759cf59984cee0a55abd Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 20 Nov 2023 19:42:29 -0800 Subject: [PATCH] Keep console messages around until the final djui_init() --- data/dynos_bin_gfx.cpp | 1 + src/pc/djui/djui_console.c | 42 +++++++++++++++++++++++++++++++++++++- src/pc/djui/djui_console.h | 1 + src/pc/pc_main.c | 1 + 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/data/dynos_bin_gfx.cpp b/data/dynos_bin_gfx.cpp index bef3a4ac8..ce8ad05eb 100644 --- a/data/dynos_bin_gfx.cpp +++ b/data/dynos_bin_gfx.cpp @@ -747,6 +747,7 @@ static void ParseGfxSymbol(GfxData* aGfxData, DataNode* aNode, Gfx*& aHead, gfx_symbol_5(gsDPLoadBlock); gfx_symbol_2(gsDPSetRenderMode, false); gfx_symbol_2(gsSPGeometryMode, false); + gfx_symbol_2(gsSPGeometryModeSetFirst, false); gfx_symbol_6(gsDPSetPrimColor); gfx_symbol_4(gsDPSetEnvColor); gfx_symbol_4(gsDPSetFogColor); diff --git a/src/pc/djui/djui_console.c b/src/pc/djui/djui_console.c index 1dae8f854..342d35462 100644 --- a/src/pc/djui/djui_console.c +++ b/src/pc/djui/djui_console.c @@ -10,6 +10,42 @@ struct DjuiConsole* gDjuiConsole = NULL; bool gDjuiConsoleFocus = false; char gDjuiConsoleTmpBuffer[CONSOLE_MAX_TMP_BUFFER] = ""; u32 sDjuiConsoleMessages = 0; +bool sDjuiConsoleQueueMessages = true; + +struct ConsoleQueuedMessage { + char* message; + struct ConsoleQueuedMessage* next; +}; + +struct ConsoleQueuedMessage* sConsoleQueuedMessages = NULL; + +static void djui_console_message_queue(char* message) { + struct ConsoleQueuedMessage* queued = malloc(sizeof(struct ConsoleQueuedMessage)); + queued->message = strdup(message); + queued->next = NULL; + if (sConsoleQueuedMessages == NULL) { + sConsoleQueuedMessages = queued; + return; + } + + struct ConsoleQueuedMessage* entry = sConsoleQueuedMessages; + while (entry->next) { entry = entry->next; } + entry->next = queued; +} + +void djui_console_message_dequeue(void) { + if (!gDjuiConsole) { return; } + sDjuiConsoleQueueMessages = false; + struct ConsoleQueuedMessage* entry = sConsoleQueuedMessages; + while (entry) { + struct ConsoleQueuedMessage* next = entry->next; + djui_console_message_create(entry->message); + free(entry->message); + free(entry); + entry = next; + } + sConsoleQueuedMessages = NULL; +} bool djui_console_render(struct DjuiBase* base) { djui_base_set_size(base, gDjuiRoot->base.width.value, gDjuiRoot->base.height.value * 0.5f); @@ -66,8 +102,12 @@ static bool djui_console_on_key_down(UNUSED struct DjuiBase* base, int scancode) } void djui_console_message_create(const char* message) { - if (!gDjuiConsole) { return; } + if (sDjuiConsoleQueueMessages || !gDjuiConsole) { + djui_console_message_queue(message); + return; + } djui_base_compute_tree(&gDjuiConsole->base); + struct DjuiBase* cfBase = &gDjuiConsole->flow->base; f32 maxTextWidth = gDjuiConsole->base.comp.width - gDjuiConsole->base.padding.left.value - gDjuiConsole->base.padding.right.value; diff --git a/src/pc/djui/djui_console.h b/src/pc/djui/djui_console.h index cb7c621f6..0186dba49 100644 --- a/src/pc/djui/djui_console.h +++ b/src/pc/djui/djui_console.h @@ -12,6 +12,7 @@ extern struct DjuiConsole* gDjuiConsole; extern bool gDjuiConsoleFocus; extern char gDjuiConsoleTmpBuffer[]; +void djui_console_message_dequeue(void); void djui_console_message_create(const char* message); void djui_console_toggle(void); struct DjuiConsole* djui_console_create(void); diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index cf5aab403..e122f5c49 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -349,6 +349,7 @@ int main(int argc, char *argv[]) { djui_init(); djui_unicode_init(); djui_init_late(); + djui_console_message_dequeue(); // Init network if (gCLIOpts.Network == NT_CLIENT) {