SaveTool: add a way to skip the disclaimer.

This commit is contained in:
Guillaume Jacquemin 2021-08-18 20:09:22 +02:00
parent 6d4bafcc2d
commit a244e468d2
3 changed files with 28 additions and 6 deletions

View file

@ -152,7 +152,7 @@ SaveTool::SaveTool(const Arguments& arguments):
} }
if(_checkUpdatesOnStartup) { if(_checkUpdatesOnStartup) {
_thread = std::thread{[this]{ checkForUpdates(); }}; _updateThread = std::thread{[this]{ checkForUpdates(); }};
_queue.addToast(Toast::Type::Default, "Checking for updates..."); _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); 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() { SaveTool::~SaveTool() {
@ -169,6 +174,7 @@ SaveTool::~SaveTool() {
_conf.setValue("cheat_mode", _cheatMode); _conf.setValue("cheat_mode", _cheatMode);
_conf.setValue("unsafe_mode", _unsafeMode); _conf.setValue("unsafe_mode", _unsafeMode);
_conf.setValue("startup_update_check", _checkUpdatesOnStartup); _conf.setValue("startup_update_check", _checkUpdatesOnStartup);
_conf.setValue("skip_disclaimer", _skipDisclaimer);
switch(_framelimit) { switch(_framelimit) {
case Framelimit::Vsync: case Framelimit::Vsync:
@ -309,7 +315,7 @@ void SaveTool::anyEvent(SDL_Event& event) {
} }
void SaveTool::initEvent(SDL_Event& event) { void SaveTool::initEvent(SDL_Event& event) {
_thread.join(); _initThread.join();
switch(event.user.code) { switch(event.user.code) {
case InitSuccess: case InitSuccess:
@ -326,7 +332,7 @@ void SaveTool::initEvent(SDL_Event& event) {
} }
void SaveTool::updateCheckEvent(SDL_Event& event) { void SaveTool::updateCheckEvent(SDL_Event& event) {
_thread.join(); _updateThread.join();
cpr::Response r{std::move(*static_cast<cpr::Response*>(event.user.data1))}; cpr::Response r{std::move(*static_cast<cpr::Response*>(event.user.data1))};
delete static_cast<cpr::Response*>(event.user.data1); delete static_cast<cpr::Response*>(event.user.data1);
@ -413,6 +419,13 @@ void SaveTool::initialiseConfiguration() {
_conf.setValue("startup_update_check", _checkUpdatesOnStartup); _conf.setValue("startup_update_check", _checkUpdatesOnStartup);
} }
if(_conf.hasValue("skip_disclaimer")) {
_skipDisclaimer = _conf.value<bool>("skip_disclaimer");
}
else {
_conf.setValue("skip_disclaimer", _skipDisclaimer);
}
if(_conf.hasValue("frame_limit")) { if(_conf.hasValue("frame_limit")) {
std::string frame_limit = _conf.value("frame_limit"); std::string frame_limit = _conf.value("frame_limit");
if(frame_limit == "vsync") { if(frame_limit == "vsync") {
@ -626,11 +639,16 @@ void SaveTool::drawDisclaimer() {
ImGui::TableSetupColumn("##Empty2", ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("##Empty2", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextRow(); 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::TableSetColumnIndex(1);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {24.0f, 12.0f}); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {24.0f, 12.0f});
if(ImGui::Button("I understand the risks")) { if(ImGui::Button("I understand the risks")) {
_uiState = UiState::Initialising; _uiState = UiState::Initialising;
_thread = std::thread{[this]{ initialiseManager(); }}; _initThread = std::thread{[this]{ initialiseManager(); }};
} }
ImGui::PopStyleVar(); ImGui::PopStyleVar();

View file

@ -164,7 +164,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
ToastQueue _queue; 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 _initEventId;
UnsignedInt _updateEventId; UnsignedInt _updateEventId;
@ -204,6 +205,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
} _framelimit{Framelimit::Vsync}; } _framelimit{Framelimit::Vsync};
UnsignedInt _fpsCap{60}; UnsignedInt _fpsCap{60};
bool _skipDisclaimer{false};
bool _checkUpdatesOnStartup{true}; bool _checkUpdatesOnStartup{true};
bool _unsafeMode{false}; bool _unsafeMode{false};

View file

@ -114,7 +114,7 @@ void SaveTool::drawMainMenu() {
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) { if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) {
_queue.addToast(Toast::Type::Default, "Checking for updates..."); _queue.addToast(Toast::Type::Default, "Checking for updates...");
_thread = std::thread{[this]{ checkForUpdates(); }}; _updateThread = std::thread{[this]{ checkForUpdates(); }};
} }
if(_updateAvailable) { if(_updateAvailable) {
@ -129,6 +129,8 @@ void SaveTool::drawMainMenu() {
} }
} }
ImGui::Checkbox("Skip disclaimer", &_skipDisclaimer);
ImGui::EndMenu(); ImGui::EndMenu();
} }