added command line argument to specify which mods the game should start with, not implemented in headless
This commit is contained in:
parent
850df38f1e
commit
ae364d1436
@ -32,6 +32,7 @@ namespace Ryujinx.Common.Configuration
|
|||||||
public static string KeysDirPathUser { get; }
|
public static string KeysDirPathUser { get; }
|
||||||
|
|
||||||
public static string LogsDirPath { get; private set; }
|
public static string LogsDirPath { get; private set; }
|
||||||
|
public static string[] CommandLineArgMods { get; private set; }
|
||||||
|
|
||||||
public const string DefaultNandDir = "bis";
|
public const string DefaultNandDir = "bis";
|
||||||
public const string DefaultSdcardDir = "sdcard";
|
public const string DefaultSdcardDir = "sdcard";
|
||||||
@ -47,8 +48,9 @@ namespace Ryujinx.Common.Configuration
|
|||||||
KeysDirPathUser = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch");
|
KeysDirPathUser = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Initialize(string baseDirPath)
|
public static void Initialize(string baseDirPath, string[] commandLineArgMods)
|
||||||
{
|
{
|
||||||
|
CommandLineArgMods = commandLineArgMods;
|
||||||
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||||
|
|
||||||
if (appDataPath.Length == 0)
|
if (appDataPath.Length == 0)
|
||||||
|
@ -41,11 +41,11 @@ namespace Ryujinx.HLE.HOS
|
|||||||
|
|
||||||
private static readonly ModMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
private static readonly ModMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||||
|
|
||||||
public readonly struct Mod<T> where T : FileSystemInfo
|
public struct Mod<T> where T : FileSystemInfo
|
||||||
{
|
{
|
||||||
public readonly string Name;
|
public readonly string Name;
|
||||||
public readonly T Path;
|
public readonly T Path;
|
||||||
public readonly bool Enabled;
|
public bool Enabled;
|
||||||
|
|
||||||
public Mod(string name, T path, bool enabled)
|
public Mod(string name, T path, bool enabled)
|
||||||
{
|
{
|
||||||
@ -169,7 +169,16 @@ namespace Ryujinx.HLE.HOS
|
|||||||
if (StrEquals(RomfsDir, modDir.Name))
|
if (StrEquals(RomfsDir, modDir.Name))
|
||||||
{
|
{
|
||||||
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path));
|
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path));
|
||||||
var enabled = modData?.Enabled ?? true;
|
|
||||||
|
bool enabled;
|
||||||
|
if (AppDataManager.CommandLineArgMods.Length == 0)
|
||||||
|
{
|
||||||
|
enabled = modData?.Enabled ?? true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enabled = AppDataManager.CommandLineArgMods.Contains(modData.Name);
|
||||||
|
}
|
||||||
|
|
||||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||||
types.Append('R');
|
types.Append('R');
|
||||||
@ -177,7 +186,16 @@ namespace Ryujinx.HLE.HOS
|
|||||||
else if (StrEquals(ExefsDir, modDir.Name))
|
else if (StrEquals(ExefsDir, modDir.Name))
|
||||||
{
|
{
|
||||||
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path));
|
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path));
|
||||||
var enabled = modData?.Enabled ?? true;
|
|
||||||
|
bool enabled;
|
||||||
|
if (AppDataManager.CommandLineArgMods.Length == 0)
|
||||||
|
{
|
||||||
|
enabled = modData?.Enabled ?? true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enabled = AppDataManager.CommandLineArgMods.Contains(modData.Name);
|
||||||
|
}
|
||||||
|
|
||||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||||
types.Append('E');
|
types.Append('E');
|
||||||
|
@ -147,7 +147,7 @@ namespace Ryujinx.Headless
|
|||||||
option.InheritMainConfig(originalArgs, ConfigurationState.Instance, out useLastUsedProfile);
|
option.InheritMainConfig(originalArgs, ConfigurationState.Instance, out useLastUsedProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppDataManager.Initialize(option.BaseDataDir);
|
AppDataManager.Initialize(option.BaseDataDir, []);
|
||||||
|
|
||||||
if (useLastUsedProfile && AccountSaveDataManager.GetLastUsedUser().TryGet(out var profile))
|
if (useLastUsedProfile && AccountSaveDataManager.GetLastUsedUser().TryGet(out var profile))
|
||||||
option.UserProfile = profile.Name;
|
option.UserProfile = profile.Name;
|
||||||
|
@ -114,7 +114,7 @@ namespace Ryujinx.Ava
|
|||||||
AppDomain.CurrentDomain.ProcessExit += (_, _) => Exit();
|
AppDomain.CurrentDomain.ProcessExit += (_, _) => Exit();
|
||||||
|
|
||||||
// Setup base data directory.
|
// Setup base data directory.
|
||||||
AppDataManager.Initialize(CommandLineState.BaseDirPathArg);
|
AppDataManager.Initialize(CommandLineState.BaseDirPathArg, CommandLineState.Mods);
|
||||||
|
|
||||||
// Initialize the configuration.
|
// Initialize the configuration.
|
||||||
ConfigurationState.Initialize();
|
ConfigurationState.Initialize();
|
||||||
|
@ -6,6 +6,7 @@ namespace Ryujinx.Ava.Utilities
|
|||||||
public static class CommandLineState
|
public static class CommandLineState
|
||||||
{
|
{
|
||||||
public static string[] Arguments { get; private set; }
|
public static string[] Arguments { get; private set; }
|
||||||
|
public static string[] Mods { get; private set; }
|
||||||
|
|
||||||
public static bool? OverrideDockedMode { get; private set; }
|
public static bool? OverrideDockedMode { get; private set; }
|
||||||
public static bool? OverrideHardwareAcceleration { get; private set; }
|
public static bool? OverrideHardwareAcceleration { get; private set; }
|
||||||
@ -21,6 +22,7 @@ namespace Ryujinx.Ava.Utilities
|
|||||||
public static void ParseArguments(string[] args)
|
public static void ParseArguments(string[] args)
|
||||||
{
|
{
|
||||||
List<string> arguments = new();
|
List<string> arguments = new();
|
||||||
|
List<string> mods = new();
|
||||||
|
|
||||||
// Parse Arguments.
|
// Parse Arguments.
|
||||||
for (int i = 0; i < args.Length; ++i)
|
for (int i = 0; i < args.Length; ++i)
|
||||||
@ -78,6 +80,39 @@ namespace Ryujinx.Ava.Utilities
|
|||||||
case "--application-id":
|
case "--application-id":
|
||||||
LaunchApplicationId = args[++i];
|
LaunchApplicationId = args[++i];
|
||||||
break;
|
break;
|
||||||
|
case "-m":
|
||||||
|
case "--mod":
|
||||||
|
int numMods;
|
||||||
|
if (i + 1 >= args.Length)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Application, $"Argument '{arg}' expects a number of mods as next argument");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!int.TryParse(args[++i], out numMods))
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
Logger.Error?.Print(LogClass.Application, $"Expected number of mods, got '{arg}'");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i + numMods >= args.Length)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Application, $"The number of expected mods exceeds the number of command line arguments left");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = i + 1; j <= i + numMods; j++)
|
||||||
|
{
|
||||||
|
mods.Add(args[j]);
|
||||||
|
|
||||||
|
Logger.Info?.Print(LogClass.Application, $"Enabled mod '{args[j]}' through cli");
|
||||||
|
}
|
||||||
|
|
||||||
|
i += numMods;
|
||||||
|
break;
|
||||||
case "--docked-mode":
|
case "--docked-mode":
|
||||||
OverrideDockedMode = true;
|
OverrideDockedMode = true;
|
||||||
break;
|
break;
|
||||||
@ -107,6 +142,7 @@ namespace Ryujinx.Ava.Utilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
Arguments = arguments.ToArray();
|
Arguments = arguments.ToArray();
|
||||||
|
Mods = mods.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user