mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-19 21:03:42 -07:00
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:
parent
237dcfec74
commit
baaedd7ab0
4 changed files with 34 additions and 0 deletions
|
@ -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, ());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue