diff --git a/AngelLoader/Common/GameSupport.cs b/AngelLoader/Common/GameSupport.cs index 2d04318fb..2b91d3233 100644 --- a/AngelLoader/Common/GameSupport.cs +++ b/AngelLoader/Common/GameSupport.cs @@ -101,17 +101,31 @@ internal enum GameIndex : uint #endregion - internal static string GetLocalizedDifficultyName(FanMission? fm, Difficulty difficulty) + internal static string GetLocalizedDifficultyName(Game game, Difficulty difficulty) { - bool fmIsT3 = fm != null && fm.Game == Game.Thief3; - bool fmIsSS2 = fm != null && fm.Game == Game.SS2; - - return difficulty switch + // More verbose but also more clear + return game == Game.Thief3 ? difficulty switch + { + Difficulty.Normal => LText.Difficulties.Easy, + Difficulty.Hard => LText.Difficulties.Normal, + Difficulty.Expert => LText.Difficulties.Hard, + Difficulty.Extreme => LText.Difficulties.Expert, + _ => throw new ArgumentOutOfRangeException(nameof(difficulty) + " is not a valid value") + } + : game == Game.SS2 ? difficulty switch + { + Difficulty.Normal => LText.Difficulties.Easy, + Difficulty.Hard => LText.Difficulties.Normal, + Difficulty.Expert => LText.Difficulties.Hard, + Difficulty.Extreme => LText.Difficulties.Impossible, + _ => throw new ArgumentOutOfRangeException(nameof(difficulty) + " is not a valid value") + } + : difficulty switch { - Difficulty.Normal => fmIsT3 || fmIsSS2 ? LText.Difficulties.Easy : LText.Difficulties.Normal, - Difficulty.Hard => fmIsT3 || fmIsSS2 ? LText.Difficulties.Normal : LText.Difficulties.Hard, - Difficulty.Expert => fmIsT3 || fmIsSS2 ? LText.Difficulties.Hard : LText.Difficulties.Expert, - Difficulty.Extreme => fmIsT3 ? LText.Difficulties.Expert : fmIsSS2 ? LText.Difficulties.Impossible : LText.Difficulties.Extreme, + Difficulty.Normal => LText.Difficulties.Normal, + Difficulty.Hard => LText.Difficulties.Hard, + Difficulty.Expert => LText.Difficulties.Expert, + Difficulty.Extreme => LText.Difficulties.Extreme, _ => throw new ArgumentOutOfRangeException(nameof(difficulty) + " is not a valid value") }; } diff --git a/AngelLoader/Forms/CustomControls/DataGridViewCustom/Menu_FM.cs b/AngelLoader/Forms/CustomControls/DataGridViewCustom/Menu_FM.cs index f12a20aa5..15769af56 100644 --- a/AngelLoader/Forms/CustomControls/DataGridViewCustom/Menu_FM.cs +++ b/AngelLoader/Forms/CustomControls/DataGridViewCustom/Menu_FM.cs @@ -364,10 +364,7 @@ private void SetFMMenuTextToLocalized() FinishedOnMenuItem!.Text = LText.FMsList.FMMenu_FinishedOn.EscapeAmpersands(); - FinishedOnNormalMenuItem!.Text = GetLocalizedDifficultyName(selFM, Difficulty.Normal).EscapeAmpersands(); - FinishedOnHardMenuItem!.Text = GetLocalizedDifficultyName(selFM, Difficulty.Hard).EscapeAmpersands(); - FinishedOnExpertMenuItem!.Text = GetLocalizedDifficultyName(selFM, Difficulty.Expert).EscapeAmpersands(); - FinishedOnExtremeMenuItem!.Text = GetLocalizedDifficultyName(selFM, Difficulty.Extreme).EscapeAmpersands(); + SetGameSpecificFinishedOnMenuItemsText(selFM?.Game ?? Game.Null); FinishedOnUnknownMenuItem!.Text = LText.Difficulties.Unknown.EscapeAmpersands(); #endregion @@ -565,23 +562,17 @@ internal void SetFinishedOnMenuItemChecked(Difficulty difficulty, bool value) } } - internal void SetFinishedOnMenuItemText(Difficulty difficulty, string text) + // Thief 1+2 difficulties: Normal, Hard, Expert, Extreme ("Extreme" is for DarkLoader compatibility) + // Thief 3 difficulties: Easy, Normal, Hard, Expert + // SS2 difficulties: Easy, Normal, Hard, Impossible + internal void SetGameSpecificFinishedOnMenuItemsText(Game game) { - switch (difficulty) - { - case Difficulty.Normal: - if (_fmMenuConstructed) FinishedOnNormalMenuItem!.Text = text; - break; - case Difficulty.Hard: - if (_fmMenuConstructed) FinishedOnHardMenuItem!.Text = text; - break; - case Difficulty.Expert: - if (_fmMenuConstructed) FinishedOnExpertMenuItem!.Text = text; - break; - case Difficulty.Extreme: - if (_fmMenuConstructed) FinishedOnExtremeMenuItem!.Text = text; - break; - } + if (!_fmMenuConstructed) return; + + FinishedOnNormalMenuItem!.Text = GetLocalizedDifficultyName(game, Difficulty.Normal).EscapeAmpersands(); + FinishedOnHardMenuItem!.Text = GetLocalizedDifficultyName(game, Difficulty.Hard).EscapeAmpersands(); + FinishedOnExpertMenuItem!.Text = GetLocalizedDifficultyName(game, Difficulty.Expert).EscapeAmpersands(); + FinishedOnExtremeMenuItem!.Text = GetLocalizedDifficultyName(game, Difficulty.Extreme).EscapeAmpersands(); } internal void SetFinishedOnUnknownMenuItemChecked(bool value) diff --git a/AngelLoader/Forms/MainForm.cs b/AngelLoader/Forms/MainForm.cs index c1a254739..792fdbc01 100644 --- a/AngelLoader/Forms/MainForm.cs +++ b/AngelLoader/Forms/MainForm.cs @@ -2730,13 +2730,7 @@ private async Task DisplaySelectedFM(bool refreshReadme, bool refreshCache = fal // We should never get here when FMsList.Count == 0, but hey if (FMsViewList.Count > 0) ScanAllFMsButton.Enabled = true; - // Thief 1+2 difficulties: Normal, Hard, Expert, Extreme ("Extreme" is for DarkLoader compatibility) - // Thief 3 difficulties: Easy, Normal, Hard, Expert - // SS2 difficulties: Easy, Normal, Hard, Impossible - FMsDGV.SetFinishedOnMenuItemText(Difficulty.Normal, GetLocalizedDifficultyName(fm, Difficulty.Normal)); - FMsDGV.SetFinishedOnMenuItemText(Difficulty.Hard, GetLocalizedDifficultyName(fm, Difficulty.Hard)); - FMsDGV.SetFinishedOnMenuItemText(Difficulty.Expert, GetLocalizedDifficultyName(fm, Difficulty.Expert)); - FMsDGV.SetFinishedOnMenuItemText(Difficulty.Extreme, GetLocalizedDifficultyName(fm, Difficulty.Extreme)); + FMsDGV.SetGameSpecificFinishedOnMenuItemsText(fm.Game); // FinishedOnUnknownMenuItem text stays the same bool gameIsSupported = GameIsKnownAndSupported(fm.Game);