From f7b0c0f4931ba6f87b4dfe773c23fbde27376b7d Mon Sep 17 00:00:00 2001 From: johnnyruz Date: Mon, 4 Jan 2021 09:46:16 -0500 Subject: [PATCH] Add cli parameter to override default settings file (#1375) * Add cli parameter to specify alternate settings file * fix issue with error message string parameter --- src/frontend-common/common_host_interface.cpp | 18 ++++++++++++++++++ src/frontend-common/common_host_interface.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 3416cecc0..88005e265 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -225,6 +225,8 @@ static void PrintCommandLineHelp(const char* progname, const char* frontend_name std::fprintf(stderr, " -nocontroller: Prevents the emulator from polling for controllers.\n" " Try this option if you're having difficulties starting\n" " the emulator.\n"); + std::fprintf(stderr, " -settings : Loads a custom settings configuration from the\n" + " specified filename. Default settings applied if file not found.\n"); std::fprintf(stderr, " --: Signals that no more arguments will follow and the remaining\n" " parameters make up the filename. Use when the filename contains\n" " spaces or starts with a dash.\n"); @@ -323,6 +325,11 @@ bool CommonHostInterface::ParseCommandLineParameters(int argc, char* argv[], state_index = -1; continue; } + else if (CHECK_ARG_PARAM("-settings")) + { + m_settings_filename = argv[++i]; + continue; + } else if (CHECK_ARG("--")) { no_more_args = true; @@ -1956,6 +1963,17 @@ bool CommonHostInterface::SaveInputProfile(const char* profile_path, SettingsInt std::string CommonHostInterface::GetSettingsFileName() const { + if (!m_settings_filename.empty()) + { + if (!FileSystem::FileExists(m_settings_filename.c_str())) + { + Log_ErrorPrintf("Could not find settings file %s, using default", m_settings_filename.c_str()); + } + else + { + return GetUserDirectoryRelativePath(m_settings_filename.c_str()); + } + } return GetUserDirectoryRelativePath("settings.ini"); } diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h index 89be710a6..d7500147e 100644 --- a/src/frontend-common/common_host_interface.h +++ b/src/frontend-common/common_host_interface.h @@ -345,6 +345,8 @@ protected: std::deque m_osd_messages; std::mutex m_osd_messages_lock; + std::string m_settings_filename; + bool m_frame_step_request = false; bool m_fast_forward_enabled = false; bool m_timer_resolution_increased = false;