Truncate player name in observer stats and diplomacy panels.
This commit is contained in:
@@ -474,14 +474,23 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
else
|
else
|
||||||
flag.GetImageName = () => player.Faction.InternalName;
|
flag.GetImageName = () => player.Faction.InternalName;
|
||||||
|
|
||||||
var playerName = template.Get<LabelWidget>("PLAYER");
|
|
||||||
var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex);
|
var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex);
|
||||||
|
var playerName = template.Get<LabelWidget>("PLAYER");
|
||||||
|
var playerNameFont = Game.Renderer.Fonts[playerName.Font];
|
||||||
|
var suffixLength = new CachedTransform<string, int>(s => playerNameFont.Measure(s).X);
|
||||||
|
var name = new CachedTransform<Pair<string, int>, string>(c =>
|
||||||
|
WidgetUtils.TruncateText(c.First, playerName.Bounds.Width - c.Second, playerNameFont));
|
||||||
|
|
||||||
playerName.GetText = () =>
|
playerName.GetText = () =>
|
||||||
{
|
{
|
||||||
|
var suffix = player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")";
|
||||||
if (client != null && client.State == Network.Session.ClientState.Disconnected)
|
if (client != null && client.State == Network.Session.ClientState.Disconnected)
|
||||||
return player.PlayerName + " (Gone)";
|
suffix = " (Gone)";
|
||||||
return player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")");
|
|
||||||
|
var sl = suffixLength.Update(suffix);
|
||||||
|
return name.Update(Pair.New(player.PlayerName, sl)) + suffix;
|
||||||
};
|
};
|
||||||
|
|
||||||
playerName.GetColor = () => player.Color.RGB;
|
playerName.GetColor = () => player.Color.RGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user