Don't crash when mousing over a bot as a non-admin.

This commit is contained in:
Paul Chote
2018-08-25 20:15:21 +01:00
committed by reaperrr
parent 8475bd6294
commit 0c098e74f1

View File

@@ -316,24 +316,27 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public static void SetupProfileWidget(Widget parent, Session.Client c, OrderManager orderManager, WorldRenderer worldRenderer)
{
var visible = c != null && c.Bot == null;
var profile = parent.GetOrNull<ImageWidget>("PROFILE");
if (profile != null && c.Bot == null)
if (profile != null)
{
var imageName = (c != null && c.IsAdmin ? "admin-" : "player-")
+ (c.Fingerprint != null ? "registered" : "anonymous");
profile.GetImageName = () => imageName;
profile.IsVisible = () => true;
profile.IsVisible = () => visible;
}
var profileTooltip = parent.GetOrNull<ClientTooltipRegionWidget>("PROFILE_TOOLTIP");
if (profileTooltip != null && c.Bot == null)
if (profileTooltip != null)
{
if (c != null && c.Fingerprint != null)
profileTooltip.Template = "REGISTERED_PLAYER_TOOLTIP";
profileTooltip.Bind(orderManager, worldRenderer, c);
profileTooltip.IsVisible = () => true;
if (visible)
profileTooltip.Bind(orderManager, worldRenderer, c);
profileTooltip.IsVisible = () => visible;
}
}