Example #1
0
        public static void Print(Graphics.SpriteBatch sb, FontInstance font, int x, int y, string text)
        {
            if (font.Font == null)
            {
                return;
            }

            Math.Vector2 cursor = new Gk3Main.Math.Vector2((float)x, (float)y);

            foreach (char c in text)
            {
                if (c == '\t')
                {
                    var space = font.Font.mapUnicodeToFontCharacter(' ');
                    cursor.X += font.Font.CharacterInfo[space].SourceRect.Width * 5;
                    continue;
                }

                int index = font.Font.mapUnicodeToFontCharacter(c);

                if (index >= 0)
                {
                    sb.Draw(font.Font.Texture, cursor, font.Font.CharacterInfo[index].SourceRect, font.Color, 0);

                    cursor.X += font.Font.CharacterInfo[index].SourceRect.Width;
                }
            }
        }
Example #2
0
        public void Render(Graphics.SpriteBatch sb, int tickCount)
        {
            if (_active)
            {
                sb.Draw(_upperBackground, new Math.Vector2(_screenX, _screenY));

                foreach (Button b in _upperButtons)
                {
                    b.Render(sb, tickCount);
                }

                if (_state != OptionsMenuState.Initial)
                {
                    // all states other than Initial render the options dropdown
                    sb.Draw(_optionsBackground, new Math.Vector2(_screenX, _screenY + _upperBackground.Height));

                    foreach (Button b in _optionsButtons)
                    {
                        b.Render(sb, tickCount);
                    }

                    if (_state == OptionsMenuState.AdvancedOption ||
                        _state == OptionsMenuState.GraphicsOptions)
                    {
                        sb.Draw(_advancedBackground, new Math.Vector2(_screenX, _screenY + _upperBackground.Height + _optionsBackground.Height));

                        foreach (Button b in _advancedOptionsButtons)
                        {
                            b.Render(sb, tickCount);
                        }

                        if (_state == OptionsMenuState.GraphicsOptions)
                        {
                            sb.Draw(_graphicsBackground, new Gk3Main.Math.Vector2(_screenX, _screenY + _upperBackground.Height + _optionsBackground.Height + _advancedBackground.Height));

                            _resolutionDropdown.Render(sb, tickCount);
                            _3dDriverDropdown.Render(sb, tickCount);
                        }
                    }
                }
            }
        }
Example #3
0
        public void Render(Graphics.SpriteBatch sb, int tickCount)
        {
            if (_enabled)
            {
                if (_mouseDown)
                {
                    sb.Draw(_downImage, new Math.Vector2(_screenX, _screenY));
                }
                else if (IsMouseOverButton(_mouseX, _mouseY))
                {
                    sb.Draw(_hoverImage, new Math.Vector2(_screenX, _screenY));
                }
                else
                {
                    sb.Draw(_upImage, new Math.Vector2(_screenX, _screenY));
                }

                if (_tooltipVisible == false && tickCount > _timeAtLastMouseMove + 500 && IsMouseOverButton(_mouseX, _mouseY))
                {
                    _tooltipVisible = true;
                }
            }
            else
            {
                sb.Draw(_disabledImage, new Math.Vector2(_screenX, _screenY));
            }

            if (_tooltipVisible)
            {
                var           size = Gui.Font.MeasureString(_tooltipFont, _tooltip);
                Graphics.Rect tooltipRect;
                tooltipRect.X      = _mouseX - 2;
                tooltipRect.Y      = _mouseY + 32;
                tooltipRect.Width  = size.X + 4;
                tooltipRect.Height = size.Y;

                Graphics.TextureResource defaultWhite = Graphics.RendererManager.CurrentRenderer.DefaultTexture;
                sb.Draw(defaultWhite, tooltipRect, null, 0);

                Gui.Font.Print(sb, _tooltipFont, _mouseX, _mouseY + 32, _tooltip);
            }
        }
Example #4
0
        public void Render(Graphics.SpriteBatch sb, int tickCount)
        {
            const int padding = 4;
            int       left    = _screenX - _width + _downArrow.Width + padding;
            int       top     = _screenY + padding;

            _downArrow.Render(sb, tickCount);

            if (_selectedIndex >= 0)
            {
                Gk3Main.Gui.Font.Print(sb, _font, left, top, _items[_selectedIndex].Value);
            }

            if (_down)
            {
                // draw the top
                sb.Draw(_top, new Gk3Main.Graphics.Rect(_boxRect.X - 1, _boxRect.Y - 1, _boxRect.Width + 2, _top.Height), null, 0);

                // draw the bottom
                sb.Draw(_top, new Gk3Main.Graphics.Rect(_boxRect.X - 1, _boxRect.Y + _boxRect.Height - 1, _boxRect.Width + 2, _top.Height), null, 0);

                // draw the left
                sb.Draw(_side, new Gk3Main.Graphics.Rect(_boxRect.X - 1, _boxRect.Y - 1, _side.Width, _boxRect.Height + 2), null, 0);

                // draw the right
                sb.Draw(_side, new Gk3Main.Graphics.Rect(_boxRect.X + _boxRect.Width - 1, _boxRect.Y - 1, _side.Width, _boxRect.Height + 2), null, 0);

                // fill
                sb.Draw(_dropdownBackground, _boxRect, new Gk3Main.Graphics.Rect(3, 3, 1, 1), 0);

                // render the item text
                int texty = _screenY + _downArrow.Height;
                foreach (KeyValuePair <string, string> item in _items)
                {
                    Gk3Main.Gui.Font.Print(sb, _font, (int)_boxRect.X + 1, texty + _itemVerticalPadding, item.Value);

                    texty += _font.Font.LineHeight + _itemVerticalPadding;
                }
            }
        }
Example #5
0
        public void Render(Graphics.SpriteBatch sb, int x, int y)
        {
            int   currentFrame = (int)((Game.GameManager.TickCount / 1000.0f) * _frameRate) % _frameCount;
            float uWidth       = _cursor.ActualPixelWidth * (_cursor.ActualWidth / _frameCount);
            float u            = uWidth * currentFrame;

            Graphics.Rect src;
            src.X      = u;
            src.Y      = 0;
            src.Width  = uWidth;
            src.Height = _cursor.Height;

            sb.Draw(_cursor, new Math.Vector2(x - _hotX, y - _hotY), src);
        }
Example #6
0
        public void Render(Graphics.SpriteBatch sb, int tickCount)
        {
            // draw the edges
            sb.Draw(_horiz, new Gk3Main.Graphics.Rect(_rect.X, _rect.Y - _horiz.Height, _rect.Width, _horiz.Height), null, 0);
            sb.Draw(_horiz, new Gk3Main.Graphics.Rect(_rect.X, _rect.Y + _rect.Height, _rect.Width, _horiz.Height), null, 0);
            sb.Draw(_vert, new Gk3Main.Graphics.Rect(_rect.X - _vert.Width, _rect.Y, _vert.Width, _rect.Height), null, 0);
            sb.Draw(_vert, new Gk3Main.Graphics.Rect(_rect.X + _rect.Width, _rect.Y, _vert.Width, _rect.Height), null, 0);

            // draw the corners
            sb.Draw(_ul, new Gk3Main.Math.Vector2(_rect.X - _ul.Width, _rect.Y - _ul.Height));
            sb.Draw(_ur, new Gk3Main.Math.Vector2(_rect.X + _rect.Width, _rect.Y - _ur.Height));
            sb.Draw(_ll, new Gk3Main.Math.Vector2(_rect.X - _ll.Width, _rect.Y + _rect.Height));
            sb.Draw(_lr, new Gk3Main.Math.Vector2(_rect.X + _rect.Width, _rect.Y + _rect.Height));

            // draw the background
            sb.Draw(_bg, _rect, null, 0);

            // draw the text
            float posY = _rect.Y + _textOffsetY;

            foreach (string line in _lines)
            {
                Font.Print(sb, _font, (int)(_rect.X + _textOffsetX), (int)posY, line);
                posY += _fontHeight;
            }

            // draw the buttons
            if (_type == MsgBoxType.YesNo)
            {
                _yes.Render(sb, tickCount);
                _no.Render(sb, tickCount);
            }
            else
            {
                _ok.Render(sb, tickCount);
            }
        }