diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index a715c5ad3..a543d35c7 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -288,7 +288,15 @@ extern std::shared_ptr mHudEditorWindow; void DrawEnhancementsMenu() { if (UIWidgets::BeginMenu("Enhancements")) { + + if (UIWidgets::BeginMenu("Masks")) { + UIWidgets::CVarCheckbox("Fierce Deity's Mask Anywhere", "gEnhancements.Masks.FierceDeitysAnywhere", { + .tooltip = "Allow using Fierce Deity's mask outside of boss rooms." + }); + ImGui::EndMenu(); + } + UIWidgets::CVarCheckbox("Fast Text", "gEnhancements.TimeSavers.FastText", { .tooltip = "Speeds up text rendering, and enables holding of B progress to next message" }); diff --git a/mm/2s2h/Enhancements/Cheats/Infinite.cpp b/mm/2s2h/Enhancements/Cheats/Infinite.cpp new file mode 100644 index 000000000..2cebeca2e --- /dev/null +++ b/mm/2s2h/Enhancements/Cheats/Infinite.cpp @@ -0,0 +1,37 @@ +#include "Infinite.h" +#include +#include "Enhancements/GameInteractor/GameInteractor.h" +#include "variables.h" + +void RegisterInfiniteCheats() { + GameInteractor::Instance->RegisterGameHook([]() { + if (gPlayState == nullptr) return; + + if (CVarGetInteger("gCheats.InfiniteHealth", 0)) { + gSaveContext.save.saveInfo.playerData.health = gSaveContext.save.saveInfo.playerData.healthCapacity; + } + + if (CVarGetInteger("gCheats.InfiniteMagic", 0)) { + uint8_t magicLevel = gSaveContext.save.saveInfo.playerData.magicLevel; + if (magicLevel == 1) { + gSaveContext.save.saveInfo.playerData.magic = MAGIC_NORMAL_METER; + } else if (magicLevel == 2) { + gSaveContext.save.saveInfo.playerData.magic = MAGIC_DOUBLE_METER; + } + } + + if (CVarGetInteger("gCheats.InfiniteRupees", 0)) { + gSaveContext.save.saveInfo.playerData.rupees = CUR_CAPACITY(UPG_WALLET); + } + + if (CVarGetInteger("gCheats.InfiniteConsumables", 0)) { + AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); + AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); + AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); + AMMO(ITEM_DEKU_STICK) = CUR_CAPACITY(UPG_DEKU_STICKS); + AMMO(ITEM_DEKU_NUT) = CUR_CAPACITY(UPG_DEKU_NUTS); + AMMO(ITEM_MAGIC_BEANS) = 20; + AMMO(ITEM_POWDER_KEG) = 1; + } + }); +} diff --git a/mm/2s2h/Enhancements/Cheats/Infinite.h b/mm/2s2h/Enhancements/Cheats/Infinite.h new file mode 100644 index 000000000..7bdffc6cc --- /dev/null +++ b/mm/2s2h/Enhancements/Cheats/Infinite.h @@ -0,0 +1,6 @@ +#ifndef CHEATS_INFINITE_H +#define CHEATS_INFINITE_H + +void RegisterInfiniteCheats(); + +#endif // CHEATS_INFINITE_H diff --git a/mm/2s2h/Enhancements/Cheats/MoonJump.cpp b/mm/2s2h/Enhancements/Cheats/MoonJump.cpp new file mode 100644 index 000000000..7963e6f4b --- /dev/null +++ b/mm/2s2h/Enhancements/Cheats/MoonJump.cpp @@ -0,0 +1,24 @@ +#include "MoonJump.h" +#include +#include "Enhancements/GameInteractor/GameInteractor.h" +#include "variables.h" + +static uint32_t moonJumpOnLGameStateUpdateHookId = 0; +void RegisterMoonJumpOnL() { + if (moonJumpOnLGameStateUpdateHookId) { + GameInteractor::Instance->UnregisterGameHook(moonJumpOnLGameStateUpdateHookId); + moonJumpOnLGameStateUpdateHookId = 0; + } + + if (CVarGetInteger("gCheats.MoonJumpOnL", 0)) { + moonJumpOnLGameStateUpdateHookId = GameInteractor::Instance->RegisterGameHook([]() { + if (gPlayState == nullptr) return; + + Player* player = GET_PLAYER(gPlayState); + + if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) { + player->actor.velocity.y = 6.34375f; + } + }); + } +} diff --git a/mm/2s2h/Enhancements/Cheats/MoonJump.h b/mm/2s2h/Enhancements/Cheats/MoonJump.h new file mode 100644 index 000000000..5f2727e82 --- /dev/null +++ b/mm/2s2h/Enhancements/Cheats/MoonJump.h @@ -0,0 +1,6 @@ +#ifndef CHEATS_MOONJUMP_H +#define CHEATS_MOONJUMP_H + +void RegisterMoonJumpOnL(); + +#endif // CHEATS_MOONJUMP_H diff --git a/mm/2s2h/Enhancements/Enhancements.cpp b/mm/2s2h/Enhancements/Enhancements.cpp index b0f306e9c..b7d82a9d7 100644 --- a/mm/2s2h/Enhancements/Enhancements.cpp +++ b/mm/2s2h/Enhancements/Enhancements.cpp @@ -1,83 +1,13 @@ #include "Enhancements.h" -#include -#include "GameInteractor/GameInteractor.h" - -extern "C" { -#include -#include "macros.h" -// #include "functions.h" -#include "variables.h" -extern PlayState* gPlayState; -} - -static uint32_t moonJumpOnLGameStateUpdateHookId = 0; -void RegisterMoonJumpOnL() { - if (moonJumpOnLGameStateUpdateHookId) { - GameInteractor::Instance->UnregisterGameHook(moonJumpOnLGameStateUpdateHookId); - moonJumpOnLGameStateUpdateHookId = 0; - } - - if (CVarGetInteger("gCheats.MoonJumpOnL", 0)) { - moonJumpOnLGameStateUpdateHookId = GameInteractor::Instance->RegisterGameHook([]() { - if (!gPlayState) return; - - Player* player = GET_PLAYER(gPlayState); - - if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) { - player->actor.velocity.y = 6.34375f; - } - }); - } -} - -void RegisterTimeSaversHooks() { - GameInteractor::Instance->RegisterGameHookForID(GI_VB_PLAY_ENTRANCE_CS, [](GIVanillaBehavior _, bool* should, void* __) { - if (CVarGetInteger("gEnhancements.TimeSavers.SkipEntranceCutscenes", 0)) { - *should = false; - } - }); - GameInteractor::Instance->RegisterGameHookForID(GI_VB_SHOW_TITLE_CARD, [](GIVanillaBehavior _, bool* should, void* __) { - if (CVarGetInteger("gEnhancements.TimeSavers.HideTitleCards", 0)) { - *should = false; - } - }); -} - -void RegisterInfiniteCheats() { - GameInteractor::Instance->RegisterGameHook([]() { - if (!gPlayState) return; - - if (CVarGetInteger("gCheats.InfiniteHealth", 0)) { - gSaveContext.save.saveInfo.playerData.health = gSaveContext.save.saveInfo.playerData.healthCapacity; - } - - if (CVarGetInteger("gCheats.InfiniteMagic", 0)) { - uint8_t magicLevel = gSaveContext.save.saveInfo.playerData.magicLevel; - if (magicLevel == 1) { - gSaveContext.save.saveInfo.playerData.magic = MAGIC_NORMAL_METER; - } else if (magicLevel == 2) { - gSaveContext.save.saveInfo.playerData.magic = MAGIC_DOUBLE_METER; - } - } - - if (CVarGetInteger("gCheats.InfiniteRupees", 0)) { - gSaveContext.save.saveInfo.playerData.rupees = CUR_CAPACITY(UPG_WALLET); - } - - if (CVarGetInteger("gCheats.InfiniteConsumables", 0)) { - AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); - AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); - AMMO(ITEM_BOMBCHU) = CUR_CAPACITY(UPG_BOMB_BAG); - AMMO(ITEM_DEKU_STICK) = CUR_CAPACITY(UPG_DEKU_STICKS); - AMMO(ITEM_DEKU_NUT) = CUR_CAPACITY(UPG_DEKU_NUTS); - AMMO(ITEM_MAGIC_BEANS) = 20; - AMMO(ITEM_POWDER_KEG) = 1; - } - }); -} void InitEnhancements() { - RegisterMoonJumpOnL(); + // Cheats RegisterInfiniteCheats(); + RegisterMoonJumpOnL(); + + // Masks + RegisterFierceDeityAnywhere(); + + // Time Savers RegisterTimeSaversHooks(); -} \ No newline at end of file +} diff --git a/mm/2s2h/Enhancements/Enhancements.h b/mm/2s2h/Enhancements/Enhancements.h index 9565c3625..9332c3860 100644 --- a/mm/2s2h/Enhancements/Enhancements.h +++ b/mm/2s2h/Enhancements/Enhancements.h @@ -1,10 +1,19 @@ +#ifndef ENHANCEMENTS_H +#define ENHANCEMENTS_H + +#include "Cheats/MoonJump.h" +#include "Cheats/Infinite.h" +#include "Masks/FierceDeityAnywhere.h" +#include "TimeSavers/TimeSavers.h" + #ifdef __cplusplus extern "C" { #endif void InitEnhancements(); -void RegisterMoonJumpOnL(); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif + +#endif // ENHANCEMENTS_H diff --git a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h index 9e56bc67f..250d75d03 100644 --- a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h +++ b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h @@ -13,6 +13,7 @@ typedef enum { // Vanilla condition: gSaveContext.showTitleCard GI_VB_SHOW_TITLE_CARD, GI_VB_PLAY_ENTRANCE_CS, + GI_VB_DISABLE_FD_MASK } GIVanillaBehavior; #ifdef __cplusplus @@ -216,6 +217,8 @@ bool GameInteractor_ShouldActorDraw(Actor* actor); void GameInteractor_ExecuteOnActorDraw(Actor* actor); bool GameInteractor_Should(GIVanillaBehavior flag, bool result, void* optionalArg); +#define REGISTER_VB_SHOULD(flag, body) \ + GameInteractor::Instance->RegisterGameHookForID(flag, [](GIVanillaBehavior _, bool* should, void* opt) body) #ifdef __cplusplus } diff --git a/mm/2s2h/Enhancements/Masks/FierceDeityAnywhere.cpp b/mm/2s2h/Enhancements/Masks/FierceDeityAnywhere.cpp new file mode 100644 index 000000000..cf14f605b --- /dev/null +++ b/mm/2s2h/Enhancements/Masks/FierceDeityAnywhere.cpp @@ -0,0 +1,10 @@ +#include +#include "Enhancements/GameInteractor/GameInteractor.h" + +void RegisterFierceDeityAnywhere() { + REGISTER_VB_SHOULD(GI_VB_DISABLE_FD_MASK, { + if (CVarGetInteger("gEnhancements.Masks.FierceDeitysAnywhere", 0)) { + *should = false; + } + }); +} diff --git a/mm/2s2h/Enhancements/Masks/FierceDeityAnywhere.h b/mm/2s2h/Enhancements/Masks/FierceDeityAnywhere.h new file mode 100644 index 000000000..ee5b87e4d --- /dev/null +++ b/mm/2s2h/Enhancements/Masks/FierceDeityAnywhere.h @@ -0,0 +1,6 @@ +#ifndef MASKS_FD_ANYWHERE_H +#define MASKS_FD_ANYWHERE_H + +void RegisterFierceDeityAnywhere(); + +#endif // MASKS_FD_ANYWHERE_H diff --git a/mm/2s2h/Enhancements/TimeSavers/TimeSavers.cpp b/mm/2s2h/Enhancements/TimeSavers/TimeSavers.cpp new file mode 100644 index 000000000..86c47fc28 --- /dev/null +++ b/mm/2s2h/Enhancements/TimeSavers/TimeSavers.cpp @@ -0,0 +1,15 @@ +#include +#include "Enhancements/GameInteractor/GameInteractor.h" + +void RegisterTimeSaversHooks() { + REGISTER_VB_SHOULD(GI_VB_PLAY_ENTRANCE_CS, { + if (CVarGetInteger("gEnhancements.TimeSavers.SkipEntranceCutscenes", 0)) { + *should = false; + } + }); + REGISTER_VB_SHOULD(GI_VB_SHOW_TITLE_CARD, { + if (CVarGetInteger("gEnhancements.TimeSavers.HideTitleCards", 0)) { + *should = false; + } + }); +} diff --git a/mm/2s2h/Enhancements/TimeSavers/TimeSavers.h b/mm/2s2h/Enhancements/TimeSavers/TimeSavers.h new file mode 100644 index 000000000..03466f19b --- /dev/null +++ b/mm/2s2h/Enhancements/TimeSavers/TimeSavers.h @@ -0,0 +1,6 @@ +#ifndef TIMESAVERS_H +#define TIMESAVERS_H + +void RegisterTimeSaversHooks(); + +#endif // TIMESAVERS_H diff --git a/mm/src/code/z_parameter.c b/mm/src/code/z_parameter.c index 3396cdfc0..4ebca32ae 100644 --- a/mm/src/code/z_parameter.c +++ b/mm/src/code/z_parameter.c @@ -16,6 +16,7 @@ #include "BenPort.h" #include #include "BenGui/HudEditor.h" +#include "Enhancements/GameInteractor/GameInteractor.h" // #region 2S2H [Port] Asset tables we can pull from instead of from ROM #define dgEmptyTexture "__OTR__textures/virtual/gEmptyTexture" @@ -2191,9 +2192,13 @@ void Interface_UpdateButtonsPart2(PlayState* play) { } } else if (GET_CUR_FORM_BTN_ITEM(i) == ITEM_MASK_FIERCE_DEITY) { // Fierce Deity's Mask is equipped - if ((play->sceneId != SCENE_MITURIN_BS) && (play->sceneId != SCENE_HAKUGIN_BS) && - (play->sceneId != SCENE_SEA_BS) && (play->sceneId != SCENE_INISIE_BS) && - (play->sceneId != SCENE_LAST_BS)) { + u8 vanillaSceneConditionResult = + (play->sceneId != SCENE_MITURIN_BS) && + (play->sceneId != SCENE_HAKUGIN_BS) && + (play->sceneId != SCENE_SEA_BS) && + (play->sceneId != SCENE_INISIE_BS) && + (play->sceneId != SCENE_LAST_BS); + if (GameInteractor_Should(GI_VB_DISABLE_FD_MASK, vanillaSceneConditionResult, NULL)) { if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { gSaveContext.buttonStatus[i] = BTN_DISABLED; restoreHudVisibility = true;