public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player) { var flag = template.Get <ImageWidget>("FLAG"); flag.GetImageCollection = () => "flags"; if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally) { flag.GetImageName = () => player.DisplayFaction.InternalName; } else { flag.GetImageName = () => player.Faction.InternalName; } 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 = () => { var suffix = player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")"; if (client != null && client.State == Session.ClientState.Disconnected) { suffix = " (Gone)"; } var sl = suffixLength.Update(suffix); return(name.Update(Pair.New(player.PlayerName, sl)) + suffix); }; playerName.GetColor = () => player.Color.RGB; }
public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player) { var flag = template.Get <ImageWidget>("FLAG"); flag.GetImageCollection = () => "flags"; if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally) { flag.GetImageName = () => player.DisplayCountry.Race; } else { flag.GetImageName = () => player.Country.Race; } var playerName = template.Get <LabelWidget>("PLAYER"); var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex); playerName.GetText = () => { if (client != null && client.State == Network.Session.ClientState.Disconnected) { return(player.PlayerName + " (Gone)"); } return(player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")")); }; playerName.GetColor = () => player.Color.RGB; }
static void AddPlayerFlagAndName(ScrollItemWidget template, Player player) { var flag = template.Get <ImageWidget>("FLAG"); flag.GetImageName = () => player.Country.Race; flag.GetImageCollection = () => "flags"; var playerName = template.Get <LabelWidget>("PLAYER"); playerName.GetText = () => player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")"); playerName.GetColor = () => player.Color.RGB; }
static void AddPlayerFlagAndName(ScrollItemWidget template, Player player) { var flag = template.Get <ImageWidget>("FLAG"); flag.GetImageCollection = () => "flags"; flag.GetImageName = () => player.Faction.InternalName; var playerName = template.Get <LabelWidget>("PLAYER"); WidgetUtils.BindPlayerNameAndStatus(playerName, player); playerName.GetColor = () => player.Color; }
public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player) { var flag = template.Get<ImageWidget>("FLAG"); flag.GetImageName = () => player.Country.Race; flag.GetImageCollection = () => "flags"; var playerName = template.Get<LabelWidget>("PLAYER"); var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex); playerName.GetText = () => { if (client != null && client.State == Network.Session.ClientState.Disconnected) return player.PlayerName + " (Gone)"; return player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")"); }; playerName.GetColor = () => player.Color.RGB; }
void SetupKeyBinding(ScrollItemWidget keyWidget, string description, Func <string> getValue, Action <string> setValue) { keyWidget.Get <LabelWidget>("FUNCTION").GetText = () => description; var textBox = keyWidget.Get <TextFieldWidget>("HOTKEY"); textBox.Text = getValue(); textBox.OnLoseFocus = () => { textBox.Text.Trim(); if (textBox.Text.Length == 0) { textBox.Text = getValue(); } else { setValue(textBox.Text); } }; textBox.OnEnterKey = () => { textBox.YieldKeyboardFocus(); return(true); }; }