diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 4f08c69905..99e6415d2a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -641,6 +641,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (orderManager.LocalClient == null) return; + var isHost = Game.IsHost; var idx = 0; foreach (var kv in orderManager.LobbyInfo.Slots) { @@ -659,7 +660,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (template == null || template.Id != emptySlotTemplate.Id) template = emptySlotTemplate.Clone(); - if (Game.IsHost) + if (isHost) LobbyUtils.SetupEditableSlotWidget(this, template, slot, client, orderManager); else LobbyUtils.SetupSlotWidget(template, slot, client); @@ -670,7 +671,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic join.OnClick = () => orderManager.IssueOrder(Order.Command("slot " + key)); } else if ((client.Index == orderManager.LocalClient.Index) || - (client.Bot != null && Game.IsHost)) + (client.Bot != null && isHost)) { // Editable player in slot if (template == null || template.Id != editablePlayerTemplate.Id) @@ -701,8 +702,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic () => panel = PanelType.Kick, () => panel = PanelType.Players); LobbyUtils.SetupColorWidget(template, slot, client); LobbyUtils.SetupFactionWidget(template, slot, client, factions); - LobbyUtils.SetupTeamWidget(template, slot, client); - LobbyUtils.SetupSpawnWidget(template, slot, client); + if (isHost) + { + LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, Map); + LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, Map); + } + else + { + LobbyUtils.SetupTeamWidget(template, slot, client); + LobbyUtils.SetupSpawnWidget(template, slot, client); + } + LobbyUtils.SetupReadyWidget(template, slot, client); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs index 755dd2d15f..48427d8d45 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyUtils.cs @@ -313,9 +313,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic slot.OnMouseDown = _ => ShowSlotDropDown(logic, slot, s, c, orderManager); // Ensure Name selector (if present) is hidden - var name = parent.GetOrNull("NAME"); - if (name != null) - name.IsVisible = () => false; + HideChildWidget(parent, "NAME"); } public static void SetupSlotWidget(Widget parent, Session.Slot s, Session.Client c) @@ -325,9 +323,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic name.GetText = () => c != null ? c.Name : s.Closed ? "Closed" : "Open"; // Ensure Slot selector (if present) is hidden - var slot = parent.GetOrNull("SLOT_OPTIONS"); - if (slot != null) - slot.IsVisible = () => false; + HideChildWidget(parent, "SLOT_OPTIONS"); } public static void SetupKickWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, Widget lobby, Action before, Action after) @@ -427,20 +423,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic public static void SetupEditableTeamWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, MapPreview map) { - var dropdown = parent.Get("TEAM"); + var dropdown = parent.Get("TEAM_DROPDOWN"); + dropdown.IsVisible = () => true; dropdown.IsDisabled = () => s.LockTeam || orderManager.LocalClient.IsReady; dropdown.OnMouseDown = _ => ShowTeamDropDown(dropdown, c, orderManager, map.PlayerCount); dropdown.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString(); + + HideChildWidget(parent, "TEAM"); } public static void SetupTeamWidget(Widget parent, Session.Slot s, Session.Client c) { parent.Get("TEAM").GetText = () => (c.Team == 0) ? "-" : c.Team.ToString(); + HideChildWidget(parent, "TEAM_DROPDOWN"); } public static void SetupEditableSpawnWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, MapPreview map) { - var dropdown = parent.Get("SPAWN"); + var dropdown = parent.Get("SPAWN_DROPDOWN"); + dropdown.IsVisible = () => true; dropdown.IsDisabled = () => s.LockSpawn || orderManager.LocalClient.IsReady; dropdown.OnMouseDown = _ => { @@ -450,11 +451,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic ShowSpawnDropDown(dropdown, c, orderManager, spawnPoints); }; dropdown.GetText = () => (c.SpawnPoint == 0) ? "-" : Convert.ToChar('A' - 1 + c.SpawnPoint).ToString(); + + HideChildWidget(parent, "SPAWN"); + } + + static void HideChildWidget(Widget parent, string widgetId) + { + var widget = parent.GetOrNull(widgetId); + if (widget != null) + widget.IsVisible = () => false; } public static void SetupSpawnWidget(Widget parent, Session.Slot s, Session.Client c) { parent.Get("SPAWN").GetText = () => (c.SpawnPoint == 0) ? "-" : Convert.ToChar('A' - 1 + c.SpawnPoint).ToString(); + HideChildWidget(parent, "SPAWN_DROPDOWN"); } public static void SetupEditableReadyWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, MapPreview map) diff --git a/mods/cnc/chrome/lobby-players.yaml b/mods/cnc/chrome/lobby-players.yaml index 1d992f3431..a177de9cce 100644 --- a/mods/cnc/chrome/lobby-players.yaml +++ b/mods/cnc/chrome/lobby-players.yaml @@ -129,12 +129,12 @@ Container@LOBBY_PLAYER_BIN: Width: 60 Height: 25 Text: Faction - DropDownButton@TEAM: + DropDownButton@TEAM_DROPDOWN: X: 416 Width: 50 Height: 25 Font: Regular - DropDownButton@SPAWN: + DropDownButton@SPAWN_DROPDOWN: X: 471 Width: 50 Height: 25 @@ -226,6 +226,18 @@ Container@LOBBY_PLAYER_BIN: Width: 25 Height: 25 Align: Center + DropDownButton@TEAM_DROPDOWN: + X: 416 + Width: 50 + Height: 25 + Font: Regular + Visible: false + DropDownButton@SPAWN_DROPDOWN: + X: 471 + Width: 50 + Height: 25 + Font: Regular + Visible: false Image@STATUS_IMAGE: X: 527 Y: 4 diff --git a/mods/common/chrome/lobby-players.yaml b/mods/common/chrome/lobby-players.yaml index 8289b60019..cdafe0decb 100644 --- a/mods/common/chrome/lobby-players.yaml +++ b/mods/common/chrome/lobby-players.yaml @@ -125,12 +125,12 @@ Container@LOBBY_PLAYER_BIN: Width: 60 Height: 25 Text: Faction - DropDownButton@TEAM: + DropDownButton@TEAM_DROPDOWN: X: 410 Width: 48 Height: 25 Text: Team - DropDownButton@SPAWN: + DropDownButton@SPAWN_DROPDOWN: X: 468 Width: 48 Height: 25 @@ -220,6 +220,16 @@ Container@LOBBY_PLAYER_BIN: Width: 23 Height: 25 Align: Center + DropDownButton@TEAM_DROPDOWN: + X: 410 + Width: 48 + Height: 25 + Visible: false + DropDownButton@SPAWN_DROPDOWN: + X: 468 + Width: 48 + Height: 25 + Visible: false Image@STATUS_IMAGE: X: 527 Y: 4 diff --git a/mods/d2k/chrome/lobby-players.yaml b/mods/d2k/chrome/lobby-players.yaml index 6edfdf4772..a382b76aa5 100644 --- a/mods/d2k/chrome/lobby-players.yaml +++ b/mods/d2k/chrome/lobby-players.yaml @@ -125,12 +125,12 @@ Container@LOBBY_PLAYER_BIN: Width: 70 Height: 25 Text: Faction - DropDownButton@TEAM: + DropDownButton@TEAM_DROPDOWN: X: 410 Width: 48 Height: 25 Text: Team - DropDownButton@SPAWN: + DropDownButton@SPAWN_DROPDOWN: X: 468 Width: 48 Height: 25 @@ -220,6 +220,16 @@ Container@LOBBY_PLAYER_BIN: Width: 23 Height: 25 Align: Center + DropDownButton@TEAM_DROPDOWN: + X: 410 + Width: 48 + Height: 25 + Visible: false + DropDownButton@SPAWN_DROPDOWN: + X: 468 + Width: 48 + Height: 25 + Visible: false Image@STATUS_IMAGE: X: 527 Y: 4