Exemplo n.º 1
0
        public override void Draw(ITextRenderer renderer)
        {
            renderer.DrawBox(0, 0, Width, Height, TextExtensions.DoubleBox, GuiSettings.Window);
            renderer.DrawText(2, 0, "[\xFE]", GuiSettings.Window);

            if (!string.IsNullOrEmpty(Caption))
                renderer.DrawText(6, 0, string.Format(" {0} ", Caption), GuiSettings.WindowCaption);

            _children.Draw(renderer.Region(1, 1, Width - 2, Height - 2));
        }
Exemplo n.º 2
0
        private static void Update()
        {
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Escape && ke.Down))
            {
                window.Close();
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Up && ke.Down))
            {
                fontSize += 0.5f;
                UpdateFont();
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Down && ke.Down))
            {
                fontSize -= 0.5f;
                UpdateFont();
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Left && ke.Down))
            {
                letterSpacing -= 0.01f;
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Right && ke.Down))
            {
                letterSpacing += 0.01f;
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Enter && ke.Down))
            {
                currentFontIndex = (currentFontIndex + 1) % fonts.Length;
                UpdateFont();
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Space && ke.Down))
            {
                currentColorIndex = (currentColorIndex + 1) % colors.Length;
            }

            infoTextRenderer.Update();
            demoTextRenderer.Update();

            var         xAccumulated = 0f;
            const float xInset       = 10;
            const float lineSpacing  = 5;

            infoTextRenderer.DrawText("Debug Controls:", new Vector2(xInset, xAccumulated += xInset), colors[0]);
            infoTextRenderer.DrawText("Up/Down = Increase/Decrease Font Size", new Vector2(xInset, xAccumulated         += lineSpacing + infoFont.FontSizeInPixels), colors[0]);
            infoTextRenderer.DrawText("Right/Left = Increase/Decrease Letter Spacing", new Vector2(xInset, xAccumulated += lineSpacing + infoFont.FontSizeInPixels), colors[0]);
            infoTextRenderer.DrawText("Enter = Change Font", new Vector2(xInset, xAccumulated            += lineSpacing + infoFont.FontSizeInPixels), colors[0]);
            infoTextRenderer.DrawText("Space = Change Colorm", new Vector2(xInset, xAccumulated          += lineSpacing + infoFont.FontSizeInPixels), colors[0]);
            infoTextRenderer.DrawText($"Current Font: {demoFont.Name}", new Vector2(xInset, xAccumulated += lineSpacing + infoFont.FontSizeInPixels), colors[0]);

            demoTextRenderer.DrawText("Sixty zippers were quickly picked from the woven jute bag.", new Vector2(xInset, xAccumulated += (lineSpacing * 5) + infoFont.FontSizeInPixels), colors[currentColorIndex], letterSpacing);
            demoTextRenderer.DrawText("The quick brown fox jumps over the lazy dog", new Vector2(xInset, xAccumulated += lineSpacing + demoFont.FontSizeInPixels), colors[(currentColorIndex + 1) % colors.Length], letterSpacing);
            demoTextRenderer.DrawText("How vexingly quick daft zebras jump!", new Vector2(xInset, xAccumulated        += lineSpacing + demoFont.FontSizeInPixels), colors[(currentColorIndex + 2) % colors.Length], letterSpacing);
        }
Exemplo n.º 3
0
        public override void Draw(ITextRenderer renderer)
        {
            if (SelectedIndex > _view + Width - 1)
                _view = SelectedIndex - (int)Width + 1;
            else if (SelectedIndex <= _view)
                _view = SelectedIndex - (int)Width - 1;
            if (_view < 0)
                _view = 0;
            if (_view > _value.Length)
                _view = _value.Length - 1;
            if (_value.Length < Width)
                _view = 0;

            var text = _value.Substring(_view);

            renderer.Clear(GuiSettings.TextBox);
            renderer.DrawText(0, 0, text, GuiSettings.TextBox);

            _frames++;
            if (_frames >= 30)
            {
                _caretVisible = !_caretVisible;
                _frames = 0;
            }

            if (Focussed && _caretVisible)
                renderer.Set(SelectedIndex - _view, 0, GuiSettings.TextBoxCaret);
        }
Exemplo n.º 4
0
        public override void Draw(ITextRenderer renderer)
        {
            renderer.Clear(new Character(0, 0, 7), true);

            for (var i = 0; i < _lines.Count; i++)
            {
                var line = _lines[i];
                renderer.DrawBox(0, i, Width - 1, 1, GuiSettings.SolidBox, new Character(0, 0, line.Background));

                if (line.SourceLine != null)
                    renderer.DrawText((int)Width - 2 - line.SourceLine.Length, i, line.SourceLine, new Character(0, 25));

                renderer.DrawText(0, i, line.Address.ToString("X8"), new Character(0, 8));
                renderer.DrawText(9, i, line.Instruction, new Character(0, line.Foreground));
            }

            _scrollbar.Draw(renderer.Region(_scrollbar.Left, _scrollbar.Top, _scrollbar.Width, _scrollbar.Height));
        }
Exemplo n.º 5
0
        public override void Draw(ITextRenderer renderer)
        {
            renderer.Set(0, 0, new Character('[', 0));
            renderer.Set(2, 0, new Character(']', 0));

            if (Checked)
                renderer.Set(1, 0, new Character('X', 0));

            renderer.DrawText(4, 0, Caption, new Character(0, 0));
        }
Exemplo n.º 6
0
        public override void Draw(ITextRenderer renderer)
        {
            var captionX = (int)(Width - 1) / 2 - Caption.Length / 2;

            if (!_holding)
            {
                renderer.DrawBox(0, 0, Width - 1, 1, GuiSettings.SolidBox, GuiSettings.Button);
                renderer.Set((int)Width - 1, 0, GuiSettings.ButtonShadowR);

                for (var i = 0; i < Width; i++)
                {
                    renderer.Set(1 + i, 1, GuiSettings.ButtonShadowB);
                }

                renderer.DrawText(captionX, 0, Caption, GuiSettings.Button);
            }
            else
            {
                renderer.DrawBox(1, 0, Width, 1, GuiSettings.SolidBox, GuiSettings.Button);
                renderer.DrawText(captionX + 1, 0, Caption, GuiSettings.Button);
            }
        }
Exemplo n.º 7
0
        public override void Draw(ITextRenderer renderer)
        {
            _offset = (int)(Math.Round(_scrollbar.Value) * _rowSize);

            renderer.Clear(new Character(0, 0, 7), true);

            if (_buffer != null)
            {
                var offset = _offset;

                for (var i = 0; i < Height; i++)
                {
                    renderer.DrawText(0, i, offset.ToString("X8"), new Character(0, 8, 7));
                    var x1 = 10;
                    var x2 = x1 + (_rowSize * 3) + 1;
                    for (var j = 0; j < _rowSize; j++, offset++, x1 += 3, x2++)
                    {
                        if (offset < 0 || offset > _buffer.Length)
                            continue;

                        var b = _buffer[offset];
                        renderer.DrawText(x1, i, b.ToString("X2"), new Character(0, 0, 7));
                        renderer.Set(x2, i, new Character(b, 0, 7));
                    }
                }
            }

            _frames++;
            if (_frames >= 30)
            {
                _caretVisible = !_caretVisible;
                _frames = 0;
            }

            if (Focussed && _caretVisible)
            {
                var offset = _selectedOffset - (_offset * 2);
                var y = (offset / 2) / _rowSize;
                var xN = offset % (_rowSize * 2);
                var x = 10 + xN + (xN / 2);
                renderer.Set(x, y, new Character(-1, 7, 0));
            }

            _scrollbar.Draw(renderer.Region(_scrollbar.Left, _scrollbar.Top, _scrollbar.Width, _scrollbar.Height));
        }
Exemplo n.º 8
0
        public void Draw(ITextRenderer renderer, bool highlight, bool extended)
        {
            var col = highlight ? GuiSettings.MenuItemHighlight : GuiSettings.MenuItem;
            var caption = string.Format(" {0} ", Caption);

            renderer.Clear(col);
            renderer.DrawText(0, 0, caption, col);

            if (extended && Items.Count > 0)
                renderer.Set((int)renderer.Width - 1, 0, GuiSettings.MenuArrow);
        }
Exemplo n.º 9
0
            public override void Draw(ITextRenderer renderer)
            {
                if (_playing)
                {
                    if (_player.Y >= Height - 1)
                        _playing = false;

                    if (_pipes.Any(p => p.Contains(_player.X, _player.Y)))
                        _playing = false;
                }

                if (_playing)
                {
                    var prevPipe = (int)_player.X / 32;

                    _player.VelY += 0.025f;
                    _player.X += _player.VelX;
                    _player.Y += _player.VelY;

                    if ((int)_player.X / 32 != prevPipe)
                        _pipes.Add(new Pipe(_camera + 100, _random.Next(2, (int)Height - 12)));

                    _pipes.RemoveAll(p => p.X < _camera - 10);
                }
                else
                {
                    _player.X = 10;
                    _player.Y = Height / 2f;
                    _player.VelX = 0;
                    _player.VelY = 0;

                    _pipes.Clear();
                }

                _camera = (int)_player.X - 15;

                renderer.Clear(new Character(0, 53, 53));

                Draw(renderer, _player.X, _player.Y, 3, 2, new Character(0, 43, 43));

                if (!_playing)
                    renderer.DrawText(_camera + 10, (int)Height / 2 + 5, "Press Space!", new Character(0, 0));

                foreach (var p in _pipes)
                {
                    Draw(renderer, p.X, 0, (uint)p.W, (uint)p.Y, new Character(0, 10, 10));
                    Draw(renderer, p.X, p.Y + p.H, (uint)p.W, 50, new Character(0, 10, 10));
                }

                Draw(renderer, _camera, Height - 1, Width, 2, new Character(0, 2, 2));
            }