diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2020-05-17 17:34:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-17 17:34:08 +0200 |
| commit | 099197b480bcc35fd84f059359ab739a30b0bac0 (patch) | |
| tree | 89228aa740dfc7ba67addef4823552b36fcc45c1 /Source/Core/DolphinNoGUI/MainNoGUI.cpp | |
| parent | cea779cc844ffe1a470b174bba7198b27d1e5d6a (diff) | |
| parent | cdf5490d56f02001fe79230a59fed76c60d69db7 (diff) | |
Merge pull request #8797 from iwubcode/save-state-CLI
Core: Add support for booting a save state from command line
Diffstat (limited to 'Source/Core/DolphinNoGUI/MainNoGUI.cpp')
| -rw-r--r-- | Source/Core/DolphinNoGUI/MainNoGUI.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Source/Core/DolphinNoGUI/MainNoGUI.cpp b/Source/Core/DolphinNoGUI/MainNoGUI.cpp index 1278d46c40..0bf4df23b8 100644 --- a/Source/Core/DolphinNoGUI/MainNoGUI.cpp +++ b/Source/Core/DolphinNoGUI/MainNoGUI.cpp @@ -156,13 +156,21 @@ int main(int argc, char* argv[]) optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv); std::vector<std::string> args = parser->args(); + std::optional<std::string> save_state_path; + if (options.is_set("save_state")) + { + save_state_path = static_cast<const char*>(options.get("save_state")); + } + std::unique_ptr<BootParameters> boot; + bool game_specified = false; if (options.is_set("exec")) { const std::list<std::string> paths_list = options.all("exec"); const std::vector<std::string> paths{std::make_move_iterator(std::begin(paths_list)), std::make_move_iterator(std::end(paths_list))}; - boot = BootParameters::GenerateFromFile(paths); + boot = BootParameters::GenerateFromFile(paths, save_state_path); + game_specified = true; } else if (options.is_set("nand_title")) { @@ -178,8 +186,9 @@ int main(int argc, char* argv[]) } else if (args.size()) { - boot = BootParameters::GenerateFromFile(args.front()); + boot = BootParameters::GenerateFromFile(args.front(), save_state_path); args.erase(args.begin()); + game_specified = true; } else { @@ -201,6 +210,12 @@ int main(int argc, char* argv[]) return 1; } + if (save_state_path && !game_specified) + { + fprintf(stderr, "A save state cannot be loaded without specifying a game to launch.\n"); + return 1; + } + Core::SetOnStateChangedCallback([](Core::State state) { if (state == Core::State::Uninitialized) s_platform->Stop(); |
