Add/Restore the option to automatically boot into Debug Warp Screen (#5485)

* Added/Restored the option to automatically boot into Debug Warp Screen

* clang-formated

* Added a new hook and moved Boot To Debug Warp Screen to it

* clang

* Added DebugEnabled to initFunc's CVar list. This should prevent Debug Warp from being triggered when Boot to Debug Warp option is enabled but Debug Mode option is disabled.

* No longer hijacks CustomLogoTitle

* Disable "Boot Sequence" dropdown when Boot to Debug Warp Screen is enabled
This commit is contained in:
nclok1405 2025-06-20 05:39:03 +09:00 committed by GitHub
commit 4f95ab3f46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,47 @@
#include <libultraship/bridge.h>
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/ShipInit.hpp"
#include "functions.h"
extern "C" {
#include "z64.h"
#include "overlays/gamestates/ovl_file_choose/file_choose.h"
}
static constexpr int32_t CVAR_DEBUG_ENABLED_DEFAULT = 0;
#define CVAR_DEBUG_ENABLED_NAME CVAR_DEVELOPER_TOOLS("DebugEnabled")
#define CVAR_DEBUG_ENABLED_VALUE CVarGetInteger(CVAR_DEBUG_ENABLED_NAME, CVAR_DEBUG_ENABLED_DEFAULT)
static constexpr int32_t CVAR_BOOT_TO_DEBUG_WARP_SCREEN_DEFAULT = 0;
#define CVAR_BOOT_TO_DEBUG_WARP_SCREEN_NAME CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen")
#define CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE \
CVarGetInteger(CVAR_BOOT_TO_DEBUG_WARP_SCREEN_NAME, CVAR_BOOT_TO_DEBUG_WARP_SCREEN_DEFAULT)
void OnFileChooseMainBootToDebugWarpScreen(void* gameState) {
FileChooseContext* fileChooseContext = (FileChooseContext*)gameState;
fileChooseContext->buttonIndex = 0xFF;
fileChooseContext->menuMode = FS_MENU_MODE_SELECT;
fileChooseContext->selectMode = SM_LOAD_GAME;
}
void OnZTitleUpdateBootToDebugWarpScreen(void* gameState) {
TitleContext* titleContext = (TitleContext*)gameState;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = GAMEMODE_FILE_SELECT;
titleContext->state.running = false;
SET_NEXT_GAMESTATE(&titleContext->state, FileChoose_Init, FileChooseContext);
}
void RegisterBootToDebugWarpScreen() {
COND_HOOK(OnFileChooseMain, CVAR_DEBUG_ENABLED_VALUE && CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE,
OnFileChooseMainBootToDebugWarpScreen);
COND_HOOK(OnZTitleUpdate, CVAR_DEBUG_ENABLED_VALUE && CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE,
OnZTitleUpdateBootToDebugWarpScreen);
}
static RegisterShipInitFunc initFunc_BootToDebugWarpScreen(RegisterBootToDebugWarpScreen,
{ CVAR_DEBUG_ENABLED_NAME,
CVAR_BOOT_TO_DEBUG_WARP_SCREEN_NAME });

View file

@ -66,6 +66,7 @@ DEFINE_HOOK(OnUpdateFileLanguageSelection, (uint8_t optionIndex));
DEFINE_HOOK(OnUpdateFileQuestSelection, (uint8_t questIndex));
DEFINE_HOOK(OnUpdateFileBossRushOptionSelection, (uint8_t optionIndex, uint8_t optionValue));
DEFINE_HOOK(OnUpdateFileNameSelection, (int16_t charCode));
DEFINE_HOOK(OnFileChooseMain, (void* gameState));
DEFINE_HOOK(OnSetGameLanguage, ());
DEFINE_HOOK(OnFileDropped, (std::string filePath));

View file

@ -298,6 +298,10 @@ void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnUpdateFileNameSelection>(charCode);
}
void GameInteractor_ExecuteOnFileChooseMain(void* gameState) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnFileChooseMain>(gameState);
}
// MARK: - Game
void GameInteractor_ExecuteOnSetGameLanguage() {

View file

@ -73,6 +73,7 @@ void GameInteractor_ExecuteOnUpdateFileLanguageSelection(uint8_t optionIndex);
void GameInteractor_ExecuteOnUpdateFileQuestSelection(uint8_t questIndex);
void GameInteractor_ExecuteOnUpdateFileBossRushOptionSelection(uint8_t optionIndex, uint8_t optionValue);
void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode);
void GameInteractor_ExecuteOnFileChooseMain(void* gameState);
// MARK: - Game
void GameInteractor_ExecuteOnSetGameLanguage();

View file

@ -19,6 +19,7 @@ typedef enum {
DISABLE_FOR_FRAME_ADVANCE_OFF,
DISABLE_FOR_ADVANCED_RESOLUTION_OFF,
DISABLE_FOR_VERTICAL_RESOLUTION_OFF,
DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON,
} DisableOption;
struct WidgetInfo;

View file

@ -155,6 +155,12 @@ void SohMenu::InitElement() {
return !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0);
},
"Vertical Resolution Toggle is Off" } },
{ DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON,
{ [](disabledInfo& info) -> bool {
return CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0) &&
CVarGetInteger(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen"), 0);
},
"\"Boot To Debug Warp Screen\" Enabled (see Dev Tools -> General)" } },
};
}

View file

@ -21,6 +21,12 @@ void SohMenu::AddMenuDevTools() {
.Options(
CheckboxOptions().Tooltip("Enables Debug Mode, allowing you to select maps with L + R + Z, noclip "
"with L + D-pad Right, and open the debug menu with L on the pause screen."));
AddWidget(path, "Boot To Debug Warp Screen", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen"))
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); })
.Options(
CheckboxOptions().Tooltip("Automatically shows Debug Warp Screen when starting or resetting the game.\n"
"This option takes precedence over \"Boot Sequence\" option."));
AddWidget(path, "OoT Registry Editor", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("RegEditEnabled"))
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); })

View file

@ -159,6 +159,10 @@ void SohMenu::AddMenuSettings() {
AddWidget(path, "Boot Sequence", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_SETTING("BootSequence"))
.RaceDisable(false)
.PreFunc([](WidgetInfo& info) {
if (mSohMenu->disabledMap.at(DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON).active)
info.activeDisables.push_back(DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON);
})
.Options(ComboboxOptions()
.DefaultIndex(BOOTSEQUENCE_DEFAULT)
.LabelPosition(LabelPositions::Far)

View file

@ -3565,6 +3565,9 @@ void FileChoose_Main(GameState* thisx) {
Input* input = &this->state.input[0];
Color_RGB8 helpTextColor = { 100, 255, 255 };
GameInteractor_ExecuteOnFileChooseMain(thisx);
if (CVarGetInteger(CVAR_COSMETIC("Title.FileChoose.Changed"), 0)) {
Color_RGB8 backgroundColor =
CVarGetColor24(CVAR_COSMETIC("Title.FileChoose.Value"), (Color_RGB8){ 100, 150, 255 });