Merge pull request #13002 from rob-v/LobbyOptionsEditableByHost
Host can change Team and Spawn of any player. #12936
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<DropDownButtonWidget>("TEAM");
|
||||
var dropdown = parent.Get<DropDownButtonWidget>("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<LabelWidget>("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<DropDownButtonWidget>("SPAWN");
|
||||
var dropdown = parent.Get<DropDownButtonWidget>("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<LabelWidget>("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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user