diff --git a/Knossos.NET/Classes/Knossos.cs b/Knossos.NET/Classes/Knossos.cs index d0a2f268..fb100018 100644 --- a/Knossos.NET/Classes/Knossos.cs +++ b/Knossos.NET/Classes/Knossos.cs @@ -210,10 +210,16 @@ private static async Task QuickLaunch() string modver = string.Empty; string modExecType = string.Empty; string toolName = string.Empty; + string buildid = string.Empty; + string buildver = string.Empty; + string? cmdline = null; bool saveID = false; bool saveVer = false; bool saveExecType = false; bool toolID = false; + bool saveBuildID = false; + bool saveBuildVer = false; + bool saveCmdline = false; foreach (var arg in args) { @@ -238,6 +244,21 @@ private static async Task QuickLaunch() saveExecType = false; modExecType = arg; } + if (saveBuildID) + { + saveBuildID = false; + buildid = arg; + } + if (saveBuildVer) + { + saveBuildVer = false; + buildver = arg; + } + if (saveCmdline) + { + saveCmdline = false; + cmdline = arg; + } if (arg.ToLower() == "-playmod") { saveID = true; @@ -254,6 +275,18 @@ private static async Task QuickLaunch() { saveExecType = true; } + if (arg.ToLower() == "-build") + { + saveBuildID = true; + } + if (arg.ToLower() == "-build-version") + { + saveBuildVer = true; + } + if (arg.ToLower() == "-cmdline") + { + saveCmdline = true; + } } if (toolName != string.Empty) @@ -275,6 +308,38 @@ private static async Task QuickLaunch() Log.Add(Log.LogSeverity.Error, "Knossos.QuickLaunch", ex); } } + FsoBuild? fsoBuild = null; + if (buildver != string.Empty) + { + //we have a version + if (buildid == string.Empty) + buildid = "fso"; + switch (buildver.ToLower()) + { + case "newerstable": + fsoBuild = GetInstalledBuildsList().Where(x => x.id.ToLower() == buildid.ToLower() && x.stability == FsoStability.Stable)?.MaxBy(x => new SemanticVersion(x.version)); + break; + case "newerrc": + fsoBuild = GetInstalledBuildsList().Where(x => x.id.ToLower() == buildid.ToLower() && x.stability == FsoStability.RC)?.MaxBy(x => new SemanticVersion(x.version)); + break; + case "newernightly": + fsoBuild = GetInstalledBuildsList().Where(x => x.id.ToLower() == buildid.ToLower() && x.stability == FsoStability.Nightly)?.MaxBy(x => new SemanticVersion(x.version)); + break; + default: + fsoBuild = GetInstalledBuildsList().FirstOrDefault(x => x.id.ToLower() == buildid.ToLower() && x.version == buildver); + break; + } + } + else if(buildid != string.Empty) + { + //no version, pick whatever is newer for this id + fsoBuild = GetInstalledBuildsList().Where(x => x.id.ToLower() == buildid.ToLower())?.MaxBy(x => new SemanticVersion(x.version)); + } + + if (buildid != string.Empty && fsoBuild == null) + { + Log.Add(Log.LogSeverity.Error, "Knossos.QuickLaunch", "Quick launch was used but we could not find a FSO build with this ID: " + buildid + " and version: " + buildver == null ? "Any" : buildver ); + } if(modid != string.Empty) { @@ -294,7 +359,7 @@ private static async Task QuickLaunch() if(mod != null) { - PlayMod(mod, execType); + PlayMod(mod, execType, false, 0, false, fsoBuild, cmdline); } else { @@ -324,7 +389,7 @@ private static async Task QuickLaunch() if(mod != null) { - PlayMod(mod, execType); + PlayMod(mod, execType, false, 0, false, fsoBuild, cmdline); } } else @@ -831,7 +896,7 @@ private static void AutoUpdateBuilds() /// /// /// - public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standaloneServer = false, int standalonePort = 0, bool vrMode = false) + public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standaloneServer = false, int standalonePort = 0, bool vrMode = false, FsoBuild? specifiedBuild = null, string? additionalCmd = null) { if (TaskViewModel.Instance?.IsSafeState() == false) { @@ -892,7 +957,12 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo var cmdline = "-parse_cmdline_only"; var modFlag = string.Empty; var modList = new List(); - FsoBuild? fsoBuild = null; + FsoBuild? fsoBuild = specifiedBuild; + + if(additionalCmd != null) + { + cmdline += " " + additionalCmd; + } /* VR Mode Stuff */ if(vrMode)