Skip to content
Open
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
6 changes: 2 additions & 4 deletions Knossos.NET/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ private void OpenLog()
}
else
{
if (MainWindow.instance != null)
MessageBox.Show(MainWindow.instance, "Log File " + KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "Knossos.log not found.", "File not found", MessageBox.MessageBoxButtons.OK);
MessageBox.Show(MainWindow.instance, "Log File " + KnUtils.GetKnossosDataFolderPath() + Path.DirectorySeparatorChar + "Knossos.log not found.", "File not found", MessageBox.MessageBoxButtons.OK);
}
}

Expand All @@ -319,8 +318,7 @@ private void OpenFS2Log()
}
else
{
if (MainWindow.instance != null)
MessageBox.Show(MainWindow.instance, "Log File " + KnUtils.GetFSODataFolderPath() + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "fs2_open.log not found.", "File not found", MessageBox.MessageBoxButtons.OK);
MessageBox.Show(MainWindow.instance, "Log File " + KnUtils.GetFSODataFolderPath() + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "fs2_open.log not found.", "File not found", MessageBox.MessageBoxButtons.OK);
}
}
}
Expand Down
89 changes: 32 additions & 57 deletions Knossos.NET/Classes/Knossos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,10 @@ 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);
if (MainWindow.instance != null)
Dispatcher.UIThread.Invoke(() =>
{
Dispatcher.UIThread.Invoke(() =>
{
MainWindow.instance.Close();
});
}
MainWindow.instance?.Close();
});
}

/// <summary>
Expand Down Expand Up @@ -575,7 +572,7 @@ await Dispatcher.UIThread.Invoke(async () => {
//Close App
Dispatcher.UIThread.Invoke(() =>
{
MainWindow.instance!.Close();
MainWindow.instance?.Close();
});
}
catch (Exception ex)
Expand Down Expand Up @@ -700,7 +697,7 @@ await Dispatcher.UIThread.Invoke(async () =>
//Close App
Dispatcher.UIThread.Invoke(() =>
{
MainWindow.instance!.Close();
MainWindow.instance?.Close();
});
}
}
Expand Down Expand Up @@ -752,7 +749,10 @@ public static void OpenQuickSetup()
{
var dialog = new QuickSetupView();
dialog.DataContext = new QuickSetupViewModel(dialog);
dialog.Show(MainWindow.instance!);
if(MainWindow.instance != null)
dialog.Show(MainWindow.instance);
else
dialog.Show();
});
}

Expand Down Expand Up @@ -938,7 +938,7 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
{
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);
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)
return;
}
Expand Down Expand Up @@ -982,11 +982,7 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo

if(missingDeps.Count > 0)
{
if (MainWindow.instance != null)
{
await MessageBox.Show(MainWindow.instance, errorMsg, "Unable to resolve dependencies", MessageBox.MessageBoxButtons.OK);
}

await MessageBox.Show(MainWindow.instance, errorMsg, "Unable to resolve dependencies", MessageBox.MessageBoxButtons.OK);
return;
}

Expand Down Expand Up @@ -1053,12 +1049,9 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
}
}
Log.Add(Log.LogSeverity.Warning, "Knossos.PlayMod()", outputString);
if (MainWindow.instance != null)
{
var result = await MessageBox.Show(MainWindow.instance, outputString, "Dependency Conflict!", MessageBox.MessageBoxButtons.ContinueCancel);
if (result != MessageBox.MessageBoxResult.Continue)
return;
}
var result = await MessageBox.Show(MainWindow.instance, outputString, "Dependency Conflict!", MessageBox.MessageBoxButtons.ContinueCancel);
if (result != MessageBox.MessageBoxResult.Continue)
return;
}
}

Expand Down Expand Up @@ -1121,10 +1114,7 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
if(rootPath == string.Empty)
{
Log.Add(Log.LogSeverity.Error, "Knossos.PlayMod()", "Unable to determine working folder for mod: " + mod.folderName);
if (MainWindow.instance != null)
{
await MessageBox.Show(MainWindow.instance, "Unable to determine working folder for mod: " + mod.folderName, "Error launching mod", MessageBox.MessageBoxButtons.OK);
}
await MessageBox.Show(MainWindow.instance, "Unable to determine working folder for mod: " + mod.folderName, "Error launching mod", MessageBox.MessageBoxButtons.OK);
return;
}
else
Expand Down Expand Up @@ -1276,16 +1266,13 @@ 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 (MainWindow.instance != null)
if (hasBuildDependency)
{
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 specify an engine build to use, you should select one in the mod settings.", "Error launching mod", MessageBox.MessageBoxButtons.OK);
}
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 specify an engine build to use, you should select one in the mod settings.", "Error launching mod", MessageBox.MessageBoxButtons.OK);
}
return;
}
Expand All @@ -1298,12 +1285,9 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
{
if (mod.modSettings.isCompressed)
{
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;
}
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 @@ -1330,12 +1314,9 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
}
if (compressedMods != string.Empty)
{
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;
}
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 @@ -1388,7 +1369,7 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo



if (MainWindow.instance != null && globalSettings.warnNewSettingsSystem && !CustomLauncher.IsCustomMode)
if (!KnUtils.IsAndroid && globalSettings.warnNewSettingsSystem && !CustomLauncher.IsCustomMode)
{
try
{
Expand Down Expand Up @@ -1450,10 +1431,7 @@ await Dispatcher.UIThread.InvokeAsync(async () => {
if (!fsoResult.IsSuccess)
{
Log.Add(Log.LogSeverity.Error, "Knossos.PlayMod()", fsoResult.ErrorMessage);
if (MainWindow.instance != null)
{
await MessageBox.Show(MainWindow.instance, fsoResult.ErrorMessage, "Error launching mod", MessageBox.MessageBoxButtons.OK);
}
await MessageBox.Show(MainWindow.instance, fsoResult.ErrorMessage, "Error launching mod", MessageBox.MessageBoxButtons.OK);
}
}

Expand Down Expand Up @@ -1610,12 +1588,9 @@ private static async Task FolderSearchRecursive(string path, bool isQuickLaunch,

if (folderLevel == 0 )
{
if (MainWindow.instance != null)
{
Dispatcher.UIThread.Invoke(() => {
MessageBox.Show(MainWindow.instance!, "KnossosNET either cannot find or does not have permission to read a previously selected Library Folder.\nEither select a new Library Folder in KnossosNET's settings, or check if the folder is now protected.", "Knossos.NET Library Folder Error" , MessageBox.MessageBoxButtons.OK);
});
}
Dispatcher.UIThread.Invoke(() => {
MessageBox.Show(MainWindow.instance, "KnossosNET either cannot find or does not have permission to read a previously selected Library Folder.\nEither select a new Library Folder in KnossosNET's settings, or check if the folder is now protected.", "Knossos.NET Library Folder Error" , MessageBox.MessageBoxButtons.OK);
});
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions Knossos.NET/ViewModels/CustomHomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private async void Install()
{
var dialog = new ModInstallView();
dialog.DataContext = new ModInstallViewModel(nebulaModVersions.First(), dialog);
await dialog.ShowDialog<ModInstallView?>(MainWindow.instance!);
await dialog.ShowDialog<ModInstallView?>(MainWindow.instance);
}
else
{
Expand All @@ -201,7 +201,7 @@ private async void Modify()
{
var dialog = new ModInstallView();
dialog.DataContext = new ModInstallViewModel(GetActiveInstalledModVersion, dialog, GetActiveInstalledModVersion.version);
await dialog.ShowDialog<ModInstallView?>(MainWindow.instance!);
await dialog.ShowDialog<ModInstallView?>(MainWindow.instance);
}
else
{
Expand All @@ -218,7 +218,7 @@ private async void Update()
{
var dialog = new ModInstallView();
dialog.DataContext = new ModInstallViewModel(GetActiveInstalledModVersion, dialog);
await dialog.ShowDialog<ModInstallView?>(MainWindow.instance!);
await dialog.ShowDialog<ModInstallView?>(MainWindow.instance);
}
else
{
Expand Down Expand Up @@ -303,7 +303,7 @@ public async void RemoveInstalledModVersion(Mod mod)
{
if (modVersions.Count > 1)
{
var resp = await MessageBox.Show(MainWindow.instance!, "You are about to delete version " + GetActiveInstalledModVersion.version + ", this will remove this version only. Do you want to continue?", "Delete version", MessageBox.MessageBoxButtons.YesNo);
var resp = await MessageBox.Show(MainWindow.instance, "You are about to delete version " + GetActiveInstalledModVersion.version + ", this will remove this version only. Do you want to continue?", "Delete version", MessageBox.MessageBoxButtons.YesNo);
if (resp == MessageBox.MessageBoxResult.Yes)
{
var delete = modVersions[ActiveVersionIndex];
Expand All @@ -316,7 +316,7 @@ public async void RemoveInstalledModVersion(Mod mod)
}
else
{
var resp = await MessageBox.Show(MainWindow.instance!, "You are about to delete the last installed version. Do you want to continue?", "Delete last version", MessageBox.MessageBoxButtons.YesNo);
var resp = await MessageBox.Show(MainWindow.instance, "You are about to delete the last installed version. Do you want to continue?", "Delete last version", MessageBox.MessageBoxButtons.YesNo);
if (resp == MessageBox.MessageBoxResult.Yes)
{
//Last version
Expand All @@ -334,7 +334,7 @@ public async void RemoveInstalledModVersion(Mod mod)
}
else
{
await MessageBox.Show(MainWindow.instance!, "You can not delete a mod while other install tasks are running, wait until they finish and try again.", "Tasks are running", MessageBox.MessageBoxButtons.OK);
await MessageBox.Show(MainWindow.instance, "You can not delete a mod while other install tasks are running, wait until they finish and try again.", "Tasks are running", MessageBox.MessageBoxButtons.OK);
}
}
}catch(Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion Knossos.NET/ViewModels/DebugViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ internal async void OpenDebugFilterView()
{
var dialog = new Views.DebugFiltersView();
dialog.DataContext = new DebugFiltersViewModel();
await dialog.ShowDialog<DebugFiltersView?>(MainWindow.instance!);
await dialog.ShowDialog<DebugFiltersView?>(MainWindow.instance);
}
}
}
2 changes: 1 addition & 1 deletion Knossos.NET/ViewModels/DeveloperModsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ internal async void CreateMod()
{
var dialog = new DevModCreateNewView();
dialog.DataContext = new DevModCreateNewViewModel(dialog);
await dialog.ShowDialog<DevModCreateNewView?>(MainWindow.instance!);
await dialog.ShowDialog<DevModCreateNewView?>(MainWindow.instance);
}

public void UpdateBuildNames(string stableIn, string nightlyIn)
Expand Down
4 changes: 2 additions & 2 deletions Knossos.NET/ViewModels/FsoBuildsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ internal void CleanNightlies()
installedNL.ForEach( x => fsoVersionString += "\n" + x.ToString() );
Dispatcher.UIThread.Invoke(async() =>
{
var reply = await MessageBox.Show(MainWindow.instance!, "You are about to delete the following FSO builds:" + fsoVersionString, "Deleting nightlies", MessageBox.MessageBoxButtons.ContinueCancel);
var reply = await MessageBox.Show(MainWindow.instance, "You are about to delete the following FSO builds:" + fsoVersionString, "Deleting nightlies", MessageBox.MessageBoxButtons.ContinueCancel);
if(reply == MessageBox.MessageBoxResult.Continue)
{
foreach (var build in installedNL)
Expand Down Expand Up @@ -407,7 +407,7 @@ internal void CleanNightlies()
{
Dispatcher.UIThread.Invoke(() =>
{
MessageBox.Show(MainWindow.instance!, "There are not installed FSO nightlies to delete", "Error deleting nightlies", MessageBox.MessageBoxButtons.OK);
MessageBox.Show(MainWindow.instance, "There are not installed FSO nightlies to delete", "Error deleting nightlies", MessageBox.MessageBoxButtons.OK);
});
}
}
Expand Down
Loading