mirror of https://github.com/PCSX2/pcsx2.git
Qt: Add Portable Mode launch argument (#12230)
This commit is contained in:
parent
bef7ae7f6c
commit
f84173e5cc
|
@ -2040,6 +2040,7 @@ void QtHost::PrintCommandLineHelp(const std::string_view progname)
|
|||
std::fprintf(stderr, " -version: Displays version information and exits.\n");
|
||||
std::fprintf(stderr, " -batch: Enables batch mode (exits after shutting down).\n");
|
||||
std::fprintf(stderr, " -nogui: Hides main window while running (implies batch mode).\n");
|
||||
std::fprintf(stderr, " -portable: Force enable portable mode to store data in local PCSX2 path instead of the default configuration path.\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, " -disc <path>: Uses the specified host DVD drive as a source.\n");
|
||||
|
@ -2111,6 +2112,11 @@ bool QtHost::ParseCommandLineOptions(const QStringList& args, std::shared_ptr<VM
|
|||
s_nogui_mode = true;
|
||||
continue;
|
||||
}
|
||||
else if (CHECK_ARG(QStringLiteral("-portable")))
|
||||
{
|
||||
EmuConfig.IsPortableMode = true;
|
||||
continue;
|
||||
}
|
||||
else if (CHECK_ARG(QStringLiteral("-fastboot")))
|
||||
{
|
||||
AutoBoot(autoboot)->fast_boot = true;
|
||||
|
|
|
@ -1328,6 +1328,7 @@ struct Pcsx2Config
|
|||
std::string CurrentIRX;
|
||||
std::string CurrentGameArgs;
|
||||
AspectRatioType CurrentAspectRatio = AspectRatioType::RAuto4_3_3_2;
|
||||
bool IsPortableMode = false;
|
||||
|
||||
Pcsx2Config();
|
||||
void LoadSave(SettingsWrapper& wrap);
|
||||
|
|
|
@ -2036,6 +2036,7 @@ void Pcsx2Config::CopyRuntimeConfig(Pcsx2Config& cfg)
|
|||
CurrentIRX = std::move(cfg.CurrentIRX);
|
||||
CurrentGameArgs = std::move(cfg.CurrentGameArgs);
|
||||
CurrentAspectRatio = cfg.CurrentAspectRatio;
|
||||
IsPortableMode = cfg.IsPortableMode;
|
||||
|
||||
for (u32 i = 0; i < sizeof(Mcd) / sizeof(Mcd[0]); i++)
|
||||
{
|
||||
|
@ -2122,8 +2123,15 @@ bool EmuFolders::SetResourcesDirectory()
|
|||
|
||||
bool EmuFolders::ShouldUsePortableMode()
|
||||
{
|
||||
// Check whether portable.ini exists in the program directory.
|
||||
return FileSystem::FileExists(Path::Combine(AppRoot, "portable.ini").c_str()) || FileSystem::FileExists(Path::Combine(AppRoot, "portable.txt").c_str());
|
||||
// Check whether portable.ini/txt exists in the program directory or the `-portable` launch arguments have been passed.
|
||||
if (FileSystem::FileExists(Path::Combine(AppRoot, "portable.ini").c_str()) ||
|
||||
FileSystem::FileExists(Path::Combine(AppRoot, "portable.txt").c_str()) ||
|
||||
EmuConfig.IsPortableMode)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string EmuFolders::GetPortableModePath()
|
||||
|
@ -2178,7 +2186,22 @@ bool EmuFolders::SetDataDirectory(Error* error)
|
|||
|
||||
// couldn't determine the data directory, or using portable mode? fallback to portable.
|
||||
if (DataRoot.empty())
|
||||
{
|
||||
#if defined(__linux__)
|
||||
// special check if we're on appimage
|
||||
// always make sure that DataRoot
|
||||
// is adjacent next to the appimage
|
||||
if (getenv("APPIMAGE"))
|
||||
{
|
||||
std::string_view appimage_path = Path::GetDirectory(getenv("APPIMAGE"));
|
||||
DataRoot = Path::RealPath(Path::Combine(appimage_path, "PCSX2"));
|
||||
}
|
||||
else
|
||||
DataRoot = Path::Combine(AppRoot, GetPortableModePath());
|
||||
#else
|
||||
DataRoot = Path::Combine(AppRoot, GetPortableModePath());
|
||||
#endif
|
||||
}
|
||||
|
||||
// inis is always below the data root
|
||||
Settings = Path::Combine(DataRoot, "inis");
|
||||
|
|
Loading…
Reference in New Issue