Ejemplo n.º 1
0
        protected override void OnRender(UIRenderContext context)
        {
            Screen.Renderer.EndBatch();

            Rectangle originalViewport = Screen.Renderer.GraphicsDevice.Viewport.Bounds;
            Rectangle viewport = new Rectangle((int)ActualX, (int)ActualY, (int)ActualWidth, (int)ActualHeight);
            if (viewport.Width == 0 || viewport.Height == 0)
                return;
            viewport = Rectangle.Intersect(originalViewport, viewport);

            using (new ViewportScope(Screen.Renderer.GraphicsDevice, new Viewport(viewport)))
            {
                if (_minimap == null)
                {
                    Camera.Camera2D minimapCam = new Camera.Camera2D(null, false);
                    minimapCam.CamViewPortHeight = (int)ActualHeight;
                    minimapCam.CamViewPortWidth = (int)ActualWidth;
                    minimapCam.CamWorldHeight = _gameManager.Galaxy.Height; //Should be gotten from the current Galaxy in GameManager
                    minimapCam.CamWorldWidth = _gameManager.Galaxy.Width; //Should be gotten from the current Galaxy in GameManager
                    minimapCam.Pos = new Vector2(minimapCam.CamWorldWidth / 2, minimapCam.CamWorldHeight / 2);

                    _minimap = RenderMiniMap(minimapCam, Screen.Renderer.GraphicsDevice);
                }

                RenderMinimapWithOverlay(Screen.Renderer.SpriteBatch);
            }
            base.OnRender(context);
        }
Ejemplo n.º 2
0
    protected override void OnRender(UIRenderContext context)
    {
      _sampleTime += context.DeltaTime;
      _numberOfFrames++;

      if (_sampleTime > SampleInterval)
      {
        Text = string.Format("FPS: {0}", (int)(_numberOfFrames / (float)_sampleTime.TotalSeconds + 0.5f));
        _sampleTime = TimeSpan.Zero;
        _numberOfFrames = 0;
      }

      base.OnRender(context);
    }
Ejemplo n.º 3
0
    public void RenderTreeViewItem(UIControl control, UIRenderContext context)
    {
      var treeViewItem = control as TreeViewItem;
      if (treeViewItem != null && treeViewItem.IsSelected && treeViewItem.Header != null)
      {
        // Draw a blue rectangle behind selected tree view items.
        context.RenderTransform.Draw(
          SpriteBatch,
          WhiteTexture,
          treeViewItem.Header.ActualBounds,
          null,
          Color.CornflowerBlue);
      }

      // Call the default render callback to draw all the rest.
      RenderCallbacks["UIControl"](control, context);
    }
Ejemplo n.º 4
0
        /// <inheritdoc/>
        protected override void OnRender(UIRenderContext context)
        {
            // Make sure the layout is up-to-date.
            UpdateLayout();

            var originalScissorRectangle = Renderer.GraphicsDevice.ScissorRectangle;

            // The renderer uses scissor test. We need to set a default rectangle.
            // (In MonoGame with OpenGL, the default scissor rectangle might not cover the full screen.)
            Renderer.GraphicsDevice.ScissorRectangle = ActualBounds.ToRectangle(true);

            // Start the rendering process.
            Renderer.BeginBatch();
            Renderer.Render(this, context);
            Renderer.EndBatch();

            Renderer.GraphicsDevice.ScissorRectangle = originalScissorRectangle;
        }
        protected override void OnRender(UIRenderContext context)
        {
            IUIRenderer renderer = Screen.Renderer;
            renderer.EndBatch();
            GraphicsDevice graphicsDevice = renderer.GraphicsDevice;

            Rectangle originalViewport = graphicsDevice.Viewport.Bounds;
            var viewport = new Rectangle((int)ActualX, (int)ActualY, (int)ActualWidth, (int)ActualHeight);
            if (viewport.Width == 0 || viewport.Height == 0)
                return;
            viewport = Rectangle.Intersect(originalViewport, viewport);

            using (new ViewportScope(graphicsDevice, new Viewport(viewport)))
            {
                OnCustomRendering();
            }

            base.OnRender(context);
        }
Ejemplo n.º 6
0
        /// <inheritdoc/>
        protected override void OnRender(UIRenderContext context)
        {
            if (!IsVisualValid)
            {
                // ----- Store VisualLines as info for the renderer.
                int lineCount = _wrappedLines.Count;                             // The total number of lines.
                int startLine = ComputeStartWrappedLine();                       // The index of the first visual line.
                int endLine   = Math.Min(lineCount, startLine + _numberOfLines); // The exclusive end line.
                VisualLines.Clear();
                for (int i = startLine; i < endLine; i++)
                {
                    VisualLines.Add(_wrappedLines[i]);
                }

                // ----- Determine the position for the caret line.
                // The number of lines for the wrapped current text.
                int numberOfLinesInCurrentText = (int)Math.Ceiling((float)(Prompt.Length + Text.Length) / _numberOfColumns);

                // The line index of the cursor relative to the wrapped current text.
                int cursorLineInCurrentText = (Prompt.Length + CaretIndex) / _numberOfColumns;

                // If the cursor is exactly in the last column of the last line, then it should not skip
                // to the next line (because there is no VisualLine for that).
                if (cursorLineInCurrentText * _numberOfColumns == (Prompt.Length + Text.Length))
                {
                    cursorLineInCurrentText--;
                }

                // The line index of the cursor relative to startLine.
                VisualCaretY = lineCount - numberOfLinesInCurrentText + cursorLineInCurrentText - startLine;

                // The column index of the cursor.
                VisualCaretX = Prompt.Length + CaretIndex - cursorLineInCurrentText * _numberOfColumns;

                if (VisualCaretY < 0 || VisualCaretY >= _numberOfLines)
                {
                    VisualCaretX = VisualCaretY = -1;
                }
            }

            base.OnRender(context);
        }
Ejemplo n.º 7
0
    /// <inheritdoc/>
    protected override void OnRender(UIRenderContext context)
    {
      if (!IsVisualValid)
      {
        // ----- Store VisualLines as info for the renderer.
        int lineCount = _wrappedLines.Count;                           // The total number of lines.
        int startLine = ComputeStartWrappedLine();                     // The index of the first visual line.
        int endLine = Math.Min(lineCount, startLine + _numberOfLines); // The exclusive end line.
        VisualLines.Clear();
        for (int i = startLine; i < endLine; i++)
          VisualLines.Add(_wrappedLines[i]);

        // ----- Determine the position for the caret line.
        // The number of lines for the wrapped current text.
        int numberOfLinesInCurrentText = (int)Math.Ceiling((float)(Prompt.Length + Text.Length) / _numberOfColumns);

        // The line index of the cursor relative to the wrapped current text.
        int cursorLineInCurrentText = (Prompt.Length + CaretIndex) / _numberOfColumns;

        // If the cursor is exactly in the last column of the last line, then it should not skip
        // to the next line (because there is no VisualLine for that).
        if (cursorLineInCurrentText * _numberOfColumns == (Prompt.Length + Text.Length))
          cursorLineInCurrentText--;

        // The line index of the cursor relative to startLine.
        VisualCaretY = lineCount - numberOfLinesInCurrentText + cursorLineInCurrentText - startLine;

        // The column index of the cursor.
        VisualCaretX = Prompt.Length + CaretIndex - cursorLineInCurrentText * _numberOfColumns;

        if (VisualCaretY < 0 || VisualCaretY >= _numberOfLines)
          VisualCaretX = VisualCaretY = -1;
      }

      base.OnRender(context);
    }
Ejemplo n.º 8
0
    /// <inheritdoc/>
    protected override void OnRender(UIRenderContext context)
    {
      // Make sure the layout is up-to-date.
      UpdateLayout();

      var originalScissorRectangle = Renderer.GraphicsDevice.ScissorRectangle;

      // The renderer uses scissor test. We need to set a default rectangle. 
      // (In MonoGame with OpenGL, the default scissor rectangle might not cover the full screen.)
      Renderer.GraphicsDevice.ScissorRectangle = ActualBounds.ToRectangle(true);

      // Start the rendering process.
      Renderer.BeginBatch();
      Renderer.Render(this, context);
      Renderer.EndBatch();

      Renderer.GraphicsDevice.ScissorRectangle = originalScissorRectangle;
    }
Ejemplo n.º 9
0
        protected override void OnRender(UIRenderContext context)
        {
            IUIRenderer renderer = Screen.Renderer;
            _graphicsDevice = renderer.GraphicsDevice;

            _gameManager.GalaxyCam.CamViewPortHeight = (int)ActualHeight;
            _gameManager.GalaxyCam.CamViewPortWidth = (int)ActualWidth;

            Rectangle originalViewport = _graphicsDevice.Viewport.Bounds;
            Rectangle viewport = new Rectangle((int)ActualX, (int)ActualY, (int)ActualWidth, (int)ActualHeight);
            if (viewport.Width == 0 || viewport.Height == 0)
                return;
            viewport = Rectangle.Intersect(originalViewport, viewport);

            //We must call this to let everything the UI has currently drawn be drawn, before changing settings for spritebatch
            renderer.EndBatch();

            using (new ViewportScope(_graphicsDevice, new Viewport(viewport)))
            {

                _spritebatch.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null);
                _spritebatch.Draw(_black, new Rectangle(0, 0, (int)ActualWidth, (int)ActualHeight), Color.White);
                _spritebatch.Draw(_textureBackground, new Rectangle(0, 0, (int)ActualWidth, (int)ActualHeight), new Rectangle((int)(1 * (int)-scrollX), (int)(1 * (int)-scrollY), _textureBackground.Width, _textureBackground.Height), Color.White);
                _spritebatch.Draw(_textureParallax, new Rectangle(0, 0, (int)ActualWidth, (int)ActualHeight), new Rectangle((int)(_parallax1SpeedMod * (int)-scrollX), (int)(_parallax1SpeedMod * (int)-scrollY), _textureParallax.Width, _textureParallax.Height), Color.White);
                _spritebatch.Draw(_textureParallax2, new Rectangle(0, 0, (int)ActualWidth, (int)ActualHeight), new Rectangle((int)(_parallax2SpeedMod * (int)-scrollX), (int)(_parallax2SpeedMod * (int)-scrollY), _textureParallax2.Width, _textureParallax2.Height), Color.White);
                _spritebatch.DrawString(_starNameFont, _mousePos.X + " / " + _mousePos.Y, Vector2.Zero, Color.White);
                _spritebatch.DrawString(_starNameFont, _gameManager.GalaxyCam.Pos.X + " / " + _gameManager.GalaxyCam.Pos.Y, Vector2.Zero + new Vector2(0, 20), Color.White);
                _spritebatch.End();

                _spritebatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, _gameManager.GalaxyCam.getTransformation() * _gameManager.GalaxyCam.getScale());
                //Render Decoration
                foreach (Model.GalaxyDecoration decor in _gameManager.Galaxy.Decorations)
                {
                    Util.TextureAtlas atlas = _content.getGalaxyDecorationAtlasFromTextureName(decor.TextureName);
                    if (atlas != null)
                    {
                        _spritebatch.Draw(atlas.AtlasTexture, new Rectangle((int)decor.Position.X, (int)decor.Position.Y, decor.Width, decor.Height), atlas.AtlasCoords[decor.TextureName], Color.White);
                    }
                }

                //Render Stars
                RenderStars();

                _spritebatch.End();

            }

            base.OnRender(context);
        }
Ejemplo n.º 10
0
        /// <summary> Called when the control and its visual children should be
        ///           rendered.</summary>
        ///
        /// <param name="context"> The render context.</param>
        protected override void OnRender(UIRenderContext context)
        {
            _hudOverlay.Render(context);

            _turnButton.IsVisible = TurnManagerObject.CurrentTurn.isAlly;
            _turnButton.Render(context);

            _currentCharacterImage.Render(context);

            base.OnRender(context);
        }