Add cli parameter to override default settings file (#1375)

* Add cli parameter to specify alternate settings file

* fix issue with error message string parameter
This commit is contained in:
johnnyruz 2021-01-04 09:46:16 -05:00 committed by GitHub
parent 35fdae0d95
commit f7b0c0f493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -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 <filename>: 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");
}

View file

@ -345,6 +345,8 @@ protected:
std::deque<OSDMessage> 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;