From 2518e45bd21ba2650a680539fce17b0c5c9257d4 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sat, 6 Apr 2024 18:33:30 -0600 Subject: [PATCH] Ported mods as enhancements and impl reset button --- include/mods.h | 2 -- include/sys.h | 3 ++- src/engine/fox_game.c | 2 +- src/engine/fox_message.c | 6 ++---- src/mods/sfxjukebox.c | 2 +- src/overlays/ovl_menu/fox_map.c | 26 ++++++-------------------- src/overlays/ovl_menu/fox_option.c | 23 ++++++++++++----------- src/port/ui/ImguiUI.cpp | 22 ++++++++++++---------- 8 files changed, 36 insertions(+), 50 deletions(-) diff --git a/include/mods.h b/include/mods.h index 6930f516..3d07f0a0 100644 --- a/include/mods.h +++ b/include/mods.h @@ -17,8 +17,6 @@ /* ************************* */ -#if MODS_LEVEL_SELECT == 1 void Map_LevelSelect(void); -#endif #endif diff --git a/include/sys.h b/include/sys.h index 5f11b886..5b0f7109 100644 --- a/include/sys.h +++ b/include/sys.h @@ -50,7 +50,8 @@ extern s32 D_game_80161A28; extern u8 D_game_80161A2C; extern u16 D_game_80161A2E; extern u16 gNextLevel; -extern u16 gNextGameState; +extern GameState gNextGameState; +extern GameState gGameState; extern u16 D_game_80161A34; extern u16 gBgColor; extern u8 gBlurAlpha; diff --git a/src/engine/fox_game.c b/src/engine/fox_game.c index 6a32f54d..3b6064a1 100644 --- a/src/engine/fox_game.c +++ b/src/engine/fox_game.c @@ -10,7 +10,7 @@ s32 D_game_80161A28; u8 D_game_80161A2C; u16 D_game_80161A2E; u16 gNextLevel; -u16 gNextGameState; +GameState gNextGameState; u16 D_game_80161A34; u16 gBgColor; u8 gBlurAlpha; diff --git a/src/engine/fox_message.c b/src/engine/fox_message.c index 874169ed..c0333e62 100644 --- a/src/engine/fox_message.c +++ b/src/engine/fox_message.c @@ -43,12 +43,10 @@ s32 Message_GetWidth(u16* msgPtr) { s32 Message_GetCharCount(u16* msgPtr) { s32 count = 0; u16* msgChar = LOAD_ASSET(msgPtr); - -#if MODS_LEVEL_SELECT == 1 - if (gCurrentPlanet == 6) { + + if (CVarGetInteger("gLevelSelector", 0) && gCurrentPlanet == 6) { return 0; } -#endif while (*msgChar != NULL) { count++; diff --git a/src/mods/sfxjukebox.c b/src/mods/sfxjukebox.c index 05d34dd6..5653c2d2 100644 --- a/src/mods/sfxjukebox.c +++ b/src/mods/sfxjukebox.c @@ -37,7 +37,7 @@ void decimalToHex(int num, char* hexString, size_t hexStringLength) { } } -void Option_ExpertSoundUpdate(void) { +void Option_JukeboxSoundUpdate(void) { char hexString[9]; // Buffer to store the hexadecimal string if ((gControllerPress[gMainController].button & R_TRIG) && (sfxBank < 4)) { diff --git a/src/overlays/ovl_menu/fox_map.c b/src/overlays/ovl_menu/fox_map.c index e76b42e7..f15e215d 100644 --- a/src/overlays/ovl_menu/fox_map.c +++ b/src/overlays/ovl_menu/fox_map.c @@ -1872,9 +1872,9 @@ void Map_8019FF48(void) { D_menu_801CDA08); } gGameFrameCount++; -#if MODS_LEVEL_SELECT == true - Map_LevelSelect(); -#endif + if(CVarGetInteger("gLevelSelector", 0)){ + Map_LevelSelect(); + } } void Map_801A01A8(void) { @@ -4092,11 +4092,9 @@ bool Map_801A62FC(PlanetId planet) { break; } -#if MODS_LEVEL_SELECT == 1 - if (gCurrentPlanet == 6) { + if (CVarGetInteger("gLevelSelector", 0) && gCurrentPlanet == 6) { return false; } -#endif if (gSaveFile.save.data.planet[planetSaveSlot].played & 1) { ret = false; @@ -5390,17 +5388,9 @@ void Map_801A9A8C(void) { RCP_SetupDL(&gMasterDisp, 0x53); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); - #if MODS_LEVEL_SELECT == 1 - if (gCurrentPlanet == 6) { - return; - } - #endif - -#if MODS_LEVEL_SELECT == 1 - if (gCurrentPlanet == 6) { + if (CVarGetInteger("gLevelSelector", 0) && gCurrentPlanet == 6) { return; } -#endif TextureRect_8bIA(&gMasterDisp, D_5000500, 112, 19, D_menu_801B6AC0[0], D_menu_801B6AC8[0], 1.0f, 1.0f); TextureRect_8bIA(&gMasterDisp, sp54, 16, 15, D_menu_801B6AC0[1], D_menu_801B6AC8[1], 1.0f, 1.0f); @@ -5935,11 +5925,9 @@ void Map_801AB300(void) { if ((D_menu_801CF018 > 0) && (D_menu_801CF018 != 100)) { Map_801AB978(D_ctx_801782A4); Map_801AB978(D_menu_801AF420[!D_menu_801CD940]); -#if MODS_LEVEL_SELECT == 1 - if (gCurrentPlanet == 6) { + if (CVarGetInteger("gLevelSelector", 0) && gCurrentPlanet == 6) { return; } -#endif func_radio_800BB388(); } } @@ -6731,6 +6719,4 @@ void Map_801AD7EC(s32 xPos, s32 yPos, s32 number) { } } -#if MODS_LEVEL_SELECT == 1 #include "../../mods/levelselect.c" -#endif diff --git a/src/overlays/ovl_menu/fox_option.c b/src/overlays/ovl_menu/fox_option.c index 2fb6801a..f5e06ccc 100644 --- a/src/overlays/ovl_menu/fox_option.c +++ b/src/overlays/ovl_menu/fox_option.c @@ -384,13 +384,11 @@ void Option_Setup(void) { continue; } if (!(gSaveFile.save.data.planet[i].normalMedal & 1)) { -#if MODS_LEVEL_SELECT == 1 - enableExpertModes = true; -#elif MODS_SFX_JUKEBOX == 1 - enableExpertModes = true; -#else - enableExpertModes = false; -#endif + if(CVarGetInteger("gLevelSelector", 0) || CVarGetInteger("gSfxJukebox", 0)) { + enableExpertModes = true; + } else { + enableExpertModes = false; + } break; } } @@ -1643,14 +1641,18 @@ void Option_ExpertSoundInit(void) { // clang-format on } -// Expert Sound Options -#if MODS_SFX_JUKEBOX == 1 #include "../../mods/sfxjukebox.c" -#else + +// Expert Sound Options void Option_ExpertSoundUpdate(void) { s32 pad; f32 sp28 = D_menu_801B931C; + if(CVarGetInteger("gSfxJukebox", 0) == 1) { + Option_JukeboxSoundUpdate(); + return; + } + if (Option_8019C66C(&sp28, 0.0f, 49.0f, &D_menu_801B9290) != 0) { AUDIO_PLAY_SFX(0x49000002, gDefaultSfxSource, 4); D_menu_801B931C = sp28; @@ -1685,7 +1687,6 @@ void Option_ExpertSoundUpdate(void) { } } } -#endif void Option_ExpertSoundDraw(void) { u8* temp_v0_4; diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index 779a4d7c..0373128f 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -12,6 +12,10 @@ #include #include "port/Engine.h" +extern "C" { +#include "sys.h" +} + namespace GameUI { std::shared_ptr mGameMenuBar; std::shared_ptr mConsoleWindow; @@ -391,7 +395,7 @@ void DrawGameMenu() { "Ctrl+R" #endif )) { - std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); + gNextGameState = GSTATE_BOOT; } #if !defined(__SWITCH__) && !defined(__WIIU__) @@ -455,19 +459,17 @@ void DrawDebugMenu() { }); UIWidgets::CVarCheckbox("Debug mode", "gEnableDebugMode", { - .tooltip = "Various debug features, including a level selector from the main menu" + .tooltip = "TBD" }); - UIWidgets::CVarCheckbox("Better Level Select", "gDeveloper.BetterLevelSelect", { - .tooltip = "Tweaks to the level select screen, like naming and allowing C-buttons to be used" + UIWidgets::CVarCheckbox("Level Selector", "gLevelSelector", { + .tooltip = "Allows you to select any level from the main menu" + }); + + UIWidgets::CVarCheckbox("SFX Jukebox", "gSfxJukebox", { + .tooltip = "Allows you to play sound effects from the game" }); - UIWidgets::CVarCheckbox("Draw DebugInfo", "gDeveloper.DrawDebugInfo"); - if (CVarGetInteger("gDeveloper.DrawDebugInfo", 0)) { - UIWidgets::CVarCombobox("DebugInfo mode", "gDeveloper.DebugInfoPage", debugInfoPages, { - .defaultIndex = 0, - }); - } UIWidgets::Spacer(0); UIWidgets::WindowButton("Stats", "gStatsEnabled", GameUI::mStatsWindow, {