From 16b8807eb7f628680d4e32fdee92e254a3c35ea7 Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 21 Nov 2022 09:19:48 +0100 Subject: [PATCH] SaveTool: remove unsafe mode. It was just not good at all. --- src/SaveTool/SaveTool.cpp | 1 - src/SaveTool/SaveTool.h | 14 +++----------- src/SaveTool/SaveTool_Initialisation.cpp | 7 ------- src/SaveTool/SaveTool_MainManager.cpp | 12 ++++++------ src/SaveTool/SaveTool_drawMainMenu.cpp | 6 ------ 5 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 1978a38..2bf542e 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -172,7 +172,6 @@ SaveTool::~SaveTool() { Utility::Debug{} << "Saving the configuration..."; _conf.setValue("cheat_mode"_s, _cheatMode); - _conf.setValue("unsafe_mode"_s, _unsafeMode); _conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup); _conf.setValue("skip_disclaimer"_s, _skipDisclaimer); diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index 91ec2f5..0ee8d6f 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -166,23 +166,16 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener template auto drawUnsafeWidget(Functor func, Args... args) -> bool { GameState game_state = _gameState; // Copying the value to reduce the risk of a data race. - if(!_unsafeMode && game_state != GameState::NotRunning) { - ImGui::BeginDisabled(); - } - + ImGui::BeginDisabled(game_state != GameState::NotRunning); bool result = func(std::forward(args)...); - - if(!_unsafeMode && game_state != GameState::NotRunning) { - ImGui::EndDisabled(); - } - + ImGui::EndDisabled(); return result; } // Obviously, should only be used with ImGui widgets that return a bool. // Also, func should be a lambda if there are any default arguments, like ImGui::Button(), etc... template void drawUnsafeText(Containers::StringView text, Args... args) { // Alternative to the above, for ImGui::Text*() variants. - if(!_unsafeMode && _gameState != GameState::NotRunning) { + if(_gameState != GameState::NotRunning) { ImGui::TextDisabled(text, std::forward(args)...); } else { @@ -276,7 +269,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener bool _skipDisclaimer{false}; bool _checkUpdatesOnStartup{true}; - bool _unsafeMode{false}; bool _updateAvailable{false}; Containers::String _latestVersion; diff --git a/src/SaveTool/SaveTool_Initialisation.cpp b/src/SaveTool/SaveTool_Initialisation.cpp index 2323b58..c6b42a0 100644 --- a/src/SaveTool/SaveTool_Initialisation.cpp +++ b/src/SaveTool/SaveTool_Initialisation.cpp @@ -54,13 +54,6 @@ void SaveTool::initialiseConfiguration() { _conf.setValue("cheat_mode"_s, _cheatMode); } - if(_conf.hasValue("unsafe_mode"_s)) { - _unsafeMode = _conf.value("unsafe_mode"_s); - } - else { - _conf.setValue("unsafe_mode"_s, _unsafeMode); - } - if(_conf.hasValue("startup_update_check"_s)) { _checkUpdatesOnStartup = _conf.value("startup_update_check"_s); } diff --git a/src/SaveTool/SaveTool_MainManager.cpp b/src/SaveTool/SaveTool_MainManager.cpp index 8232113..49cbfbe 100644 --- a/src/SaveTool/SaveTool_MainManager.cpp +++ b/src/SaveTool/SaveTool_MainManager.cpp @@ -146,8 +146,8 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView name_view) -> bool { callback, nullptr); ImGui::SameLine(); GameState game_state = _gameState; - if((!_unsafeMode && game_state != GameState::NotRunning) || - !(len >= 6 && len <= 32) || + if(game_state != GameState::NotRunning || + !(len >= 6 && len <= 32) || !(name_view[0] != ' ' && name_view[len - 1] != ' ')) { ImGui::BeginDisabled(); @@ -158,8 +158,8 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView name_view) -> bool { ImGui::CloseCurrentPopup(); } - if((!_unsafeMode && game_state != GameState::NotRunning) || - !(len >= 6 && len <= 32) || + if(game_state != GameState::NotRunning || + !(len >= 6 && len <= 32) || !(name_view[0] != ' ' && name_view[len - 1] != ' ')) { ImGui::EndDisabled(); @@ -249,7 +249,7 @@ void SaveTool::drawGeneralInfo() { } drawTooltip("Story progress directly affects unlocked levels."); if(ImGui::BeginPopup("StoryProgressMenu")) { - if(!_unsafeMode && _gameState != GameState::NotRunning) { + if(_gameState != GameState::NotRunning) { ImGui::CloseCurrentPopup(); } for(const auto& sp : story_progress) { @@ -473,7 +473,7 @@ void SaveTool::drawMassManager() { ImGui::EndDragDropSource(); } - if((_unsafeMode || _gameState == GameState::NotRunning) && ImGui::BeginDragDropTarget()) { + if(_gameState == GameState::NotRunning && ImGui::BeginDragDropTarget()) { if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("StagedMass")) { if(payload->DataSize != sizeof(Containers::String)) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error", diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/SaveTool/SaveTool_drawMainMenu.cpp index 3250be4..0c51eb8 100644 --- a/src/SaveTool/SaveTool_drawMainMenu.cpp +++ b/src/SaveTool/SaveTool_drawMainMenu.cpp @@ -103,12 +103,6 @@ void SaveTool::drawMainMenu() { drawHelpMarker("This gives access to save edition features that can be considered cheats.", Float(windowSize().x()) * 0.4f); - ImGui::Checkbox("Unsafe mode", &_unsafeMode); - ImGui::SameLine(); - ImGui::AlignTextToFramePadding(); - drawHelpMarker("This allows changing the state of save files in the game's save folder even when the game is running.", - Float(windowSize().x()) * 0.4f); - ImGui::Checkbox("Check for updates on startup", &_checkUpdatesOnStartup); ImGui::SameLine(); if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) {