From f2a64aa8e7ca1fad9d8216c1a39b95a18ee7f58f Mon Sep 17 00:00:00 2001 From: GH Cao Date: Fri, 3 Jan 2020 08:18:48 +0800 Subject: [PATCH] UWP: Save config on exit --- .../RetroArch-msvc2017-UWP.vcxproj.filters | 3 ++ uwp/uwp_main.cpp | 28 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pkg/msvc-uwp/RetroArch-msvc2017-UWP/RetroArch-msvc2017-UWP.vcxproj.filters b/pkg/msvc-uwp/RetroArch-msvc2017-UWP/RetroArch-msvc2017-UWP.vcxproj.filters index 57ec176ea0..659a23e637 100644 --- a/pkg/msvc-uwp/RetroArch-msvc2017-UWP/RetroArch-msvc2017-UWP.vcxproj.filters +++ b/pkg/msvc-uwp/RetroArch-msvc2017-UWP/RetroArch-msvc2017-UWP.vcxproj.filters @@ -25,6 +25,9 @@ + + + diff --git a/uwp/uwp_main.cpp b/uwp/uwp_main.cpp index 7b46bdffcd..120e8757b7 100644 --- a/uwp/uwp_main.cpp +++ b/uwp/uwp_main.cpp @@ -18,10 +18,14 @@ #include #include +#include #include #include #include +#include "configuration.h" +#include "paths.h" + #include "uwp_main.h" #include "../retroarch.h" #include "../frontend/frontend.h" @@ -372,10 +376,32 @@ void App::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args) // aware that a deferral may not be held indefinitely. After about five seconds, // the app will be forced to exit. SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral(); + auto app = this; - create_task([this, deferral]() + create_task([app, deferral]() { // TODO: Maybe creating a save state here would be a good idea? + settings_t* settings = config_get_ptr(); + if (settings->bools.config_save_on_exit) { + if (!path_is_empty(RARCH_PATH_CONFIG)) + { + const char* config_path = path_get(RARCH_PATH_CONFIG); + bool path_exists = !string_is_empty(config_path); + + if (path_exists && config_save_file(config_path)) + { + RARCH_LOG("[config] %s \"%s\".\n", + msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), + config_path); + } + else if (path_exists) + { + RARCH_ERR("[config] %s \"%s\".\n", + msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO), + config_path); + } + } + } deferral->Complete(); });