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