コード例 #1
0
        void OnBindingClick(Game game, Widget widget, MouseButton mouseBtn)
        {
            if (mouseBtn == MouseButton.Right && (curWidget == null || curWidget == widget))
            {
                curWidget = (ButtonWidget)widget;
                int     index   = Array.IndexOf <Widget>(widgets, curWidget) - 2;
                KeyBind mapping = Get(index, left, right);
                HandlesKeyDown(game.InputHandler.Keys.GetDefault(mapping));
            }
            if (mouseBtn != MouseButton.Left)
            {
                return;
            }

            if (curWidget == widget)
            {
                curWidget = null;
                statusWidget.SetText("");
            }
            else
            {
                curWidget = (ButtonWidget)widget;
                int    index = Array.IndexOf <Widget>(widgets, curWidget) - 2;
                string desc  = Get(index, leftDesc, rightDesc);
                string text  = "&ePress new key binding for " + desc + ":";
                statusWidget.SetText(text);
            }
        }
コード例 #2
0
        public override void Init()
        {
            font    = new Font(game.FontName, 14);
            posFont = new Font(game.FontName, 14, FontStyle.Italic);
            game.Events.ChatFontChanged += ChatFontChanged;

            fpsText               = new ChatTextWidget(game, font);
            fpsText.XOffset       = 2;
            fpsText.YOffset       = 2;
            fpsText.ReducePadding = true;
            fpsText.Init();

            string msg = text.Length > 0 ? text.GetString() :
                         "FPS: no data yet";

            fpsText.SetText(msg);
            MakePosTextWidget();

            hackStates               = new ChatTextWidget(game, posFont);
            hackStates.XOffset       = 2;
            hackStates.YOffset       = fpsText.Height + posTex.Height + 2;
            hackStates.ReducePadding = true;
            hackStates.Init();
            UpdateHackState(true);
        }
コード例 #3
0
 public static TextWidget Create( Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font )
 {
     TextWidget widget = new TextWidget( game, font );
     widget.Init();
     widget.HorizontalAnchor = horizontal;
     widget.VerticalAnchor = vertical;
     widget.XOffset = x;
     widget.YOffset = y;
     widget.SetText( text );
     return widget;
 }
コード例 #4
0
        public static TextWidget Create(Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font)
        {
            TextWidget widget = new TextWidget(game, font);

            widget.Init();
            widget.HorizontalAnchor = horizontal;
            widget.VerticalAnchor   = vertical;
            widget.XOffset          = x;
            widget.YOffset          = y;
            widget.SetText(text);
            return(widget);
        }
コード例 #5
0
        void UpdateFPS(double delta)
        {
            fpsCount++;
            maxDelta     = Math.Max(maxDelta, delta);
            accumulator += delta;
            if (accumulator < 1)
            {
                return;
            }

            int index = 0;

            totalSeconds++;
            int FPS = (int)(fpsCount / accumulator);

            if (game.ClassicMode)
            {
                text.Clear()
                .AppendNum(ref index, FPS).Append(ref index, " fps, ")
                .AppendNum(ref index, game.ChunkUpdates).Append(ref index, " chunk updates");
            }
            else
            {
                text.Clear()
                .AppendNum(ref index, FPS).Append(ref index, " fps (")
                .AppendNum(ref index, (int)(1f / maxDelta)).Append(ref index, " min), ")
                .AppendNum(ref index, game.ChunkUpdates).Append(ref index, " chunks/s, ")
                .AppendNum(ref index, game.Vertices).Append(ref index, " vertices");
            }

            CheckClock();
            string textString = text.GetString();

            fpsText.SetText(textString);
            maxDelta          = 0;
            accumulator       = 0;
            fpsCount          = 0;
            game.ChunkUpdates = 0;
        }
コード例 #6
0
        public override void Init()
        {
            font = new Font( game.FontName, 14 );
            posFont = new Font( game.FontName, 14, FontStyle.Italic );
            game.Events.ChatFontChanged += ChatFontChanged;

            fpsText = new ChatTextWidget( game, font );
            fpsText.XOffset = 2;
            fpsText.YOffset = 2;
            fpsText.ReducePadding = true;
            fpsText.Init();

            string msg = text.Length > 0 ? text.GetString() :
                "FPS: no data yet";
            fpsText.SetText( msg );
            MakePosTextWidget();

            hackStates = new ChatTextWidget( game, posFont );
            hackStates.XOffset = 2;
            hackStates.YOffset = fpsText.Height + posTex.Height + 2;
            hackStates.ReducePadding = true;
            hackStates.Init();
            UpdateHackState( true );
        }