From 074a6e479a88bea972230ff9f1e08d8ff83e73a6 Mon Sep 17 00:00:00 2001 From: JohnAFernandez Date: Fri, 7 Mar 2025 00:39:40 -0500 Subject: [PATCH 1/2] Start adding installation button WIP, I still need to adjust the button size and make the filter text play nice with it. Also displaying the sort is not working too well on the play tab --- Knossos.NET/ViewModels/ModListViewModel.cs | 23 +++++++++++++++++- .../ViewModels/NebulaModListViewModel.cs | 24 ++++++++++++++++++- Knossos.NET/Views/ModListView.axaml | 1 + Knossos.NET/Views/NebulaModListView.axaml | 1 + .../Views/Windows/Fs2InstallerView.axaml | 2 +- 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/Knossos.NET/ViewModels/ModListViewModel.cs b/Knossos.NET/ViewModels/ModListViewModel.cs index b07b3f61..19921f0b 100644 --- a/Knossos.NET/ViewModels/ModListViewModel.cs +++ b/Knossos.NET/ViewModels/ModListViewModel.cs @@ -5,6 +5,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using Knossos.NET.Classes; using Knossos.NET.Models; +using Knossos.NET.Views; using ObservableCollections; namespace Knossos.NET.ViewModels @@ -28,6 +29,9 @@ public partial class ModListViewModel : ViewModelBase /// internal ModSortType localSort = ModSortType.name; + [ObservableProperty] + internal bool fs2Present = true; + internal string search = string.Empty; internal string Search { @@ -146,7 +150,7 @@ private void BuildFilterString(){ TextInfo myTI = new CultureInfo("en-US", false).TextInfo; foreach (var filter in MainWindowViewModel.Instance.tagFilter) { - if (count > 3){ + if (count > 2){ FilterString += " and ..."; break; // easiest case, this handles a filter list of one and the start of all other cases @@ -184,6 +188,7 @@ public void OpenTab() SortString = "Sorted by " + Search; BuildFilterString(); + Fs2Present = Knossos.retailFs2RootFound; } public void CloseTab() @@ -318,5 +323,21 @@ public void RemoveModVersion(Mod mod) } } } + + /// + /// Open the retails FS2 installer window + /// + internal async void InstallFS2Command() + { + if (MainWindow.instance != null) + { + var dialog = new Fs2InstallerView(); + dialog.DataContext = new Fs2InstallerViewModel(); + + await dialog.ShowDialog(MainWindow.instance); + + Fs2Present = Knossos.retailFs2RootFound; + } + } } } diff --git a/Knossos.NET/ViewModels/NebulaModListViewModel.cs b/Knossos.NET/ViewModels/NebulaModListViewModel.cs index 74dd4f53..701a2589 100644 --- a/Knossos.NET/ViewModels/NebulaModListViewModel.cs +++ b/Knossos.NET/ViewModels/NebulaModListViewModel.cs @@ -7,6 +7,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using Knossos.NET.Classes; using Knossos.NET.Models; +using Knossos.NET.Views; using ObservableCollections; namespace Knossos.NET.ViewModels @@ -47,6 +48,9 @@ internal bool isLoading{ [ObservableProperty] internal LoadingIconViewModel loadingAnimation = new LoadingIconViewModel(); + [ObservableProperty] + internal bool fs2Present = true; + /// /// Search string /// @@ -169,7 +173,7 @@ private void BuildFilterString(){ TextInfo myTI = new CultureInfo("en-US", false).TextInfo; foreach (var filter in MainWindowViewModel.Instance.tagFilter) { - if (count > 3){ + if (count > 2){ FilterString += " and ..."; break; // easiest case, this handles a filter list of one and the start of all other cases @@ -194,6 +198,7 @@ private void BuildFilterString(){ public void OpenTab() { IsTabOpen = true; + if (!isLoading) { Task.Run(() => @@ -223,6 +228,8 @@ public void OpenTab() ShowTiles = true; }); } + + Fs2Present = Knossos.retailFs2RootFound; } /// @@ -371,5 +378,20 @@ public void CancelModInstall(string id) modCard.CancelInstall(); } } + + /// + /// Open the retails FS2 installer window + /// + internal async void InstallFS2Command() + { + if (MainWindow.instance != null) + { + var dialog = new Fs2InstallerView(); + dialog.DataContext = new Fs2InstallerViewModel(); + + await dialog.ShowDialog(MainWindow.instance); + Fs2Present = Knossos.retailFs2RootFound; + } + } } } diff --git a/Knossos.NET/Views/ModListView.axaml b/Knossos.NET/Views/ModListView.axaml index 6ffae928..868df31c 100644 --- a/Knossos.NET/Views/ModListView.axaml +++ b/Knossos.NET/Views/ModListView.axaml @@ -55,6 +55,7 @@ + diff --git a/Knossos.NET/Views/Windows/Fs2InstallerView.axaml b/Knossos.NET/Views/Windows/Fs2InstallerView.axaml index f6547165..36ef25fc 100644 --- a/Knossos.NET/Views/Windows/Fs2InstallerView.axaml +++ b/Knossos.NET/Views/Windows/Fs2InstallerView.axaml @@ -26,7 +26,7 @@ - + From efb2ba47362be42b0780cd454bb465ce01127690 Mon Sep 17 00:00:00 2001 From: JohnAFernandez Date: Mon, 10 Mar 2025 23:53:35 -0400 Subject: [PATCH 2/2] Polish Button And fix Search filter bug The initial value was being set to the wrong string. --- Knossos.NET/Classes/Knossos.cs | 5 ++++- Knossos.NET/ViewModels/ModListViewModel.cs | 16 ++++++++++++++-- Knossos.NET/ViewModels/NebulaModListViewModel.cs | 13 ++++++++++++- Knossos.NET/Views/ModListView.axaml | 6 +++++- Knossos.NET/Views/NebulaModListView.axaml | 6 +++++- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Knossos.NET/Classes/Knossos.cs b/Knossos.NET/Classes/Knossos.cs index 62aa3169..61498417 100644 --- a/Knossos.NET/Classes/Knossos.cs +++ b/Knossos.NET/Classes/Knossos.cs @@ -819,9 +819,12 @@ await Task.Run(async () => { //generate mod tag buttons Dispatcher.UIThread.Invoke(() => - { + { NebulaModListView.Instance?.GenerateFilterButtons(); ModListView.Instance?.GenerateFilterButtons(); + MainWindowViewModel.Instance?.NebulaModsView?.UpdateFS2InstallButton(); + MainWindowViewModel.Instance?.InstalledModsView?.UpdateFS2InstallButton(); + }); initIsComplete = true; diff --git a/Knossos.NET/ViewModels/ModListViewModel.cs b/Knossos.NET/ViewModels/ModListViewModel.cs index 19921f0b..93bfcaf2 100644 --- a/Knossos.NET/ViewModels/ModListViewModel.cs +++ b/Knossos.NET/ViewModels/ModListViewModel.cs @@ -169,6 +169,14 @@ private void BuildFilterString(){ } } + /// + /// Used to signal the mod list view to update its "have you installed FS2" button + /// + public void UpdateFS2InstallButton() + { + Fs2Present = Knossos.retailFs2RootFound; + } + /// /// /// @@ -186,9 +194,13 @@ public void OpenTab() } } - SortString = "Sorted by " + Search; + if (Knossos.initIsComplete) + { + Fs2Present = Knossos.retailFs2RootFound; + } + + SortString = "Sorted by " + localSort; BuildFilterString(); - Fs2Present = Knossos.retailFs2RootFound; } public void CloseTab() diff --git a/Knossos.NET/ViewModels/NebulaModListViewModel.cs b/Knossos.NET/ViewModels/NebulaModListViewModel.cs index 701a2589..6274208a 100644 --- a/Knossos.NET/ViewModels/NebulaModListViewModel.cs +++ b/Knossos.NET/ViewModels/NebulaModListViewModel.cs @@ -192,6 +192,14 @@ private void BuildFilterString(){ } } + /// + /// Used to signal the mod list view to update its "have you installed FS2" button + /// + public void UpdateFS2InstallButton() + { + Fs2Present = Knossos.retailFs2RootFound; + } + /// /// Open the tab code /// @@ -229,7 +237,10 @@ public void OpenTab() }); } - Fs2Present = Knossos.retailFs2RootFound; + if (Knossos.initIsComplete) + { + Fs2Present = Knossos.retailFs2RootFound; + } } /// diff --git a/Knossos.NET/Views/ModListView.axaml b/Knossos.NET/Views/ModListView.axaml index 868df31c..971fa3cd 100644 --- a/Knossos.NET/Views/ModListView.axaml +++ b/Knossos.NET/Views/ModListView.axaml @@ -55,7 +55,11 @@ - + +