Add "Delete All Saves" QoL Feature.

*Added "Enable Delete All Saves" Checkbox.
*Added "Delete All Saves" Button

Both are in "Settings -> General -> General Settings" under the
"Open App Files Folder" button.

The "Enable Delete All Saves" Checkbox when checked enables the
"Delete All Saves" Button.It is uncheck by default.

The purpose for the "Enable Delete All Saves" checkbox is to prevent the
possibility of accidentally pressing the "Delete All Saves" Button by
mistake.

When the "Delete All Saves" Button is pressed it will delete all 3 save
files and resets SoH and then disables itself by turning off
"Enable Delete All Saves" Checkbox.

The Reasoning for this Qol is to have a quick way to
delete all saves instead of deleting each file using the in-game
file menu(takes a while took 30 actions to delete all 3 files)
or navigating the App file folder(Would require closing Soh, the
reset button doesn't clear the files slots in-game
if files are deleted outside of SoH.).
This commit is contained in:
Glought 2025-07-26 08:24:57 -07:00
commit baaedd7ab0
4 changed files with 34 additions and 0 deletions

View file

@ -47,6 +47,7 @@ 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(OnDeleteAllFiles, ());
DEFINE_HOOK(OnDialogMessage, ());
DEFINE_HOOK(OnPresentTitleCard, ());

View file

@ -124,6 +124,9 @@ SaveManager::SaveManager() {
AddInitFunction(InitFileImpl);
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnDeleteAllFiles>(
[this]() { this->DeleteAllZeldaFiles(); });
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnExitGame>(
[this](uint32_t fileNum) { ThreadPoolWait(); });
@ -2371,6 +2374,12 @@ void SaveManager::DeleteZeldaFile(int fileNum) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnDeleteFile>(fileNum);
}
void SaveManager::DeleteAllZeldaFiles() {
for (int fileNum = 0; fileNum < MaxFiles; fileNum++) {
DeleteZeldaFile(fileNum);
}
}
bool SaveManager::IsRandoFile() {
return IS_RANDO;
}

View file

@ -103,6 +103,8 @@ 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.

View file

@ -187,6 +187,28 @@ 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, "Enable Delete All Saves", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_SETTING("EnableDeleteAllSaveFilesButton"))
.RaceDisable(false)
.Options(CheckboxOptions()
.Tooltip("Turn on to enable the \"Delete All Saves\" button.Turns off automatically "
"when \"Delete All Saves\" is pressed")
.DefaultValue(false));
AddWidget(path, "Delete All Saves", WIDGET_BUTTON)
.RaceDisable(false)
.PreFunc([](WidgetInfo& info) {
info.options->disabled = !CVarGetInteger(CVAR_SETTING("EnableDeleteAllSaveFilesButton"), 0);
info.options->disabledTooltip =
"This button is disabled because \"Enable Delete All Saves\" is turned off.";
})
.Callback([](WidgetInfo& info) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnDeleteAllFiles>();
CVarSetInteger(CVAR_SETTING("EnableDeleteAllSaveFilesButton"), 0);
std::reinterpret_pointer_cast<Ship::ConsoleWindow>(
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
->Dispatch("reset");
})
.Options(ButtonOptions().Tooltip("Warning deletes all save files"));
AddWidget(path, "Boot", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Boot Sequence", WIDGET_CVAR_COMBOBOX)