[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>
This commit is contained in:
balloondude2
2024-07-11 21:44:08 -04:00
committed by GitHub
co-authored by Archez
parent 2e4710c6c2
commit aa1b0108f4
2 changed files with 13 additions and 2 deletions
+4
View File
@@ -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");
+9 -2
View File
@@ -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;
}
});
}