diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index c8a85aae4..51a6ab5a8 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -47,8 +47,6 @@ DEFINE_HOOK(OnVanillaBehavior, (GIVanillaBehavior flag, bool* result, va_list or DEFINE_HOOK(OnSaveFile, (int32_t fileNum)); DEFINE_HOOK(OnLoadFile, (int32_t fileNum)); DEFINE_HOOK(OnDeleteFile, (int32_t fileNum)); -DEFINE_HOOK(OnDeleteSelectedFile, ()); -DEFINE_HOOK(OnDeleteAllFiles, ()); DEFINE_HOOK(OnDialogMessage, ()); DEFINE_HOOK(OnPresentTitleCard, ()); diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index ef5d1aa25..4b830f846 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -124,14 +124,6 @@ SaveManager::SaveManager() { AddInitFunction(InitFileImpl); - GameInteractor::Instance->RegisterGameHook( - [this]() { this->DeleteAllZeldaFiles(); }); - - GameInteractor::Instance->RegisterGameHook([this]() { - int selectedFileNum = CVarGetInteger(CVAR_SETTING("DeleteSelectedSaveFileNum"), 0); - this->DeleteZeldaFile(selectedFileNum - 1 ); - }); - GameInteractor::Instance->RegisterGameHook( [this](uint32_t fileNum) { ThreadPoolWait(); }); @@ -2379,12 +2371,6 @@ void SaveManager::DeleteZeldaFile(int fileNum) { GameInteractor::Instance->ExecuteHooks(fileNum); } -void SaveManager::DeleteAllZeldaFiles() { - for (int fileNum = 0; fileNum < MaxFiles; fileNum++) { - DeleteZeldaFile(fileNum); - } -} - bool SaveManager::IsRandoFile() { return IS_RANDO; } diff --git a/soh/soh/SaveManager.h b/soh/soh/SaveManager.h index d89e090cb..6d7ef3b33 100644 --- a/soh/soh/SaveManager.h +++ b/soh/soh/SaveManager.h @@ -103,8 +103,6 @@ class SaveManager { void CopyZeldaFile(int from, int to); void DeleteZeldaFile(int fileNum); - void DeleteAllZeldaFiles(); - bool IsRandoFile(); // Use a name of "" to save to an array. You must be in a SaveArray callback. diff --git a/soh/soh/SohGui/SohMenuSettings.cpp b/soh/soh/SohGui/SohMenuSettings.cpp index b507eb1ee..1c8abe980 100644 --- a/soh/soh/SohGui/SohMenuSettings.cpp +++ b/soh/soh/SohGui/SohMenuSettings.cpp @@ -3,6 +3,7 @@ #include "soh/OTRGlobals.h" #include #include "soh/ResourceManagerHelpers.h" +#include "soh/SaveManager.h" #include "UIWidgets.hpp" #include @@ -187,7 +188,7 @@ void SohMenu::AddMenuSettings() { SDL_OpenURL(std::string("file:///" + std::filesystem::absolute(filesPath).string()).c_str()); }) .Options(ButtonOptions().Tooltip("Opens the folder that contains the save and mods folders, etc.")); - + AddWidget(path, "Saves", WIDGET_SEPARATOR_TEXT); auto deleteSaveFilesDisabledFunc = [](WidgetInfo& info) { info.options->disabled = !CVarGetInteger(CVAR_SETTING("EnableDeleteAllSelectedSaveFiles"), 0); @@ -205,13 +206,16 @@ void SohMenu::AddMenuSettings() { .RaceDisable(false) .PreFunc(deleteSaveFilesDisabledFunc) .Callback([](WidgetInfo& info) { - GameInteractor::Instance->ExecuteHooks(); + for (int fileNum = 0; fileNum < SaveManager::MaxFiles; fileNum++) { + SaveManager::Instance->DeleteZeldaFile(fileNum); + } + CVarSetInteger(CVAR_SETTING("EnableDeleteAllSelectedSaveFiles"), 0); std::reinterpret_pointer_cast( Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch("reset"); }) - .Options(ButtonOptions().Tooltip("Warning deletes all save files")); + .Options(ButtonOptions().Tooltip("Warning deletes all save files")); AddWidget(path, "Select Save File To Delete: ", WIDGET_CVAR_SLIDER_INT) .CVar(CVAR_SETTING("DeleteSelectedSaveFileNum")) .PreFunc(deleteSaveFilesDisabledFunc) @@ -225,7 +229,9 @@ void SohMenu::AddMenuSettings() { .RaceDisable(false) .PreFunc(deleteSaveFilesDisabledFunc) .Callback([](WidgetInfo& info) { - GameInteractor::Instance->ExecuteHooks(); + int selectedFileNum = CVarGetInteger(CVAR_SETTING("DeleteSelectedSaveFileNum"), 0); + SaveManager::Instance->DeleteZeldaFile(selectedFileNum - 1); + CVarSetInteger(CVAR_SETTING("EnableDeleteAllSelectedSaveFiles"), 0); std::reinterpret_pointer_cast( Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))