Fix a lack of difficulty dropdown yaml in other mods (d2k/cnc) causing crashes

This commit is contained in:
Scott_NZ
2013-01-09 21:50:20 +13:00
parent 50f8465d1e
commit eb3685fe67

View File

@@ -156,7 +156,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
var difficulty = lobby.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
var difficulty = lobby.GetOrNull<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
if (difficulty != null)
{
difficulty.IsVisible = () => Map != null && Map.Difficulties != null && Map.Difficulties.Any();
difficulty.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null || orderManager.LocalClient.IsReady;
difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty;
@@ -176,6 +178,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
};
difficulty.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
};
}
var startGameButton = lobby.Get<ButtonWidget>("START_GAME_BUTTON");
startGameButton.IsVisible = () => Game.IsHost;