public override void DrawStringBaseline(string fontName, float size, string text, float x, float y, float start_x, Color4 color, bool underline = false, TextShadow shadow = default)
 {
     using (var layout = new TextLayout(dwFactory, text, GetFormat(fontName, ConvertSize(size)), float.MaxValue, float.MaxValue))
     {
         var indent = (x - start_x);
         if (Math.Abs(indent) > 0.001f)
         {
             layout.SetInlineObject(new Indent(indent), new TextRange(0, 0));
         }
         layout.SetDrawingEffect(new ColorDrawingEffect(color, shadow), new TextRange(0, text.Length));
         layout.Draw(Renderer, 0, 0);
         foreach (var q in Renderer.Quads)
         {
             var d = q.Destination;
             d.X += (int)start_x;
             d.Y += (int)y;
             if (q.Texture == null)
             {
                 render2d.FillRectangle(d, q.Color);
             }
             else
             {
                 render2d.Draw(q.Texture, q.Source, d, q.Color);
             }
         }
         Renderer.Quads = new List <DrawQuad>();
     }
 }
Beispiel #2
0
 void Draw(PGQuad *quads, int count)
 {
     if (drawX == int.MaxValue)
     {
         lastQuads = new PGQuad[count];
         for (int i = 0; i < lastQuads.Length; i++)
         {
             lastQuads[i] = quads[i];
         }
         return;
     }
     for (int i = 0; i < count; i++)
     {
         var q = quads[i];
         q.Dest.X += drawX;
         q.Dest.Y += drawY;
         if (q.Texture == (PGTexture *)0)
         {
             ren.FillRectangle(q.Dest, q.Color);
         }
         else
         {
             var t = textures[(int)q.Texture->UserData];
             ren.Draw(t, q.Source, q.Dest, q.Color);
         }
     }
 }
 private void DrawPart(Vector2 pos, Texture2D tex, Nullable <Rectangle> source, float opacity = 1f)
 {
     if (tex != null && pos != null)
     {
         Renderer2D r2d = (Renderer2D)Renderer;
         if (source == null)
         {
             r2d.Draw(tex, pos, Color.White * opacity, BlendState.AlphaBlend);
         }
         else
         {
             r2d.Draw(tex, pos, (Rectangle)source, Color.White * opacity, BlendState.AlphaBlend);
         }
     }
 }
Beispiel #4
0
        protected override void Draw(GameTime time)
        {
            GraphicsDevice.Clear(new Color(51, 51, 51));
            render = new Rectangle(200, 0, GraphicsDevice.Viewport.Width - 200, GraphicsDevice.Viewport.Height - 80);
            if (!ConsoleCommands.FreezeGame)
            {
                GraphicsDevice.SetRenderTarget(gameContent);
                GraphicsDevice.Clear(Color.Black);
                phaseManager.Draw(renderer, time);
                GraphicsDevice.SetRenderTarget(null);
                render = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
                recorder.AddRecordEntry(new RecordEntry(gameContent, time));
            }
            renderer.Begin();
            renderer.Draw(gameContent, render, Color.White);
            if (ConsoleCommands.FreezeGame && ConsoleCommands.PlayLoop)
            {
                recorder.Draw(renderer, time);
            }
            consoleControl.Draw(renderer);
            batch.End();

            TimeWatcher.ClearCurrent();

            base.Draw(time);
        }
Beispiel #5
0
 public void Draw(Renderer2D renderer)
 {
     if (texture != null)
     {
         renderer.Draw(texture, renderSize, Color.White);
     }
 }
Beispiel #6
0
 public void Draw(Renderer2D renderer, GameTime time)
 {
     renderer.Draw(Font.CourierNew14, "UpdateFPS: " + counter.UpdateFPS + "\nDrawFPS: " + counter.DrawFPS, new Vector2(), Color.Green);
     if (time.IsRunningSlowly)
     {
         renderer.DrawRectangle(new Rectangle(0, 0, Control.RenderWidth - 5, Control.RenderHeight - 5), Color.Red, 5);
     }
 }
 public void Draw(Renderer2D renderer, GameTime time)
 {
     Keys[] keys = keyboard.GetPressedKeys();
     for (int i = 0; i < keys.Length; i++)
     {
         renderer.Draw(Font.Arial16, keys[i].ToString(), new Vector2(0, Font.Arial16.PixelHeight * i), Color.White);
     }
 }
Beispiel #8
0
 internal void Draw(Renderer2D renderer)
 {
     renderer.Draw(Prerendered, Vector2.Zero, Color.White);
     foreach (var tile in animatedOrInteractiveTiles)
     {
         if (tile is InteractiveTile interactive)
         {
             interactive.Draw(renderer, Color.White);
         }
     }
 }
Beispiel #9
0
        public void Draw(Renderer2D renderer, GameTime time)
        {
            currentFrame = (currentFrame + 1) % savedFrames.Count;
            var cur = savedFrames.ElementAt(currentFrame);

            renderer.Draw(cur.RenderTarget, Vector2.Zero, Color.White);
            if (time.ElapsedGameTime < cur.Time)
            {
                Thread.Sleep((int)(cur.Time.TotalMilliseconds - time.ElapsedGameTime.TotalMilliseconds));
            }
        }
Beispiel #10
0
        public override void RenderText(BuiltRichText txt, int x, int y)
        {
            var dw = (DirectWriteBuiltText)txt;

            foreach (var q in dw.Quads)
            {
                var d = q.Destination;
                d.X += x;
                d.Y += y;
                if (q.Texture == null)
                {
                    render2d.FillRectangle(d, q.Color);
                }
                else
                {
                    render2d.Draw(q.Texture, q.Source, d, q.Color);
                }
            }
        }
Beispiel #11
0
        protected override void _Draw(Renderer2D renderer)
        {
            input.Draw(renderer);
            label.Draw(renderer);
            if (GameConsole.WaitingMessages > 0)
            {
                waitingMessages.Content = "(" + GameConsole.WaitingMessages + ") Messages waiting. Press Enter to continue";
                waitingMessages.Draw(renderer);
            }
            int yDif = input.Font.PixelHeight;

            foreach (var msg in GameConsole.MessagesToPrint())
            {
                if (msg.HasBackground)
                {
                    renderer.DrawFilledRectangle(new Rectangle(AbsoluteX, AbsoluteY + yDif, Width, Font.CourierNew14.PixelHeight), msg.BackgroundColor);
                }
                renderer.Draw(Font.CourierNew14, msg.Message, new Vector2(AbsoluteX, AbsoluteY + yDif), msg.Color);
                yDif += Font.CourierNew14.PixelHeight;
            }
        }
Beispiel #12
0
 void Draw(PGQuad *quads, PGTexture *texture, int count)
 {
     if (texture == (PGTexture *)0)
     {
         for (int i = 0; i < count; i++)
         {
             var q = quads[i];
             q.Dest.X += drawX;
             q.Dest.Y += drawY;
             ren.FillRectangle(q.Dest, q.Color);
         }
     }
     else
     {
         var t = textures[(int)texture->UserData];
         for (int i = 0; i < count; i++)
         {
             var q = quads[i];
             q.Dest.X += drawX;
             q.Dest.Y += drawY;
             ren.Draw(t, q.Source, q.Dest, q.Color);
         }
     }
 }
Beispiel #13
0
        public void Draw(Renderer2D renderer, Matrix cam, Rectangle areaOfInfluence)
        {
            renderTarget?.Dispose();
            renderTarget     = new RenderTarget2D(renderer.GraphicsDevice, areaOfInfluence.Width, areaOfInfluence.Height);
            oldRenderTargets = renderer.GraphicsDevice.GetRenderTargets();
            renderer.GraphicsDevice.SetRenderTarget(null);
            renderer.GraphicsDevice.SetRenderTarget(renderTarget);
            renderer.GraphicsDevice.Clear(Color.TransparentBlack);

            renderer.End();
            renderer.Begin();
            int x;
            int y;

            int[]     data;
            TileSet   tileSet;
            int       actualData;
            Rectangle sourceRectangle;

            foreach (var layer in map.Layers)
            {
                data = layer.GetRawData();

                for (int i = 0; i < data.Length; i++)
                {
                    if (data[i] == 0)
                    {
                        continue;
                    }
                    x = 16 * (i % map.TileSize.X);
                    y = 16 * (i / map.TileSize.X);
                    if (x + 16 < areaOfInfluence.X || y + 16 < areaOfInfluence.Y ||
                        x - 16 > areaOfInfluence.Right || y - 16 > areaOfInfluence.Bottom)
                    {
                        continue;
                    }

                    tileSet = tileSetsShadow.TileSets.FirstOrDefault(t => t.Name == tileSetsMap.IndexToTileSet(data[i]).Name + "_shadow");

                    if (tileSet == null)
                    {
                        continue;
                    }


                    actualData = tileSetsMap.ShortenIndex(data[i]) + 1;
                    if (tileSetsMap.IsAnimation(data[i]))
                    {
                        var tile = animatedTileLightings.FirstOrDefault(t => t.Index == new DataTypes.Index2((i % map.TileSize.X), (i / map.TileSize.X)));
                        renderer.Draw(tile.Current(), new Rectangle(x - areaOfInfluence.X, y - areaOfInfluence.Y, 16, 16), Color.White);
                        continue;
                    }
                    sourceRectangle = tileSetsShadow.GetSourceRectangle(actualData);

                    renderer.Draw(tileSet.Texture, new Rectangle(x - areaOfInfluence.X, y - areaOfInfluence.Y, 16, 16), sourceRectangle, Color.White);                     //16  //
                }
            }
            renderer.End();
            renderer.GraphicsDevice.SetRenderTarget(null);
            renderer.GraphicsDevice.SetRenderTargets(oldRenderTargets);
            renderer.Begin(cam);
            using (FileStream fs = new FileStream("obstacles.png", FileMode.Create))
                renderTarget.SaveAsPng(fs, renderTarget.Width, renderTarget.Height);
        }
Beispiel #14
0
 protected override void _Draw(Renderer2D renderer)
 {
     renderer.Draw(Font, textInput.TypedText, new Vector2(AbsoluteX, AbsoluteY), TextColor);
 }
Beispiel #15
0
 public void Draw(Renderer2D renderer, Color color)
 {
     renderer.Draw(Animations, new Rectangle(Position.X, Position.Y, Size, Size), color);
 }
Beispiel #16
0
 protected override void _Draw(Renderer2D renderer)
 {
     renderer.Draw(texture, new Vector2(AbsoluteX, AbsoluteY), Color.White);
 }
Beispiel #17
0
 protected override void _Draw(Renderer2D renderer)
 {
     renderer.Draw(Font, Content, new Vector2(AbsoluteX, AbsoluteY), TextColor);
 }