Skip to content

Commit

Permalink
added some conditions for addons
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed May 28, 2024
1 parent 134250a commit b8bbdbd
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 13 deletions.
31 changes: 28 additions & 3 deletions src/Avalonia/Core/Controls/CampaignsControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BuildLauncher.Helpers;
using BuildLauncher.ViewModels;
using Common.Enums;
using Common.Enums.Addons;
using Common.Helpers;
using Common.Interfaces;
using CommunityToolkit.Mvvm.Input;
Expand Down Expand Up @@ -60,9 +61,33 @@ private void AddPortsButtons()
Content = sp,
Command = new RelayCommand(() =>
_viewModel.StartCampaignCommand.Execute(port),
() => port.IsInstalled && CampaignsList.SelectedItem is not null &&
(((IAddon)CampaignsList.SelectedItem).RequiredFeatures is null || !((IAddon)CampaignsList.SelectedItem).RequiredFeatures!.Except(port.SupportedFeatures).Any())
),
() =>
{
if (!port.IsInstalled)
{
return false;
}

if (CampaignsList.SelectedItem is null)
{
return false;
}

var selectedCampaign = (IAddon)CampaignsList.SelectedItem;

if (port.PortEnum is PortEnum.BuildGDX &&
(selectedCampaign.Type is not AddonTypeEnum.Official || selectedCampaign.Id.Equals(DukeAddonEnum.DukeNW.ToString(), StringComparison.InvariantCultureIgnoreCase)))
{
return false;
}

if (selectedCampaign.RequiredFeatures is null || !selectedCampaign.RequiredFeatures!.Except(port.SupportedFeatures).Any())
{
return true;
}

return false;
}),
Margin = new(5),
Padding = new(5),
};
Expand Down
29 changes: 26 additions & 3 deletions src/Avalonia/Core/Controls/MapsControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,32 @@ private void AddPortsButtons()
Content = sp,
Command = new RelayCommand(() =>
_viewModel.StartMapCommand.Execute(port),
() => port.IsInstalled && MapsList.SelectedItem is not null &&
(((IAddon)MapsList.SelectedItem)?.RequiredFeatures is null || !((IAddon)MapsList.SelectedItem).RequiredFeatures!.Except(port.SupportedFeatures).Any())
),
() =>
{
if (!port.IsInstalled)
{
return false;
}

if (MapsList.SelectedItem is null)
{
return false;
}

var selectedMap = (IAddon)MapsList.SelectedItem;

if (port.PortEnum is PortEnum.BuildGDX)
{
return false;
}

if (selectedMap.RequiredFeatures is null || !selectedMap.RequiredFeatures!.Except(port.SupportedFeatures).Any())
{
return true;
}

return false;
}),
Margin = new(5),
Padding = new(5),
};
Expand Down
5 changes: 4 additions & 1 deletion src/Common/Enums/FeatureEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public enum FeatureEnum
Sloped_Sprites,
TROR,
Wall_Rotate_Cstat,
CustomDude
CustomDude,
WorldTourSupport,
[Obsolete]
VacaDcSupport
}
}
6 changes: 3 additions & 3 deletions src/Games/Games/DukeGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Duke Nukem 3D is a first-person shooter developed and published by **3D Realms**
""",
Version = null,
SupportedGame = new(GameEnum.Duke3D, DukeVersionEnum.Duke3D_WT),
RequiredFeatures = null,
RequiredFeatures = [FeatureEnum.WorldTourSupport],
PathToFile = null,
DependentAddons = null,
IncompatibleAddons = null,
Expand Down Expand Up @@ -166,7 +166,7 @@ Duke Nukem 3D is a first-person shooter developed and published by **3D Realms**
""",
Version = null,
SupportedGame = new(GameEnum.Duke3D, DukeVersionEnum.Duke3D_Atomic),
RequiredFeatures = null,
RequiredFeatures = [FeatureEnum.VacaDcSupport],
PathToFile = null,
DependentAddons = new() { {DukeAddonEnum.DukeVaca.ToString(), null } },
IncompatibleAddons = null,
Expand Down Expand Up @@ -232,7 +232,7 @@ Duke Nukem must travel to the North Pole in order to stop the brainwashed Santa
""",
Version = null,
SupportedGame = new(GameEnum.Duke3D, DukeVersionEnum.Duke3D_Atomic),
RequiredFeatures = null,
RequiredFeatures = [FeatureEnum.VacaDcSupport],
PathToFile = null,
DependentAddons = new() { { DukeAddonEnum.DukeDC.ToString(), null } },
IncompatibleAddons = null,
Expand Down
2 changes: 1 addition & 1 deletion src/Ports/Ports/BuildGDX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public sealed class BuildGDX : BasePort
public override bool IsInstalled => File.Exists(Path.Combine(PathToExecutableFolder, "BuildGDX.jar"));

/// <inheritdoc/>
public override List<FeatureEnum> SupportedFeatures => [];
public override List<FeatureEnum> SupportedFeatures => [FeatureEnum.WorldTourSupport];


/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion src/Ports/Ports/EDuke32/EDuke32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class EDuke32 : BasePort
];

/// <inheritdoc/>
public override List<FeatureEnum> SupportedFeatures => [FeatureEnum.EDuke32_CON];
public override List<FeatureEnum> SupportedFeatures => [FeatureEnum.EDuke32_CON, FeatureEnum.WorldTourSupport];

/// <inheritdoc/>
public override string? InstalledVersion
Expand Down
2 changes: 1 addition & 1 deletion src/Ports/Ports/Raze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public sealed class Raze : BasePort
protected override string AddGrpParam => throw new NotImplementedException();

/// <inheritdoc/>
public override List<FeatureEnum> SupportedFeatures => [];
public override List<FeatureEnum> SupportedFeatures => [FeatureEnum.WorldTourSupport, FeatureEnum.VacaDcSupport];

/// <inheritdoc/>
protected override void GetSkipIntroParameter(StringBuilder sb) => sb.Append(" -quick");
Expand Down

0 comments on commit b8bbdbd

Please sign in to comment.