Skip to content

Commit

Permalink
Check icons (#13)
Browse files Browse the repository at this point in the history
* update branch in sub

* add mdt to solution

* update branch in sub

* add mdt to solution

* prototype texture verifier

* improve error reporting

* finish new game init reporting

* start GameManagers

* update subs

* update sub

* move to gamemanager arch

* first support for gui dialogs

* remove valuelistdict to xml objects to avoid boxing

* fix gameobject land terrain model mapping uses only the first ocurrance

* update deps and module

* minor changes

* fix initialization

* correct file not found handling

* use spans for repositories

* support custom xml parser action

* reduce allocations in repository

* update valuestringbuilder usages

* fix some files are not found.

* extract constants

* implement parsing commandbar components (except colors)

* move code

* move code

* move code

* remove submodule

* remove module

* update all deps and make run again

* read corrupt string throws BinaryCorruptedExcpetion

* update to .net9
  • Loading branch information
AnakinRaW authored Feb 3, 2025
1 parent ec3b6d3 commit 6aa6fca
Show file tree
Hide file tree
Showing 173 changed files with 4,697 additions and 2,029 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Create NetFramework Release
run: dotnet publish .\src\ModVerify.CliApp\ModVerify.CliApp.csproj --configuration Release -f net48 --output ./releases/net48
- name: Create Net Core Release
run: dotnet publish .\src\ModVerify.CliApp\ModVerify.CliApp.csproj --configuration Release -f net8.0 --output ./releases/net8.0
run: dotnet publish .\src\ModVerify.CliApp\ModVerify.CliApp.csproj --configuration Release -f net9.0 --output ./releases/net9.0
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -53,8 +53,8 @@ jobs:
path: ./releases
- name: Create NET Core .zip
# Change into the artifacts directory to avoid including the directory itself in the zip archive
working-directory: ./releases/net8.0
run: zip -r ../ModVerify-Net8.zip .
working-directory: ./releases/net9.0
run: zip -r ../ModVerify-Net9.zip .
- uses: dotnet/[email protected]
id: nbgv
- name: Create GitHub release
Expand All @@ -66,4 +66,4 @@ jobs:
generate_release_notes: true
files: |
./releases/net48/ModVerify.exe
./releases/ModVerify-Net8.zip
./releases/ModVerify-Net9.zip
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
submodules: recursive
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Build & Test in Release Mode
run: dotnet test --configuration Release
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Condition="!Exists('packages.config')">
<PrivateAssets>all</PrivateAssets>
<Version>3.6.139</Version>
<Version>3.6.143</Version>
</PackageReference>
</ItemGroup>
</Project>
21 changes: 0 additions & 21 deletions ModVerify.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ VisualStudioVersion = 17.11.34909.67
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PetroglyphTools", "PetroglyphTools", "{15F8B753-814A-406E-9147-EB048DADAC96}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.Commons", "PetroglyphTools\PG.Commons\PG.Commons\PG.Commons.csproj", "{1A9E1B15-DD77-47E3-893E-AFADF982CEC6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Files.DAT", "PetroglyphTools\PG.StarWarsGame.Files.DAT\PG.StarWarsGame.Files.DAT\PG.StarWarsGame.Files.DAT.csproj", "{4630F85C-D1C4-4454-9126-BE13F6901E0B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PG.StarWarsGame.Files.MEG", "PetroglyphTools\PG.StarWarsGame.Files.MEG\PG.StarWarsGame.Files.MEG\PG.StarWarsGame.Files.MEG.csproj", "{885291F4-E5E8-45B2-B0B4-40B2910228A3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModVerify", "src\ModVerify\ModVerify.csproj", "{22ED0E2C-FF3B-40EB-9CE2-DCDE65CDF31B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModVerify.CliApp", "src\ModVerify.CliApp\ModVerify.CliApp.csproj", "{84479931-A329-4113-9BE5-90B71E5486E6}"
Expand All @@ -29,18 +23,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1A9E1B15-DD77-47E3-893E-AFADF982CEC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A9E1B15-DD77-47E3-893E-AFADF982CEC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A9E1B15-DD77-47E3-893E-AFADF982CEC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A9E1B15-DD77-47E3-893E-AFADF982CEC6}.Release|Any CPU.Build.0 = Release|Any CPU
{4630F85C-D1C4-4454-9126-BE13F6901E0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4630F85C-D1C4-4454-9126-BE13F6901E0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4630F85C-D1C4-4454-9126-BE13F6901E0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4630F85C-D1C4-4454-9126-BE13F6901E0B}.Release|Any CPU.Build.0 = Release|Any CPU
{885291F4-E5E8-45B2-B0B4-40B2910228A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{885291F4-E5E8-45B2-B0B4-40B2910228A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{885291F4-E5E8-45B2-B0B4-40B2910228A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{885291F4-E5E8-45B2-B0B4-40B2910228A3}.Release|Any CPU.Build.0 = Release|Any CPU
{22ED0E2C-FF3B-40EB-9CE2-DCDE65CDF31B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22ED0E2C-FF3B-40EB-9CE2-DCDE65CDF31B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22ED0E2C-FF3B-40EB-9CE2-DCDE65CDF31B}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -70,9 +52,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1A9E1B15-DD77-47E3-893E-AFADF982CEC6} = {15F8B753-814A-406E-9147-EB048DADAC96}
{4630F85C-D1C4-4454-9126-BE13F6901E0B} = {15F8B753-814A-406E-9147-EB048DADAC96}
{885291F4-E5E8-45B2-B0B4-40B2910228A3} = {15F8B753-814A-406E-9147-EB048DADAC96}
{92F2A0C8-61B6-424B-99D5-7898CDBA7CA6} = {15F8B753-814A-406E-9147-EB048DADAC96}
{DF76A383-C94E-4D03-A07C-22D61ED37059} = {15F8B753-814A-406E-9147-EB048DADAC96}
{418C68FA-531B-432E-8459-6433181C8AD3} = {15F8B753-814A-406E-9147-EB048DADAC96}
Expand Down
1 change: 0 additions & 1 deletion PetroglyphTools
Submodule PetroglyphTools deleted from 034767
28 changes: 14 additions & 14 deletions src/ModVerify.CliApp/GameFinder/GameFinderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using PG.StarWarsGame.Infrastructure.Games;
using PG.StarWarsGame.Infrastructure.Mods;
using PG.StarWarsGame.Infrastructure.Services;
using PG.StarWarsGame.Infrastructure.Services.Dependencies;
using PG.StarWarsGame.Infrastructure.Services.Detection;

namespace AET.ModVerifyTool.GameFinder;
Expand Down Expand Up @@ -69,17 +68,20 @@ public GameFinderResult FindGamesFromPathOrGlobal(string path)
private bool TryDetectGame(GameType gameType, IList<IGameDetector> detectors, out GameDetectionResult result)
{
var gd = new CompositeGameDetector(detectors, _serviceProvider);
result = gd.Detect(new GameDetectorOptions(gameType));

if (result.Error is not null)
try
{
_logger?.LogTrace($"Unable to find game installation: {result.Error.Message}", result.Error);
return false;
result = gd.Detect(gameType);
if (result.GameLocation is null)
return false;
return true;
}
if (result.GameLocation is null)
catch (Exception e)
{
result = GameDetectionResult.NotInstalled(gameType);
_logger?.LogTrace($"Unable to find game installation: {e.Message}");
return false;

return true;
}
}

private GameFinderResult FindGames(IList<IGameDetector> detectors)
Expand Down Expand Up @@ -128,15 +130,15 @@ private GameFinderResult FindGames(IList<IGameDetector> detectors)

private void SetupMods(IGame game)
{
var modFinder = _serviceProvider.GetRequiredService<IModReferenceFinder>();
var modFinder = _serviceProvider.GetRequiredService<IModFinder>();
var modRefs = modFinder.FindMods(game);

var mods = new List<IMod>();

foreach (var modReference in modRefs)
{
var mod = _modFactory.FromReference(game, modReference, CultureInfo.InvariantCulture);
mods.AddRange(mod);
var mod = _modFactory.CreatePhysicalMod(game, modReference, CultureInfo.InvariantCulture);
mods.Add(mod);
}

foreach (var mod in mods)
Expand All @@ -145,9 +147,7 @@ private void SetupMods(IGame game)
// Mods need to be added to the game first, before resolving their dependencies.
foreach (var mod in mods)
{
var resolver = _serviceProvider.GetRequiredService<IDependencyResolver>();
mod.ResolveDependencies(resolver,
new DependencyResolverOptions { CheckForCycle = true, ResolveCompleteChain = true });
mod.ResolveDependencies();
}
}
}
26 changes: 16 additions & 10 deletions src/ModVerify.CliApp/ModSelectors/AutomaticModSelector.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO.Abstractions;
using System.Linq;
using AET.ModVerifyTool.GameFinder;
using AET.ModVerifyTool.Options;
using EawModinfo.Model;
using EawModinfo.Spec;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using PG.StarWarsGame.Engine;
using PG.StarWarsGame.Infrastructure;
using PG.StarWarsGame.Infrastructure.Games;
using PG.StarWarsGame.Infrastructure.Mods;
using PG.StarWarsGame.Infrastructure.Services;
using PG.StarWarsGame.Infrastructure.Services.Dependencies;
using PG.StarWarsGame.Infrastructure.Services.Detection;

namespace AET.ModVerifyTool.ModSelectors;

internal class AutomaticModSelector(IServiceProvider serviceProvider) : ModSelectorBase(serviceProvider)
{
private readonly IFileSystem _fileSystem = serviceProvider.GetRequiredService<IFileSystem>();

public override GameLocations? Select(GameInstallationsSettings settings, out IPhysicalPlayableObject? targetObject, out GameEngineType? actualEngineType)
public override GameLocations? Select(
GameInstallationsSettings settings,
out IPhysicalPlayableObject? targetObject,
out GameEngineType? actualEngineType)
{
var pathToVerify = settings.AutoPath;
Debug.Assert(pathToVerify is not null);
if (pathToVerify is null)
throw new InvalidOperationException("path to verify cannot be null.");

actualEngineType = settings.EngineType;

Expand Down Expand Up @@ -100,14 +102,18 @@ private GameLocations GetDetachedModLocations(string modPath, GameFinderResult g
if (game is null)
throw new GameNotFoundException($"Unable to find game of type '{settings.EngineType}'");

var modFinder = ServiceProvider.GetRequiredService<IModFinder>();
var modRef = modFinder.FindMods(game, _fileSystem.DirectoryInfo.New(modPath)).FirstOrDefault();

if (modRef is null)
throw new NotSupportedException($"The mod at '{modPath}' is not compatible to the found game '{game}'.");

var modFactory = ServiceProvider.GetRequiredService<IModFactory>();
mod = modFactory.FromReference(game, new ModReference(modPath, ModType.Default), true, CultureInfo.InvariantCulture);
mod = modFactory.CreatePhysicalMod(game, modRef, CultureInfo.InvariantCulture);

game.AddMod(mod);

var resolver = ServiceProvider.GetRequiredService<IDependencyResolver>();
mod.ResolveDependencies(resolver,
new DependencyResolverOptions { CheckForCycle = true, ResolveCompleteChain = true });
mod.ResolveDependencies();

return GetLocations(mod, gameResult, settings.AdditionalFallbackPaths);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ModVerify.CliApp/ModSelectors/ConsoleModSelector.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using AET.Modinfo.Spec;
using AET.ModVerifyTool.GameFinder;
using AET.ModVerifyTool.Options;
using EawModinfo.Spec;
using PG.StarWarsGame.Engine;
using PG.StarWarsGame.Infrastructure;
using PG.StarWarsGame.Infrastructure.Mods;
Expand All @@ -11,7 +11,7 @@ namespace AET.ModVerifyTool.ModSelectors;

internal class ConsoleModSelector(IServiceProvider serviceProvider) : ModSelectorBase(serviceProvider)
{
public override GameLocations? Select(GameInstallationsSettings settings, out IPhysicalPlayableObject? targetObject,
public override GameLocations Select(GameInstallationsSettings settings, out IPhysicalPlayableObject targetObject,
out GameEngineType? actualEngineType)
{
var gameResult = GameFinderService.FindGames();
Expand Down
6 changes: 4 additions & 2 deletions src/ModVerify.CliApp/ModSelectors/ManualModSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace AET.ModVerifyTool.ModSelectors;

internal class ManualModSelector(IServiceProvider serviceProvider) : ModSelectorBase(serviceProvider)
{
public override GameLocations Select(GameInstallationsSettings settings, out IPhysicalPlayableObject? targetObject,
public override GameLocations Select(
GameInstallationsSettings settings,
out IPhysicalPlayableObject? targetObject,
out GameEngineType? actualEngineType)
{
actualEngineType = settings.EngineType;
Expand All @@ -21,7 +23,7 @@ public override GameLocations Select(GameInstallationsSettings settings, out IPh

return new GameLocations(
settings.ModPaths,
settings.GamePath,
settings.GamePath!,
GetFallbackPaths(settings.FallbackGamePath, settings.AdditionalFallbackPaths));
}
}
5 changes: 3 additions & 2 deletions src/ModVerify.CliApp/ModSelectors/ModSelectorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ protected ModSelectorBase(IServiceProvider serviceProvider)
GameFinderService = new GameFinderService(serviceProvider);
}

public abstract GameLocations? Select(GameInstallationsSettings settings, out IPhysicalPlayableObject? targetObject,
public abstract GameLocations? Select(
GameInstallationsSettings settings,
out IPhysicalPlayableObject? targetObject,
out GameEngineType? actualEngineType);

protected GameLocations GetLocations(IPhysicalPlayableObject playableObject, GameFinderResult finderResult, IList<string> additionalFallbackPaths)
Expand Down Expand Up @@ -66,7 +68,6 @@ private IList<string> GetModPaths(IPhysicalPlayableObject modOrGame)

var traverser = ServiceProvider.GetRequiredService<IModDependencyTraverser>();
return traverser.Traverse(mod)
.Select(x => x.Mod)
.OfType<IPhysicalMod>().Select(x => x.Directory.FullName)
.ToList();
}
Expand Down
30 changes: 2 additions & 28 deletions src/ModVerify.CliApp/ModSelectors/SettingsBasedModSelector.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
using System;
using System.Globalization;
using System.IO.Abstractions;
using System.Linq;
using AET.ModVerifyTool.Options;
using EawModinfo.Model;
using EawModinfo.Spec;
using Microsoft.Extensions.DependencyInjection;
using PG.StarWarsGame.Engine;
using PG.StarWarsGame.Infrastructure;
using PG.StarWarsGame.Infrastructure.Games;
using PG.StarWarsGame.Infrastructure.Services.Name;

namespace AET.ModVerifyTool.ModSelectors;

internal class SettingsBasedModSelector(IServiceProvider serviceProvider)
{
private readonly IFileSystem _fileSystem = serviceProvider.GetRequiredService<IFileSystem>();
public VerifyGameInstallationData CreateInstallationDataFromSettings(GameInstallationsSettings settings)
{
var gameLocations = new ModSelectorFactory(serviceProvider).CreateSelector(settings)
Expand All @@ -35,30 +27,12 @@ public VerifyGameInstallationData CreateInstallationDataFromSettings(GameInstall
};
}

private string GetNameFromGameLocations(IPlayableObject? targetObject, GameLocations gameLocations, GameEngineType engineType)
private static string GetNameFromGameLocations(IPlayableObject? targetObject, GameLocations gameLocations, GameEngineType engineType)
{
if (targetObject is not null)
return targetObject.Name;

var mod = gameLocations.ModPaths.FirstOrDefault();

var name = mod is not null ? GetNameFromMod(mod) : GetNameFromGame(engineType);

if (string.IsNullOrEmpty(name))
throw new InvalidOperationException("Mod or game name cannot be null or empty.");

return name;
}

private string? GetNameFromGame(GameEngineType type)
{
var nameResolver = serviceProvider.GetRequiredService<IGameNameResolver>();
return nameResolver.ResolveName(new GameIdentity(type.FromEngineType(), GamePlatform.Undefined), CultureInfo.InvariantCulture);
}

private string? GetNameFromMod(string mod)
{
var nameResolver = serviceProvider.GetRequiredService<IModNameResolver>();
return nameResolver.ResolveName(new ModReference(_fileSystem.Path.GetFullPath(mod), ModType.Default), CultureInfo.InvariantCulture);
return mod ?? gameLocations.GamePath;
}
}
Loading

0 comments on commit 6aa6fca

Please sign in to comment.