Allow non-hosts to open the map chooser
This commit is contained in:
@@ -155,7 +155,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var mapButton = lobby.GetOrNull<ButtonWidget>("CHANGEMAP_BUTTON");
|
||||
if (mapButton != null)
|
||||
{
|
||||
mapButton.IsDisabled = configurationDisabled;
|
||||
mapButton.IsDisabled = () => gameStarting || panel == PanelType.Kick || panel == PanelType.ForceStart ||
|
||||
orderManager.LocalClient == null || orderManager.LocalClient.IsReady;
|
||||
mapButton.OnClick = () =>
|
||||
{
|
||||
var onSelect = new Action<string>(uid =>
|
||||
@@ -173,7 +174,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
{ "initialMap", Map.Uid },
|
||||
{ "onExit", DoNothing },
|
||||
{ "onSelect", onSelect },
|
||||
{ "onSelect", Game.IsHost ? onSelect : null },
|
||||
{ "filter", MapVisibility.Lobby },
|
||||
});
|
||||
};
|
||||
|
||||
@@ -36,7 +36,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var approving = new Action(() => { Ui.CloseWindow(); onSelect(selectedUid); });
|
||||
var canceling = new Action(() => { Ui.CloseWindow(); onExit(); });
|
||||
|
||||
widget.Get<ButtonWidget>("BUTTON_OK").OnClick = approving;
|
||||
var okButton = widget.Get<ButtonWidget>("BUTTON_OK");
|
||||
okButton.Disabled = this.onSelect == null;
|
||||
okButton.OnClick = approving;
|
||||
widget.Get<ButtonWidget>("BUTTON_CANCEL").OnClick = canceling;
|
||||
|
||||
scrollpanel = widget.Get<ScrollPanelWidget>("MAP_LIST");
|
||||
@@ -128,8 +130,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
// Access the minimap to trigger async generation of the minimap.
|
||||
preview.GetMinimap();
|
||||
|
||||
Action dblClick = () =>
|
||||
{
|
||||
if (onSelect != null)
|
||||
{
|
||||
Ui.CloseWindow();
|
||||
onSelect(preview.Uid);
|
||||
}
|
||||
};
|
||||
|
||||
var item = ScrollItemWidget.Setup(preview.Uid, itemTemplate, () => selectedUid == preview.Uid,
|
||||
() => selectedUid = preview.Uid, () => { Ui.CloseWindow(); onSelect(preview.Uid); });
|
||||
() => selectedUid = preview.Uid, dblClick);
|
||||
item.IsVisible = () => item.RenderBounds.IntersectsWith(scrollpanel.RenderBounds);
|
||||
|
||||
var titleLabel = item.Get<LabelWidget>("TITLE");
|
||||
|
||||
Reference in New Issue
Block a user