예제 #1
0
파일: Font.cs 프로젝트: shff/gk3tools
        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;
                }
            }
        }
예제 #2
0
 public void Render(Graphics.SpriteBatch sb, int tickCount)
 {
     foreach (Button b in _buttons)
     {
         b.Render(sb, tickCount);
     }
 }
예제 #3
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);
        }
예제 #4
0
파일: GuiMaster.cs 프로젝트: shff/gk3tools
        public static bool Render(Graphics.SpriteBatch sb, int tickCount)
        {
            bool mouseIntercepted = false;

            // remove inactive layers
            for (int i = _layers.Count - 1; i >= 0; i--)
            {
                if (_layers[i].IsActive == false)
                {
                    _layers.RemoveAt(i);
                }
                else
                {
                    break;
                }
            }

            // look for the first layer that needs rendering...
            int firstNonPopupLayer = _layers.Count - 1;

            while (firstNonPopupLayer >= 0 && _layers[firstNonPopupLayer].IsPopup)
            {
                firstNonPopupLayer--;
            }

            if (firstNonPopupLayer < 0)
            {
                firstNonPopupLayer = 0;
            }

            // now start rendering layers
            for (int i = firstNonPopupLayer; i < _layers.Count; i++)
            {
                _layers[i].Render(sb, tickCount);

                if (_layers[i].InterceptMouse)
                {
                    mouseIntercepted = true;
                }
            }

            return(mouseIntercepted);
        }
예제 #5
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);
                        }
                    }
                }
            }
        }
예제 #6
0
파일: Button.cs 프로젝트: shff/gk3tools
        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);
            }
        }
예제 #7
0
파일: Dropdown.cs 프로젝트: shff/gk3tools
        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;
                }
            }
        }
예제 #8
0
파일: MsgBox.cs 프로젝트: shff/gk3tools
        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);
            }
        }
예제 #9
0
파일: Game.cs 프로젝트: johang88/triton
 /// <summary>
 /// Preload resources before the main loop is started
 /// </summary>
 protected virtual void LoadCoreResources()
 {
     DebugFont = CoreResources.Load<Triton.Graphics.Resources.BitmapFont>("/fonts/system_font");
     SpriteRenderer = GraphicsBackend.CreateSpriteBatch();
 }
예제 #10
0
        private static void LoadContent()
        {
            MyRender.Log.WriteLine("MyRender.LoadContent() - START");

            MyRender.GetRenderProfiler().StartProfilingBlock("MyRender::LoadContent");

            m_screenshot = null;

            DumpSettingsToLog();

            UpdateScreenSize();

            CreateRenderTargets();
            CreateEnvironmentMapsRT(MyRenderConstants.ENVIRONMENT_MAP_SIZE);

            DefaultSurface = GraphicsDevice.GetRenderTarget(0);
            DefaultSurface.DebugName = "DefaultSurface";
            DefaultDepth = GraphicsDevice.DepthStencilSurface;
            DefaultDepth.DebugName = "DefaultDepth";

            m_randomTexture = CreateRandomTexture();

            LoadEffects();

            if (m_shadowRenderer == null)
            {
                m_shadowRenderer = new MyShadowRenderer(GetShadowCascadeSize(), MyRenderTargets.ShadowMap, MyRenderTargets.ShadowMapZBuffer, true);
            }

            if (m_spotShadowRenderer == null)
                m_spotShadowRenderer = new MySpotShadowRenderer();


            foreach (var renderComponent in m_renderComponents)
            {
                renderComponent.Value.LoadContent(GraphicsDevice);
            }

            m_spriteBatch = new Graphics.SpriteBatch(GraphicsDevice, "SpriteBatch");
            m_fullscreenQuad = new MyFullScreenQuad();

            BlankTexture = MyTextureManager.GetTexture<MyTexture2D>("Textures\\GUI\\Blank.dds", flags: TextureFlags.IgnoreQuality);

            MyEnvironmentMap.Reset();

            foreach (var ro in m_renderObjects)
            {
                ro.Value.LoadContent();
            }

            LoadContent_Video();

            MyRender.GetRenderProfiler().EndProfilingBlock();

            MyRender.Log.WriteLine("MyRender.LoadContent() - END");
        }