From 9b502346a77067e8f7f69847026341b62fca6628 Mon Sep 17 00:00:00 2001 From: EmeraldLockdown <86802223+EmeraldLoc@users.noreply.github.com> Date: Sat, 28 Oct 2023 07:18:23 +0000 Subject: [PATCH] Console Overhaul (#490) Completely redid the console ui to look more like the rest of coop Added log_to_console and djui_console_toggle to lua Made the keybind to activate it the tilda key (~) instead of ctrl+f1 --- autogen/autogen.sh | 2 +- autogen/convert_functions.py | 4 +- autogen/lua_definitions/functions.lua | 11 +++++ docs/lua/functions-3.md | 24 +++++++++++ docs/lua/functions-5.md | 20 +++++++++ docs/lua/functions.md | 6 +++ lang/Czech.ini | 4 ++ lang/Dutch.ini | 4 ++ lang/English.ini | 4 ++ lang/French.ini | 4 ++ lang/German.ini | 4 ++ lang/Italian.ini | 4 ++ lang/Portuguese.ini | 4 ++ lang/Russian.ini | 4 ++ lang/Spanish.ini | 4 ++ src/pc/configfile.c | 1 + src/pc/configfile.h | 1 + src/pc/djui/djui.c | 1 - src/pc/djui/djui_console.c | 54 ++++++++++--------------- src/pc/djui/djui_console.h | 2 +- src/pc/djui/djui_interactable.c | 15 ++----- src/pc/djui/djui_panel_controls_extra.c | 3 +- src/pc/lua/smlua_functions_autogen.c | 41 +++++++++++++++++++ src/pc/lua/utils/smlua_misc_utils.c | 7 ++++ src/pc/lua/utils/smlua_misc_utils.h | 1 + 25 files changed, 180 insertions(+), 49 deletions(-) diff --git a/autogen/autogen.sh b/autogen/autogen.sh index 4d46dec0..6105d698 100755 --- a/autogen/autogen.sh +++ b/autogen/autogen.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash python3 ./autogen/convert_structs.py $1 python3 ./autogen/convert_functions.py $1 python3 ./autogen/convert_constants.py $1 diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 5065228d..cfae7484 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -30,6 +30,7 @@ in_files = [ "src/game/rumble_init.c", "src/pc/djui/djui_popup.h", "src/pc/network/network_utils.h", + "src/pc/djui/djui_console.h", "src/pc/djui/djui_chat_message.h", "src/game/interaction.h", "src/game/level_info.h", @@ -91,8 +92,9 @@ override_disallowed_functions = { "src/game/mario_actions_object.c": [ "^[us]32 act_.*" ], "src/game/mario_actions_stationary.c": [ "^[us]32 act_.*" ], "src/game/mario_actions_submerged.c": [ "^[us]32 act_.*" ], - "src/game/mario_step.h": [ " stub_mario_step", "transfer_bully_speed"], + "src/game/mario_step.h": [ " stub_mario_step", "transfer_bully_speed" ], "src/game/mario.h": [ " init_mario" ], + "src/pc/djui/djui_console.h": [ " djui_console_create", "djui_console_message_create" ], "src/pc/djui/djui_chat_message.h": [ "create_from" ], "src/game/interaction.h": [ "process_interactions", "_handle_" ], "src/game/sound_init.h": [ "_loop_", "thread4_", "set_sound_mode" ], diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 10a274f2..8197707c 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3627,6 +3627,11 @@ function djui_chat_message_create(message) -- ... end +--- @return nil +function djui_console_toggle() + -- ... +end + --- @return number function djui_hud_get_mouse_x() -- ... @@ -8774,6 +8779,12 @@ function is_transition_playing() -- ... end +--- @param message string +--- @return nil +function log_to_console(message) + -- ... +end + --- @param name string --- @param level integer --- @param area integer diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index 79133f12..6d4c88dd 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -2050,6 +2050,30 @@
+--- +# functions from djui_console.h + +
+ + +## [djui_console_toggle](#djui_console_toggle) + +### Lua Example +`djui_console_toggle()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void djui_console_toggle(void);` + +[:arrow_up_small:](#) + +
+ --- # functions from djui_hud_utils.h diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index 4a76c5a4..344c9deb 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -1261,6 +1261,26 @@
+## [log_to_console](#log_to_console) + +### Lua Example +`log_to_console(message)` + +### Parameters +| Field | Type | +| ----- | ---- | +| message | `string` | + +### Returns +- None + +### C Prototype +`void log_to_console(const char* message);` + +[:arrow_up_small:](#) + +
+ ## [movtexqc_register](#movtexqc_register) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 232cf7e5..655f2f94 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -716,6 +716,11 @@
+- djui_console.h + - [djui_console_toggle](functions-3.md#djui_console_toggle) + +
+ - djui_hud_utils.h - [djui_hud_get_mouse_x](functions-3.md#djui_hud_get_mouse_x) - [djui_hud_get_mouse_y](functions-3.md#djui_hud_get_mouse_y) @@ -1631,6 +1636,7 @@ - [hud_show](functions-5.md#hud_show) - [is_game_paused](functions-5.md#is_game_paused) - [is_transition_playing](functions-5.md#is_transition_playing) + - [log_to_console](functions-5.md#log_to_console) - [movtexqc_register](functions-5.md#movtexqc_register) - [play_transition](functions-5.md#play_transition) - [save_file_get_using_backup_slot](functions-5.md#save_file_get_using_backup_slot) diff --git a/lang/Czech.ini b/lang/Czech.ini index 637f9443..dc13e0a1 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -102,6 +102,7 @@ D_LEFT = "D-Pad vlevo" D_RIGHT = "D-Pad vpravo" X = "X" Y = "Y" +CONSOLE = "Řídicí panel" PREV = "Před Stránka" NEXT = "Další Strana" @@ -245,6 +246,9 @@ MENU_OPTIONS = "Nastavení hlavního menu" DEBUG = "Debug" LANGUAGE = "Jazyk" +[CONSOLE] +CONSOLE = "ŘÍDICÍ PANEL" + [MODLIST] MODS = "MODY" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index b2f8ec1f..0184f5a6 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -101,6 +101,7 @@ D_LEFT = "D Links" D_RIGHT = "D Rechts" X = "X" Y = "Y" +CONSOLE = "Logboek" PREV = "Vori Bladzijde" NEXT = "Volg Bladzijde" @@ -244,6 +245,9 @@ MENU_OPTIONS = "Menu Instellingen" DEBUG = "Debug" LANGUAGE = "Taal" +[CONSOLE] +CONSOLE = "LOGBOEK" + [MODLIST] MODS = "MODS" diff --git a/lang/English.ini b/lang/English.ini index 30f24953..44313959 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -102,6 +102,7 @@ D_LEFT = "D Left" D_RIGHT = "D Right" X = "X" Y = "Y" +CONSOLE = "Console" PREV = "Prev Page" NEXT = "Next Page" @@ -245,6 +246,9 @@ MENU_OPTIONS = "Menu Options" DEBUG = "Debug" LANGUAGE = "Language" +[CONSOLE] +CONSOLE = "CONSOLE" + [MODLIST] MODS = "MODS" diff --git a/lang/French.ini b/lang/French.ini index 758f6a3e..5d8facf8 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -102,6 +102,7 @@ D_LEFT = "D Gauche" D_RIGHT = "D Droite" X = "X" Y = "Y" +CONSOLE = "Console" PREV = "Page Préc" NEXT = "Page Suiv" @@ -245,6 +246,9 @@ MENU_OPTIONS = "Options du menu" DEBUG = "Débogage" LANGUAGE = "Langue" +[CONSOLE] +CONSOLE = "CONSOLE" + [MODLIST] MODS = "MODS" diff --git a/lang/German.ini b/lang/German.ini index a10b9c94..869f2e23 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -102,6 +102,7 @@ D_LEFT = "D Links" D_RIGHT = "D Rechts" X = "X" Y = "Y" +CONSOLE = "Konsole" PREV = "Vorh Seite" NEXT = "Näch Seite" @@ -245,6 +246,9 @@ MENU_OPTIONS = "Menü Optionen" DEBUG = "Debug" LANGUAGE = "Sprache" +[CONSOLE] +CONSOLE = "KONSOLE" + [MODLIST] MODS = "MODIFIKATIONEN" diff --git a/lang/Italian.ini b/lang/Italian.ini index 63af67ed..5209f6f5 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -100,6 +100,7 @@ D_LEFT = "D Sinistra" D_RIGHT = "D Destra" X = "X" Y = "Y" +CONSOLE = "Consolle" PREV = "Pagina Prec" NEXT = "Pagina Succ" @@ -242,6 +243,9 @@ MENU_OPTIONS = "Opzioni Menù" DEBUG = "Debug" LANGUAGE = "Lingua" +[CONSOLE] +CONSOLE = "CONSOLE" + [MODLIST] MODS = "MODS" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index 33b53c80..27529bdb 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -102,6 +102,7 @@ D_LEFT = "D LEFT" D_RIGHT = "D RIGHT" X = "X" Y = "Y" +CONSOLE = "Console" PREV = "Página Ante" NEXT = "Próx Página" @@ -245,6 +246,9 @@ MENU_OPTIONS = "Opções de Menu" DEBUG = "Debug" LANGUAGE = "Idioma" +[CONSOLE] +CONSOLE = "CONSOLE" + [MODLIST] MODS = "MODS" diff --git a/lang/Russian.ini b/lang/Russian.ini index 639fad9a..d3eae869 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -101,6 +101,7 @@ D_LEFT = "Крестовина влево" D_RIGHT = "Крестовина вправо" X = "X" Y = "Y" +CONSOLE = "пульт" PREV = "Пред Cтраница" NEXT = "След Cтраница" @@ -244,6 +245,9 @@ MENU_OPTIONS = "Параметры меню" DEBUG = "Отладка" LANGUAGE = "Язык" +[CONSOLE] +CONSOLE = "пульт" + [MODLIST] MODS = "MODS" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index 8d9f64f4..c115f85a 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -102,6 +102,7 @@ D_LEFT = "Cruz Izquierda" D_RIGHT = "Cruz Derecha" X = "X" Y = "Y" +CONSOLE = "Consola" PREV = "Pagina Ante" NEXT = "Sigu Página" @@ -245,6 +246,9 @@ MENU_OPTIONS = "Opciones del menú" DEBUG = "Depuración" LANGUAGE = "Idioma" +[CONSOLE] +CONSOLE = "CONSOLA" + [MODLIST] MODS = "MODS" diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 9c9cef4b..be09f754 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -97,6 +97,7 @@ unsigned int configKeyDUp[MAX_BINDS] = { 0x0147, 0x100b, VK_INVALID unsigned int configKeyDDown[MAX_BINDS] = { 0x014f, 0x100c, VK_INVALID }; unsigned int configKeyDLeft[MAX_BINDS] = { 0x0153, 0x100d, VK_INVALID }; unsigned int configKeyDRight[MAX_BINDS] = { 0x0151, 0x100e, VK_INVALID }; +unsigned int configKeyConsole[MAX_BINDS] = { 0x0029, 0x003B, VK_INVALID }; unsigned int configKeyPrevPage[MAX_BINDS] = { 0x0016, VK_INVALID, VK_INVALID }; unsigned int configKeyNextPage[MAX_BINDS] = { 0x0018, VK_INVALID, VK_INVALID }; unsigned int configStickDeadzone = 16; // 16*DEADZONE_STEP=4960 (the original default deadzone) diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 17f74a9a..d4081db2 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -56,6 +56,7 @@ extern unsigned int configKeyDUp[]; extern unsigned int configKeyDDown[]; extern unsigned int configKeyDLeft[]; extern unsigned int configKeyDRight[]; +extern unsigned int configKeyConsole[]; extern unsigned int configKeyPrevPage[]; extern unsigned int configKeyNextPage[]; extern unsigned int configStickDeadzone; diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c index 13884403..10a09f39 100644 --- a/src/pc/djui/djui.c +++ b/src/pc/djui/djui.c @@ -135,7 +135,6 @@ void djui_render(void) { } djui_cursor_update(); - djui_base_render(&gDjuiConsole->base); djui_interactable_update(); djui_gfx_displaylist_end(); } diff --git a/src/pc/djui/djui_console.c b/src/pc/djui/djui_console.c index 3d39247a..359e1f0a 100644 --- a/src/pc/djui/djui_console.c +++ b/src/pc/djui/djui_console.c @@ -1,6 +1,7 @@ #include #include #include "djui.h" +#include "djui_panel_menu.h" #include "djui_console.h" #define MAX_CONSOLE_MESSAGES 500 @@ -10,26 +11,14 @@ bool gDjuiConsoleFocus = false; char gDjuiConsoleTmpBuffer[CONSOLE_MAX_TMP_BUFFER] = ""; u32 sDjuiConsoleMessages = 0; -bool djui_console_render(struct DjuiBase* base) { - djui_base_set_size(base, gDjuiRoot->base.width.value, gDjuiRoot->base.height.value * 0.6f); - - djui_rect_render(base); - return true; -} - -static void djui_console_destroy(struct DjuiBase* base) { - struct DjuiConsole* console = (struct DjuiConsole*)base; - free(console); -} - void djui_console_toggle(void) { if (gDjuiConsole == NULL) { return; } gDjuiConsoleFocus = !gDjuiConsoleFocus; - djui_base_set_visible(&gDjuiConsole->base, gDjuiConsoleFocus); + djui_base_set_visible(&gDjuiConsole->panel->base, gDjuiConsoleFocus); if (gDjuiConsoleFocus) { if (gDjuiChatBoxFocus) { djui_chat_box_toggle(); } - djui_interactable_set_input_focus(&gDjuiConsole->base); + djui_interactable_set_input_focus(&gDjuiConsole->panel->base); } else { djui_interactable_set_input_focus(NULL); } @@ -37,19 +26,20 @@ void djui_console_toggle(void) { static bool djui_console_on_key_down(UNUSED struct DjuiBase* base, int scancode) { if (gDjuiConsole == NULL) { return false; } - f32 yMax = gDjuiConsole->base.comp.height - gDjuiConsole->flow->base.height.value; + struct DjuiBase* body = djui_three_panel_get_body(gDjuiConsole->panel); + f32 yMax = body->height.value - gDjuiConsole->flow->base.height.value; f32* yValue = &gDjuiConsole->flow->base.y.value; bool canScrollUp = (*yValue > yMax); bool canScrollDown = (*yValue < 0); - f32 pageAmount = gDjuiConsole->base.comp.height * 3.0f / 4.0f; + f32 pageAmount = body->height.value; switch (scancode) { case SCANCODE_UP: - if (canScrollUp) { *yValue = fmax(*yValue - 15, yMax); } + if (canScrollUp) { *yValue = fmax(*yValue - 30, yMax); } break; case SCANCODE_DOWN: - if (canScrollDown) { *yValue = fmin(*yValue + 15, 0); } + if (canScrollDown) { *yValue = fmin(*yValue + 30, 0); } break; case SCANCODE_PAGE_UP: if (canScrollUp) { *yValue = fmax(*yValue - pageAmount, yMax); } @@ -66,10 +56,10 @@ static bool djui_console_on_key_down(UNUSED struct DjuiBase* base, int scancode) void djui_console_message_create(char* message) { if (!gDjuiConsole) { return; } - djui_base_compute_tree(&gDjuiConsole->base); + djui_base_compute_tree(&gDjuiConsole->panel->base); struct DjuiBase* cfBase = &gDjuiConsole->flow->base; - f32 maxTextWidth = gDjuiConsole->base.comp.width - gDjuiConsole->base.padding.left.value - gDjuiConsole->base.padding.right.value; + f32 maxTextWidth = gDjuiConsole->panel->base.comp.width - gDjuiConsole->panel->base.padding.left.value - gDjuiConsole->panel->base.padding.right.value - 20; struct DjuiText* text = djui_text_create(cfBase, message); struct DjuiBase* tBase = &text->base; @@ -107,25 +97,25 @@ void djui_console_message_create(char* message) { struct DjuiConsole* djui_console_create(void) { if (gDjuiConsole != NULL) { - djui_base_destroy(&gDjuiConsole->base); + djui_base_destroy(&gDjuiConsole->panel->base); gDjuiConsole = NULL; } struct DjuiConsole* console = calloc(1, sizeof(struct DjuiConsole)); - struct DjuiBase* base = &console->base; + struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(CONSOLE, CONSOLE)); + djui_three_panel_set_body_size(panel, 750); + console->panel = panel; - djui_base_init(NULL, base, djui_console_render, djui_console_destroy); - djui_base_set_size_type(base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE); - djui_base_set_size(base, gDjuiRoot->base.width.value, gDjuiRoot->base.height.value * 0.6f); - djui_base_set_alignment(base, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP); - djui_base_set_color(base, 0, 0, 0, 250); - djui_base_set_padding(base, 0, 8, 8, 8); - djui_base_set_visible(base, false); + djui_base_set_alignment(&panel->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER); + djui_base_set_size_type(&panel->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&panel->base, 850, 750 + (32 + 16) + 32 + 32); + djui_base_set_visible(&panel->base, false); - djui_interactable_create(base, NULL); - djui_interactable_hook_key(base, djui_console_on_key_down, NULL); + djui_interactable_create(&panel->base, NULL); + djui_interactable_hook_key(&panel->base, djui_console_on_key_down, NULL); - struct DjuiFlowLayout* flow = djui_flow_layout_create(base); + struct DjuiBase* body = djui_three_panel_get_body(panel); + struct DjuiFlowLayout* flow = djui_flow_layout_create(body); struct DjuiBase* cfBase = &flow->base; djui_base_set_alignment(cfBase, DJUI_HALIGN_LEFT, DJUI_VALIGN_BOTTOM); djui_base_set_location(cfBase, 0, 0); diff --git a/src/pc/djui/djui_console.h b/src/pc/djui/djui_console.h index 5163830f..7ddfc140 100644 --- a/src/pc/djui/djui_console.h +++ b/src/pc/djui/djui_console.h @@ -2,7 +2,7 @@ #include "djui.h" struct DjuiConsole { - struct DjuiBase base; + struct DjuiThreePanel* panel; struct DjuiFlowLayout* flow; bool scrolling; }; diff --git a/src/pc/djui/djui_interactable.c b/src/pc/djui/djui_interactable.c index 7b5f322a..524ae1de 100644 --- a/src/pc/djui/djui_interactable.c +++ b/src/pc/djui/djui_interactable.c @@ -18,8 +18,6 @@ #define CALL_CALLBACK(x) if (base->interactable->x != NULL) { base->interactable->x(base); } #define CALL_CALLBACK_PARAM(x, y) if (base->interactable->x != NULL) { base->interactable->x(base, y); } -#define SCANCODE_F1 59 - enum PadHoldDirection { PAD_HOLD_DIR_NONE, PAD_HOLD_DIR_UP, PAD_HOLD_DIR_DOWN, PAD_HOLD_DIR_LEFT, PAD_HOLD_DIR_RIGHT }; static enum PadHoldDirection sKeyboardHoldDirection = PAD_HOLD_DIR_NONE; static u16 sKeyboardButtons = 0; @@ -35,7 +33,6 @@ bool gInteractableOverridePad = false; OSContPad gInteractablePad = { 0 }; static OSContPad sLastInteractablePad = { 0 }; static int sLastMouseButtons = 0; -static bool sControlDown = false; static void djui_interactable_update_style(struct DjuiBase* base) { if (base == NULL) { return; } @@ -184,7 +181,7 @@ void djui_interactable_set_binding(struct DjuiBase* base) { } void djui_interactable_set_input_focus(struct DjuiBase* base) { - if (gDjuiConsoleFocus && base != &gDjuiConsole->base) { + if (gDjuiConsoleFocus && base != &gDjuiConsole->panel->base) { return; } @@ -203,10 +200,8 @@ bool djui_interactable_on_key_down(int scancode) { return true; } - if (scancode == SCANCODE_CONTROL_LEFT) { - sControlDown = true; - } else if (sControlDown && scancode == SCANCODE_F1) { - djui_console_toggle(); + for (int i = 0; i < MAX_BINDS; i++) { + if (scancode == (int)configKeyConsole[i]) { djui_console_toggle(); } } bool keyFocused = (gInteractableFocus != NULL) @@ -305,10 +300,6 @@ void djui_interactable_on_key_up(int scancode) { } } - if (scancode == SCANCODE_CONTROL_LEFT) { - sControlDown = false; - } - if (keyFocused) { gInteractableFocus->interactable->on_key_up(gInteractableFocus, scancode); sKeyboardHoldDirection = PAD_HOLD_DIR_NONE; diff --git a/src/pc/djui/djui_panel_controls_extra.c b/src/pc/djui/djui_panel_controls_extra.c index 09479b6e..25e8e482 100644 --- a/src/pc/djui/djui_panel_controls_extra.c +++ b/src/pc/djui/djui_panel_controls_extra.c @@ -4,7 +4,7 @@ #include "src/pc/configfile.h" void djui_panel_controls_extra_create(struct DjuiBase* caller) { - f32 bindBodyHeight = 28 * 10 + 1 * 7; + f32 bindBodyHeight = 28 * 11 + 1 * 10; struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(CONTROLS, CONTROLS)); struct DjuiBase* body = djui_three_panel_get_body(panel); @@ -23,6 +23,7 @@ void djui_panel_controls_extra_create(struct DjuiBase* caller) { djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_RIGHT), configKeyDRight); djui_bind_create(&bindBody->base, DLANG(CONTROLS, X), configKeyX); djui_bind_create(&bindBody->base, DLANG(CONTROLS, Y), configKeyY); + djui_bind_create(&bindBody->base, DLANG(CONTROLS, CONSOLE), configKeyConsole); djui_bind_create(&bindBody->base, DLANG(CONTROLS, PREV), configKeyPrevPage); djui_bind_create(&bindBody->base, DLANG(CONTROLS, NEXT), configKeyNextPage); } diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 5fcf03d1..3f90957c 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -13,6 +13,7 @@ #include "src/game/mario.h" #include "src/pc/djui/djui_popup.h" #include "src/pc/network/network_utils.h" +#include "src/pc/djui/djui_console.h" #include "src/pc/djui/djui_chat_message.h" #include "src/game/interaction.h" #include "src/game/level_info.h" @@ -12064,6 +12065,25 @@ int smlua_func_djui_chat_message_create(lua_State* L) { return 1; } + //////////////////// + // djui_console.h // +//////////////////// + +int smlua_func_djui_console_toggle(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_console_toggle", 0, top); + return 0; + } + + + djui_console_toggle(); + + return 1; +} + ////////////////////// // djui_hud_utils.h // ////////////////////// @@ -28953,6 +28973,23 @@ int smlua_func_is_transition_playing(UNUSED lua_State* L) { return 1; } +int smlua_func_log_to_console(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "log_to_console", 1, top); + return 0; + } + + const char* message = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "log_to_console"); return 0; } + + log_to_console(message); + + return 1; +} + int smlua_func_movtexqc_register(lua_State* L) { if (L == NULL) { return 0; } @@ -31630,6 +31667,9 @@ void smlua_bind_functions_autogen(void) { // djui_chat_message.h smlua_bind_function(L, "djui_chat_message_create", smlua_func_djui_chat_message_create); + // djui_console.h + smlua_bind_function(L, "djui_console_toggle", smlua_func_djui_console_toggle); + // djui_hud_utils.h smlua_bind_function(L, "djui_hud_get_mouse_x", smlua_func_djui_hud_get_mouse_x); smlua_bind_function(L, "djui_hud_get_mouse_y", smlua_func_djui_hud_get_mouse_y); @@ -32489,6 +32529,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "hud_show", smlua_func_hud_show); smlua_bind_function(L, "is_game_paused", smlua_func_is_game_paused); smlua_bind_function(L, "is_transition_playing", smlua_func_is_transition_playing); + smlua_bind_function(L, "log_to_console", smlua_func_log_to_console); smlua_bind_function(L, "movtexqc_register", smlua_func_movtexqc_register); smlua_bind_function(L, "play_transition", smlua_func_play_transition); smlua_bind_function(L, "save_file_get_using_backup_slot", smlua_func_save_file_get_using_backup_slot); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 0433b316..1595a336 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -16,6 +16,7 @@ #include "game/object_list_processor.h" #include "game/rendering_graph_node.h" #include "game/level_update.h" +#include "pc/djui/djui_console.h" #include "pc/djui/djui_hud_utils.h" #include "game/skybox.h" #include "pc/gfx/gfx_pc.h" @@ -89,6 +90,12 @@ bool hud_is_hidden(void) { /// +void log_to_console(const char* message) { + djui_console_message_create((char*)message); +} + +/// + extern u8 gLastCollectedStarOrKey; s32 get_last_star_or_key(void) { return gLastCollectedStarOrKey; diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 90aa7312..2c228435 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -34,6 +34,7 @@ enum HudDisplayFlags { }; void djui_popup_create_global(const char* message, int lines); +void log_to_console(const char* message); bool djui_is_popup_disabled(void); void djui_set_popup_disabled_override(bool value); void djui_reset_popup_disabled_override(void);