Skip to content

Commit

Permalink
Migrate enhancements to ShipInit pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjoecox committed Nov 29, 2024
1 parent 3917e3b commit 11340f1
Show file tree
Hide file tree
Showing 79 changed files with 1,254 additions and 1,561 deletions.
83 changes: 31 additions & 52 deletions mm/2s2h/BenGui/BenMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <unordered_map>
#include <string>
#include "2s2h/Enhancements/Enhancements.h"
#include "2s2h/Enhancements/Graphics/Graphics.h"
#include "2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.h"
#include "2s2h/DeveloperTools/DeveloperTools.h"
#include "HudEditor.h"
Expand Down Expand Up @@ -410,13 +411,11 @@ void DrawEnhancementsMenu() {
}

ImGui::SeparatorText("Free Look");
if (UIWidgets::CVarCheckbox(
"Free Look", "gEnhancements.Camera.FreeLook.Enable",
{ .tooltip = "Enables free look camera control\nNote: You must remap C buttons off of the right "
"stick in the controller config menu, and map the camera stick to the right stick.",
.disabled = CVarGetInteger("gEnhancements.Camera.DebugCam.Enable", 0) != 0 })) {
RegisterCameraFreeLook();
}
UIWidgets::CVarCheckbox(
"Free Look", "gEnhancements.Camera.FreeLook.Enable",
{ .tooltip = "Enables free look camera control\nNote: You must remap C buttons off of the right "
"stick in the controller config menu, and map the camera stick to the right stick.",
.disabled = CVarGetInteger("gEnhancements.Camera.DebugCam.Enable", 0) != 0 });

if (CVarGetInteger("gEnhancements.Camera.FreeLook.Enable", 0)) {
UIWidgets::CVarCheckbox("Invert Camera X Axis", "gEnhancements.Camera.RightStick.InvertXAxis",
Expand All @@ -443,12 +442,9 @@ void DrawEnhancementsMenu() {
}

ImGui::SeparatorText("'Debug' Camera");
if (UIWidgets::CVarCheckbox(
"Debug Camera", "gEnhancements.Camera.DebugCam.Enable",
{ .tooltip = "Enables free camera control.",
.disabled = CVarGetInteger("gEnhancements.Camera.FreeLook.Enable", 0) != 0 })) {
RegisterDebugCam();
}
UIWidgets::CVarCheckbox("Debug Camera", "gEnhancements.Camera.DebugCam.Enable",
{ .tooltip = "Enables free camera control.",
.disabled = CVarGetInteger("gEnhancements.Camera.FreeLook.Enable", 0) != 0 });

if (CVarGetInteger("gEnhancements.Camera.DebugCam.Enable", 0)) {
UIWidgets::CVarCheckbox("Invert Camera X Axis", "gEnhancements.Camera.RightStick.InvertXAxis",
Expand Down Expand Up @@ -649,10 +645,8 @@ void DrawEnhancementsMenu() {
"model and texture on the boot logo start screen" });
UIWidgets::CVarCheckbox("Bow Reticle", "gEnhancements.Graphics.BowReticle",
{ .tooltip = "Gives the bow a reticle when you draw an arrow" });
if (UIWidgets::CVarCheckbox("3D Item Drops", "gEnhancements.Graphics.3DItemDrops",
{ .tooltip = "Makes item drops 3D" })) {
Register3DItemDrops();
}
UIWidgets::CVarCheckbox("3D Item Drops", "gEnhancements.Graphics.3DItemDrops",
{ .tooltip = "Makes item drops 3D" });
UIWidgets::CVarCheckbox(
"Disable Black Bar Letterboxes", "gEnhancements.Graphics.DisableBlackBars",
{ .tooltip = "Disables Black Bar Letterboxes during cutscenes and Z-targeting\nNote: there may be "
Expand Down Expand Up @@ -686,11 +680,9 @@ void DrawEnhancementsMenu() {
UIWidgets::CVarCheckbox("Fierce Deity's Mask Anywhere", "gEnhancements.Masks.FierceDeitysAnywhere",
{ .tooltip = "Allow using Fierce Deity's mask outside of boss rooms." });
UIWidgets::CVarCheckbox("No Blast Mask Cooldown", "gEnhancements.Masks.NoBlastMaskCooldown", {});
if (UIWidgets::CVarCheckbox("Persistent Bunny Hood", "gEnhancements.Masks.PersistentBunnyHood.Enabled",
{ .tooltip = "Permanently toggle a speed boost from the bunny hood by pressing "
"'A' on it in the mask menu." })) {
UpdatePersistentMasksState();
}
UIWidgets::CVarCheckbox("Persistent Bunny Hood", "gEnhancements.Masks.PersistentBunnyHood.Enabled",
{ .tooltip = "Permanently toggle a speed boost from the bunny hood by pressing "
"'A' on it in the mask menu." });

ImGui::EndMenu();
}
Expand All @@ -717,9 +709,7 @@ void DrawEnhancementsMenu() {
UIWidgets::CVarCheckbox("Hyrule Warriors Young Link", "gModes.HyruleWarriorsStyledLink",
{ .tooltip = "When acquired, places the Keaton and Fierce Deity masks on Link "
"similarly to how he wears them in Hyrule Warriors" });
if (UIWidgets::CVarCheckbox("Time Moves When You Move", "gModes.TimeMovesWhenYouMove")) {
RegisterTimeMovesWhenYouMove();
}
UIWidgets::CVarCheckbox("Time Moves When You Move", "gModes.TimeMovesWhenYouMove");
if (UIWidgets::CVarCheckbox("Mirrored World", "gModes.MirroredWorld.Mode")) {
if (CVarGetInteger("gModes.MirroredWorld.Mode", 0)) {
CVarSetInteger("gModes.MirroredWorld.State", 1);
Expand All @@ -734,12 +724,9 @@ void DrawEnhancementsMenu() {
if (UIWidgets::BeginMenu("Player")) {
UIWidgets::CVarSliderInt("Climb speed", "gEnhancements.Player.ClimbSpeed", 1, 5, 1,
{ .tooltip = "Increases the speed at which Link climbs vines and ladders." });
if (UIWidgets::CVarCheckbox("Fast Deku Flower Launch", "gEnhancements.Player.FastFlowerLaunch",
{ .tooltip =
"Speeds up the time it takes to be able to get maximum height from "
"launching out of a deku flower" })) {
RegisterFastFlowerLaunch();
}
UIWidgets::CVarCheckbox("Fast Deku Flower Launch", "gEnhancements.Player.FastFlowerLaunch",
{ .tooltip = "Speeds up the time it takes to be able to get maximum height from "
"launching out of a deku flower" });
UIWidgets::CVarCheckbox("Instant Putaway", "gEnhancements.Player.InstantPutaway",
{ .tooltip = "Allows Link to instantly puts away held item without waiting." });
UIWidgets::CVarCheckbox("Fierce Deity Putaway", "gEnhancements.Player.FierceDeityPutaway",
Expand All @@ -760,13 +747,11 @@ void DrawEnhancementsMenu() {
UIWidgets::CVarCheckbox("Tatl ISG", "gEnhancements.Restorations.TatlISG",
{ .tooltip = "Restores Navi ISG from OOT, but now with Tatl." });

if (UIWidgets::CVarCheckbox(
"Woodfall Mountain Appearance", "gEnhancements.Restorations.WoodfallMountainAppearance",
{ .tooltip = "Restores the appearance of Woodfall mountain to not look poisoned "
"when viewed from Termina Field after clearing Woodfall Temple\n\n"
"Requires a scene reload to take effect" })) {
RegisterWoodfallMountainAppearance();
}
UIWidgets::CVarCheckbox("Woodfall Mountain Appearance",
"gEnhancements.Restorations.WoodfallMountainAppearance",
{ .tooltip = "Restores the appearance of Woodfall mountain to not look poisoned "
"when viewed from Termina Field after clearing Woodfall Temple\n\n"
"Requires a scene reload to take effect" });

ImGui::EndMenu();
}
Expand All @@ -793,11 +778,9 @@ void DrawEnhancementsMenu() {
}

if (UIWidgets::BeginMenu("Difficulty Options")) {
if (UIWidgets::CVarCheckbox("Disable Takkuri Steal", "gEnhancements.Cheats.DisableTakkuriSteal",
{ .tooltip = "Prevents the Takkuri from stealing key items like bottles and "
"swords. It may still steal other items." })) {
RegisterDisableTakkuriSteal();
}
UIWidgets::CVarCheckbox("Disable Takkuri Steal", "gEnhancements.Cheats.DisableTakkuriSteal",
{ .tooltip = "Prevents the Takkuri from stealing key items like bottles and "
"swords. It may still steal other items." });

UIWidgets::CVarCombobox(
"Deku Guard Search Balls", "gEnhancements.Cheats.DekuGuardSearchBalls", dekuGuardSearchBallsOptions,
Expand Down Expand Up @@ -833,21 +816,17 @@ void DrawCheatsMenu() {
UIWidgets::CVarCheckbox("Infinite Magic", "gCheats.InfiniteMagic");
UIWidgets::CVarCheckbox("Infinite Rupees", "gCheats.InfiniteRupees");
UIWidgets::CVarCheckbox("Infinite Consumables", "gCheats.InfiniteConsumables");
if (UIWidgets::CVarCheckbox(
"Longer Deku Flower Glide", "gCheats.LongerFlowerGlide",
{ .tooltip = "Allows Deku Link to glide longer, no longer dropping after a certain distance" })) {
RegisterLongerFlowerGlide();
}
UIWidgets::CVarCheckbox(
"Longer Deku Flower Glide", "gCheats.LongerFlowerGlide",
{ .tooltip = "Allows Deku Link to glide longer, no longer dropping after a certain distance" });
UIWidgets::CVarCheckbox("No Clip", "gCheats.NoClip");
UIWidgets::CVarCheckbox("Unbreakable Razor Sword", "gCheats.UnbreakableRazorSword");
UIWidgets::CVarCheckbox("Unrestricted Items", "gCheats.UnrestrictedItems");
UIWidgets::CVarCheckbox("Hookshot Anywhere", "gCheats.HookshotAnywhere",
{ .tooltip = "Allows most surfaces to be hookshot-able" });

if (UIWidgets::CVarCheckbox("Moon Jump on L", "gCheats.MoonJumpOnL",
{ .tooltip = "Holding L makes you float into the air" })) {
RegisterMoonJumpOnL();
}
UIWidgets::CVarCheckbox("Moon Jump on L", "gCheats.MoonJumpOnL",
{ .tooltip = "Holding L makes you float into the air" });
UIWidgets::CVarCheckbox("Elegy of Emptiness Anywhere", "gCheats.ElegyAnywhere",
{ .tooltip = "Allows Elegy of Emptiness outside of Ikana" });
UIWidgets::CVarCombobox(
Expand Down
70 changes: 19 additions & 51 deletions mm/2s2h/BenGui/SearchableMenuItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ void AddEnhancements() {
"stick in the controller config menu, and map the camera stick to the right stick.",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { RegisterCameraFreeLook(); },
nullptr,
[](widgetInfo& info) {
if (disabledMap.at(DISABLE_FOR_DEBUG_CAM_ON).active)
info.activeDisables.push_back(DISABLE_FOR_DEBUG_CAM_ON);
Expand Down Expand Up @@ -939,7 +939,7 @@ void AddEnhancements() {
"Enables free camera control.",
WIDGET_CVAR_CHECKBOX,
{},
([](widgetInfo& info) { RegisterDebugCam(); }),
nullptr,
[](widgetInfo& info) {
if (disabledMap.at(DISABLE_FOR_FREE_LOOK_ON).active) {
info.activeDisables.push_back(DISABLE_FOR_FREE_LOOK_ON);
Expand Down Expand Up @@ -1014,25 +1014,18 @@ void AddEnhancements() {
{ "Infinite Rupees", "gCheats.InfiniteRupees", "Always have a full Wallet.", WIDGET_CVAR_CHECKBOX, {} },
{ "Infinite Consumables", "gCheats.InfiniteConsumables",
"Always have max Consumables, you must have collected the consumables first.", WIDGET_CVAR_CHECKBOX },
{ "Longer Deku Flower Glide",
"gCheats.LongerFlowerGlide",
{ "Longer Deku Flower Glide", "gCheats.LongerFlowerGlide",
"Allows Deku Link to glide longer, no longer dropping after a certain distance.",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { RegisterLongerFlowerGlide(); } },
WIDGET_CVAR_CHECKBOX },
{ "No Clip", "gCheats.NoClip", "Allows Link to phase through collision.", WIDGET_CVAR_CHECKBOX },
{ "Unbreakable Razor Sword", "gCheats.UnbreakableRazorSword",
"Allows to Razor Sword to be used indefinitely without dulling its blade.", WIDGET_CVAR_CHECKBOX },
{ "Unrestricted Items", "gCheats.UnrestrictedItems", "Allows all Forms to use all Items.",
WIDGET_CVAR_CHECKBOX },
{ "Hookshot Anywhere", "gCheats.HookshotAnywhere", "Allows most surfaces to be hookshot-able",
WIDGET_CVAR_CHECKBOX },
{ "Moon Jump on L",
"gCheats.MoonJumpOnL",
"Holding L makes you float into the air.",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { RegisterMoonJumpOnL(); } },
{ "Moon Jump on L", "gCheats.MoonJumpOnL", "Holding L makes you float into the air.",
WIDGET_CVAR_CHECKBOX },
{ "Elegy of Emptiness Anywhere", "gCheats.ElegyAnywhere", "Allows Elegy of Emptiness outside of Ikana",
WIDGET_CVAR_CHECKBOX },
{ "Stop Time in Dungeons",
Expand All @@ -1049,12 +1042,9 @@ void AddEnhancements() {
{ "Gameplay",
3,
{ { { .widgetName = "Player", .widgetType = WIDGET_SEPARATOR_TEXT },
{ "Fast Deku Flower Launch",
"gEnhancements.Player.FastFlowerLaunch",
{ "Fast Deku Flower Launch", "gEnhancements.Player.FastFlowerLaunch",
"Speeds up the time it takes to be able to get maximum height from launching out of a deku flower",
WIDGET_CVAR_CHECKBOX,
{},
([](widgetInfo& info) { RegisterFastFlowerLaunch(); }) },
WIDGET_CVAR_CHECKBOX },
{ "Instant Putaway", "gEnhancements.Player.InstantPutaway",
"Allows Link to instantly puts away held item without waiting.", WIDGET_CVAR_CHECKBOX },
{ "Fierce Deity Putaway", "gEnhancements.Player.FierceDeityPutaway",
Expand Down Expand Up @@ -1103,12 +1093,8 @@ void AddEnhancements() {
"When acquired, places the Keaton and Fierce Deity masks on Link similarly to how he wears them in "
"Hyrule Warriors",
WIDGET_CVAR_CHECKBOX },
{ "Time Moves when you Move",
"gModes.TimeMovesWhenYouMove",
"Time only moves when Link is not standing still.",
WIDGET_CVAR_CHECKBOX,
{},
([](widgetInfo& info) { RegisterTimeMovesWhenYouMove(); }) },
{ "Time Moves when you Move", "gModes.TimeMovesWhenYouMove",
"Time only moves when Link is not standing still.", WIDGET_CVAR_CHECKBOX },
{ "Mirrored World",
"gModes.MirroredWorld.Mode",
"Mirrors the world horizontally.",
Expand Down Expand Up @@ -1241,12 +1227,7 @@ void AddEnhancements() {
disabledMap.at(DISABLE_FOR_MOTION_BLUR_OFF).active;
} },
{ .widgetName = "Other", .widgetType = WIDGET_SEPARATOR_TEXT },
{ "3D Item Drops",
"gEnhancements.Graphics.3DItemDrops",
"Makes item drops 3D",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { Register3DItemDrops(); } },
{ "3D Item Drops", "gEnhancements.Graphics.3DItemDrops", "Makes item drops 3D", WIDGET_CVAR_CHECKBOX },
{ "Authentic Logo", "gEnhancements.Graphics.AuthenticLogo",
"Hide the game version and build details and display the authentic "
"model and texture on the boot logo start screen",
Expand Down Expand Up @@ -1291,13 +1272,10 @@ void AddEnhancements() {
"Removes the delay when using transformation masks.", WIDGET_CVAR_CHECKBOX },
{ "Fierce Deity's Mask Anywhere", "gEnhancements.Masks.FierceDeitysAnywhere",
"Allow using Fierce Deity's mask outside of boss rooms.", WIDGET_CVAR_CHECKBOX },
{ "Persistent Bunny Hood",
"gEnhancements.Masks.PersistentBunnyHood.Enabled",
{ "Persistent Bunny Hood", "gEnhancements.Masks.PersistentBunnyHood.Enabled",
"Permanently toggle a speed boost from the bunny hood by pressing "
"'A' on it in the mask menu.",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { UpdatePersistentMasksState(); } },
WIDGET_CVAR_CHECKBOX },
{ "No Blast Mask Cooldown", "gEnhancements.Masks.NoBlastMaskCooldown",
"Eliminates the Cooldown between Blast Mask usage.", WIDGET_CVAR_CHECKBOX } },
// Song Enhancements
Expand All @@ -1322,12 +1300,8 @@ void AddEnhancements() {
"Prevent dropping inputs when playing the ocarina quickly.", WIDGET_CVAR_CHECKBOX },
{ "Skip Scarecrow Song", "gEnhancements.Playback.SkipScarecrowSong",
"Pierre appears when the Ocarina is pulled out.", WIDGET_CVAR_CHECKBOX },
{ "Faster Song Playback",
"gEnhancements.Songs.FasterSongPlayback",
"Speeds up the playback of songs.",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { RegisterFasterSongPlayback(); } } } } });
{ "Faster Song Playback", "gEnhancements.Songs.FasterSongPlayback", "Speeds up the playback of songs.",
WIDGET_CVAR_CHECKBOX } } } });
enhancementsSidebar.push_back(
{ "Time Savers",
3,
Expand Down Expand Up @@ -1411,24 +1385,18 @@ void AddEnhancements() {
WIDGET_CVAR_CHECKBOX },
{ "Tatl ISG", "gEnhancements.Restorations.TatlISG", "Restores Navi ISG from OoT, but now with Tatl.",
WIDGET_CVAR_CHECKBOX },
{ "Woodfall Mountain Appearance",
"gEnhancements.Restorations.WoodfallMountainAppearance",
{ "Woodfall Mountain Appearance", "gEnhancements.Restorations.WoodfallMountainAppearance",
"Restores the appearance of Woodfall mountain to not look poisoned "
"when viewed from Termina Field after clearing Woodfall Temple\n\n"
"Requires a scene reload to take effect",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { RegisterWoodfallMountainAppearance(); } } } } });
WIDGET_CVAR_CHECKBOX } } } });

enhancementsSidebar.push_back(
{ "Difficulty Options",
3,
{ { { "Disable Takkuri Steal",
"gEnhancements.Cheats.DisableTakkuriSteal",
{ { { "Disable Takkuri Steal", "gEnhancements.Cheats.DisableTakkuriSteal",
"Prevents the Takkuri from stealing key items like bottles and swords. It may still steal other items.",
WIDGET_CVAR_CHECKBOX,
{},
[](widgetInfo& info) { RegisterDisableTakkuriSteal(); } },
WIDGET_CVAR_CHECKBOX },
{ "Deku Guard Search Balls",
"gEnhancements.Cheats.DekuGuardSearchBalls",
"Choose when to show the Deku Palace Guards' search balls\n"
Expand Down
8 changes: 0 additions & 8 deletions mm/2s2h/Enhancements/Camera/Camera.h

This file was deleted.

Loading

0 comments on commit 11340f1

Please sign in to comment.