Skip to content

Commit a688845

Browse files
authored
Merge pull request #5 from AlamoEngine-Tools/develop
Update CLI params
2 parents 64bbae5 + ec3b6d3 commit a688845

37 files changed

Lines changed: 757 additions & 347 deletions

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ jobs:
5555
# Change into the artifacts directory to avoid including the directory itself in the zip archive
5656
working-directory: ./releases/net8.0
5757
run: zip -r ../ModVerify-Net8.zip .
58-
- name: Rename .NET Framework executable
59-
run: mv ./releases/net48/ModVerify.CliApp.exe ./releases/net48/ModVerify.exe
6058
- uses: dotnet/nbgv@v0.4.2
6159
id: nbgv
6260
- name: Create GitHub release

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ A `.JSON` file lists all found issues. Into seperate `.txt` files the same error
3232

3333
You can also run the tool with command line arguments to adjust the tool to your needs.
3434

35-
To see all available options, open the command line and type:
35+
To see all available options, especially if you have custom folder setups, open the command line and type:
3636

3737
```bash
3838
ModVerify.exe --help
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using PG.StarWarsGame.Engine;
2+
using PG.StarWarsGame.Infrastructure.Games;
3+
4+
namespace AET.ModVerifyTool;
5+
6+
internal static class ExtensionMethods
7+
{
8+
public static GameEngineType ToEngineType(this GameType type)
9+
{
10+
return type == GameType.Foc ? GameEngineType.Foc : GameEngineType.Eaw;
11+
}
12+
13+
public static GameType FromEngineType(this GameEngineType type)
14+
{
15+
return type == GameEngineType.Foc ? GameType.Foc : GameType.Eaw;
16+
}
17+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using PG.StarWarsGame.Infrastructure.Games;
22

3-
namespace ModVerify.CliApp;
3+
namespace AET.ModVerifyTool.GameFinder;
44

55
internal record GameFinderResult(IGame Game, IGame? FallbackGame);
Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.IO.Abstractions;
45
using Microsoft.Extensions.DependencyInjection;
56
using Microsoft.Extensions.Logging;
@@ -10,7 +11,7 @@
1011
using PG.StarWarsGame.Infrastructure.Services.Dependencies;
1112
using PG.StarWarsGame.Infrastructure.Services.Detection;
1213

13-
namespace ModVerify.CliApp;
14+
namespace AET.ModVerifyTool.GameFinder;
1415

1516
internal class GameFinderService
1617
{
@@ -40,33 +41,34 @@ public GameFinderResult FindGames()
4041
return FindGames(detectors);
4142
}
4243

43-
public GameFinderResult FindGamesFromPath(string path)
44+
public GameFinderResult FindGamesFromPathOrGlobal(string path)
4445
{
45-
// There are three common situations:
46+
// There are four common situations:
4647
// 1. path points to the actual game directory
4748
// 2. path points to a local mod in game/Mods/ModDir
4849
// 3. path points to a workshop mod
50+
// 4. path points to a "detached mod" at a completely different location
4951
var givenDirectory = _fileSystem.DirectoryInfo.New(path);
5052
var possibleGameDir = givenDirectory.Parent?.Parent;
51-
var possibleSteamAppsFolder = givenDirectory.Parent?.Parent?.Parent?.Parent?.Parent;
5253

5354
var detectors = new List<IGameDetector>
5455
{
56+
// Case 1
5557
new DirectoryGameDetector(givenDirectory, _serviceProvider)
5658
};
5759

60+
// Case 2
5861
if (possibleGameDir is not null)
5962
detectors.Add(new DirectoryGameDetector(possibleGameDir, _serviceProvider));
6063

61-
if (possibleSteamAppsFolder is not null && possibleSteamAppsFolder.Name == "steamapps" && uint.TryParse(givenDirectory.Name, out _))
62-
detectors.Add(new SteamPetroglyphStarWarsGameDetector(_serviceProvider));
63-
64+
// Cases 3 & 4
65+
detectors.Add(new SteamPetroglyphStarWarsGameDetector(_serviceProvider));
6466
return FindGames(detectors);
6567
}
6668

6769
private bool TryDetectGame(GameType gameType, IList<IGameDetector> detectors, out GameDetectionResult result)
6870
{
69-
var gd = new CompositeGameDetector(detectors, _serviceProvider, true);
71+
var gd = new CompositeGameDetector(detectors, _serviceProvider);
7072
result = gd.Detect(new GameDetectorOptions(gameType));
7173

7274
if (result.Error is not null)
@@ -80,48 +82,22 @@ private bool TryDetectGame(GameType gameType, IList<IGameDetector> detectors, ou
8082
return true;
8183
}
8284

83-
84-
private void SetupMods(IGame game)
85-
{
86-
var modFinder = _serviceProvider.GetRequiredService<IModReferenceFinder>();
87-
var modRefs = modFinder.FindMods(game);
88-
89-
var mods = new List<IMod>();
90-
91-
foreach (var modReference in modRefs)
92-
{
93-
var mod = _modFactory.FromReference(game, modReference);
94-
mods.AddRange(mod);
95-
}
96-
97-
foreach (var mod in mods)
98-
game.AddMod(mod);
99-
100-
// Mods need to be added to the game first, before resolving their dependencies.
101-
foreach (var mod in mods)
102-
{
103-
var resolver = _serviceProvider.GetRequiredService<IDependencyResolver>();
104-
mod.ResolveDependencies(resolver,
105-
new DependencyResolverOptions { CheckForCycle = true, ResolveCompleteChain = true });
106-
}
107-
}
108-
10985
private GameFinderResult FindGames(IList<IGameDetector> detectors)
11086
{
11187
// FoC needs to be tried first
11288
if (!TryDetectGame(GameType.Foc, detectors, out var result))
11389
{
11490
_logger?.LogTrace("Unable to find FoC installation. Trying again with EaW...");
115-
if (!TryDetectGame(GameType.EaW, detectors, out result))
116-
throw new GameException("Unable to find game installation: Wrong install path?");
91+
if (!TryDetectGame(GameType.Eaw, detectors, out result))
92+
throw new GameNotFoundException("Unable to find game installation: Wrong install path?");
11793
}
11894

11995
if (result.GameLocation is null)
120-
throw new GameException("Unable to find game installation: Wrong install path?");
96+
throw new GameNotFoundException("Unable to find game installation: Wrong install path?");
12197

12298
_logger?.LogTrace($"Found game installation: {result.GameIdentity} at {result.GameLocation.FullName}");
12399

124-
var game = _gameFactory.CreateGame(result);
100+
var game = _gameFactory.CreateGame(result, CultureInfo.InvariantCulture);
125101

126102
SetupMods(game);
127103

@@ -137,16 +113,41 @@ private GameFinderResult FindGames(IList<IGameDetector> detectors)
137113
else
138114
throw new NotImplementedException("Searching fallback game for non-Steam games is currently is not yet implemented.");
139115

140-
if (!TryDetectGame(GameType.EaW, fallbackDetectors, out var fallbackResult) || fallbackResult.GameLocation is null)
141-
throw new GameException("Unable to find fallback game installation: Wrong install path?");
116+
if (!TryDetectGame(GameType.Eaw, fallbackDetectors, out var fallbackResult) || fallbackResult.GameLocation is null)
117+
throw new GameNotFoundException("Unable to find fallback game installation: Wrong install path?");
142118

143119
_logger?.LogTrace($"Found fallback game installation: {fallbackResult.GameIdentity} at {fallbackResult.GameLocation.FullName}");
144120

145-
fallbackGame = _gameFactory.CreateGame(fallbackResult);
121+
fallbackGame = _gameFactory.CreateGame(fallbackResult, CultureInfo.InvariantCulture);
146122

147123
SetupMods(fallbackGame);
148124
}
149125

150126
return new GameFinderResult(game, fallbackGame);
151127
}
128+
129+
private void SetupMods(IGame game)
130+
{
131+
var modFinder = _serviceProvider.GetRequiredService<IModReferenceFinder>();
132+
var modRefs = modFinder.FindMods(game);
133+
134+
var mods = new List<IMod>();
135+
136+
foreach (var modReference in modRefs)
137+
{
138+
var mod = _modFactory.FromReference(game, modReference, CultureInfo.InvariantCulture);
139+
mods.AddRange(mod);
140+
}
141+
142+
foreach (var mod in mods)
143+
game.AddMod(mod);
144+
145+
// Mods need to be added to the game first, before resolving their dependencies.
146+
foreach (var mod in mods)
147+
{
148+
var resolver = _serviceProvider.GetRequiredService<IDependencyResolver>();
149+
mod.ResolveDependencies(resolver,
150+
new DependencyResolverOptions { CheckForCycle = true, ResolveCompleteChain = true });
151+
}
152+
}
152153
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using PG.StarWarsGame.Infrastructure.Games;
2+
3+
namespace AET.ModVerifyTool;
4+
5+
internal class GameNotFoundException(string message) : GameException(message);

src/ModVerify.CliApp/ModOrGameSelector.cs

Lines changed: 0 additions & 141 deletions
This file was deleted.

src/ModVerify.CliApp/ModSelectionResult.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)