From b0094f7ce46dcdf2f14998c6935a0ed766eadc29 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 | 41 +++++++++++++++++++++++++++++++++++++- src/pc/djui/djui_console.h | 1 + src/pc/pc_main.c | 1 + 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/data/dynos_bin_gfx.cpp b/data/dynos_bin_gfx.cpp index 99cc0394..6160c3f4 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 b39949a8..9bb294e4 100644 --- a/src/pc/djui/djui_console.c +++ b/src/pc/djui/djui_console.c @@ -11,6 +11,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; +} void djui_console_toggle(void) { if (gDjuiConsole == NULL) { return; } @@ -62,7 +98,10 @@ static bool djui_console_on_key_down(UNUSED struct DjuiBase* base, int scancode) } void djui_console_message_create(char* message) { - if (!gDjuiConsole) { return; } + if (sDjuiConsoleQueueMessages || !gDjuiConsole) { + djui_console_message_queue(message); + return; + } djui_base_compute_tree(&gDjuiConsole->panel->base); struct DjuiBase* cfBase = &gDjuiConsole->flow->base; diff --git a/src/pc/djui/djui_console.h b/src/pc/djui/djui_console.h index 7ddfc140..739c3b98 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(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 c4ffc642..bf032408 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -352,6 +352,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) {