This commit is contained in:
Glought 2025-08-14 06:12:20 -07:00 committed by GitHub
commit 241dcdaefa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include <soh/GameVersions.h> #include <soh/GameVersions.h>
#include "soh/ResourceManagerHelpers.h" #include "soh/ResourceManagerHelpers.h"
#include "soh/SaveManager.h"
#include "UIWidgets.hpp" #include "UIWidgets.hpp"
#include <spdlog/fmt/fmt.h> #include <spdlog/fmt/fmt.h>
@ -191,6 +192,55 @@ void SohMenu::AddMenuSettings() {
}) })
.Options(ButtonOptions().Tooltip("Opens the folder that contains the save and mods folders, etc.")); .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("EnableSaveDeletionOptions"), 0);
info.options->disabledTooltip = "This is disabled because \"Enable Save Deletion Options\" is turned off.";
};
AddWidget(path, "Enable Save Deletion Options", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_SETTING("EnableSaveDeletionOptions"))
.RaceDisable(false)
.Options(CheckboxOptions()
.Tooltip("Turn on to enable the save deletion options below.Turns off automatically "
"when \"Delete All/Selected Saves\" button is pressed")
.DefaultValue(false));
AddWidget(path, "Delete All Saves", WIDGET_BUTTON)
.RaceDisable(false)
.PreFunc(deleteSaveFilesDisabledFunc)
.Callback([](WidgetInfo& info) {
for (int fileNum = 0; fileNum < SaveManager::MaxFiles; fileNum++) {
SaveManager::Instance->DeleteZeldaFile(fileNum);
}
CVarSetInteger(CVAR_SETTING("EnableSaveDeletionOptions"), 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, "Select Save File To Delete: ", WIDGET_CVAR_SLIDER_INT)
.CVar(CVAR_SETTING("DeleteSelectedSaveFileNum"))
.PreFunc(deleteSaveFilesDisabledFunc)
.Options(IntSliderOptions()
.Min(1)
.Max(3)
.DefaultValue(1)
.Format("File %d ")
.Tooltip("Select which save file to delete.Then press \"Delete Selected Save File\" to delete."));
AddWidget(path, "Delete Selected Save File", WIDGET_BUTTON)
.RaceDisable(false)
.PreFunc(deleteSaveFilesDisabledFunc)
.Callback([](WidgetInfo& info) {
int selectedFileNum = CVarGetInteger(CVAR_SETTING("DeleteSelectedSaveFileNum"), 0);
SaveManager::Instance->DeleteZeldaFile(selectedFileNum - 1);
CVarSetInteger(CVAR_SETTING("EnableSaveDeletionOptions"), 0);
std::reinterpret_pointer_cast<Ship::ConsoleWindow>(
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
->Dispatch("reset");
})
.Options(ButtonOptions().Tooltip("Warning deletes selected save file"));
AddWidget(path, "Boot", WIDGET_SEPARATOR_TEXT); AddWidget(path, "Boot", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Boot Sequence", WIDGET_CVAR_COMBOBOX) AddWidget(path, "Boot Sequence", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_SETTING("BootSequence")) .CVar(CVAR_SETTING("BootSequence"))