public static void BindPlayerNameAndStatus(LabelWidget label, Player p) { var client = p.World.LobbyInfo.ClientWithIndex(p.ClientIndex); var nameFont = Game.Renderer.Fonts[label.Font]; var name = new CachedTransform <Tuple <string, WinState, Session.ClientState>, string>(c => { var suffix = c.Item2 == WinState.Undefined ? "" : " (" + c.Item2 + ")"; if (c.Item3 == Session.ClientState.Disconnected) { suffix = " (Gone)"; } return(TruncateText(c.Item1, label.Bounds.Width - nameFont.Measure(suffix).X, nameFont) + suffix); }); label.GetText = () => { var clientState = client != null ? client.State : Session.ClientState.Ready; return(name.Update(Tuple.Create(p.PlayerName, p.WinState, clientState))); }; }
protected LabelWithHighlightWidget(LabelWithHighlightWidget other) : base(other) { HighlightColor = other.HighlightColor; textComponents = new CachedTransform <string, Pair <string, bool>[]>(MakeComponents); }
protected LabelForInputWidget(LabelForInputWidget other) : base(other) { inputWidget = Exts.Lazy(() => Parent.Get <InputWidget>(other.For)); textColor = new CachedTransform <bool, Color>(disabled => disabled ? TextDisabledColor : TextColor); }
public LabelWithHighlightWidget() : base() { textComponents = new CachedTransform <string, Pair <string, bool>[]>(MakeComponents); }
public LabelForInputWidget() : base() { inputWidget = Exts.Lazy(() => Parent.Get <InputWidget>(For)); textColor = new CachedTransform <bool, Color>(disabled => disabled ? TextDisabledColor : TextColor); }