diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index c04196469..f087a7171 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -1005,6 +1005,24 @@ namespace GameMenuBar { UIWidgets::Spacer(0); + if (ImGui::BeginMenu("Shooting Gallery")) { + UIWidgets::EnhancementCheckbox("Customize Behavior", "gCustomizeShootingGallery"); + UIWidgets::Tooltip("Turn on/off changes to the shooting gallery behavior"); + bool disabled = CVar_GetS32("gCustomizeShootingGallery", 0) == 0; + const char* disabledTooltip = "This option is disabled because \"Customize Behavior\" is turned off"; + UIWidgets::EnhancementCheckbox("Instant Win", "gInstantShootingGalleryWin", disabled, disabledTooltip); + UIWidgets::Tooltip("Skips the shooting gallery minigame"); + UIWidgets::EnhancementCheckbox("No Rupee Randomization", "gConstantAdultGallery", disabled, disabledTooltip); + UIWidgets::Tooltip("Forces the rupee order to not be randomized as adult, making it the same as chlid"); + UIWidgets::PaddedEnhancementSliderInt("Child Starting Ammunition: %d", "##cShootingGalleryAmmunition", "gChildShootingGalleryAmmunition", 10, 30, "", 15, false, true, false, disabled, disabledTooltip); + UIWidgets::Tooltip("The ammunition at the start of the shooting gallery minigame as a child"); + UIWidgets::PaddedEnhancementSliderInt("Adult Starting Ammunition: %d", "##aShootingGalleryAmmunition", "gAdultShootingGalleryAmmunition", 10, 30, "", 15, false, true, false, disabled, disabledTooltip); + UIWidgets::Tooltip("The ammunition at the start of the shooting gallery minigame as an adult"); + ImGui::EndMenu(); + } + + UIWidgets::Spacer(0); + if (ImGui::BeginMenu("Fishing")) { UIWidgets::EnhancementCheckbox("Instant Fishing", "gInstantFishing"); UIWidgets::Tooltip("All fish will be caught instantly"); diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index ab5fbda0d..db47946bb 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -261,9 +261,35 @@ namespace UIWidgets { Spacer(0); } - void EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton) { + void DisableComponentSwitch(const char* disabledTooltipText, const float alpha) { + // End of disable region of previous component + ImGui::PopStyleVar(1); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) { + ImGui::SetTooltip("%s", disabledTooltipText); + } + ImGui::PopItemFlag(); + + // Start of disable region of next component + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); + } + + void EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) { int val = CVar_GetS32(cvarName, defaultValue); + + float alpha; + if (disabled) { + alpha = ImGui::GetStyle().Alpha * 0.5f; + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); + } + ImGui::Text(text, val); + + if (disabled) { + DisableComponentSwitch(disabledTooltipText, alpha); + } + if(PlusMinusButton) { std::string MinusBTNName = " - ##"; MinusBTNName += cvarName; @@ -274,6 +300,10 @@ namespace UIWidgets { } ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + + if (disabled) { + DisableComponentSwitch(disabledTooltipText, alpha); + } } if (ImGui::SliderInt(id, &val, min, max, format)) @@ -283,6 +313,10 @@ namespace UIWidgets { } if(PlusMinusButton) { + if (disabled) { + DisableComponentSwitch(disabledTooltipText, alpha); + } + std::string PlusBTNName = " + ##"; PlusBTNName += cvarName; ImGui::SameLine(); @@ -294,6 +328,14 @@ namespace UIWidgets { } } + if (disabled) { + ImGui::PopStyleVar(1); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) { + ImGui::SetTooltip("%s", disabledTooltipText); + } + ImGui::PopItemFlag(); + } + if (val < min) { val = min; @@ -309,9 +351,14 @@ namespace UIWidgets { } } - void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton) { + void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) { float val = CVar_GetFloat(cvarName, defaultValue); + if (disabled) { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); + } + if (!isPercentage) { ImGui::Text(text, val); } else { @@ -371,6 +418,14 @@ namespace UIWidgets { } } + if (disabled) { + ImGui::PopStyleVar(1); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) { + ImGui::SetTooltip("%s", disabledTooltipText); + } + ImGui::PopItemFlag(); + } + if (val < min) { val = min; CVar_SetFloat(cvarName, val); @@ -384,11 +439,11 @@ namespace UIWidgets { } } - void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool padTop, bool padBottom) { + void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText) { if (padTop) Spacer(0); - EnhancementSliderInt(text, id, cvarName, min, max, format, defaultValue, PlusMinusButton); + EnhancementSliderInt(text, id, cvarName, min, max, format, defaultValue, PlusMinusButton, disabled, disabledTooltipText); if (padBottom) Spacer(0); diff --git a/soh/soh/UIWidgets.hpp b/soh/soh/UIWidgets.hpp index 015761aa2..5d871aec6 100644 --- a/soh/soh/UIWidgets.hpp +++ b/soh/soh/UIWidgets.hpp @@ -38,9 +38,9 @@ namespace UIWidgets { void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector& items, int defaultValue = 0); bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue); void PaddedText(const char* text, bool padTop = true, bool padBottom = true); - void EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false); - void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool padTop = true, bool padBottom = true); - void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = false); + void EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool disabled = false, const char* disabledTooltipText = ""); + void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); + void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = false, bool disabled = false, const char* disabledTooltipText = ""); void EnhancementRadioButton(const char* text, const char* cvarName, int id); bool EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false); diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c b/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c index ce9d38646..dec99b6e6 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c +++ b/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c @@ -110,7 +110,11 @@ void EnSyatekiItm_Idle(EnSyatekiItm* this, PlayState* play) { player->currentYaw = player->actor.world.rot.y = player->actor.shape.rot.y = 0x7F03; player->actor.world.rot.x = player->actor.shape.rot.x = player->actor.world.rot.z = player->actor.shape.rot.z = 0; - func_8008EF44(play, 15); + s32 ammunition = 15; + if(CVar_Get("gCustomizeShootingGallery", 0)) { + ammunition = CVar_GetS32(LINK_IS_ADULT ? "gAdultShootingGalleryAmmunition" : "gChildShootingGalleryAmmunition", 15); + } + func_8008EF44(play, ammunition); this->roundNum = this->hitCount = 0; for (i = 0; i < 6; i++) { this->roundFlags[i] = false; @@ -128,7 +132,7 @@ void EnSyatekiItm_StartRound(EnSyatekiItm* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->unkTimer == 0) { - if (LINK_IS_ADULT) { + if (LINK_IS_ADULT && !(CVar_Get("gCustomizeShootingGallery", 0) && CVar_Get("gConstantAdultGallery", 0))) { for (i = 0, j = 0; i < SYATEKI_ROUND_MAX; i++) { if (this->roundFlags[i]) { j++; diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 041104ef3..992c477e0 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -289,7 +289,12 @@ void EnSyatekiMan_StartGame(EnSyatekiMan* this, PlayState* play) { Message_CloseTextbox(play); gallery = ((EnSyatekiItm*)this->actor.parent); if (gallery->actor.update != NULL) { - gallery->signal = ENSYATEKI_START; + if(CVar_Get("gCustomizeShootingGallery", 0) && CVar_Get("gInstantShootingGalleryWin", 0)) { + gallery->hitCount = 10; + gallery->signal = ENSYATEKI_END; + } else { + gallery->signal = ENSYATEKI_START; + } this->actionFunc = EnSyatekiMan_WaitForGame; } } @@ -395,7 +400,11 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, PlayState* play) { break; case SYATEKI_RESULT_ALMOST: this->timer = 20; - func_8008EF44(play, 15); + s32 ammunition = 15; + if(CVar_Get("gCustomizeShootingGallery", 0)) { + ammunition = CVar_GetS32(LINK_IS_ADULT ? "gAdultShootingGalleryAmmunition" : "gChildShootingGalleryAmmunition", 15); + } + func_8008EF44(play, ammunition); this->actionFunc = EnSyatekiMan_RestartGame; break; default: