MCPcopy Create free account
hub / github.com/clementgallet/libTAS / save

Method save

src/program/Config.cpp:37–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void Config::save(const std::filesystem::path& gamepath) {
38 /* Save only if game file exists */
39 if (!std::filesystem::exists(gamepath))
40 return;
41
42 /* Save the gamepath in recent gamepaths */
43 auto it = std::find(recent_gamepaths.begin(), recent_gamepaths.end(), gamepath);
44 if (it != recent_gamepaths.end()) {
45 recent_gamepaths.erase(it);
46 }
47 recent_gamepaths.push_front(gamepath);
48
49 /* Save the option in recent options */
50 auto arg_it = std::find(recent_args.begin(), recent_args.end(), gameargs);
51 if (arg_it != recent_args.end()) {
52 recent_args.erase(arg_it);
53 }
54 recent_args.push_front(gameargs);
55
56 /* Open the general preferences */
57 std::filesystem::path generalPath = configdir / "libTAS.ini";
58
59 QSettings general_settings(QString(generalPath.c_str()), QSettings::IniFormat);
60 general_settings.setFallbacksEnabled(false);
61
62 general_settings.remove("recent_gamepaths");
63 general_settings.beginWriteArray("recent_gamepaths");
64 int i = 0;
65 for (auto& path : recent_gamepaths) {
66 general_settings.setArrayIndex(i++);
67 general_settings.setValue("gamepath", path.c_str());
68 if (i > 10) break;
69 }
70 general_settings.endArray();
71
72 general_settings.setValue("debugger", debugger);
73 general_settings.setValue("strace_events", strace_events.c_str());
74 general_settings.setValue("allow_downloads", allow_downloads);
75
76 general_settings.setValue("datadir", datadir.c_str());
77 general_settings.setValue("steamuserdir", steamuserdir.c_str());
78 general_settings.setValue("tempmoviedir", tempmoviedir.c_str());
79 general_settings.setValue("savestatedir", savestatedir.c_str());
80 general_settings.setValue("ramsearchdir", ramsearchdir.c_str());
81 general_settings.setValue("extralib32dir", extralib32dir.c_str());
82 general_settings.setValue("extralib64dir", extralib64dir.c_str());
83
84 /* Open the preferences for the game */
85 QSettings settings(iniPath(gamepath), QSettings::IniFormat);
86 settings.setFallbacksEnabled(false);
87
88 /* Save recent options */
89 settings.remove("recent_args");
90 settings.beginWriteArray("recent_args");
91 i = 0;
92 for (auto& args : recent_args) {
93 settings.setArrayIndex(i++);
94 settings.setValue("args", args.c_str());

Callers 1

mainFunction · 0.45

Calls 5

findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected