Skip to content
Merged
Show file tree
Hide file tree
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
49 changes: 30 additions & 19 deletions Knossos.NET/Classes/Knossos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,13 @@ private static async Task QuickLaunch()
Log.Add(Log.LogSeverity.Error, "Knossos.QuickLaunch", "Quick launch was used but the modid was not detected.");
}
await Task.Delay(2000);
Dispatcher.UIThread.Invoke(() =>
if (MainWindow.instance != null)
{
MainWindow.instance!.Close();
});
Dispatcher.UIThread.Invoke(() =>
{
MainWindow.instance.Close();
});
}
}

/// <summary>
Expand Down Expand Up @@ -740,7 +743,7 @@ private static void AutoUpdateBuilds()
/// <param name="standalonePort"></param>
public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standaloneServer = false, int standalonePort = 0)
{
if (TaskViewModel.Instance!.IsSafeState() == false)
if (TaskViewModel.Instance?.IsSafeState() == false)
{
var result = await MessageBox.Show(MainWindow.instance!, "Other important tasks are running, it is recommended that you wait until they finish before launching the game because it may cause them to fail.\nIf you are absolutely sure those tasks cannot interfere you can continue.", "Tasks are running", MessageBox.MessageBoxButtons.ContinueCancel);
if(result != MessageBox.MessageBoxResult.Continue)
Expand Down Expand Up @@ -1064,15 +1067,17 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
if (fsoBuild == null)
{
Log.Add(Log.LogSeverity.Error, "Knossos.PlayMod()", "Unable to find a valid FSO build for this mod!");
if(hasBuildDependency)
{
await MessageBox.Show(MainWindow.instance!, "Unable to find a valid FSO build for this mod!", "Error launching mod", MessageBox.MessageBoxButtons.OK);
}
else
if (MainWindow.instance != null)
{
await MessageBox.Show(MainWindow.instance!, "This mod does not especifies a engine build to use, you should select one in the mod settings.", "Error launching mod", MessageBox.MessageBoxButtons.OK);
if (hasBuildDependency)
{
await MessageBox.Show(MainWindow.instance!, "Unable to find a valid FSO build for this mod!", "Error launching mod", MessageBox.MessageBoxButtons.OK);
}
else
{
await MessageBox.Show(MainWindow.instance!, "This mod does not especifies a engine build to use, you should select one in the mod settings.", "Error launching mod", MessageBox.MessageBoxButtons.OK);
}
}

return;
}
else
Expand All @@ -1084,9 +1089,12 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
{
if (mod.modSettings.isCompressed)
{
var result = await MessageBox.Show(MainWindow.instance!, "This mod currently resolves to FSO build: " + fsoBuild.version + " and it is compressed, the minimum to fully support all compression features is: " + VPCompression.MinimumFSOVersion + ".\n23.0.0 may work if the mod do not have loose files, older versions are not going to work. Use a newer FSO version or uncompress this mod.", "FSO Version below minimum for compression", MessageBox.MessageBoxButtons.ContinueCancel);
if (result != MessageBox.MessageBoxResult.Continue)
return;
if (MainWindow.instance != null)
{
var result = await MessageBox.Show(MainWindow.instance!, "This mod currently resolves to FSO build: " + fsoBuild.version + " and it is compressed, the minimum to fully support all compression features is: " + VPCompression.MinimumFSOVersion + ".\n23.0.0 may work if the mod do not have loose files, older versions are not going to work. Use a newer FSO version or uncompress this mod.", "FSO Version below minimum for compression", MessageBox.MessageBoxButtons.ContinueCancel);
if (result != MessageBox.MessageBoxResult.Continue)
return;
}
}
else
{
Expand All @@ -1113,9 +1121,12 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
}
if (compressedMods != string.Empty)
{
var result = await MessageBox.Show(MainWindow.instance!, "This mod currently resolves to FSO build: " + fsoBuild.version + " and depends on mods: " + compressedMods + " that are currently compressed, the minimum to fully support all compression features is: " + VPCompression.MinimumFSOVersion + ".\n23.0.0 may work if the mod do not have loose files, older versions are not going to work. Use a newer FSO version or uncompress those mods.", "FSO Version below minimum for compression", MessageBox.MessageBoxButtons.ContinueCancel);
if (result != MessageBox.MessageBoxResult.Continue)
return;
if (MainWindow.instance != null)
{
var result = await MessageBox.Show(MainWindow.instance!, "This mod currently resolves to FSO build: " + fsoBuild.version + " and depends on mods: " + compressedMods + " that are currently compressed, the minimum to fully support all compression features is: " + VPCompression.MinimumFSOVersion + ".\n23.0.0 may work if the mod do not have loose files, older versions are not going to work. Use a newer FSO version or uncompress those mods.", "FSO Version below minimum for compression", MessageBox.MessageBoxButtons.ContinueCancel);
if (result != MessageBox.MessageBoxResult.Continue)
return;
}
}
}
}
Expand Down Expand Up @@ -1344,9 +1355,9 @@ private static async Task FolderSearchRecursive(string path, bool isQuickLaunch,
await Dispatcher.UIThread.InvokeAsync(() => FsoBuildsViewModel.Instance?.AddBuildToUi(build), DispatcherPriority.Background);
break;
}
if(modJson.devMode)
if(modJson.devMode && !isQuickLaunch)
{
await Dispatcher.UIThread.InvokeAsync(() => MainWindowViewModel.Instance!.AddDevMod(modJson), DispatcherPriority.Background);
await Dispatcher.UIThread.InvokeAsync(() => MainWindowViewModel.Instance?.AddDevMod(modJson), DispatcherPriority.Background);
}
}
catch (Exception ex)
Expand Down
35 changes: 24 additions & 11 deletions Knossos.NET/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class Program
public static void Main(string[] args)
{
bool softwareRendering = false;
bool isQuickLaunch = false;

//Check app args
foreach (var arg in args)
Expand All @@ -21,24 +22,36 @@ public static void Main(string[] args)
{
softwareRendering = true;
}
if (arg.ToLower() == "-playmod")
{
isQuickLaunch = true;
}
}

//Check enviroment variables
var renderMode = KnUtils.GetEnvironmentVariable("KNET_RENDER_MODE");

if (renderMode != null && renderMode.ToLower() == "software")
if (isQuickLaunch)
{
softwareRendering = true;
}

//Start App
if (softwareRendering)
{
BuildAvaloniaAppSoftware().StartWithClassicDesktopLifetime(args);
Knossos.StartUp(true, false);
}
else
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
//Check enviroment variables
var renderMode = KnUtils.GetEnvironmentVariable("KNET_RENDER_MODE");

if (renderMode != null && renderMode.ToLower() == "software")
{
softwareRendering = true;
}

//Start App
if (softwareRendering)
{
BuildAvaloniaAppSoftware().StartWithClassicDesktopLifetime(args);
}
else
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
}
}

Expand Down