Skip to content

Commit d330d54

Browse files
authored
Merge pull request #234 from AlamoEngine-Tools/develop
Public GameExeUtilities
2 parents bb6e248 + d082d3b commit d330d54

47 files changed

Lines changed: 116 additions & 90 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sampleApp/SampleApplication.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
10+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/AET.SteamAbstraction/AET.SteamAbstraction.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
<PackageReference Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
2626
<PackageReference Include="AnakinRaW.CommonUtilities" Version="12.3.9" />
2727
<PackageReference Include="AnakinRaW.CommonUtilities.FileSystem" Version="12.3.9" />
28-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
29-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
28+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
29+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
3030
<PackageReference Include="Nullable" Version="1.3.1">
3131
<PrivateAssets>all</PrivateAssets>
3232
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3333
</PackageReference>
34-
<PackageReference Include="System.Text.Json" Version="10.0.0" />
34+
<PackageReference Include="System.Text.Json" Version="10.0.1" />
3535
</ItemGroup>
3636
</Project>

src/AET.SteamAbstraction/SteamAbstractionLayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void InitializeServices(IServiceCollection serviceCollection)
1919
{
2020
serviceCollection.AddSingleton<ISteamWrapperFactory>(sp => new SteamWrapperFactory(sp));
2121
serviceCollection.AddSingleton<ISteamRegistryFactory>(sp => new SteamRegistryFactory(sp));
22-
serviceCollection.AddSingleton<IProcessHelper>(sp => new ProcessHelper());
22+
serviceCollection.AddSingleton<IProcessHelper>(new ProcessHelper());
2323
serviceCollection.AddSingleton<ISteamLibraryFinder>(sp => new SteamLibraryFinder(sp));
2424
}
2525
}

src/AET.SteamAbstraction/SteamWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public bool? UserWantsOfflineMode
5151
try
5252
{
5353
var config = SteamVdfReader.ReadLoginUsers(FileSystem.FileInfo.New(configFile));
54-
return config.Users.Any(user => user.MostRecent && user.UserWantsOffline);
54+
return config.Users.Any(user => user is { MostRecent: true, UserWantsOffline: true });
5555
}
5656
catch (SteamException)
5757
{

src/AET.SteamAbstraction/Vdf/Linq/VConditional.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace AET.SteamAbstraction.Vdf.Linq;
88

99
internal class VConditional : VToken
1010
{
11-
private readonly List<Token> _tokens = new();
11+
private readonly List<Token> _tokens = [];
1212

1313
public override VTokenType Type => VTokenType.Conditional;
1414

src/AET.SteamAbstraction/Vdf/Linq/VObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public VToken? this[string key]
7575

7676
public VObject()
7777
{
78-
_children = new List<VToken>();
78+
_children = [];
7979
}
8080

8181
public VObject(VObject other)

src/PG.StarWarsGame.Infrastructure/Clients/Arguments/GameArgumentNames.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace PG.StarWarsGame.Infrastructure.Clients.Arguments;
99
/// </summary>
1010
public static class GameArgumentNames
1111
{
12+
// ReSharper disable InconsistentNaming
1213
internal const string ModListArg = "MODLIST";
1314
internal const string WindowedArg = "WINDOWED";
1415
internal const string MCEArg = "MCE";
@@ -68,6 +69,7 @@ public static class GameArgumentNames
6869
internal const string ConsoleCommandFileArg = "CONSOLECOMMANDFILE";
6970
internal const string ConnectPortArg = "CONNECTPORT";
7071
internal const string ConnectIPArg = "CONNECTIP";
72+
// ReSharper enable InconsistentNaming
7173

7274
internal static readonly IReadOnlyCollection<string> SupportedFlagArgumentNames =
7375
new ReadOnlyCollection<string>(

src/PG.StarWarsGame.Infrastructure/Clients/Arguments/GameArguments/AILogStyle.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments;
44

5+
// ReSharper disable once InconsistentNaming
56
/// <summary>
67
/// Level of detail of LUA logging.
78
/// </summary>

src/PG.StarWarsGame.Infrastructure/Clients/Arguments/GameArguments/GameArguments.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace PG.StarWarsGame.Infrastructure.Clients.Arguments.GameArguments;
77

8+
// ReSharper disable InconsistentNaming
9+
810
#region Flags Normal
911

1012
/// <summary>
@@ -304,7 +306,7 @@ internal override string ValueToCommandLine()
304306
/// File location where LUA logging shall be stored to.
305307
/// </summary>
306308
/// <remarks>
307-
/// The directory of the file must already exists.
309+
/// The directory of the file must already exist.
308310
/// </remarks>
309311
public sealed class AILogFileArgument(IFileInfo value, IDirectoryInfo gameDir) : NamedArgument<IFileInfo>(GameArgumentNames.AILogFileArg, value, true)
310312
{

src/PG.StarWarsGame.Infrastructure/Clients/Utilities/GameExecutableFileUtilities.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,43 @@
66

77
namespace PG.StarWarsGame.Infrastructure.Clients.Utilities;
88

9-
internal class GameExecutableFileUtilities
9+
/// <summary>
10+
/// Provides utility methods for locating game executable files for different game platforms and build types.
11+
/// </summary>
12+
public static class GameExecutableFileUtilities
1013
{
1114
private const string SteamFileNameBase = "StarWars";
1215
private const string SteamReleaseSuffix = "G";
1316
private const string SteamDebugSuffix = "I";
1417

18+
/// <summary>
19+
/// Gets the executable file for the specified game and build type or <see langword="null"/> if not found.
20+
/// </summary>
21+
/// <param name="game">The game for which to locate the executable file.</param>
22+
/// <param name="buildType">The build type of the game executable to locate.</param>
23+
/// <returns>An <see cref="IFileInfo"/> representing the executable file if found; otherwise, <see langword="null"/>.</returns>
24+
/// <exception cref="ArgumentNullException"><paramref name="game"/> is <see langword="null"/>.</exception>
1525
public static IFileInfo? GetExecutableForGame(IGame game, GameBuildType buildType)
1626
{
17-
var exeFileName = GetExecutableFileName(game, buildType);
27+
if (game == null)
28+
throw new ArgumentNullException(nameof(game));
1829

19-
if (string.IsNullOrEmpty(exeFileName))
30+
// Only SteamGold supports debug builds
31+
if (buildType == GameBuildType.Debug && game.Platform != GamePlatform.SteamGold)
2032
return null;
2133

34+
var exeFileName = GetExecutableFileName(game, buildType);
35+
2236
return game.Directory
23-
.EnumerateFiles(exeFileName!, SearchOption.TopDirectoryOnly)
37+
.EnumerateFiles(exeFileName, SearchOption.TopDirectoryOnly)
2438
.FirstOrDefault();
2539
}
2640

27-
private static string? GetExecutableFileName(IGame game, GameBuildType buildType)
41+
private static string GetExecutableFileName(IGame game, GameBuildType buildType)
2842
{
2943
if (game.Platform == GamePlatform.SteamGold)
3044
return GetSteamFileName(buildType);
3145

32-
if (buildType is GameBuildType.Debug)
33-
return null;
34-
3546
return game.Type switch
3647
{
3748
GameType.Eaw => PetroglyphStarWarsGameConstants.EmpireAtWarExeFileName,

0 commit comments

Comments
 (0)