diff --git a/AngelLoader/Common/GameSupport.cs b/AngelLoader/Common/GameSupport.cs index 4d48b727b..2d04318fb 100644 --- a/AngelLoader/Common/GameSupport.cs +++ b/AngelLoader/Common/GameSupport.cs @@ -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 @@ -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 diff --git a/AngelLoader/Ini/ConfigIni.cs b/AngelLoader/Ini/ConfigIni.cs index bfa4bfe56..126c256a9 100644 --- a/AngelLoader/Ini/ConfigIni.cs +++ b/AngelLoader/Ini/ConfigIni.cs @@ -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 @@ -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); @@ -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)); @@ -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);