diff options
| author | balloondude2 <55861555+balloondude2@users.noreply.github.com> | 2024-07-11 19:44:08 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-11 21:44:08 -0400 |
| commit | aa1b0108f41104f95779b5b6361293f81345556c (patch) | |
| tree | 6f049bf617b064983be416a3d663161a04b47245 | |
| parent | 2e4710c6c2d165de9ca8d4fe0eab29f2dbcfb110 (diff) | |
[Enhancement] Preseve time speed during cycle reset (#658)
* preseve time speed during cycle reset enhancement
* clang format
* update variable assignment
Co-authored-by: Archez <Archez@users.noreply.github.com>
* add default value
* better initial value
---------
Co-authored-by: Archez <Archez@users.noreply.github.com>
| -rw-r--r-- | mm/2s2h/BenGui/BenMenuBar.cpp | 4 | ||||
| -rw-r--r-- | mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 37089aa7f..465ae3b8a 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -465,6 +465,10 @@ void DrawEnhancementsMenu() { { .tooltip = "Playing the Song Of Time will not reset the Sword back to Kokiri Sword." }); UIWidgets::CVarCheckbox("Do not reset Rupees", "gEnhancements.Cycle.DoNotResetRupees", { .tooltip = "Playing the Song Of Time will not reset the your rupees." }); + UIWidgets::CVarCheckbox( + "Do not reset Time Speed", "gEnhancements.Cycle.DoNotResetTimeSpeed", + { .tooltip = + "Playing the Song Of Time will not reset the current time speed set by Inverted Song of Time." }); ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(255, 255, 0, 255)); ImGui::SeparatorText("Unstable"); diff --git a/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp b/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp index d1afedaac..9624d337b 100644 --- a/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp +++ b/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp @@ -7,10 +7,13 @@ extern "C" { } SaveInfo saveInfoCopy; +s32 timeSpeedOffsetCopy = 0; void RegisterEndOfCycleSaveHooks() { - GameInteractor::Instance->RegisterGameHook<GameInteractor::BeforeEndOfCycleSave>( - []() { memcpy(&saveInfoCopy, &gSaveContext.save.saveInfo, sizeof(SaveInfo)); }); + GameInteractor::Instance->RegisterGameHook<GameInteractor::BeforeEndOfCycleSave>([]() { + memcpy(&saveInfoCopy, &gSaveContext.save.saveInfo, sizeof(SaveInfo)); + timeSpeedOffsetCopy = gSaveContext.save.timeSpeedOffset; + }); GameInteractor::Instance->RegisterGameHook<GameInteractor::AfterEndOfCycleSave>([]() { if (CVarGetInteger("gEnhancements.Cycle.DoNotResetRupees", 0)) { @@ -77,5 +80,9 @@ void RegisterEndOfCycleSaveHooks() { SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_RAZOR); CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_RAZOR; } + + if (CVarGetInteger("gEnhancements.Cycle.DoNotResetTimeSpeed", 0)) { + gSaveContext.save.timeSpeedOffset = timeSpeedOffsetCopy; + } }); } |
