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

@@ -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");
locationLabel.GetText = () => client.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;
}
}