Esempio n. 1
0
        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)));
            };
        }
Esempio n. 2
0
 protected LabelWithHighlightWidget(LabelWithHighlightWidget other)
     : base(other)
 {
     HighlightColor = other.HighlightColor;
     textComponents = new CachedTransform <string, Pair <string, bool>[]>(MakeComponents);
 }
Esempio n. 3
0
 protected LabelForInputWidget(LabelForInputWidget other)
     : base(other)
 {
     inputWidget = Exts.Lazy(() => Parent.Get <InputWidget>(other.For));
     textColor   = new CachedTransform <bool, Color>(disabled => disabled ? TextDisabledColor : TextColor);
 }
Esempio n. 4
0
 public LabelWithHighlightWidget()
     : base()
 {
     textComponents = new CachedTransform <string, Pair <string, bool>[]>(MakeComponents);
 }
Esempio n. 5
0
 public LabelForInputWidget()
     : base()
 {
     inputWidget = Exts.Lazy(() => Parent.Get <InputWidget>(For));
     textColor   = new CachedTransform <bool, Color>(disabled => disabled ? TextDisabledColor : TextColor);
 }