Skip to content

Commit

Permalink
GameRelease.GetLanguageFormat moved to GameConstants
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Oct 30, 2023
1 parent c496b99 commit 9744f63
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 32 deletions.
27 changes: 0 additions & 27 deletions Mutagen.Bethesda.Core/Extensions/GameReleaseExt.cs

This file was deleted.

1 change: 0 additions & 1 deletion Mutagen.Bethesda.Core/Mutagen.Bethesda.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@
<Compile Include="Extensions\FormLinkRemappingMixIn.cs" />
<Compile Include="Extensions\RemoveExt.cs" />
<Compile Include="Extensions\LoadOrderExt.cs" />
<Compile Include="Extensions\GameReleaseExt.cs" />
<Compile Include="Plugins\Implicit\ImplicitRecordFormKeys.cs" />
<Compile Include="Plugins\Implicit\ImplicitListings.cs" />
<Compile Include="Plugins\Implicit\ImplicitBaseMasters.cs" />
Expand Down
8 changes: 8 additions & 0 deletions Mutagen.Bethesda.Core/Plugins/Meta/GameConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public sealed record GameConstants

public string IniName { get; init; }

public StringsLanguageFormat? StringsLanguageFormat { get; init; }

/// <summary>
/// Constructor
/// </summary>
Expand All @@ -72,6 +74,7 @@ public GameConstants(
MajorRecordConstants majorConstants,
RecordHeaderConstants subConstants,
Language[] languages,
StringsLanguageFormat? languageFormat,
EncodingBundle encodings,
bool hasEnabledMarkers,
ushort? defaultFormVersion,
Expand All @@ -89,6 +92,7 @@ public GameConstants(
HasEnabledMarkers = hasEnabledMarkers;
DefaultFormVersion = defaultFormVersion;
MyDocumentsString = myDocumentsString;
StringsLanguageFormat = languageFormat;
IniName = iniName;
}

Expand Down Expand Up @@ -145,6 +149,7 @@ public GameConstants(
headerLength: 6,
lengthLength: 2),
languages: Array.Empty<Language>(),
languageFormat: null,
hasEnabledMarkers: false,
defaultFormVersion: null,
myDocumentsString: "Oblivion",
Expand Down Expand Up @@ -211,6 +216,7 @@ public GameConstants(
Language.Chinese,
Language.Russian,
},
languageFormat: Strings.StringsLanguageFormat.FullName,
hasEnabledMarkers: false,
defaultFormVersion: 43,
myDocumentsString: "Skyrim",
Expand Down Expand Up @@ -328,6 +334,7 @@ public GameConstants(
Language.Russian,
Language.Japanese,
},
languageFormat: Strings.StringsLanguageFormat.Iso,
hasEnabledMarkers: true,
defaultFormVersion: 131,
myDocumentsString: "Fallout4",
Expand Down Expand Up @@ -408,6 +415,7 @@ public GameConstants(
Language.Russian,
Language.Japanese,
},
languageFormat: Strings.StringsLanguageFormat.Iso,
hasEnabledMarkers: true,
defaultFormVersion: 555,
myDocumentsString: null,
Expand Down
5 changes: 3 additions & 2 deletions Mutagen.Bethesda.Core/Strings/StringsFolderLookupOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Noggog;
using System.Diagnostics.CodeAnalysis;
using Mutagen.Bethesda.Installs.DI;
using Mutagen.Bethesda.Plugins.Meta;
using Mutagen.Bethesda.Strings.DI;

namespace Mutagen.Bethesda.Strings;
Expand Down Expand Up @@ -53,7 +54,7 @@ public static StringsFolderLookupOverlay TypicalFactory(
DirectoryPath dataPath,
StringsReadParameters? instructions)
{
var languageFormat = release.GetLanguageFormat();
var languageFormat = GameConstants.Get(release).StringsLanguageFormat ?? throw new ArgumentException($"Tried to get language format for an unsupported game: {release}", nameof(release));
var encodings = instructions?.EncodingProvider ?? new MutagenEncodingProvider();
var stringsFolderPath = instructions?.StringsFolderOverride;
if (stringsFolderPath == null)
Expand Down Expand Up @@ -99,7 +100,7 @@ public static StringsFolderLookupOverlay TypicalFactory(
foreach (var item in stringsFolder.Files)
{
if (!StringsUtility.TryRetrieveInfoFromString(
release.GetLanguageFormat(),
languageFormat,
Path.GetFileName(item.Path),
out var type,
out var lang,
Expand Down
3 changes: 2 additions & 1 deletion Mutagen.Bethesda.Core/Strings/StringsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Mutagen.Bethesda.Plugins.Binary.Translations;
using Noggog;
using System.IO.Abstractions;
using Mutagen.Bethesda.Plugins.Meta;
using Mutagen.Bethesda.Strings.DI;

namespace Mutagen.Bethesda.Strings;
Expand Down Expand Up @@ -34,7 +35,7 @@ public StringsWriter(
ModKey = modKey;
EncodingProvider = encodingProvider;
FileSystem = fileSystem.GetOrDefault();
LanguageFormat = release.GetLanguageFormat();
LanguageFormat = GameConstants.Get(release).StringsLanguageFormat ?? throw new ArgumentException($"Tried to get language format for an unsupported game: {release}", nameof(release));
WriteDir = writeDirectory;
}

Expand Down
3 changes: 2 additions & 1 deletion Mutagen.Bethesda.Tests/Passthrough Tests/PassthroughTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,10 @@ public IEnumerable<Test> AssertStringsEqual(
DirectoryPath processedDir,
DirectoryPath writeDir)
{
var languageFormat = GameConstants.Get(GameRelease).StringsLanguageFormat!.Value;
foreach (var source in Enums<StringsSource>.Values)
{
var stringsFileName = StringsUtility.GetFileName(GameRelease.GetLanguageFormat(), ModKey, Language.English, source);
var stringsFileName = StringsUtility.GetFileName(languageFormat, ModKey, Language.English, source);
var sourcePath = Path.Combine(processedDir.Path, stringsFileName);
var pathToTest = Path.Combine(writeDir.Path, stringsFileName);
bool sourceExists = File.Exists(sourcePath);
Expand Down

0 comments on commit 9744f63

Please sign in to comment.