Add suffix to player name in shroud selector

This commit is contained in:
Ivaylo Draganov
2020-05-18 17:53:40 +03:00
committed by Paul Chote
parent 7a213338a2
commit 31a965b29a
13 changed files with 37 additions and 24 deletions

View File

@@ -33,6 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly World world;
CameraOption selected;
LabelWidget shroudLabel;
class CameraOption
{
@@ -50,7 +51,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Color = p.Color;
Faction = p.Faction.InternalName;
IsSelected = () => p.World.RenderPlayer == p;
OnClick = () => { p.World.RenderPlayer = p; logic.selected = this; p.World.Selection.Clear(); };
OnClick = () =>
{
p.World.RenderPlayer = p;
logic.selected = this;
p.World.Selection.Clear();
WidgetUtils.BindPlayerNameAndStatus(logic.shroudLabel, p);
};
}
public CameraOption(ObserverShroudSelectorLogic logic, World w, string label, Player p)
@@ -107,9 +114,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var label = item.Get<LabelWidget>("LABEL");
label.IsVisible = () => showFlag;
label.GetText = () => option.Label;
label.GetColor = () => option.Color;
if (showFlag)
WidgetUtils.BindPlayerNameAndStatus(label, option.Player);
else
label.GetText = () => option.Label;
var flag = item.Get<ImageWidget>("FLAG");
flag.IsVisible = () => showFlag;
flag.GetImageCollection = () => "flags";
@@ -126,7 +137,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
shroudSelector.ShowDropDown("SPECTATOR_DROPDOWN_TEMPLATE", 400, groups, setupItem);
};
var shroudLabel = shroudSelector.Get<LabelWidget>("LABEL");
shroudLabel = shroudSelector.Get<LabelWidget>("LABEL");
shroudLabel.IsVisible = () => selected.Faction != null;
shroudLabel.GetText = () => selected.Label;
shroudLabel.GetColor = () => selected.Color;