Skip to content

Commit

Permalink
More gengames cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
FenPhoenix committed May 14, 2020
1 parent 7625335 commit 0d88829
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
23 changes: 12 additions & 11 deletions AngelLoader/Common/GameSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ internal enum GameIndex : uint
SS2
}

// IMPORTANT: These are used in Config.ini, so they must remain the same for compatibility. Don't change
// the existing values, only add new ones!
private static readonly string[] GamePrefixes =
{
"T1",
"T2",
"T3",
"SS2"
};

private static readonly string[] SteamAppIds =
{
"211600", // Thief Gold
Expand All @@ -53,18 +63,9 @@ internal enum GameIndex : uint

#endregion

internal static string GetGameSteamId(GameIndex index) => SteamAppIds[(int)index];
internal static string GetGamePrefix(GameIndex index) => GamePrefixes[(int)index];

// IMPORTANT: These are used in Config.ini, so they must remain the same for compatibility. Don't change
// the existing values, only add new ones!
internal static string GetGameTypePrefix(GameIndex index) => index switch
{
GameIndex.Thief1 => "T1",
GameIndex.Thief2 => "T2",
GameIndex.Thief3 => "T3",
GameIndex.SS2 => "SS2",
_ => throw new ArgumentOutOfRangeException(nameof(index), ((uint)index).ToString(), nameof(GameIndex) + @" argument out of range.")
};
internal static string GetGameSteamId(GameIndex index) => SteamAppIds[(int)index];

#region Conversion

Expand Down
8 changes: 4 additions & 4 deletions AngelLoader/Ini/ConfigIni.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ static string commaCombineFinishedStates(FinishedState finished)
for (int i = 0; i < SupportedGameCount; i++)
{
GameIndex gameIndex = (GameIndex)i;
sw.WriteLine(GetGameTypePrefix(gameIndex) + "Exe=" + config.GetGameExe(gameIndex).Trim());
sw.WriteLine(GetGamePrefix(gameIndex) + "Exe=" + config.GetGameExe(gameIndex).Trim());
}

#endregion
Expand All @@ -1027,7 +1027,7 @@ static string commaCombineFinishedStates(FinishedState finished)
for (int i = 0; i < SupportedGameCount; i++)
{
GameIndex gameIndex = (GameIndex)i;
sw.WriteLine(GetGameTypePrefix(gameIndex) + "UseSteam=" + config.GetUseSteamSwitch(gameIndex));
sw.WriteLine(GetGamePrefix(gameIndex) + "UseSteam=" + config.GetUseSteamSwitch(gameIndex));
}

sw.WriteLine(nameof(config.SteamExe) + "=" + config.SteamExe);
Expand Down Expand Up @@ -1083,7 +1083,7 @@ static string FilterDate(DateTime? dt) => dt == null
for (int i = 0; i < SupportedGameCount + 1; i++)
{
Filter filter = i == 0 ? config.Filter : config.GameTabsState.GetFilter((GameIndex)(i - 1));
string p = i == 0 ? "" : GetGameTypePrefix((GameIndex)(i - 1));
string p = i == 0 ? "" : GetGamePrefix((GameIndex)(i - 1));

if (i == 0) sw.WriteLine("FilterGames=" + commaCombineGameFlags(config.Filter.Games));

Expand Down Expand Up @@ -1162,7 +1162,7 @@ static string TagsToString(CatAndTagsList tagsList)
for (int i = 0; i < SupportedGameCount + 1; i++)
{
SelectedFM selFM = i == 0 ? config.SelFM : config.GameTabsState.GetSelectedFM((GameIndex)(i - 1));
string p = i == 0 ? "" : GetGameTypePrefix((GameIndex)(i - 1));
string p = i == 0 ? "" : GetGamePrefix((GameIndex)(i - 1));

sw.WriteLine(p + "SelFMInstDir=" + selFM.InstalledName);
sw.WriteLine(p + "SelFMIndexFromTop=" + selFM.IndexFromTop);
Expand Down

0 comments on commit 0d88829

Please sign in to comment.