Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 74 additions & 4 deletions Knossos.NET/Classes/Knossos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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)
{
Expand All @@ -294,7 +359,7 @@ private static async Task QuickLaunch()

if(mod != null)
{
PlayMod(mod, execType);
PlayMod(mod, execType, false, 0, false, fsoBuild, cmdline);
}
else
{
Expand Down Expand Up @@ -324,7 +389,7 @@ private static async Task QuickLaunch()

if(mod != null)
{
PlayMod(mod, execType);
PlayMod(mod, execType, false, 0, false, fsoBuild, cmdline);
}
}
else
Expand Down Expand Up @@ -831,7 +896,7 @@ private static void AutoUpdateBuilds()
/// <param name="fsoExecType"></param>
/// <param name="standaloneServer"></param>
/// <param name="standalonePort"></param>
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)
{
Expand Down Expand Up @@ -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<Mod>();
FsoBuild? fsoBuild = null;
FsoBuild? fsoBuild = specifiedBuild;

if(additionalCmd != null)
{
cmdline += " " + additionalCmd;
}

/* VR Mode Stuff */
if(vrMode)
Expand Down