Пример #1
0
        public override void Draw(GameTime gameTime)
        {
            if (Texture != null)
            {
                //Lazy initializing
                if (SpriteBatch == null)
                {
                    SpriteBatch = new SpriteBatch(this.GraphicsDevice);
                }

                Matrix DrawMatrix = Matrix.CreateScale(Scale);

                SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, DrawMatrix);
                SpriteBatch.Draw(Texture, new Rectangle(-HorizontalSB.Value, -VerticalSB.Value, Texture.Width, Texture.Height), Color.White);

                for (int i = 0; i < BUFFER_SIZE; i++)
                {
                    if (Buffer[i].Region != Rectangle.Empty && i != CurrentBufferIndex)
                    {
                        Selection _sel = Buffer[i];
                        SelectionUtil.DrawRectangle(SpriteBatch, Color.Black * .4f, new Rectangle(_sel.Region.X - HorizontalSB.Value, _sel.Region.Y - VerticalSB.Value, _sel.Region.Width, _sel.Region.Height));
                        SelectionUtil.FillRectangle(SpriteBatch, Color.White * .2f, new Rectangle(_sel.Region.X + 1 - HorizontalSB.Value, _sel.Region.Y + 1 - VerticalSB.Value, _sel.Region.Width - 1, _sel.Region.Height - 1));
                    }
                }

                Selection sel = Buffer[CurrentBufferIndex];
                SelectionUtil.DrawRectangle(SpriteBatch, Color.Black * .7f, new Rectangle(sel.Region.X - HorizontalSB.Value, sel.Region.Y - VerticalSB.Value, sel.Region.Width, sel.Region.Height));
                SelectionUtil.FillRectangle(SpriteBatch, Color.White * .4f, new Rectangle(sel.Region.X + 1 - HorizontalSB.Value, sel.Region.Y + 1 - VerticalSB.Value, sel.Region.Width - 1, sel.Region.Height - 1));

                SpriteBatch.End();
            }
        }
Пример #2
0
        public void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = EditorEngine.Instance.World.ViewData.SpriteBatch;

            foreach (MapEntity worldEntity in SelectedEntities)
            {
                this.drawOverlay(worldEntity, gameTime);
            }
            foreach (MapEntity worldEntity in EntitiesToSelect)
            {
                this.drawOverlay(worldEntity, gameTime);
            }

            if (this.selectedRegion != Rectangle.Empty)
            {
                float   scale  = EditorEngine.Instance.World.Camera.Scale;
                Vector2 scroll = EditorEngine.Instance.World.Camera.Location;

                Rectangle displayRegion = new Rectangle((int)(this.selectedRegion.X * scale), (int)(this.selectedRegion.Y * scale), (int)(selectedRegion.Width * scale), (int)(selectedRegion.Height * scale)).Add(scroll);

                SelectionUtil.DrawRectangle(
                    spriteBatch,
                    Color.Black,
                    new Rectangle(
                        displayRegion.X + 1,
                        displayRegion.Y + 1,
                        displayRegion.Width,
                        displayRegion.Height));

                SelectionUtil.DrawRectangle(spriteBatch, Color.White, displayRegion);
            }
        }
Пример #3
0
        public override void Draw(GameTime gameTime)
        {
            //this.GraphicsDevice.Clear(Color.CornflowerBlue);

            this.spriteBatch.Begin();
            if (this.Tileset != null)
            {
                this.spriteBatch.Draw(
                    this.Tileset.Texture.Texture,
                    new Vector2(0, -this.scrollBar.Value),
                    Color.White);
            }
            Vector2 position = new Vector2(this.selection.Region.X, this.selection.Region.Y) * new Vector2(16, 16);

            position -= new Vector2(0, scrolling.Value);

            SelectionUtil.DrawRectangle(
                this.spriteBatch,
                Color.Black,
                new Rectangle(
                    this.selection.Region.X * 16 + 1,
                    this.selection.Region.Y * 16 + 1 - this.scrollBar.Value,
                    this.selection.Region.Width * 16,
                    this.selection.Region.Height * 16));

            SelectionUtil.DrawRectangle(
                this.spriteBatch,
                Color.White,
                new Rectangle(
                    this.selection.Region.X * 16,
                    this.selection.Region.Y * 16 - this.scrollBar.Value,
                    this.selection.Region.Width * 16,
                    this.selection.Region.Height * 16));
            this.spriteBatch.End();
        }
Пример #4
0
        public override void Draw(GameTime gameTime)
        {
            if (SpriteBatch == null)
            {
                SpriteBatch = new SpriteBatch(GraphicsDevice);
            }

            if (Template != null && Template.Texture != null)
            {
                Rectangle dest = Template.Texture.GetSource(0);
                SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise);
                if (Mode == 0)                   /*Viewer*/
                {
                    SpriteBatch.Draw(Template.Texture.Texture, dest, Template.Texture.GetSource(0), Color.White);
                }
                else if (Mode == 1)                     /*Collisions*/
                {
                    SpriteBatch.Draw(Template.Texture.Texture, dest, Color.White);

                    Color col  = new Color(255, 75, 0, 255);
                    Color col2 = new Color(250, 35, 0, 255);
                    foreach (Rectangle rect in Template.CollisionMap)
                    {
                        Rectangle w1 = new Rectangle(rect.X * 16, rect.Y * 16, rect.Width * 16, rect.Height * 16);
                        Rectangle w2 = new Rectangle(rect.X * 16 + 1, rect.Y * 16 + 1, rect.Width * 16 - 1, rect.Height * 16 - 1);

                        SelectionUtil.DrawRectangle(SpriteBatch, col * .7f, w1);
                        SelectionUtil.FillRectangle(SpriteBatch, col2 * .3f, w2);
                    }

                    Rectangle ww = new Rectangle(selection.Region.X * 16, selection.Region.Y * 16, selection.Region.Width * 16, selection.Region.Height * 16);
                    SelectionUtil.DrawRectangle(SpriteBatch, Color.White, ww);
                }
                else if (Mode == 2)
                {
                    Vector2   pos    = new Vector2(0, Template.ShadowOffset);
                    Rectangle src    = Template.Texture.GetSource(0);
                    Rectangle target = new Rectangle((int)pos.X, (int)pos.Y, Template.Texture.FrameWidth, (int)(Template.Texture.FrameHeight * 0.6f));
                    if (Template.ShadowType == ShadowType.Perspective)
                    {
                        SpriteBatch.Draw(Template.Texture.Texture, target, src, new Color(0f, 0f, 0f, 0.3f), 0.0f, Vector2.Zero, SpriteEffects.FlipVertically, 0f);
                    }
                    SpriteBatch.Draw(Template.Texture.Texture, dest, Color.White);

                    SelectionUtil.DrawStraightLine(SpriteBatch, Color.White, 0, Template.ShadowOffset, 1, Width);
                }
                SpriteBatch.End();
            }
        }
Пример #5
0
        public void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            Vector2     position = new Vector2(this.selection.Region.X, this.selection.Region.Y) * new Vector2(16, 16);
            SpriteBatch batch    = EditorEngine.Instance.World.ViewData.SpriteBatch;

            if (batch != null && capturedmouse)
            {
                Vector2 scroll = EditorEngine.Instance.World.Camera.Location;
                float   scale  = EditorEngine.Instance.World.Camera.Scale;

                Rectangle target = new Rectangle((int)(position.X * scale), (int)(position.Y * scale), (int)(selection.Region.Width * 16 * scale), (int)(selection.Region.Height * 16 * scale)).Add(scroll);

                SelectionUtil.FillRectangle(batch, Color.Blue * .35f, target);
                SelectionUtil.DrawRectangle(batch, Color.Black, target.Add(new Vector2(1, 1)));
                SelectionUtil.DrawRectangle(batch, Color.White, target);
            }
        }
Пример #6
0
        public void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            SpriteBatch spriteBatch = EditorEngine.Instance.World.ViewData.SpriteBatch;

            if (selection.Region != Rectangle.Empty)
            {
                int xs = (int)EditorEngine.Instance.World.Camera.Location.X;
                int ys = (int)EditorEngine.Instance.World.Camera.Location.Y;

                float   scale  = EditorEngine.Instance.World.Camera.Scale;
                Vector2 scroll = EditorEngine.Instance.World.Camera.Location;

                Rectangle target = new Rectangle((int)(selection.Region.X * scale * 16 + scroll.X), (int)(selection.Region.Y * scale * 16 + scroll.Y), (int)(selection.Region.Width * 16 * scale), (int)(selection.Region.Height * 16 * scale));

                SelectionUtil.DrawRectangle(spriteBatch, Color.Black, target.Add(new Vector2(1, 1)));
                SelectionUtil.DrawRectangle(spriteBatch, Color.White, target);
            }
        }
Пример #7
0
        public void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            SpriteBatch batch = EditorEngine.Instance.World.ViewData.SpriteBatch;

            if (batch != null)
            {
                foreach (LogicPathSquare sq in path)
                {
                    float   scale  = EditorEngine.Instance.World.Camera.Scale;
                    Vector2 scroll = EditorEngine.Instance.World.Camera.Location;

                    Rectangle target = new Rectangle((int)(sq.x * 16 * scale), (int)(sq.y * 16 * scale), (int)(16 * scale), (int)(16 * scale)).Add(scroll);

                    SelectionUtil.DrawRectangle(batch, Color.CornflowerBlue * .7f, target);
                    SelectionUtil.DrawRectangle(batch, Color.Black * .8f, target.Add(new Vector2(1, 1)));
                }
            }
        }
Пример #8
0
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            int ypos = vscrollbar.Value;
            int xpos = hscrollbar.Value;

            if (Tileset != null)
            {
                if (Tileset.Texture != null && Tileset.Texture.Texture != null)
                {
                    batch.Begin();
                    batch.Draw(Tileset.Texture.Texture, -new Vector2(xpos, ypos), Color.White);

                    int x = Tileset.Texture.Texture.Width - xpos;
                    int y = Tileset.Texture.Texture.Height - ypos;

                    SelectionUtil.DrawStraightLine(batch, new Color(.9f, .4f, .4f, 1f), 1f, x, -ypos, 2, Tileset.Texture.Texture.Height);                    //vertical
                    SelectionUtil.DrawStraightLine(batch, new Color(.9f, .4f, .4f, 1f), 1f, -xpos, y, 1, Tileset.Texture.Texture.Width);                     //horizontal

                    SelectionUtil.DrawRectangle(batch, new Color(.7f, .1f, 0f, .6f), new Rectangle((xt << 4) - xpos, (yt << 4) - ypos, 16, 16));
                    SelectionUtil.FillRectangle(batch, new Color(.4f, .1f, 0f, .6f), new Rectangle((xt << 4) + 1 - xpos, (yt << 4) + 1 - ypos, 16, 16));

                    int ry = 0;
                    int rx = 0;
                    foreach (Tile t in Tileset.Tiles)
                    {
                        if (rx + 1 > Tileset.Texture.Texture.Width / 16)
                        {
                            rx = 0;
                            ry++;
                        }
                        batch.Draw(ox.Texture, new Rectangle((rx << 4) - xpos, (ry << 4) - ypos, 16, 16), ox.GetSource(t.DefaultBehavior.BehaviorId == this.Behavior ? 0 : 1), Color.White * 0.8f);
                        rx++;
                    }
                    batch.End();
                }
            }

            base.Draw(gameTime);
        }
Пример #9
0
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            if (initialized)
            {
                this.spriteBatch.Begin();
                if (this.sheet != null)
                {
                    this.spriteBatch.Draw(
                        this.sheet.Texture.Texture,
                        new Vector2(0, -scrollBar.Value),
                        Color.White);
                }
                this.spriteBatch.End();

                Selection selection = new Selection();
                selection.Start(new Vector2(xt << 4, yt << 4));
                selection.End(new Vector2(xt << 4, yt << 4));
                SelectionUtil.DrawRectangle(
                    this.spriteBatch,
                    Color.Black,
                    new Rectangle(
                        selection.Region.X * 16 + 1,
                        selection.Region.Y * 16 + 1 - this.scrollBar.Value,
                        selection.Region.Width * 16,
                        selection.Region.Height * 16));

                SelectionUtil.DrawRectangle(
                    this.spriteBatch,
                    Color.White,
                    new Rectangle(
                        selection.Region.X * 16,
                        selection.Region.Y * 16 - this.scrollBar.Value,
                        selection.Region.Width * 16,
                        selection.Region.Height * 16));
            }
            base.Draw(gameTime);
        }
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.Draw(gameTime);
            if (this.initialized)
            {
                spriteBatch.Begin();

                for (byte i = 0; i < collisions.Count; i++)
                {
                    Rectangle    rect = collisions[i];
                    TileBehavior b    = TileBehavior.GetBehavior(i);

                    spriteBatch.Draw(pixel, rect, b.Color);
                    const int font = 2;
                    FontRenderer.Instance.Draw(spriteBatch, b.Identifier, font, (int)(rect.X + 16 / 2 - Math.Floor(FontRenderer.Instance.Width(b.Identifier, font) / 2f)), rect.Y + 14);
                    if (i == this.SelectedId)
                    {
                        SelectionUtil.DrawRectangle(spriteBatch, Color.Red, new Rectangle(rect.X, rect.Y, rect.Width - 1, rect.Height - 1));
                    }
                }

                spriteBatch.End();
            }
        }
Пример #11
0
        public override void Draw(Microsoft.Xna.Framework.GameTime time)
        {
            spriteBatch.Begin();

            int x = 0;
            int y = 0;

            try {
                foreach (TileLogicScript logic in TileLogicManager.Instance.logics)
                {
                    Tileset _s_0 = EditorEngine.Instance.GetTilesetByName(logic.s_0);
                    int     _s_1 = logic.s_1;

                    if ((x << 4) + 16 > this.Width)
                    {
                        y++;
                        x = 0;
                    }

                    Rectangle srcRect    = _s_0.Texture.GetSource(_s_1);
                    Rectangle targetRect = new Rectangle(x << 4, (y << 4) - scrollbar.Value, 16, 16);

                    spriteBatch.Draw(_s_0.Texture.Texture, targetRect, srcRect, Color.White);
                    x += 1;
                }

                this.yMax = y << 4;

                if (!initializedYMax)
                {
                    initializedYMax = true;
                    refreshScrollbar();
                }
            } catch (Exception e) {
                Console.WriteLine("Bullshit occured: " + e);
            }

            Selection selection = new Selection();

            selection.Start(new Vector2(xt << 4, yt << 4));
            selection.End(new Vector2(xt << 4, yt << 4));

            SelectionUtil.DrawRectangle(
                spriteBatch,
                Color.Black,
                new Rectangle(
                    selection.Region.X * 16 + 1,
                    selection.Region.Y * 16 + 1 - this.scrollbar.Value,
                    selection.Region.Width * 16,
                    selection.Region.Height * 16));

            SelectionUtil.DrawRectangle(
                spriteBatch,
                Color.White,
                new Rectangle(
                    selection.Region.X * 16,
                    selection.Region.Y * 16 - this.scrollbar.Value,
                    selection.Region.Width * 16,
                    selection.Region.Height * 16));
            spriteBatch.End();
        }