示例#1
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));
        }
示例#2
0
        public override void Draw(ITextRenderer renderer)
        {
            renderer.Set(0, 0, GuiSettings.ScrollbarUp);
            for (var y = 1; y < Height - 1; y++)
            {
                renderer.Set(0, y, GuiSettings.Scrollbar);
            }
            renderer.Set(0, (int)Height - 1, GuiSettings.ScrollbarDown);

            var x = 1 + (InternalValue * (Height - 3));
            renderer.Set(0, (int)x, GuiSettings.ScrollbarThumb);
        }
示例#3
0
        public override void Draw(ITextRenderer renderer)
        {
            var x = 0;
            var y = 0;

            foreach (var c in Caption)
            {
                if (c == '\n')
                {
                    x = 0;
                    y++;
                    continue;
                }

                renderer.Set(x, y, new Character(c, GuiSettings.Label.Foreground, GuiSettings.Label.Background));

                x++;
                if (x >= Width)
                {
                    x = 0;
                    y++;
                }

                if (y >= Height)
                    break;
            }
        }
示例#4
0
        public void Set(int x, int y, Character character, bool useBlending = true)
        {
            if (x < 0 || x > Width - 1 || y < 0 || y > Height - 1)
            {
                return;
            }

            if (useBlending && character.HasTransparentComponent)
            {
                var glyph = character.Glyph;
                var fore  = character.Foreground;
                var back  = character.Background;

                var ch = Get(x, y);

                if (glyph == -1)
                {
                    glyph = ch.Glyph;
                }

                if (fore == -1)
                {
                    fore = ch.Foreground;
                }

                if (back == -1)
                {
                    back = ch.Background;
                }

                character = new Character(glyph, fore, back);
            }

            _renderer.Set(x, y, _effect(x, y, character), useBlending);
        }
示例#5
0
 /// <summary>
 /// Draw unformatted text. Will not handle control characters.
 /// </summary>
 public static void DrawText(this ITextRenderer renderer, int x, int y, string text, Character color)
 {
     foreach (var c in text)
     {
         renderer.Set(x, y, new Character(c, color.Foreground, color.Background));
         x++;
     }
 }
示例#6
0
        // TODO: drawtext with formatting characters

        /// <summary>
        /// Draw a 9-patch box.
        ///
        /// Box indices:
        /// 012
        /// 345
        /// 678
        /// </summary>
        public static void DrawBox(this ITextRenderer renderer, int x, int y, uint w, uint h, string box, Character color)
        {
            for (int putY = y, yy = 0; putY < y + h; putY++, yy++)
            {
                for (int putX = x, xx = 0; putX < x + w; putX++, xx++)
                {
                    char c;
                    if (yy == 0)
                    {
                        if (xx == 0)
                        {
                            c = box[0];
                        }
                        else if (xx == w - 1)
                        {
                            c = box[2];
                        }
                        else
                        {
                            c = box[1];
                        }
                    }
                    else if (yy == h - 1)
                    {
                        if (xx == 0)
                        {
                            c = box[6];
                        }
                        else if (xx == w - 1)
                        {
                            c = box[8];
                        }
                        else
                        {
                            c = box[7];
                        }
                    }
                    else
                    {
                        if (xx == 0)
                        {
                            c = box[3];
                        }
                        else if (xx == w - 1)
                        {
                            c = box[5];
                        }
                        else
                        {
                            c = box[4];
                        }
                    }

                    renderer.Set(putX, putY, new Character(c, color.Foreground, color.Background));
                }
            }
        }
示例#7
0
        public void Set(int x, int y, Character character, bool useBlending = true)
        {
            if (x < 0 || x > Width - 1 || y < 0 || y > Height - 1)
            {
                return;
            }

            _renderer.Set(_startX + x, _startY + y, character, useBlending);
        }
示例#8
0
 /// <summary>
 /// Clear this renderer to a character.
 /// </summary>
 public static void Clear(this ITextRenderer renderer, Character character, bool useBlending = false)
 {
     for (var y = 0; y < renderer.Height; y++)
     {
         for (var x = 0; x < renderer.Width; x++)
         {
             renderer.Set(x, y, character, useBlending);
         }
     }
 }
示例#9
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);
            }
        }
示例#10
0
        /// <summary>
        /// Draw part of a renderer to this renderer.
        /// </summary>
        public static void DrawImagePartial(this ITextRenderer renderer, int x, int y, ITextRenderer image, uint startX, uint startY, uint width, uint height)
        {
            if (x < -width || x > renderer.Width || y < -height || y > renderer.Height)
            {
                return;
            }

            for (var yy = 0; yy < height; yy++)
            {
                for (var xx = 0; xx < width; xx++)
                {
                    renderer.Set(x + xx, y + yy, image.Get((int)startX + xx, (int)startY + yy));
                }
            }
        }
示例#11
0
        /// <summary>
        /// Draw a renderer to this renderer.
        /// </summary>
        public static void DrawImage(this ITextRenderer renderer, int x, int y, ITextRenderer image)
        {
            if (x < -image.Width || x > renderer.Width || y < -image.Height || y > renderer.Height)
            {
                return;
            }

            for (var yy = 0; yy < image.Height; yy++)
            {
                for (var xx = 0; xx < image.Width; xx++)
                {
                    renderer.Set(x + xx, y + yy, image.Get(xx, yy));
                }
            }
        }
示例#12
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);
        }
示例#13
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));
        }
示例#14
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);
        }