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

This commit is contained in:
nclok1405 2025-06-13 13:07:37 +09:00
commit a3a32a19d0
5 changed files with 39 additions and 8 deletions

View file

@ -0,0 +1,30 @@
#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 RegisterBootToDebugWarpScreen() {
COND_HOOK(OnFileChooseMain, CVAR_DEBUG_ENABLED_VALUE && CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE, OnFileChooseMainBootToDebugWarpScreen);
}
static RegisterShipInitFunc initFunc_BootToDebugWarpScreen(RegisterBootToDebugWarpScreen, { 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

@ -3557,6 +3557,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 });
@ -3588,14 +3591,6 @@ void FileChoose_Main(GameState* thisx) {
gSaveContext.skyboxTime += 0x10;
}
// Boot to Debug Warp Screen
if ((CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0) != 0) &&
(CVarGetInteger(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen"), 0) != 0)) {
this->buttonIndex = 0xFF;
this->menuMode = FS_MENU_MODE_SELECT;
this->selectMode = SM_LOAD_GAME;
}
OPEN_DISPS(this->state.gfxCtx);
this->n64ddFlag = 0;