Skip to content

Commit 9a433f6

Browse files
committed
zoom platform support
1 parent a208efc commit 9a433f6

File tree

8 files changed

+53
-106
lines changed

8 files changed

+53
-106
lines changed

Directory.Packages.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
2626
<PackageVersion Include="xunit" Version="2.8.1" />
2727
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
28-
<PackageVersion Include="AWSSDK.S3" Version="3.7.309.5" />
28+
<PackageVersion Include="AWSSDK.S3" Version="3.7.309.7" />
2929
<PackageVersion Include="ConfigureAwaitAnalyzer" Version="1.0.3" />
3030
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.6.2" />
3131
<PackageVersion Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.6" />

src/Games/Games/BaseGame.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ protected bool IsInstalled(string file)
106106
return false;
107107
}
108108

109-
if (!File.Exists(Path.Combine(GameInstallFolder, file)))
109+
if (!File.Exists(Path.Combine(GameInstallFolder, file)) &&
110+
!File.Exists(Path.Combine(GameInstallFolder, "addons", file)))
110111
{
111112
return false;
112113
}

src/Games/Games/WangGame.cs

+1-76
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Common;
22
using Common.Enums;
3-
using Common.Enums.Addons;
43
using Common.Helpers;
54
using Common.Interfaces;
65
using Mods.Addons;
@@ -22,23 +21,13 @@ public sealed class WangGame : BaseGame
2221
/// <inheritdoc/>
2322
public override List<string> RequiredFiles => ["SW.GRP"];
2423

25-
/// <summary>
26-
/// Is Duke it Out in DC installed
27-
/// </summary>
28-
public bool IsWantonInstalled => IsInstalled("WT.GRP");
29-
30-
/// <summary>
31-
/// Is Nuclear Winter installed
32-
/// </summary>
33-
public bool IsTwinDragonInstalled => IsInstalled("TD.GRP");
34-
3524

3625
/// <summary>
3726
/// Get list of original campaigns
3827
/// </summary>
3928
public override Dictionary<AddonVersion, IAddon> GetOriginalCampaigns()
4029
{
41-
Dictionary<AddonVersion, IAddon> campaigns = new(3);
30+
Dictionary<AddonVersion, IAddon> campaigns = new(1);
4231

4332
if (IsBaseGameInstalled)
4433
{
@@ -68,70 +57,6 @@ public override Dictionary<AddonVersion, IAddon> GetOriginalCampaigns()
6857
StartMap = null,
6958
PreviewImage = null,
7059
});
71-
72-
if (IsWantonInstalled)
73-
{
74-
var wangWdId = nameof(WangAddonEnum.Wanton).ToLower();
75-
campaigns.Add(new(wangWdId), new WangCampaign()
76-
{
77-
Id = wangWdId,
78-
Type = AddonTypeEnum.Official,
79-
Title = "Wanton Destruction",
80-
GridImage = ImageHelper.FileNameToStream("Wang.wanton.jpg", Assembly.GetExecutingAssembly()),
81-
Author = "Sunstorm Interactive",
82-
Description = """
83-
**Wanton Destruction** is an official expansion that was created by **Sunstorm Interactive** and tested by **3D Realms**, but was not released by the distributor.
84-
It was found and released for free on September 9, 2005.
85-
86-
The add-on chronicles Lo Wang's adventures after the original game. He visits his relatives in USA, but is forced to fight off Zilla's forces again.
87-
The game culminates with a battle against Master Zilla above the streets of Tokyo, which ends with Master Zilla's death.
88-
89-
The game features 12 new levels, new artwork and a few new enemy replacements, such as human enemies; though they still act like their original counterparts.
90-
""",
91-
Version = null,
92-
SupportedGame = new(GameEnum.ShadowWarrior),
93-
RequiredFeatures = null,
94-
PathToFile = null,
95-
DependentAddons = new(StringComparer.OrdinalIgnoreCase) { { nameof(WangAddonEnum.Wanton), null } },
96-
IncompatibleAddons = null,
97-
MainDef = null,
98-
AdditionalDefs = null,
99-
StartMap = null,
100-
PreviewImage = null,
101-
});
102-
}
103-
104-
if (IsTwinDragonInstalled)
105-
{
106-
var wangTdId = nameof(WangAddonEnum.TwinDragon).ToLower();
107-
campaigns.Add(new(wangTdId), new WangCampaign()
108-
{
109-
Id = wangTdId,
110-
Type = AddonTypeEnum.Official,
111-
Title = "Twin Dragon",
112-
GridImage = ImageHelper.FileNameToStream("Wang.twin.jpg", Assembly.GetExecutingAssembly()),
113-
Author = "Wylde Productions, Level Infinity",
114-
Description = """
115-
**Twin Dragon** is an official expansion to the Shadow Warrior that was released as a free download on July 4, 1998.
116-
117-
The game reveals that Lo Wang has a twin brother, Hung Lo, with whom he was separated in early childhood. Hung Lo becomes a dark person whose goal is to destroy the world.
118-
Similar to Master Zilla, he uses the creatures from the dark side, criminal underworld and Zilla's remnants to further his goals. Lo Wang has to journey through his dark minions,
119-
reach his palace and defeat the evil Twin Dragon Hung Lo once and for all. When he reaches the palace, Lo Wang defeats his brother by shooting a Nuke at him, which kills Hung Lo in the process.
120-
121-
The game features 13 new levels, new sounds, artwork and a new final boss, Hung Lo, who replaced Zilla.
122-
""",
123-
Version = null,
124-
SupportedGame = new(GameEnum.ShadowWarrior),
125-
RequiredFeatures = null,
126-
PathToFile = null,
127-
DependentAddons = new(StringComparer.OrdinalIgnoreCase) { { nameof(WangAddonEnum.TwinDragon), null } },
128-
IncompatibleAddons = null,
129-
MainDef = null,
130-
AdditionalDefs = null,
131-
StartMap = null,
132-
PreviewImage = null,
133-
});
134-
}
13560
}
13661

13762
return campaigns;

src/Games/Providers/GamesPathsProvider.cs

+20-8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ public GamesPathsProvider(IConfigProvider config)
2828
{
2929
_config = config;
3030

31+
if (OperatingSystem.IsWindows())
32+
{
33+
var zoomPath = (string?)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ZOOM PLATFORM\Duke Nukem 3D - Atomic Edition", "InstallPath", null);
34+
35+
if (!string.IsNullOrWhiteSpace(zoomPath))
36+
{
37+
if (Directory.Exists(zoomPath))
38+
{
39+
_dukePath ??= zoomPath;
40+
}
41+
}
42+
}
43+
3144
var libs = GetSteamLibraries();
3245

3346
foreach (var lib in libs)
@@ -47,19 +60,13 @@ public GamesPathsProvider(IConfigProvider config)
4760
_dukePath ??= pathToGame;
4861
}
4962

50-
//World Tour
51-
//Using WT as a base game as a last resort
52-
pathToGame = Path.Combine(lib, "Duke Nukem 3D Twentieth Anniversary World Tour");
53-
if (Directory.Exists(pathToGame))
54-
{
55-
_dukePath ??= pathToGame;
56-
}
57-
5863

5964
//WORLD TOUR
6065
pathToGame = Path.Combine(lib, "Duke Nukem 3D Twentieth Anniversary World Tour");
6166
if (Directory.Exists(pathToGame))
6267
{
68+
//Using WT as a base game as a last resort
69+
_dukePath ??= pathToGame;
6370
_dukeWtPath ??= pathToGame;
6471
}
6572

@@ -126,6 +133,8 @@ public GamesPathsProvider(IConfigProvider config)
126133
_redneckPath ??= pathToGame;
127134
}
128135

136+
137+
//RIDES AGAIN
129138
pathToGame = Path.Combine(lib, "Redneck Rampage Rides Again", "AGAIN");
130139
if (Directory.Exists(pathToGame))
131140
{
@@ -156,6 +165,7 @@ public GamesPathsProvider(IConfigProvider config)
156165
_witch1Path ??= pathToGame;
157166
}
158167

168+
//WITCHAVEN II
159169
pathToGame = Path.Combine(lib, "Witchaven II Blood Vengeance", "Original", "GAME", "WHAVEN2");
160170
if (Directory.Exists(pathToGame))
161171
{
@@ -190,6 +200,8 @@ public GamesPathsProvider(IConfigProvider config)
190200
{
191201
return game switch
192202
{
203+
DukeVersionEnum.Duke3D_13D => _dukePath,
204+
DukeVersionEnum.Duke3D_Atomic => _dukePath,
193205
DukeVersionEnum.Duke3D_WT => _dukeWtPath,
194206
_ => throw new NotImplementedException()
195207
};

src/Mods/Providers/InstalledAddonsProvider.cs

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ClientCommon.Config;
22
using Common;
33
using Common.Enums;
4+
using Common.Enums.Addons;
45
using Common.Enums.Versions;
56
using Common.Helpers;
67
using Common.Interfaces;
@@ -170,25 +171,17 @@ public Dictionary<AddonVersion, IAddon> GetInstalledCampaigns()
170171

171172
if (result is not null)
172173
{
173-
foreach (var customCamp in result.OrderBy(static x => x.Value.Title))
174+
foreach (var customCamp in result
175+
//hack so SW addons end up at the beginning of the list
176+
.OrderByDescending(static x => x.Key.Id.Equals(nameof(WangAddonEnum.TwinDragon), StringComparison.InvariantCultureIgnoreCase))
177+
.ThenByDescending(static x => x.Key.Id.Equals(nameof(WangAddonEnum.Wanton), StringComparison.InvariantCultureIgnoreCase))
178+
.ThenBy(static x => x.Value.Title))
174179
{
175-
if (campaigns.TryGetValue(customCamp.Key, out var _))
176-
{
177-
//replacing original campaign with the downloaded one
178-
campaigns[customCamp.Key] = customCamp.Value;
179-
}
180-
else
181-
{
182-
campaigns.Add(customCamp.Key, customCamp.Value);
183-
}
180+
campaigns.Add(customCamp.Key, customCamp.Value);
184181
}
185-
186-
return campaigns;
187-
}
188-
else
189-
{
190-
return [];
191182
}
183+
184+
return campaigns;
192185
}
193186

194187
/// <inheritdoc/>

src/Ports/Ports/EDuke32/EDuke32.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,14 @@ protected void GetDukeArgs(StringBuilder sb, DukeGame game, IAddon addon)
184184
dukeAddon = (byte)DukeAddonEnum.DukeVaca;
185185
}
186186

187-
sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}"" -addon {dukeAddon}");
187+
sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}""");
188+
189+
if (Directory.Exists(Path.Combine(game.GameInstallFolder!, "AddOns")))
190+
{
191+
sb.Append($@" {AddDirectoryParam}""{Path.Combine(game.GameInstallFolder!, "AddOns")}""");
192+
}
193+
194+
sb.Append($@" -addon {dukeAddon}");
188195
}
189196

190197

src/Ports/Ports/EDuke32/VoidSW.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ protected override void BeforeStart(IGame game, IAddon campaign)
6969
protected override void GetStartCampaignArgs(StringBuilder sb, IGame game, IAddon addon)
7070
{
7171
//don't search for steam/gog installs
72-
sb.Append($@" -usecwd");
73-
74-
sb.Append($@" {AddDirectoryParam}""{game.GameInstallFolder}""");
72+
sb.Append($@" -usecwd {AddDirectoryParam}""{game.GameInstallFolder}""");
7573

7674
if (addon.MainDef is not null)
7775
{

src/Ports/Ports/Raze.cs

+11
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ private static void AddGamePathsToConfig(string gameFolder, string modsFolder, s
487487
var path = gameFolder.Replace('\\', '/');
488488
sb.Append("Path=").AppendLine(path);
489489

490+
if (Directory.Exists(Path.Combine(gameFolder, "addons")))
491+
{
492+
sb.Append("Path=").AppendLine(path + "/addons");
493+
}
494+
490495
do
491496
{
492497
i++;
@@ -503,6 +508,12 @@ private static void AddGamePathsToConfig(string gameFolder, string modsFolder, s
503508

504509
var path = gameFolder.Replace('\\', '/');
505510
sb.Append("Path=").AppendLine(path);
511+
512+
if (Directory.Exists(Path.Combine(gameFolder, "addons")))
513+
{
514+
sb.Append("Path=").AppendLine(path + "/addons");
515+
}
516+
506517
path = modsFolder.Replace('\\', '/');
507518
sb.Append("Path=").AppendLine(path);
508519

0 commit comments

Comments
 (0)