From a244e468d2b6e1cbcecdb9f71d0196e39ce5e98e Mon Sep 17 00:00:00 2001 From: William JCM Date: Wed, 18 Aug 2021 20:09:22 +0200 Subject: [PATCH] SaveTool: add a way to skip the disclaimer. --- src/SaveTool/SaveTool.cpp | 26 ++++++++++++++++++++++---- src/SaveTool/SaveTool.h | 4 +++- src/SaveTool/SaveTool_drawMainMenu.cpp | 4 +++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 3cfb068..f00fa1f 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -152,7 +152,7 @@ SaveTool::SaveTool(const Arguments& arguments): } if(_checkUpdatesOnStartup) { - _thread = std::thread{[this]{ checkForUpdates(); }}; + _updateThread = std::thread{[this]{ checkForUpdates(); }}; _queue.addToast(Toast::Type::Default, "Checking for updates..."); } @@ -161,6 +161,11 @@ SaveTool::SaveTool(const Arguments& arguments): { GL::DebugOutput::setEnabled(GL::DebugOutput::Source::Api, GL::DebugOutput::Type::Other, {131185}, false); } + + if(_skipDisclaimer) { + _uiState = UiState::Initialising; + _initThread = std::thread{[this]{ initialiseManager(); }}; + } } SaveTool::~SaveTool() { @@ -169,6 +174,7 @@ SaveTool::~SaveTool() { _conf.setValue("cheat_mode", _cheatMode); _conf.setValue("unsafe_mode", _unsafeMode); _conf.setValue("startup_update_check", _checkUpdatesOnStartup); + _conf.setValue("skip_disclaimer", _skipDisclaimer); switch(_framelimit) { case Framelimit::Vsync: @@ -309,7 +315,7 @@ void SaveTool::anyEvent(SDL_Event& event) { } void SaveTool::initEvent(SDL_Event& event) { - _thread.join(); + _initThread.join(); switch(event.user.code) { case InitSuccess: @@ -326,7 +332,7 @@ void SaveTool::initEvent(SDL_Event& event) { } void SaveTool::updateCheckEvent(SDL_Event& event) { - _thread.join(); + _updateThread.join(); cpr::Response r{std::move(*static_cast(event.user.data1))}; delete static_cast(event.user.data1); @@ -413,6 +419,13 @@ void SaveTool::initialiseConfiguration() { _conf.setValue("startup_update_check", _checkUpdatesOnStartup); } + if(_conf.hasValue("skip_disclaimer")) { + _skipDisclaimer = _conf.value("skip_disclaimer"); + } + else { + _conf.setValue("skip_disclaimer", _skipDisclaimer); + } + if(_conf.hasValue("frame_limit")) { std::string frame_limit = _conf.value("frame_limit"); if(frame_limit == "vsync") { @@ -626,11 +639,16 @@ void SaveTool::drawDisclaimer() { ImGui::TableSetupColumn("##Empty2", ImGuiTableColumnFlags_WidthStretch); ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Dummy({0.0f, 5.0f}); + ImGui::Dummy({4.0f, 0.0f}); + ImGui::SameLine(); + ImGui::Checkbox("Don't show next time", &_skipDisclaimer); ImGui::TableSetColumnIndex(1); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {24.0f, 12.0f}); if(ImGui::Button("I understand the risks")) { _uiState = UiState::Initialising; - _thread = std::thread{[this]{ initialiseManager(); }}; + _initThread = std::thread{[this]{ initialiseManager(); }}; } ImGui::PopStyleVar(); diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index 9e727b8..f50f6cf 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -164,7 +164,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener ToastQueue _queue; - std::thread _thread; // used for threaded operations such as profile manager init or update checking. + std::thread _initThread; + std::thread _updateThread; UnsignedInt _initEventId; UnsignedInt _updateEventId; @@ -204,6 +205,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener } _framelimit{Framelimit::Vsync}; UnsignedInt _fpsCap{60}; + bool _skipDisclaimer{false}; bool _checkUpdatesOnStartup{true}; bool _unsafeMode{false}; diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/SaveTool/SaveTool_drawMainMenu.cpp index e69478b..6fd1128 100644 --- a/src/SaveTool/SaveTool_drawMainMenu.cpp +++ b/src/SaveTool/SaveTool_drawMainMenu.cpp @@ -114,7 +114,7 @@ void SaveTool::drawMainMenu() { ImGui::SameLine(); if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) { _queue.addToast(Toast::Type::Default, "Checking for updates..."); - _thread = std::thread{[this]{ checkForUpdates(); }}; + _updateThread = std::thread{[this]{ checkForUpdates(); }}; } if(_updateAvailable) { @@ -129,6 +129,8 @@ void SaveTool::drawMainMenu() { } } + ImGui::Checkbox("Skip disclaimer", &_skipDisclaimer); + ImGui::EndMenu(); }