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
63 changes: 63 additions & 0 deletions Knossos.NET/Models/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,5 +1024,68 @@ public static bool IsMetaUpdate(Mod modA, Mod modB)
}
return null;
}

/// <summary>
/// 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
/// </summary>
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;
}
}
}
19 changes: 19 additions & 0 deletions Knossos.NET/ViewModels/CustomHomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ private Mod? GetActiveInstalledModVersion
/// </summary>
[ObservableProperty]
public ViewModelBase? taskVM;
[ObservableProperty]
internal bool isQtFredAvailable = false;
[ObservableProperty]
internal bool isQtFredDebugAvailable = false;


public CustomHomeViewModel()
{
Expand Down Expand Up @@ -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];
}
}
}
21 changes: 21 additions & 0 deletions Knossos.NET/ViewModels/Templates/ModCardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -176,6 +180,8 @@ await Task.Run(() =>
});
}
}

RefreshQtFredAvailability();
});
}

Expand All @@ -201,6 +207,7 @@ public void SwitchModVersion(int newIndex)
LoadImage();
CheckDependencyActiveVersion();
RefreshSpecialIcons();
RefreshQtFredAvailability();
}
}

Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions Knossos.NET/Views/CustomHomeView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
<StackPanel>
<Button Name="ButtonPlayVR" Command="{Binding HardcodedButtonCommand}" CommandParameter="playvr" Content="Play in VR" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Name="ButtonFred2" Command="{Binding HardcodedButtonCommand}" CommandParameter="fred2" Content="Fred2" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Name="ButtonQtFred" Command="{Binding HardcodedButtonCommand}" CommandParameter="qtfred" Content="QtFred" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Name="ButtonQtFred" Command="{Binding HardcodedButtonCommand}" CommandParameter="qtfred" Content="QtFred" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" IsVisible="{Binding IsQtFredAvailable}" ></Button>
<Button Name="ButtonDebug" Command="{Binding HardcodedButtonCommand}" CommandParameter="debug" Content="FSO Debug" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Name="ButtonFred2Debug" Command="{Binding HardcodedButtonCommand}" CommandParameter="fred2debug" Content="Fred2 Debug" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Name="ButtonQtFredDebug" Command="{Binding HardcodedButtonCommand}" CommandParameter="qtfreddebug" Content="QtFred Debug" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Name="ButtonQtFredDebug" Command="{Binding HardcodedButtonCommand}" CommandParameter="qtfreddebug" Content="QtFred Debug" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" IsVisible="{Binding IsQtFredDebugAvailable}" ></Button>
<Button Name="ButtonLogFile" Command="{Binding HardcodedButtonCommand}" CommandParameter="logfile" Content="Open Logfile" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
</StackPanel>
</Flyout>
Expand Down
6 changes: 3 additions & 3 deletions Knossos.NET/Views/Templates/ModCardView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
</TabItem.Header>
<StackPanel Margin="5">
<Button Command="{Binding ButtonCommand}" CommandParameter="playvr" Content="Play in VR" Classes="Accept Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="100" ></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="fred2" Content="Fred2" Classes="Secondary Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="100" ></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="qtfred" Content="QtFred" Classes="Settings Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="100" ></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="fred2" Content="Fred2" Classes="Secondary Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="100" ></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="qtfred" Content="QtFred" Classes="Settings Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="100" IsVisible="{Binding IsQtFredAvailable}"></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="delete" Content="Delete" Classes="Cancel Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="100" ></Button>
</StackPanel>
</TabItem>
Expand All @@ -69,7 +69,7 @@
<StackPanel Margin="5">
<Button Command="{Binding ButtonCommand}" CommandParameter="debug" Content="FSO Debug" Classes="Primary Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="fred2debug" Content="Fred2 Debug" Classes="Secondary Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="qtfreddebug" Content="QtFred Debug" Classes="Settings Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="qtfreddebug" Content="QtFred Debug" Classes="Settings Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" IsVisible="{Binding IsQtFredDebugAvailable}"></Button>
<Button Command="{Binding ButtonCommand}" CommandParameter="logfile" Content="Open Logfile" Classes="Quaternary Rounded" HorizontalAlignment="Center" Margin="0,2,0,0" Width="115" ></Button>
</StackPanel>
</TabItem>
Expand Down