Beispiel #1
0
        public void DrawDebugs(SpriteBatch spriteBatch)
        {
            foreach (KeyValuePair <string, DebugDraw> e in p_DrawDebugs)
            {
                switch (e.Value.DrawMode)
                {
                case DebugDrawMode.Rectangle:
                    spriteBatch.DrawRectangle(e.Value.DrawRect, e.Value.Color, 1f);
                    break;

                case DebugDrawMode.Line:
                    spriteBatch.DrawLine(e.Value.DrawLine.StartPoint, e.Value.DrawLine.EndPoint, e.Value.Color, 1f);
                    break;

                case DebugDrawMode.Text:
                    spriteBatch.DrawString(ContentLoader.GetFontByName("NullFont"), e.Value.DrawString, e.Value.DistinationRect, e.Value.Color);
                    break;

                case DebugDrawMode.Point:
                    var pixel = new Texture2D(spriteBatch.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                    pixel.SetData(new[] { Color.White });
                    spriteBatch.Draw(pixel, e.Value.DrawPoint.ToVector2(), e.Value.Color);
                    break;

                case DebugDrawMode.None:
                    break;
                }
            }

            foreach (Entity e in EntitiesToDebug)
            {
                spriteBatch.DrawRectangle(e.p_DrawArea, Color.Black, 1f);
            }
        }
Beispiel #2
0
        public TextBox(TextBoxProps textBoxProps) : base(textBoxProps)
        {
            Lines.Add("");

            p_Font     = ContentLoader.GetFontByName("BitStreamRoman");
            p_mode     = TextBoxMode.Multiline;
            p_WordWrap = true;
        }
Beispiel #3
0
        public void Draw(SpriteBatch spriteBatch)
        {
            fps.Update(p_gameTime.ElapsedGameTime.TotalSeconds);

            int newScreenWidth  = spriteBatch.GraphicsDevice.Viewport.Width;
            int newScreenHeight = spriteBatch.GraphicsDevice.Viewport.Height;

            if (ScreenWidth != newScreenWidth || ScreenHeight != newScreenHeight)
            {
                ScreenWidth  = newScreenWidth;
                ScreenHeight = newScreenHeight;
                Root.MarkasRectUpdate();
            }

            if (UseRenderTarget)
            {
                if (p_renderTarget == null || p_renderTarget.Width != ScreenWidth || p_renderTarget.Height != ScreenHeight)
                {
                    DisposeRenderTarget();
                    p_renderTarget = new RenderTarget2D(spriteBatch.GraphicsDevice,
                                                        ScreenWidth, ScreenHeight, false,
                                                        spriteBatch.GraphicsDevice.PresentationParameters.BackBufferFormat,
                                                        spriteBatch.GraphicsDevice.PresentationParameters.DepthStencilFormat, 0,
                                                        RenderTargetUsage.PreserveContents);
                }
                else
                {
                    spriteBatch.GraphicsDevice.SetRenderTarget(p_renderTarget);
                    spriteBatch.GraphicsDevice.Clear(Color.Transparent);
                }
            }

            Root.Draw(spriteBatch);

            if (ShowCursor && (IncludeCursorInRenderTarget || !UseRenderTarget))
            {
                DrawCursor(spriteBatch);
            }

            string FPS = string.Format("DrawsPS: {0}", (int)fps.AverageFramesPreSecond);

            spriteBatch.Begin();
            spriteBatch.DrawString(ContentLoader.GetFontByName("NullFont"), FPS, new Vector2(ScreenWidth - ContentLoader.GetFontByName("NullFont").MeasureString("DrawsPS: 0000").X, 1), Color.Black);
            spriteBatch.DrawString(ContentLoader.GetFontByName("NullFont"), UpdatesPreSecound, new Vector2(ScreenWidth - ContentLoader.GetFontByName("NullFont").MeasureString("UpdatesPS: 0000").X, ContentLoader.GetFontByName("NullFont").MeasureString("UpdatesPS: 0000").Y + 1), Color.Black);
            spriteBatch.End();

            debugUtils.BeforeDrawDebugs(spriteBatch);
            spriteBatch.Begin();
            debugUtils.DrawDebugs(spriteBatch);
            spriteBatch.End();

            if (UseRenderTarget)
            {
                spriteBatch.GraphicsDevice.SetRenderTarget(null);
            }
        }
Beispiel #4
0
 protected SpriteFont GetCurrentFont()
 {
     return(ContentLoader.GetFontByName("BitStreamRoman"));
 }