Merge pull request #3000 from Mailaender/dynamic-orderlag

Display Ping of joining Clients in Lobby and use it to calculate OrderLatency
This commit is contained in:
Chris Forbes
2013-04-20 16:57:00 -07:00
6 changed files with 88 additions and 14 deletions

View File

@@ -478,6 +478,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
template.Get<LabelWidget>("NAME").GetText = () => client.Name;
if (client.IsAdmin)
template.Get<LabelWidget>("NAME").Font = "Bold";
if (client.Ping > -1)
template.Get<LabelWidget>("NAME").GetColor = () => LobbyUtils.GetPingColor(client.Ping);
var color = template.Get<ColorBlockWidget>("COLOR");
color.GetColor = () => client.ColorRamp.GetColor(0);

View File

@@ -26,6 +26,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
if (c.IsAdmin)
name.Font = "Bold";
name.Text = c.Name;
if (c.Ping > -1)
name.TextColor = GetPingColor(c.Ping);
name.OnEnterKey = () =>
{
name.Text = name.Text.Trim();
@@ -189,5 +191,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.Renderer.Fonts["Bold"].DrawTextWithContrast(client.Name, position + new int2(5, 5), Color.White, Color.Black, 1);
}
}
public static Color GetPingColor(int ping)
{
if (ping > 720) // OrderLag > 6
return Color.Red;
if (ping > 360) // OrderLag > 3
return Color.Orange;
return Color.LimeGreen;
}
}
}