예제 #1
0
 void ConstructWidgets()
 {
     textInput         = new TextInputWidget(game, chatFont, chatBoldFont);
     textInput.YOffset = blockSize + 5;
     status            = new TextGroupWidget(game, 5, chatFont, chatUnderlineFont,
                                             Anchor.BottomOrRight, Anchor.LeftOrTop);
     status.Init();
     status.SetUsePlaceHolder(0, false);
     status.SetUsePlaceHolder(1, false);
     bottomRight = new TextGroupWidget(game, 3, chatFont, chatUnderlineFont,
                                       Anchor.BottomOrRight, Anchor.BottomOrRight);
     bottomRight.YOffset = blockSize * 3 / 2;
     bottomRight.Init();
     normalChat = new TextGroupWidget(game, chatLines, chatFont, chatUnderlineFont,
                                      Anchor.LeftOrTop, Anchor.BottomOrRight);
     normalChat.XOffset = 10;
     normalChat.YOffset = blockSize * 2 + 15;
     normalChat.Init();
     clientStatus = new TextGroupWidget(game, game.Chat.ClientStatus.Length, chatFont,
                                        chatUnderlineFont, Anchor.LeftOrTop, Anchor.BottomOrRight);
     clientStatus.XOffset = 10;
     clientStatus.YOffset = blockSize * 2 + 15;
     clientStatus.Init();
     announcement = ChatTextWidget.Create(game, 0, 0, null,
                                          Anchor.Centre, Anchor.Centre, announcementFont);
     announcement.YOffset = -game.Height / 4;
 }
        void MakeExtendedHelp(string[] desc)
        {
            extendedHelp = new ChatTextWidget[desc.Length];
            int x = 0, y = extHelpY;

            tableWidth = 0;

            for (int i = 0; i < desc.Length; i++)
            {
                extendedHelp[i] = ChatTextWidget.Create(game, 0, y,
                                                        desc[i], Anchor.Centre, Anchor.Centre, extendedHelpFont);
                tableWidth = Math.Max(extendedHelp[i].Width, tableWidth);
                y         += extendedHelp[i].Height + 5;
            }
            tableHeight = y - extHelpY;

            int yOffset = 0;

            for (int i = 0; i < desc.Length; i++)
            {
                ChatTextWidget widget = extendedHelp[i];
                widget.XOffset = (widget.Width - tableWidth) / 2;
                x = CalcOffset(game.Width, widget.Width, widget.XOffset, Anchor.Centre);

                widget.YOffset = yOffset + extHelpY + extendedHelp[0].Height / 2;
                y        = CalcOffset(game.Height, widget.Height, widget.YOffset, Anchor.Centre);
                yOffset += extendedHelp[i].Height + 5;
                widget.MoveTo(x, y);
            }
        }
 public void SetMessage(string message)
 {
     if (messageWidget != null)
     {
         messageWidget.Dispose();
     }
     messageWidget = ChatTextWidget.Create(game, 0, -30, message, Anchor.Centre, Anchor.Centre, font);
 }
 public void SetTitle(string title)
 {
     if (titleWidget != null)
     {
         titleWidget.Dispose();
     }
     titleWidget = ChatTextWidget.Create(game, 0, -80, title, Anchor.Centre, Anchor.Centre, font);
 }
예제 #5
0
 public static ChatTextWidget Create( Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font )
 {
     ChatTextWidget widget = new ChatTextWidget( game, font );
     widget.Init();
     widget.HorizontalAnchor = horizontal; widget.VerticalAnchor = vertical;
     widget.XOffset = x; widget.YOffset = y;
     widget.SetText( text );
     return widget;
 }
        public static new ChatTextWidget Create(Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font)
        {
            ChatTextWidget widget = new ChatTextWidget(game, font);

            widget.Init();
            widget.HorizontalAnchor = horizontal; widget.VerticalAnchor = vertical;
            widget.XOffset          = x; widget.YOffset = y;
            widget.SetText(text);
            return(widget);
        }
예제 #7
0
 public override void Init()
 {
     graphicsApi.ClearColour(new FastColour(65, 31, 31));
     widgets = new Widget[] {
         ChatTextWidget.Create(game, 0, -30, title, Anchor.Centre, Anchor.Centre, titleFont),
         ChatTextWidget.Create(game, 0, 10, message, Anchor.Centre, Anchor.Centre, messageFont),
         ButtonWidget.Create(game, 0, 80, 280, 35, "Try to reconnect.. " + delay,
                             Anchor.Centre, Anchor.Centre, titleFont, ReconnectClick),
     };
     initTime     = DateTime.UtcNow;
     lastSecsLeft = delay;
 }
예제 #8
0
 public override void Init()
 {
     base.Init();
     descriptions = normDescriptions;
     originKey    = KeyBinding.MouseLeft;
     widgets      = new Widget[descriptions.Length + 3];
     MakeKeys(KeyBinding.MouseLeft, 0, 3, 0);
     widgets[index++] = MakeBack(false, titleFont,
                                 (g, w) => g.SetNewScreen(new PauseScreen(g)));
     widgets[index++] = ButtonWidget.Create(
         game, 0, 170, 300, 35, "Normal key bindings",
         Anchor.Centre, Anchor.Centre, titleFont, NextClick);
     widgets[index++] = ChatTextWidget.Create(
         game, 0, -40, "&eRight click to remove the key binding",
         Anchor.Centre, Anchor.Centre, regularFont);
 }
예제 #9
0
        public override void Init()
        {
            font = new Font( "Arial", 13 );
            posFont = new Font( "Arial", 12, FontStyle.Italic );
            game.Events.ChatFontChanged += ChatFontChanged;

            fpsTextWidget = new ChatTextWidget( game, font );
            fpsTextWidget.XOffset = 2;
            fpsTextWidget.YOffset = 2;
            fpsTextWidget.Init();
            string fpsText = text.Length > 0 ? text.GetString() :
                "FPS: no data yet";
            fpsTextWidget.SetText( fpsText );
            MakePosTextWidget();

            hackStatesWidget = new ChatTextWidget( game, posFont );
            hackStatesWidget.XOffset = 2;
            hackStatesWidget.YOffset = fpsTextWidget.Height + posHeight + 2;
            hackStatesWidget.Init();
            UpdateHackState( true );
        }
        public override void Init()
        {
            DrawTextArgs measureArgs = new DrawTextArgs("ABC", font, false);

            elemHeight = game.Drawer2D.MeasureChatSize(ref measureArgs).Height;
            overview   = ChatTextWidget.Create(game, 0, 0, "Connected players:",
                                               Anchor.Centre, Anchor.Centre, font);

            base.Init();
            if (!extList)
            {
                game.EntityEvents.EntityAdded   += PlayerSpawned;
                game.EntityEvents.EntityRemoved += PlayerDespawned;
            }
            else
            {
                game.EntityEvents.CpeListInfoAdded   += PlayerListInfoAdded;
                game.EntityEvents.CpeListInfoRemoved += PlayerDespawned;
                game.EntityEvents.CpeListInfoChanged += PlayerListInfoChanged;
            }
        }
예제 #11
0
        public override void Init()
        {
            font    = new Font(game.FontName, 13);
            posFont = new Font(game.FontName, 12, FontStyle.Italic);
            game.Events.ChatFontChanged += ChatFontChanged;

            fpsTextWidget         = new ChatTextWidget(game, font);
            fpsTextWidget.XOffset = 2;
            fpsTextWidget.YOffset = 2;
            fpsTextWidget.Init();
            string fpsText = text.Length > 0 ? text.GetString() :
                             "FPS: no data yet";

            fpsTextWidget.SetText(fpsText);
            MakePosTextWidget();

            hackStatesWidget         = new ChatTextWidget(game, posFont);
            hackStatesWidget.XOffset = 2;
            hackStatesWidget.YOffset = fpsTextWidget.Height + posHeight + 2;
            hackStatesWidget.Init();
            UpdateHackState(true);
        }