UWP: Save config on exit

This commit is contained in:
GH Cao 2020-01-03 08:18:48 +08:00
parent b6d01ce448
commit f2a64aa8e7
2 changed files with 30 additions and 1 deletions

View File

@ -25,6 +25,9 @@
<None Include="cores\$(Platform)\cores\*.dll" /> <None Include="cores\$(Platform)\cores\*.dll" />
<None Include="ANGLE\$(Platform)\*.dll" /> <None Include="ANGLE\$(Platform)\*.dll" />
<None Include="ANGLE\$(Platform)\*.dll" /> <None Include="ANGLE\$(Platform)\*.dll" />
<None Include="cores\$(Platform)\cores\*.dll" />
<None Include="ANGLE\$(Platform)\*.dll" />
<None Include="ANGLE\$(Platform)\*.dll" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\uwp\uwp_func.h"> <ClInclude Include="..\..\..\uwp\uwp_func.h">

View File

@ -18,10 +18,14 @@
#include <windows.devices.enumeration.h> #include <windows.devices.enumeration.h>
#include <encodings/utf.h> #include <encodings/utf.h>
#include <string/stdstring.h>
#include <lists/string_list.h> #include <lists/string_list.h>
#include <queues/task_queue.h> #include <queues/task_queue.h>
#include <retro_timers.h> #include <retro_timers.h>
#include "configuration.h"
#include "paths.h"
#include "uwp_main.h" #include "uwp_main.h"
#include "../retroarch.h" #include "../retroarch.h"
#include "../frontend/frontend.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, // aware that a deferral may not be held indefinitely. After about five seconds,
// the app will be forced to exit. // the app will be forced to exit.
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral(); 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? // 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(); deferral->Complete();
}); });