mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-19 21:03:42 -07:00
Removed the need for the "OnDeleteSelectedFile and "OnDeleteAllFiles Hooks.
Reworked it to use the SaveManger's "DeleteZeldaFile()" function in the "Delete Selected Save File" and "Delete All Saves" button callback.
This commit is contained in:
parent
dff2f76965
commit
564fdce5d4
4 changed files with 10 additions and 22 deletions
|
@ -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, ());
|
||||
|
|
|
@ -124,14 +124,6 @@ SaveManager::SaveManager() {
|
|||
|
||||
AddInitFunction(InitFileImpl);
|
||||
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnDeleteAllFiles>(
|
||||
[this]() { this->DeleteAllZeldaFiles(); });
|
||||
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnDeleteSelectedFile>([this]() {
|
||||
int selectedFileNum = CVarGetInteger(CVAR_SETTING("DeleteSelectedSaveFileNum"), 0);
|
||||
this->DeleteZeldaFile(selectedFileNum - 1 );
|
||||
});
|
||||
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnExitGame>(
|
||||
[this](uint32_t fileNum) { ThreadPoolWait(); });
|
||||
|
||||
|
@ -2379,12 +2371,6 @@ 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,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.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "soh/OTRGlobals.h"
|
||||
#include <soh/GameVersions.h>
|
||||
#include "soh/ResourceManagerHelpers.h"
|
||||
#include "soh/SaveManager.h"
|
||||
#include "UIWidgets.hpp"
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
|
||||
|
@ -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<GameInteractor::OnDeleteAllFiles>();
|
||||
for (int fileNum = 0; fileNum < SaveManager::MaxFiles; fileNum++) {
|
||||
SaveManager::Instance->DeleteZeldaFile(fileNum);
|
||||
}
|
||||
|
||||
CVarSetInteger(CVAR_SETTING("EnableDeleteAllSelectedSaveFiles"), 0);
|
||||
std::reinterpret_pointer_cast<Ship::ConsoleWindow>(
|
||||
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<GameInteractor::OnDeleteSelectedFile>();
|
||||
int selectedFileNum = CVarGetInteger(CVAR_SETTING("DeleteSelectedSaveFileNum"), 0);
|
||||
SaveManager::Instance->DeleteZeldaFile(selectedFileNum - 1);
|
||||
|
||||
CVarSetInteger(CVAR_SETTING("EnableDeleteAllSelectedSaveFiles"), 0);
|
||||
std::reinterpret_pointer_cast<Ship::ConsoleWindow>(
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue