Hide location and IP labels if not known.

This commit is contained in:
Paul Chote
2020-01-11 12:45:48 +00:00
committed by abcdefg30
parent d74a5065b9
commit 422cc2b0d0
5 changed files with 45 additions and 26 deletions

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Network
}
}
return "Unknown Location";
return null;
}
}
}

View File

@@ -316,16 +316,30 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
widget.Bounds.Width = nameFont.Measure(nameLabel.Text).X + 2 * nameLabel.Bounds.Left;
var ipLabel = widget.Get<LabelWidget>("IP");
ipLabel.GetText = () => client.IpAddress;
var locationLabel = widget.Get<LabelWidget>("LOCATION");
var ipLabel = widget.Get<LabelWidget>("IP");
var adminLabel = widget.Get("GAME_ADMIN");
if (client.Location != null)
{
locationLabel.IsVisible = () => true;
locationLabel.GetText = () => client.Location;
widget.Bounds.Height += locationLabel.Bounds.Height;
ipLabel.Bounds.Y += locationLabel.Bounds.Height;
adminLabel.Bounds.Y += locationLabel.Bounds.Height;
}
if (client.IpAddress != null)
{
ipLabel.IsVisible = () => true;
ipLabel.GetText = () => client.IpAddress;
widget.Bounds.Height += ipLabel.Bounds.Height;
adminLabel.Bounds.Y += locationLabel.Bounds.Height;
}
if (client.IsAdmin)
{
var adminLabel = widget.Get("GAME_ADMIN");
adminLabel.IsVisible = () => client.IsAdmin;
adminLabel.IsVisible = () => true;
widget.Bounds.Height += adminLabel.Bounds.Height;
}
}

View File

@@ -400,7 +400,7 @@ Background@LATENCY_TOOLTIP:
Background@ANONYMOUS_PLAYER_TOOLTIP:
Logic: AnonymousProfileTooltipLogic
Background: panel-black
Height: 55
Height: 30
Width: 200
Children:
Label@NAME:
@@ -411,30 +411,31 @@ Background@ANONYMOUS_PLAYER_TOOLTIP:
Font: MediumBold
Label@LOCATION:
X: 5
Y: 24
Y: 25
Height: 12
Visible: False
Font: TinyBold
Label@IP:
X: 5
Y: 37
Y: 25
Height: 12
Visible: False
Font: TinyBold
Container@GAME_ADMIN:
X: 5
Y: 49
Y: 25
Height: 12
Visible: False
Children:
Image@ICON:
X: 1
Y: 5
Y: 4
Width: 7
Height: 5
ImageCollection: lobby-bits
ImageName: admin
Label@LABEL:
X: 10
Y: 1
Height: 12
Text: Game Admin
Font: TinyBold

View File

@@ -133,7 +133,7 @@ Background@LATENCY_TOOLTIP:
Background@ANONYMOUS_PLAYER_TOOLTIP:
Logic: AnonymousProfileTooltipLogic
Background: dialog4
Height: 56
Height: 30
Width: 200
Children:
Label@NAME:
@@ -144,29 +144,31 @@ Background@ANONYMOUS_PLAYER_TOOLTIP:
Font: MediumBold
Label@LOCATION:
X: 7
Y: 24
Y: 25
Height: 12
Visible: False
Font: TinyBold
Label@IP:
X: 7
Y: 37
Y: 25
Height: 12
Visible: False
Font: TinyBold
Container@GAME_ADMIN:
X: 7
Y: 49
Y: 25
Height: 12
Visible: False
Children:
Image@ICON:
Y: 5
X: 1
Y: 4
Width: 7
Height: 5
ImageCollection: lobby-bits
ImageName: admin
Label@LABEL:
X: 9
Y: 1
X: 10
Height: 12
Text: Game Admin
Font: TinyBold

View File

@@ -133,32 +133,35 @@ Background@LATENCY_TOOLTIP:
Background@ANONYMOUS_PLAYER_TOOLTIP:
Logic: AnonymousProfileTooltipLogic
Background: dialog3
Height: 57
Height: 32
Width: 200
Children:
Label@NAME:
X: 7
Y: 2
Y: 3
Text: Anonymous Player
Height: 24
Font: MediumBold
Label@LOCATION:
X: 7
Y: 25
Y: 26
Height: 12
Visible: False
Font: TinyBold
Label@IP:
X: 7
Y: 38
Y: 26
Height: 12
Visible: False
Font: TinyBold
Container@GAME_ADMIN:
X: 7
Y: 50
Y: 26
Height: 12
Visible: False
Children:
Image@ICON:
X: 1
Y: 4
Width: 7
Height: 5
@@ -166,7 +169,6 @@ Background@ANONYMOUS_PLAYER_TOOLTIP:
ImageName: admin
Label@LABEL:
X: 10
Y: 3
Height: 12
Text: Game Admin
Font: TinyBold