From beea900d6f00433e814ade60eefe992c12cc2707 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Sun, 10 Nov 2024 20:06:50 +0100 Subject: [PATCH] Added --fullscreen argument --- src/main.cpp | 31 +++++++++++++++++++++++++++++-- src/qt_gui/main.cpp | 28 +++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a86c53300c..063a85ee3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ #include "unordered_map" #include +#include "common/config.h" #include "common/memory_patcher.h" #include "emulator.h" @@ -57,6 +58,27 @@ int main(int argc, char* argv[]) { } }}, {"--patch", [&](int& i) { arg_map["-p"](i); }}, + {"-f", + [&](int& i) { + if (++i >= argc) { + std::cerr << "Error: Missing argument for -f/--fullscreen\n"; + exit(1); + } + std::string f_param(argv[i]); + bool is_fullscreen; + if (f_param == "true") { + is_fullscreen = true; + } else if (f_param == "false") { + is_fullscreen = false; + } else { + std::cerr + << "Error: Invalid argument for -f/--fullscreen. Use 'true' or 'false'.\n"; + exit(1); + } + // Set fullscreen mode without saving it to config file + Config::setFullscreenMode(is_fullscreen); + }}, + {"--fullscreen", [&](int& i) { arg_map["-f"](i); }}, }; if (argc == 1) { @@ -76,13 +98,18 @@ int main(int argc, char* argv[]) { game_path = argv[i]; has_game_argument = true; } else { - std::cerr << "Unknown argument: " << cur_arg << "\n"; + std::cerr << "Unknown argument: " << cur_arg << ", see --help for info.\n"; return 1; } } + if (!has_game_argument) { + std::cerr << "Error: Please provide a game path or ID.\n"; + exit(1); + } + // Check if the game path or ID exists - if (!has_game_argument || !std::filesystem::exists(game_path)) { + if (!std::filesystem::exists(game_path)) { std::cerr << "Error: Game file not found\n"; return -1; } diff --git a/src/qt_gui/main.cpp b/src/qt_gui/main.cpp index 7e1bbd17f1..040c1f53b2 100644 --- a/src/qt_gui/main.cpp +++ b/src/qt_gui/main.cpp @@ -74,6 +74,27 @@ int main(int argc, char* argv[]) { } }}, {"--patch", [&](int& i) { arg_map["-p"](i); }}, + {"-f", + [&](int& i) { + if (++i >= argc) { + std::cerr << "Error: Missing argument for -f/--fullscreen\n"; + exit(1); + } + std::string f_param(argv[i]); + bool is_fullscreen; + if (f_param == "true") { + is_fullscreen = true; + } else if (f_param == "false") { + is_fullscreen = false; + } else { + std::cerr + << "Error: Invalid argument for -f/--fullscreen. Use 'true' or 'false'.\n"; + exit(1); + } + // Set fullscreen mode without saving it to config file + Config::setFullscreenMode(is_fullscreen); + }}, + {"--fullscreen", [&](int& i) { arg_map["-f"](i); }}, }; // Parse command-line arguments using the map @@ -83,7 +104,7 @@ int main(int argc, char* argv[]) { if (it != arg_map.end()) { it->second(i); // Call the associated lambda function } else { - std::cerr << "Unknown argument: " << cur_arg << "\n"; + std::cerr << "Unknown argument: " << cur_arg << ", see --help for info.\n"; return 1; } } @@ -103,6 +124,11 @@ int main(int argc, char* argv[]) { m_main_window->Init(); } + if (has_command_line_argument && !has_game_argument) { + std::cerr << "Error: Please provide a game path or ID.\n"; + exit(1); + } + // Process game path or ID if provided if (has_game_argument) { std::filesystem::path game_file_path(gamePath);