Fix a lack of difficulty dropdown yaml in other mods (d2k/cnc) causing crashes
This commit is contained in:
@@ -156,26 +156,29 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
|
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
|
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
|
||||||
|
|
||||||
var difficulty = lobby.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
|
var difficulty = lobby.GetOrNull<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
|
||||||
difficulty.IsVisible = () => Map != null && Map.Difficulties != null && Map.Difficulties.Any();
|
if (difficulty != null)
|
||||||
difficulty.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null || orderManager.LocalClient.IsReady;
|
|
||||||
difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty;
|
|
||||||
difficulty.OnMouseDown = _ =>
|
|
||||||
{
|
{
|
||||||
var options = Map.Difficulties.Select(d => new DifficultyDropDownOption
|
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;
|
||||||
|
difficulty.OnMouseDown = _ =>
|
||||||
{
|
{
|
||||||
Title = d,
|
var options = Map.Difficulties.Select(d => new DifficultyDropDownOption
|
||||||
IsSelected = () => orderManager.LobbyInfo.GlobalSettings.Difficulty == d,
|
{
|
||||||
OnClick = () => orderManager.IssueOrder(Order.Command("difficulty {0}".F(d)))
|
Title = d,
|
||||||
});
|
IsSelected = () => orderManager.LobbyInfo.GlobalSettings.Difficulty == d,
|
||||||
Func<DifficultyDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
OnClick = () => orderManager.IssueOrder(Order.Command("difficulty {0}".F(d)))
|
||||||
{
|
});
|
||||||
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
Func<DifficultyDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
||||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
{
|
||||||
return item;
|
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
||||||
|
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
||||||
|
return item;
|
||||||
|
};
|
||||||
|
difficulty.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
|
||||||
};
|
};
|
||||||
difficulty.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
var startGameButton = lobby.Get<ButtonWidget>("START_GAME_BUTTON");
|
var startGameButton = lobby.Get<ButtonWidget>("START_GAME_BUTTON");
|
||||||
startGameButton.IsVisible = () => Game.IsHost;
|
startGameButton.IsVisible = () => Game.IsHost;
|
||||||
|
|||||||
Reference in New Issue
Block a user