Exemplo n.º 1
0
        public void DefaultDraw(Batcher batcher, Rectangle finalBounds)
        {
            var isEmpty = string.IsNullOrEmpty(TextValue);
            var start   = finalBounds.Location.ToVector2() + new Vector2(Padding);

            batcher.DrawRect(finalBounds, PanelColor);

            // Ghost or normal
            if (isEmpty)
            {
                batcher.DrawString(LabelFont, GhostValue, start, FontGhostColor);
            }
            else
            {
                batcher.DrawString(LabelFont, TextValue, start, FontColor);
            }

            if (Manager?.GetFocus() == this)
            {
                if (caretVisible)
                {
                    var end = LabelFont.MeasureString(isEmpty ? "." : TextValue);
                    batcher.DrawLine(start.X + end.X, start.Y, start.X + end.X, start.Y + end.Y, FontColor);
                }
            }
        }
Exemplo n.º 2
0
        public override void Render(Batcher batcher, Camera camera)
        {
            // nothing is enabled - don't draw the debug view.
            if (Flags == 0)
            {
                return;
            }

            Core.GraphicsDevice.RasterizerState   = RasterizerState.CullNone;
            Core.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            _primitiveBatch.Begin(camera.ProjectionMatrix, camera.TransformMatrix);
            DrawDebugData();
            _primitiveBatch.End();

            if ((Flags & DebugViewFlags.PerformanceGraph) == DebugViewFlags.PerformanceGraph)
            {
                _primitiveBatch.Begin(ref _localProjection, ref _localView);
                DrawPerformanceGraph();
                _primitiveBatch.End();
            }

            // draw any strings we have
            for (int i = 0; i < _stringData.Count; i++)
            {
                batcher.DrawString(Graphics.Instance.BitmapFont, _stringData[i].Text, _stringData[i].Position,
                                   _stringData[i].Color);
            }

            _stringData.Clear();
        }
Exemplo n.º 3
0
        public override void Draw(GameTime gameTime)
        {
            Batcher.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null);
            //background
            Batcher.Draw(WhiteTexture, Window, BackgroundColor);
            //cursor
            int textY = Window.Y + Window.Height - font.LineSpacing;

            if (Activated)
            {
                Batcher.Draw(WhiteTexture, new Rectangle(Window.X + (int)font.MeasureString(line.ToString().Substring(0, CursorPosition)).X, textY, 2, font.LineSpacing), Color.White);
            }
            //command line
            Batcher.DrawString(font, line, new Vector2(Window.X, textY), Color.White);
            //output
            foreach (var outputLine in output.Lines.Reverse())
            {
                textY -= font.LineSpacing;

                if (textY < Window.Y)
                {
                    break;
                }
                Batcher.DrawString(font, outputLine, new Vector2(Window.X, textY), Color.White);
            }

            Batcher.End();

            base.Draw(gameTime);
        }
Exemplo n.º 4
0
 public void DefaultDraw(Batcher batcher, Rectangle finalBounds)
 {
     if (bind != null)
     {
         CheckCache();
     }
     batcher.DrawString(LabelFont, Message, finalBounds.Location.ToVector2(), Color);
 }
Exemplo n.º 5
0
        public override void DebugRender(Batcher batcher)
        {
            base.DebugRender(batcher);

            batcher.DrawString(Graphics.Instance.BitmapFont,
                               "Hello World",
                               Screen.Center - Scene.Camera.InverseTransformMatrix.Translation,
                               Color.White);
        }
Exemplo n.º 6
0
        public override void Draw(Batcher batcher, float parentAlpha)
        {
            Validate();

            var color = ColorExt.Create(this.color, (int)(this.color.A * parentAlpha));

            _style.Background?.Draw(batcher, x, y, width == 0 ? _prefSize.X : width, height, color);

            batcher.DrawString(_style.Font, _wrappedString, new Vector2(x, y) + _textPosition,
                               _style.FontColor, 0, Vector2.Zero, new Vector2(_fontScaleX, _fontScaleY), SpriteEffects.None, 0);
        }
Exemplo n.º 7
0
        public void drawTo(Batcher batcher, IFont font, Vector2 pos)
        {
            // draw each line as a string
            var drawPos = pos;

            foreach (var line in lines)
            {
                batcher.DrawString(font, line.text, drawPos, line.col);
                drawPos += new Vector2(0, font.LineSpacing);
            }
        }
Exemplo n.º 8
0
        public override void Render(Batcher batcher, Camera camera)
        {
            batcher.DrawCircle(Transform.Position, 2, Color.Red);
            batcher.DrawHollowRect((Transform.Position.RoundToPoint() - new Point(0, height * Constants.pixelsPerTile)).ToVector2(), Width, Height, OutlineColour, 6);
            batcher.DrawRect((Transform.Position.RoundToPoint() - new Point(0, height * Constants.pixelsPerTile)).ToVector2(),
                             Width, Height, BackgroundColour);

            for (int y = 0; y < height + 2; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    DrawGridTile(batcher, new Point(x, y));
                }
            }

            foreach (var player in players)
            {
                var piece = player.piece;
                if (piece != null)
                {
                    var ghost = piece.GetLandedOffset();
                    foreach (Point point in piece.Shape)
                    {
                        DrawOutline(batcher, point + piece.position, player.outlineTint, 6);
                        DrawOutline(batcher, point + piece.position + ghost, player.outlineTint, 6);
                    }
                    foreach (Point point in piece.Shape)
                    {
                        Utilities.DrawTile(batcher, point + piece.position + ghost, Transform.Position.ToPoint(), piece.definition.type, piece.definition.type.ghostColor);
                    }
                    foreach (Point point in piece.Shape)
                    {
                        Utilities.DrawTile(batcher, point + piece.position, Transform.Position.ToPoint(), piece.definition.type);
                    }
                    int temp = 0;
                    foreach (Point point in piece.outline)
                    {
                        Point gridOffset = point + piece.position;
                        Point offset     = new Point(Constants.pixelsPerTile * gridOffset.X, -Constants.pixelsPerTile * gridOffset.Y);
                        batcher.DrawCircle(Transform.Position + offset.ToVector2(), 2, Color.Green);
                        batcher.DrawString(Graphics.Instance.BitmapFont, temp + "", Transform.Position + offset.ToVector2(), Color.White);
                        temp++;
                    }
                }
            }
        }
Exemplo n.º 9
0
        public override void DebugRender(Batcher batcher)
        {
            base.DebugRender(batcher);
            debugBuilder.Clear();
            debugBuilder.AppendLine($"{TargetLevel.Project.Name} - {TargetLevel.Name}");
            debugBuilder.Append($"{Tilerenders} Tiles Rendered");

            var str             = debugBuilder.ToString();
            var measurement     = Graphics.Instance.DevFont.MeasureString(str);
            var end             = Bounds.Location + Bounds.Size - measurement - pad;
            var desiredLocation = Entity.Scene.Camera.Bounds.Location + (Entity.Scene.Camera.Bounds.Size * 0.5f);

            desiredLocation.X -= measurement.X * 0.5f;
            desiredLocation.Y  = Entity.Position.Y + pad.Y;
            var final = Vector2.Clamp(Vector2.Max(desiredLocation, Entity.Scene.Camera.Bounds.Location + pad), Entity.Position + pad, end);

            batcher.DrawString(Graphics.Instance.DevFont, str, final, ECDebug.Colors.DebugText);
        }
Exemplo n.º 10
0
        public override void Draw(Batcher batcher, float parentAlpha)
        {
            Validate();

            IDrawable background;

            if (_isDisabled && style.BackgroundDisabled != null)
            {
                background = style.BackgroundDisabled;
            }
            else if (_selectBoxList.HasParent() && style.BackgroundOpen != null)
            {
                background = style.BackgroundOpen;
            }
            else if (_isMouseOver && style.BackgroundOver != null)
            {
                background = style.BackgroundOver;
            }
            else if (style.Background != null)
            {
                background = style.Background;
            }
            else
            {
                background = null;
            }

            var font      = style.Font;
            var fontColor = _isDisabled ? style.DisabledFontColor : style.FontColor;

            var color = GetColor();

            color = ColorExt.Create(color, (int)(color.A * parentAlpha));
            float x      = GetX();
            float y      = GetY();
            float width  = GetWidth();
            float height = GetHeight();

            if (background != null)
            {
                background.Draw(batcher, x, y, width, height, color);
            }

            var selected = _selection.First();

            if (selected != null)
            {
                var str = selected.ToString();
                if (background != null)
                {
                    width  -= background.LeftWidth + background.RightWidth;
                    height -= background.BottomHeight + background.TopHeight;
                    x      += background.LeftWidth;
                    y      += (int)(height / 2 + background.BottomHeight - font.LineHeight / 2);
                }
                else
                {
                    y += (int)(height / 2 + font.LineHeight / 2);
                }

                fontColor = ColorExt.Create(fontColor, (int)(fontColor.A * parentAlpha));
                batcher.DrawString(font, str, new Vector2(x, y), fontColor);
            }
        }
Exemplo n.º 11
0
        public override void Draw(Batcher batcher, float parentAlpha)
        {
            // update our hoved item if the mouse is over the list
            if (_isMouseOverList)
            {
                var mousePos = ScreenToLocalCoordinates(stage.GetMousePosition());
                _hoveredItemIndex = GetItemIndexUnderMousePosition(mousePos);
            }

            Validate();

            var font             = _style.Font;
            var selectedDrawable = _style.Selection;

            var color = GetColor();

            color = new Color(color, (int)(color.A * parentAlpha));

            float x = GetX(), y = GetY(), width = GetWidth(), height = GetHeight();
            var   itemY = 0f;

            var background = _style.Background;

            if (background != null)
            {
                background.Draw(batcher, x, y, width, height, color);
                var leftWidth = background.LeftWidth;
                x     += leftWidth;
                itemY += background.TopHeight;
                width -= leftWidth + background.RightWidth;
            }

            var unselectedFontColor =
                new Color(_style.FontColorUnselected, (int)(_style.FontColorUnselected.A * parentAlpha));
            var selectedFontColor =
                new Color(_style.FontColorSelected, (int)(_style.FontColorSelected.A * parentAlpha));
            var   hoveredFontColor = new Color(_style.FontColorHovered, (int)(_style.FontColorHovered.A * parentAlpha));
            Color fontColor;

            for (var i = 0; i < _items.Count; i++)
            {
                if (!_cullingArea.HasValue ||
                    (itemY - _itemHeight <= _cullingArea.Value.Y + _cullingArea.Value.Height &&
                     itemY >= _cullingArea.Value.Y))
                {
                    var item     = _items[i];
                    var selected = _selection.Contains(item);
                    if (selected)
                    {
                        selectedDrawable.Draw(batcher, x, y + itemY, width, _itemHeight, color);
                        fontColor = selectedFontColor;
                    }
                    else if (i == _hoveredItemIndex && _style.HoverSelection != null)
                    {
                        _style.HoverSelection.Draw(batcher, x, y + itemY, width, _itemHeight, color);
                        fontColor = hoveredFontColor;
                    }
                    else
                    {
                        fontColor = unselectedFontColor;
                    }

                    var textPos = new Vector2(x + _textOffsetX, y + itemY + _textOffsetY);
                    batcher.DrawString(font, item.ToString(), textPos, fontColor);
                }
                else if (itemY < _cullingArea.Value.Y)
                {
                    break;
                }

                itemY += _itemHeight;
            }
        }
Exemplo n.º 12
0
 public override void Render(Batcher batcher, Camera camera)
 {
     batcher.DrawString(Graphics.Instance.BitmapFont, Input.MousePosition.ToString(), Input.MousePosition, Color.White);
 }
Exemplo n.º 13
0
        public override void Draw(Batcher batcher, float parentAlpha)
        {
            var font      = style.Font;
            var fontColor = (disabled && style.DisabledFontColor.HasValue)
                                ? style.DisabledFontColor.Value
                                : ((_isFocused && style.FocusedFontColor.HasValue) ? style.FocusedFontColor.Value : style.FontColor);
            IDrawable selection  = style.Selection;
            IDrawable background = (disabled && style.DisabledBackground != null)
                                ? style.DisabledBackground
                                : ((_isFocused && style.FocusedBackground != null) ? style.FocusedBackground : style.Background);

            var color  = GetColor();
            var x      = GetX();
            var y      = GetY();
            var width  = GetWidth();
            var height = GetHeight();

            float bgLeftWidth = 0, bgRightWidth = 0;

            if (background != null)
            {
                background.Draw(batcher, x, y, width, height, ColorExt.Create(color, (int)(color.A * parentAlpha)));
                bgLeftWidth  = background.LeftWidth;
                bgRightWidth = background.RightWidth;
            }

            var textY   = GetTextY(font, background);
            var yOffset = (textY < 0) ? -textY - font.LineHeight / 2f + GetHeight() / 2 : 0;

            CalculateOffsets();

            if (_isFocused && hasSelection && selection != null)
            {
                DrawSelection(selection, batcher, font, x + bgLeftWidth, y + textY + yOffset);
            }

            if (displayText.Length == 0)
            {
                if (!_isFocused && messageText != null)
                {
                    var messageFontColor = style.MessageFontColor.HasValue
                                                ? style.MessageFontColor.Value
                                                : new Color(180, 180, 180, (int)(color.A * parentAlpha));
                    var messageFont = style.MessageFont != null ? style.MessageFont : font;
                    batcher.DrawString(messageFont, messageText,
                                       new Vector2(x + bgLeftWidth, y + textY + yOffset), messageFontColor);

                    //messageFont.draw( batcher.batcher, messageText, x + bgLeftWidth, y + textY + yOffset, 0, messageText.length(),
                    //	width - bgLeftWidth - bgRightWidth, textHAlign, false, "..." );
                }
            }
            else
            {
                var col = ColorExt.Create(fontColor, (int)(fontColor.A * parentAlpha));
                var t   = displayText.Substring(visibleTextStart, visibleTextEnd - visibleTextStart);
                batcher.DrawString(font, t, new Vector2(x + bgLeftWidth + textOffset, y + textY + yOffset),
                                   col);
            }

            if (_isFocused && !disabled)
            {
                Blink();
                if (cursorOn && style.Cursor != null)
                {
                    DrawCursor(style.Cursor, batcher, font, x + bgLeftWidth, y + textY + yOffset);
                }
            }
        }
        public override void Render(Batcher batcher, Camera camera)
        {
            UiLayout();

            batcher.DrawString(_defaultFont, "Press Left Mouse Button to add obstacles\n Right Mouse Button to add path nodes", Vector2.One * 16, Color.Black);
        }
Exemplo n.º 15
0
 public void DefaultDraw(Batcher batcher, Rectangle finalBounds)
 {
     realColor = Color.Lerp(realColor, target, 5f * Time.UnscaledDeltaTime);
     batcher.DrawRect(finalBounds, realColor);
     batcher.DrawString(LabelFont, Message, finalBounds.Location.ToVector2() + new Vector2(Padding, Padding), FontColor);
 }