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
2 changes: 1 addition & 1 deletion Knossos.NET/ViewModels/GlobalSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ internal async void InstallFS2Command()
if (MainWindow.instance != null)
{
var dialog = new Fs2InstallerView();
dialog.DataContext = new Fs2InstallerViewModel();
dialog.DataContext = new Fs2InstallerViewModel(dialog);

await dialog.ShowDialog<Fs2InstallerView?>(MainWindow.instance);
}
Expand Down
2 changes: 1 addition & 1 deletion Knossos.NET/ViewModels/ModListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ internal async void InstallFS2Command()
if (MainWindow.instance != null)
{
var dialog = new Fs2InstallerView();
dialog.DataContext = new Fs2InstallerViewModel();
dialog.DataContext = new Fs2InstallerViewModel(dialog);

await dialog.ShowDialog<Fs2InstallerView?>(MainWindow.instance);

Expand Down
2 changes: 1 addition & 1 deletion Knossos.NET/ViewModels/NebulaModListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ internal async void InstallFS2Command()
if (MainWindow.instance != null)
{
var dialog = new Fs2InstallerView();
dialog.DataContext = new Fs2InstallerViewModel();
dialog.DataContext = new Fs2InstallerViewModel(dialog);

await dialog.ShowDialog<Fs2InstallerView?>(MainWindow.instance);
Fs2Present = Knossos.retailFs2RootFound;
Expand Down
10 changes: 5 additions & 5 deletions Knossos.NET/ViewModels/Templates/DevModFsoSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ private void LoadFsoPicker()
{
if (editor.ActiveVersion.modSettings.customBuildId == null)
{
FsoPicker = new FsoBuildPickerViewModel(null);
FsoPicker = new FsoBuildPickerViewModel(null,null);
}
else
{
if (editor.ActiveVersion.modSettings.customBuildExec != null)
{
FsoPicker = new FsoBuildPickerViewModel(new FsoBuild(editor.ActiveVersion.modSettings.customBuildExec));
FsoPicker = new FsoBuildPickerViewModel(new FsoBuild(editor.ActiveVersion.modSettings.customBuildExec), null);
}
else
{
Expand All @@ -51,18 +51,18 @@ private void LoadFsoPicker()
var theBuild = matchingBuilds.FirstOrDefault(build => build.version == editor.ActiveVersion.modSettings.customBuildVersion);
if (theBuild != null)
{
FsoPicker = new FsoBuildPickerViewModel(theBuild);
FsoPicker = new FsoBuildPickerViewModel(theBuild, null);
}
else
{
Log.Add(Log.LogSeverity.Warning, "DevModFsoSettingsViewModel.Constructor()", "Missing user-saved build version for mod: " + editor.ActiveVersion.tile + " - " + editor.ActiveVersion.version + " requested build id: " + editor.ActiveVersion.modSettings.customBuildId + " and version: " + editor.ActiveVersion.modSettings.customBuildVersion);
FsoPicker = new FsoBuildPickerViewModel(null);
FsoPicker = new FsoBuildPickerViewModel(null, null);
}
}
else
{
Log.Add(Log.LogSeverity.Warning, "DevModFsoSettingsViewModel.Constructor()", "Missing user-saved build id for mod: " + editor.ActiveVersion.tile + " - " + editor.ActiveVersion.version + " requested build id: " + editor.ActiveVersion.modSettings.customBuildId);
FsoPicker = new FsoBuildPickerViewModel(null);
FsoPicker = new FsoBuildPickerViewModel(null, null);
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions Knossos.NET/ViewModels/Templates/FsoBuildPickerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Knossos.NET.ViewModels
public partial class FsoBuildPickerViewModel : ViewModelBase
{
private bool directSeparatorAdded = false;
private Window? window = null;
[ObservableProperty]
internal ObservableCollection<ComboBoxItem> buildItems = new ObservableCollection<ComboBoxItem>();

Expand Down Expand Up @@ -89,9 +90,15 @@ public FsoBuildPickerViewModel()
{
}

public FsoBuildPickerViewModel(FsoBuild? preSelected)
public FsoBuildPickerViewModel(Window window)
{
this.window = window;
}

public FsoBuildPickerViewModel(FsoBuild? preSelected, Window? window)
{
FillBuildsItems(preSelected);
this.window = window;
}

/*
Expand Down Expand Up @@ -292,7 +299,8 @@ internal async void OpenFileCommand()
FilePickerOpenOptions options = new FilePickerOpenOptions();
options.AllowMultiple = false;
options.Title = "Select the FSO executable file";
var result = await MainWindow.instance.StorageProvider.OpenFilePickerAsync(options);
var topmostWindow = window == null ? MainWindow.instance! : window;
var result = await topmostWindow.StorageProvider.OpenFilePickerAsync(options);

if (result != null && result.Count > 0)
{
Expand Down
17 changes: 15 additions & 2 deletions Knossos.NET/ViewModels/Windows/Fs2InstallerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Threading.Tasks;
using System.IO;
using Avalonia.Platform.Storage;
using Avalonia.Controls;

namespace Knossos.NET.ViewModels
{
Expand Down Expand Up @@ -54,6 +55,7 @@ public partial class Fs2InstallerViewModel : ViewModelBase
[ObservableProperty]
internal bool innoExtractIsAvailable = false;
private string? gogExe = null;
private Window? window;

public Fs2InstallerViewModel()
{
Expand All @@ -63,6 +65,15 @@ public Fs2InstallerViewModel()
}
}

public Fs2InstallerViewModel(Window window)
{
if (KnUtils.IsWindows || KnUtils.IsMacOS || KnUtils.IsLinux && (KnUtils.CpuArch == "X64" || KnUtils.CpuArch == "X86" || KnUtils.CpuArch == "Arm64" || KnUtils.CpuArch == "RiscV64"))
{
InnoExtractIsAvailable = true;
}
this.window = window;
}

/// <summary>
/// The main install process
/// </summary>
Expand Down Expand Up @@ -336,7 +347,8 @@ internal async void LoadGoGExeCommand()
FilePickerOpenOptions options = new FilePickerOpenOptions();
options.AllowMultiple = false;
options.Title = "Select your Freespace 2 gog .exe installer file";
var result = await MainWindow.instance!.StorageProvider.OpenFilePickerAsync(options);
var topmostWindow = window == null ? MainWindow.instance! : window;
var result = await topmostWindow.StorageProvider.OpenFilePickerAsync(options);

if (result != null && result.Count > 0)
{
Expand Down Expand Up @@ -458,7 +470,8 @@ internal async void LoadFolderCommand()
FolderPickerOpenOptions options = new FolderPickerOpenOptions();
options.AllowMultiple = false;
options.Title = "Select your Freespace 2 retail folder";
var result = await MainWindow.instance!.StorageProvider.OpenFolderPickerAsync(options);
var topmostWindow = window == null ? MainWindow.instance! : window;
var result = await topmostWindow.StorageProvider.OpenFolderPickerAsync(options);

if (result != null && result.Count > 0)
{
Expand Down
20 changes: 14 additions & 6 deletions Knossos.NET/ViewModels/Windows/ModSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.IO;
using VP.NET;
using System.Diagnostics;
using Avalonia.Controls;

namespace Knossos.NET.ViewModels
{
Expand All @@ -21,6 +22,7 @@ public partial class ModSettingsViewModel : ViewModelBase
{
private Mod? modJson;
private ModCardViewModel? modCardViewModel;
private Window? window = null;

internal ObservableCollection<DependencyItemViewModel> DepItems { get; set; } = new ObservableCollection<DependencyItemViewModel>();

Expand Down Expand Up @@ -61,6 +63,12 @@ public ModSettingsViewModel()
fsoPicker = new FsoBuildPickerViewModel();
}

public ModSettingsViewModel(Window window)
{
fsoPicker = new FsoBuildPickerViewModel(window);
this.window = window;
}

/// <summary>
/// Open Mod Settings of a certain, installed, Mod.
/// If modcard is passed it will force a status icons update on Save()
Expand Down Expand Up @@ -103,13 +111,13 @@ public ModSettingsViewModel(Mod modJson, ModCardViewModel? modCard=null)

if(modJson.modSettings.customBuildId == null)
{
fsoPicker = new FsoBuildPickerViewModel(null);
fsoPicker = new FsoBuildPickerViewModel(null, window);
}
else
{
if (modJson.modSettings.customBuildExec != null)
{
fsoPicker = new FsoBuildPickerViewModel(new FsoBuild(modJson.modSettings.customBuildExec));
fsoPicker = new FsoBuildPickerViewModel(new FsoBuild(modJson.modSettings.customBuildExec), window);
}
else
{
Expand All @@ -119,20 +127,20 @@ public ModSettingsViewModel(Mod modJson, ModCardViewModel? modCard=null)
var theBuild = matchingBuilds.FirstOrDefault(build => build.version == modJson.modSettings.customBuildVersion);
if (theBuild != null)
{
fsoPicker = new FsoBuildPickerViewModel(theBuild);
fsoPicker = new FsoBuildPickerViewModel(theBuild, window);
}
else
{
Log.Add(Log.LogSeverity.Warning, "ModSettingsViewModel.Constructor()", "Missing user-saved build version for mod: " + modJson.title + " - " + modJson.version + " requested build id: " + modJson.modSettings.customBuildId + " and version: " + modJson.modSettings.customBuildVersion);
BuildMissingWarning = "Missing user-saved build version for mod: " + modJson.title + " - " + modJson.version + " requested build id: " + modJson.modSettings.customBuildId + " and version: " + modJson.modSettings.customBuildVersion;
fsoPicker = new FsoBuildPickerViewModel(null);
fsoPicker = new FsoBuildPickerViewModel(null, window);
}
}
else
{
Log.Add(Log.LogSeverity.Warning, "ModSettingsViewModel.Constructor()", "Missing user-saved build id for mod: " + modJson.title + " - " + modJson.version + " requested build id: " + modJson.modSettings.customBuildId);
BuildMissingWarning = "Missing user-saved build id for mod: " + modJson.title + " - " + modJson.version + " requested build id: " + modJson.modSettings.customBuildId;
fsoPicker = new FsoBuildPickerViewModel(null);
fsoPicker = new FsoBuildPickerViewModel(null, window);
}
}
}
Expand Down Expand Up @@ -413,7 +421,7 @@ internal void ResetSettingsCommand()
{
CustomDependencies = false;
BuildMissingWarning = string.Empty;
FsoPicker = new FsoBuildPickerViewModel(null);
FsoPicker = new FsoBuildPickerViewModel(null, window);
FsoFlags = null;
ConfigureBuild(true);
DepItems.Clear();
Expand Down