From 387554acbb2cf35a12987fe0838c5f44ec340b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 2 Jul 2024 16:41:25 +0200 Subject: [PATCH] Fixed a crash on empty mission options. --- .../Widgets/Logic/MissionBrowserLogic.cs | 12 +++++++++++- mods/common/languages/en.ftl | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs index c45d0af594..300f3a9e0f 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MissionBrowserLogic.cs @@ -45,6 +45,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic [TranslationReference] const string CantPlayCancel = "dialog-cant-play-video.cancel"; + [TranslationReference] + const string NotAvailable = "label-not-available"; + readonly ModData modData; readonly Action onStart; readonly Widget missionDetail; @@ -379,7 +382,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic var dropdown = dropdownColumns.Dequeue(); - dropdown.GetText = () => option.Values[missionOptions[option.Id]]; + dropdown.GetText = () => + { + if (option.Values.TryGetValue(missionOptions[option.Id], out var value)) + return value; + + return TranslationProvider.GetString(NotAvailable); + }; + if (option.Description != null) { var (text, desc) = LobbyUtils.SplitOnFirstToken(option.Description); diff --git a/mods/common/languages/en.ftl b/mods/common/languages/en.ftl index 37ebb34816..98c99c2c2b 100644 --- a/mods/common/languages/en.ftl +++ b/mods/common/languages/en.ftl @@ -349,7 +349,7 @@ options-slot-admin = button-general-chat = All button-team-chat = Team -## LobbyOptionsLogic +## LobbyOptionsLogic, MissionBrowserLogic label-not-available = Not Available ## LobbyUtils