Add Command Line Parameter to Override Mods #499
@ -32,6 +32,7 @@ namespace Ryujinx.Common.Configuration
|
||||
public static string KeysDirPathUser { get; }
|
||||
|
||||
public static string LogsDirPath { get; private set; }
|
||||
public static string[] OverrideMods { get; private set; }
|
||||
|
||||
public const string DefaultNandDir = "bis";
|
||||
public const string DefaultSdcardDir = "sdcard";
|
||||
@ -47,8 +48,9 @@ namespace Ryujinx.Common.Configuration
|
||||
KeysDirPathUser = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch");
|
||||
}
|
||||
|
||||
public static void Initialize(string baseDirPath)
|
||||
public static void Initialize(string baseDirPath, string[] commandLineArgMods)
|
||||
{
|
||||
OverrideMods = commandLineArgMods;
|
||||
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
|
||||
if (appDataPath.Length == 0)
|
||||
|
@ -41,11 +41,11 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
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 T Path;
|
||||
public readonly bool Enabled;
|
||||
public bool Enabled;
|
||||
|
||||
public Mod(string name, T path, bool enabled)
|
||||
{
|
||||
@ -169,7 +169,16 @@ namespace Ryujinx.HLE.HOS
|
||||
if (StrEquals(RomfsDir, modDir.Name))
|
||||
{
|
||||
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path));
|
||||
var enabled = modData?.Enabled ?? true;
|
||||
|
||||
bool enabled;
|
||||
if (AppDataManager.OverrideMods.Length == 0)
|
||||
{
|
||||
enabled = modData?.Enabled ?? true;
|
||||
}
|
||||
else
|
||||
{
|
||||
enabled = AppDataManager.OverrideMods.Contains(modData.Name);
|
||||
}
|
||||
|
||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||
types.Append('R');
|
||||
@ -177,7 +186,16 @@ namespace Ryujinx.HLE.HOS
|
||||
else if (StrEquals(ExefsDir, modDir.Name))
|
||||
{
|
||||
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path));
|
||||
var enabled = modData?.Enabled ?? true;
|
||||
|
||||
bool enabled;
|
||||
if (AppDataManager.OverrideMods.Length == 0)
|
||||
{
|
||||
enabled = modData?.Enabled ?? true;
|
||||
}
|
||||
else
|
||||
{
|
||||
enabled = AppDataManager.OverrideMods.Contains(modData.Name);
|
||||
}
|
||||
|
||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||
types.Append('E');
|
||||
|
@ -1,6 +1,7 @@
|
||||
using CommandLine;
|
||||
using Gommon;
|
||||
using Ryujinx.Ava;
|
||||
using Ryujinx.Ava.Utilities;
|
||||
using Ryujinx.Ava.Utilities.Configuration;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
@ -147,7 +148,7 @@ namespace Ryujinx.Headless
|
||||
option.InheritMainConfig(originalArgs, ConfigurationState.Instance, out useLastUsedProfile);
|
||||
}
|
||||
|
||||
AppDataManager.Initialize(option.BaseDataDir);
|
||||
AppDataManager.Initialize(option.BaseDataDir, option.OverrideMods.Split(","));
|
||||
|
||||
if (useLastUsedProfile && AccountSaveDataManager.GetLastUsedUser().TryGet(out var profile))
|
||||
option.UserProfile = profile.Name;
|
||||
|
@ -420,5 +420,11 @@ namespace Ryujinx.Headless
|
||||
public string InputPath { get; set; }
|
||||
|
||||
public SafeDictionary<PlayerIndex, InputConfig> InheritedInputConfigs = new();
|
||||
|
||||
// Mod
|
||||
|
||||
[Option('m', "mod", Required = false, Default = "", HelpText = "Overrides enabled mods with user input (Format: \"mod1\",\"mod2\").")]
|
||||
public string OverrideMods { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ namespace Ryujinx.Ava
|
||||
AppDomain.CurrentDomain.ProcessExit += (_, _) => Exit();
|
||||
|
||||
// Setup base data directory.
|
||||
AppDataManager.Initialize(CommandLineState.BaseDirPathArg);
|
||||
AppDataManager.Initialize(CommandLineState.BaseDirPathArg, CommandLineState.OverrideMods);
|
||||
|
||||
// Initialize the configuration.
|
||||
ConfigurationState.Initialize();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Ava.Utilities
|
||||
@ -6,6 +7,7 @@ namespace Ryujinx.Ava.Utilities
|
||||
public static class CommandLineState
|
||||
{
|
||||
public static string[] Arguments { get; private set; }
|
||||
public static string[] OverrideMods { get; private set; }
|
||||
|
||||
public static bool? OverrideDockedMode { get; private set; }
|
||||
public static bool? OverrideHardwareAcceleration { get; private set; }
|
||||
@ -78,6 +80,17 @@ namespace Ryujinx.Ava.Utilities
|
||||
case "--application-id":
|
||||
LaunchApplicationId = args[++i];
|
||||
break;
|
||||
case "-m":
|
||||
case "--mod":
|
||||
if (i + 1 >= args.Length)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
OverrideMods = args[++i].Split(',');
|
||||
break;
|
||||
case "--docked-mode":
|
||||
OverrideDockedMode = true;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user