Merge pull request #9949 from pchote/fix-more-overlaps
Truncate player names in more places.
This commit is contained in:
@@ -10,7 +10,10 @@
|
|||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Network;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -50,11 +53,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var client = world.LobbyInfo.ClientWithIndex(pp.ClientIndex);
|
var client = world.LobbyInfo.ClientWithIndex(pp.ClientIndex);
|
||||||
var item = playerTemplate.Clone();
|
var item = playerTemplate.Clone();
|
||||||
var nameLabel = item.Get<LabelWidget>("NAME");
|
var nameLabel = item.Get<LabelWidget>("NAME");
|
||||||
|
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
|
||||||
|
|
||||||
|
var suffixLength = new CachedTransform<string, int>(s => nameFont.Measure(s).X);
|
||||||
|
var name = new CachedTransform<Pair<string, int>, string>(c =>
|
||||||
|
WidgetUtils.TruncateText(c.First, nameLabel.Bounds.Width - c.Second, nameFont));
|
||||||
|
|
||||||
nameLabel.GetText = () =>
|
nameLabel.GetText = () =>
|
||||||
{
|
{
|
||||||
|
var suffix = pp.WinState == WinState.Undefined ? "" : " (" + pp.WinState + ")";
|
||||||
if (client != null && client.State == Network.Session.ClientState.Disconnected)
|
if (client != null && client.State == Network.Session.ClientState.Disconnected)
|
||||||
return pp.PlayerName + " (Gone)";
|
suffix = " (Gone)";
|
||||||
return pp.PlayerName + (pp.WinState == WinState.Undefined ? "" : " (" + pp.WinState + ")");
|
|
||||||
|
var sl = suffixLength.Update(suffix);
|
||||||
|
return name.Update(Pair.New(pp.PlayerName, sl)) + suffix;
|
||||||
};
|
};
|
||||||
nameLabel.GetColor = () => pp.Color.RGB;
|
nameLabel.GetColor = () => pp.Color.RGB;
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -639,7 +639,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var item = ScrollItemWidget.Setup(playerTemplate, () => false, () => { });
|
var item = ScrollItemWidget.Setup(playerTemplate, () => false, () => { });
|
||||||
|
|
||||||
var label = item.Get<LabelWidget>("LABEL");
|
var label = item.Get<LabelWidget>("LABEL");
|
||||||
label.GetText = () => o.Name;
|
var font = Game.Renderer.Fonts[label.Font];
|
||||||
|
var name = WidgetUtils.TruncateText(o.Name, label.Bounds.Width, font);
|
||||||
|
label.GetText = () => name;
|
||||||
label.GetColor = () => color;
|
label.GetColor = () => color;
|
||||||
|
|
||||||
var flag = item.Get<ImageWidget>("FLAG");
|
var flag = item.Get<ImageWidget>("FLAG");
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ Container@REPLAYBROWSER_PANEL:
|
|||||||
Height: 16
|
Height: 16
|
||||||
Label@LABEL:
|
Label@LABEL:
|
||||||
X: 40
|
X: 40
|
||||||
Width: 60
|
Width: PARENT_RIGHT-50
|
||||||
Height: 25
|
Height: 25
|
||||||
Label@NOFLAG_LABEL:
|
Label@NOFLAG_LABEL:
|
||||||
X: 5
|
X: 5
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ Background@REPLAYBROWSER_PANEL:
|
|||||||
Height: 16
|
Height: 16
|
||||||
Label@LABEL:
|
Label@LABEL:
|
||||||
X: 40
|
X: 40
|
||||||
Width: 60
|
Width: PARENT_RIGHT-50
|
||||||
Height: 25
|
Height: 25
|
||||||
Label@NOFLAG_LABEL:
|
Label@NOFLAG_LABEL:
|
||||||
X: 5
|
X: 5
|
||||||
|
|||||||
Reference in New Issue
Block a user