From 3a42602f03f97e07361f7e04607931f80251b48a Mon Sep 17 00:00:00 2001 From: John Fernandez Date: Wed, 19 Mar 2025 23:26:10 -0400 Subject: [PATCH 1/2] Only have the qtfred button appear sometimes Disallow the qtfred and qtfred debug buttons when those builds are not available. --- Knossos.NET/Models/Mod.cs | 63 +++++++++++++++++++ .../ViewModels/Templates/ModCardViewModel.cs | 21 +++++++ Knossos.NET/Views/Templates/ModCardView.axaml | 6 +- 3 files changed, 87 insertions(+), 3 deletions(-) diff --git a/Knossos.NET/Models/Mod.cs b/Knossos.NET/Models/Mod.cs index 967759c7..b33f3d81 100644 --- a/Knossos.NET/Models/Mod.cs +++ b/Knossos.NET/Models/Mod.cs @@ -1024,5 +1024,68 @@ public static bool IsMetaUpdate(Mod modA, Mod modB) } return null; } + + /// + /// Check to see if a mod has a qtfred build + /// used mainly to see if we should create a qtfred button on the mod tiles + /// + public bool[] IsQtFredAvailable() + { + FsoBuild? fsoBuild = null; + + /* Resolve Dependencies should be all valid at this point */ + var dependencyList = GetModDependencyList(false,true); + if (dependencyList != null) + { + foreach (var dep in dependencyList) + { + var selectedMod = dep.SelectMod(); + if (selectedMod == null) + { + /* + It has to be the engine dependency ... based on what shivanSPS commented elsewhere - Cyborg + */ + if (fsoBuild == null && modSettings.customBuildId == null) + { + fsoBuild = dep.SelectBuild(true); + } + } + } + } + + if (fsoBuild == null) + { + if (modSettings.customBuildExec == null) + { + fsoBuild = Knossos.GetInstalledBuildsList().FirstOrDefault(builds => builds.id == modSettings.customBuildId && builds.version == modSettings.customBuildVersion); + } + else + { + fsoBuild = new FsoBuild(modSettings.customBuildExec); + } + } + + bool[] result = { false, false }; + + if (fsoBuild == null) + { + return result; + } + + var exe = fsoBuild.GetExecutable(FsoExecType.QtFred); + var exe2 = fsoBuild.GetExecutable(FsoExecType.QtFredDebug); + + if (exe != null) + { + result[0] = true; + } + + if (exe != null) + { + result[1] = true; + } + + return result; + } } } diff --git a/Knossos.NET/ViewModels/Templates/ModCardViewModel.cs b/Knossos.NET/ViewModels/Templates/ModCardViewModel.cs index af330147..7bef91fc 100644 --- a/Knossos.NET/ViewModels/Templates/ModCardViewModel.cs +++ b/Knossos.NET/ViewModels/Templates/ModCardViewModel.cs @@ -80,6 +80,10 @@ public bool Visible internal bool isCustomConfig = false; [ObservableProperty] internal bool cardVisible = true; + [ObservableProperty] + internal bool isQtFredAvailable = false; + [ObservableProperty] + internal bool isQtFredDebugAvailable = false; private Bitmap? tileModBitmap; /* Should only be used by the editor preview */ @@ -176,6 +180,8 @@ await Task.Run(() => }); } } + + RefreshQtFredAvailability(); }); } @@ -201,6 +207,7 @@ public void SwitchModVersion(int newIndex) LoadImage(); CheckDependencyActiveVersion(); RefreshSpecialIcons(); + RefreshQtFredAvailability(); } } @@ -253,6 +260,20 @@ public void RefreshSpecialIcons() IsCustomConfig = !modVersions[activeVersionIndex].modSettings.IsDefaultConfig(); } + public void RefreshQtFredAvailability() + { + var bools = modVersions[activeVersionIndex].IsQtFredAvailable(); + + if (bools == null || bools.Length < 2){ + IsQtFredAvailable = false; + IsQtFredDebugAvailable = false; + return; + } + + IsQtFredAvailable = bools[0]; + IsQtFredDebugAvailable = bools[1]; + } + /* Button Commands */ internal void ButtonCommand(object command) { diff --git a/Knossos.NET/Views/Templates/ModCardView.axaml b/Knossos.NET/Views/Templates/ModCardView.axaml index d1e288ed..5542fb96 100644 --- a/Knossos.NET/Views/Templates/ModCardView.axaml +++ b/Knossos.NET/Views/Templates/ModCardView.axaml @@ -57,8 +57,8 @@ - - + + @@ -69,7 +69,7 @@ - + From 7c8aa2a2cb63b6153a197c88c9832e10e062b33e Mon Sep 17 00:00:00 2001 From: John Fernandez Date: Fri, 21 Mar 2025 11:15:50 -0400 Subject: [PATCH 2/2] Add QTFred Button Enabling for custom mod view --- Knossos.NET/ViewModels/CustomHomeViewModel.cs | 19 +++++++++++++++++++ Knossos.NET/Views/CustomHomeView.axaml | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Knossos.NET/ViewModels/CustomHomeViewModel.cs b/Knossos.NET/ViewModels/CustomHomeViewModel.cs index ebc8dcd6..a1bf4204 100644 --- a/Knossos.NET/ViewModels/CustomHomeViewModel.cs +++ b/Knossos.NET/ViewModels/CustomHomeViewModel.cs @@ -86,6 +86,11 @@ private Mod? GetActiveInstalledModVersion /// [ObservableProperty] public ViewModelBase? taskVM; + [ObservableProperty] + internal bool isQtFredAvailable = false; + [ObservableProperty] + internal bool isQtFredDebugAvailable = false; + public CustomHomeViewModel() { @@ -523,5 +528,19 @@ internal void ChangeBasePath() ShowBasePathSelector = false; } } + + public void RefreshQtFredAvailability() + { + var bools = modVersions[ActiveVersionIndex].IsQtFredAvailable(); + + if (bools == null || bools.Length < 2){ + IsQtFredAvailable = false; + IsQtFredDebugAvailable = false; + return; + } + + IsQtFredAvailable = bools[0]; + IsQtFredDebugAvailable = bools[1]; + } } } diff --git a/Knossos.NET/Views/CustomHomeView.axaml b/Knossos.NET/Views/CustomHomeView.axaml index 5c39e931..b98ef0e5 100644 --- a/Knossos.NET/Views/CustomHomeView.axaml +++ b/Knossos.NET/Views/CustomHomeView.axaml @@ -76,10 +76,10 @@ - + - +