Qt/VMManager: Add -gamecfg command-line arg

This commit is contained in:
Tundrak
2026-09-23 12:57:14 -04:00
committed by Ty
parent 6bf754d3f5
commit 81f28fc644
3 changed files with 32 additions and 1 deletions
+7 -1
View File
@@ -2136,7 +2136,8 @@ void QtHost::PrintCommandLineHelp(const std::string_view progname)
std::fprintf(stderr, " -portable: Force enable portable mode to store data in local PCSX2 path instead of the default configuration path. Overrides '-datapath'.\n");
std::fprintf(stderr, " -datapath <path>: Specify the directory to be used for all application data.\n");
std::fprintf(stderr, " -elf <file>: Overrides the boot ELF with the specified filename.\n");
std::fprintf(stderr, " -gameargs <string>: passes the specified quoted space-delimited string of launch arguments.\n");
std::fprintf(stderr, " -gameargs <string>: Passes the specified quoted space-delimited string of launch arguments.\n");
std::fprintf(stderr, " -gamecfg <file>: Overrides the game settings with the ones in the specified INI file.\n");
std::fprintf(stderr, " -disc <path>: Uses the specified host DVD drive as a source.\n");
std::fprintf(stderr, " -logfile <path>: Writes the application log to path instead of emulog.txt.\n");
std::fprintf(stderr, " -bios: Starts the BIOS (System Menu/OSDSYS).\n");
@@ -2249,6 +2250,11 @@ bool QtHost::ParseCommandLineOptions(const QStringList& args, std::shared_ptr<VM
EmuConfig.CurrentGameArgs = (++it)->toStdString();
continue;
}
else if (CHECK_ARG_PARAM(QStringLiteral("-gamecfg")))
{
AutoBoot(autoboot)->game_config = (++it)->toStdString();
continue;
}
else if (CHECK_ARG_PARAM(QStringLiteral("-disc")))
{
AutoBoot(autoboot)->source_type = CDVD_SourceType::Disc;
+24
View File
@@ -180,6 +180,7 @@ static std::string s_elf_path;
static std::pair<u32, u32> s_elf_text_range;
static bool s_elf_executed = false;
static std::string s_elf_override;
static std::string s_game_settings_override;
static std::string s_input_profile_name;
static u32 s_frame_advance_count = 0;
static bool s_fast_boot_requested = false;
@@ -818,6 +819,10 @@ bool VMManager::ReloadGameSettings()
std::string VMManager::GetGameSettingsPath(const std::string_view game_serial, u32 game_crc)
{
// Game settings override via -gamecfg command line flag
if (!s_game_settings_override.empty())
return s_game_settings_override;
std::string sanitized_serial(Path::SanitizeFileName(game_serial));
return game_serial.empty() ?
@@ -1373,6 +1378,7 @@ VMBootResult VMManager::Initialize(const VMBootParameters& boot_params, Error* e
GSDumpReplayer::Shutdown();
s_elf_override = {};
s_game_settings_override = {};
ClearELFInfo();
ClearDiscDetails();
@@ -1473,6 +1479,23 @@ VMBootResult VMManager::Initialize(const VMBootParameters& boot_params, Error* e
}
ScopedGuard close_cdvd(&DoCDVDclose);
if (!boot_params.game_config.empty())
{
if (!StringUtil::compareNoCase(Path::GetExtension(boot_params.game_config), "ini"))
{
Error::SetStringFmt(error,
TRANSLATE_FS("VMManager", "Requested game config '{}' is not an INI file."), boot_params.game_config);
return VMBootResult::StartupFailure;
}
else if (!FileSystem::FileExists(boot_params.game_config.c_str()))
{
Error::SetStringFmt(error,
TRANSLATE_FS("VMManager", "Requested game config '{}' does not exist."), boot_params.game_config);
return VMBootResult::StartupFailure;
}
s_game_settings_override = boot_params.game_config;
}
// Figure out which game we're running! This also loads game settings.
UpdateDiscDetails(true);
@@ -1690,6 +1713,7 @@ void VMManager::Shutdown(bool save_resume_state)
SaveSessionTime(s_disc_serial);
s_elf_override = {};
s_game_settings_override = {};
ClearELFInfo();
CDVDsys_ClearFiles();
+1
View File
@@ -32,6 +32,7 @@ struct VMBootParameters
std::string filename;
std::string elf_override;
std::string save_state;
std::string game_config;
std::optional<s32> state_index;
std::optional<CDVD_SourceType> source_type;