예제 #1
0
        public void Draw(DevicePanel d)
        {
            if (!Visible)
            {
                return;
            }

            bool LoopX = true;

            bool DrawLined = Editor.Instance.EditLayer != this && Layer.ScrollIndexes.Length > 1;

            int Transperncy = (Editor.Instance.EditLayer != null && Editor.Instance.EditLayer != this) ? 0x32 : 0xFF;

            Rectangle screen = d.GetScreen();

            int alteredX = screen.X * Layer.ScrollingInfo[0].RelativeX / 0x100;
            int alteredY = screen.Y * Layer.RelativeY / 0x100;

            int start_x = alteredX / (TILES_CHUNK_SIZE * TILE_SIZE);
            int end_x   = Math.Min(DivideRoundUp(alteredX + screen.Width, TILES_CHUNK_SIZE * TILE_SIZE), TileChunksTextures[0].Length);

            if (LoopX)
            {
                end_x = DivideRoundUp(alteredX + screen.Width, TILES_CHUNK_SIZE * TILE_SIZE);
            }

            int start_y = alteredY / (TILES_CHUNK_SIZE * TILE_SIZE);
            int end_y   = Math.Min(DivideRoundUp(alteredY + screen.Height, TILES_CHUNK_SIZE * TILE_SIZE), TileChunksTextures.Length);


            for (int y = start_y; y < end_y; y++)
            {
                for (int oldx = start_x; oldx < end_x; oldx++)
                {
                    int x = oldx % TileChunksTextures[0].Length;

                    Rectangle rect = GetTilesChunkArea(x, y);

                    rect.X += oldx / TileChunksTextures[0].Length * TileChunksTextures[0].Length * TILES_CHUNK_SIZE;

                    if (SelectedTiles.IsChunkUsed(x, y) || TempSelectionTiles.IsChunkUsed(x, y))
                    {
                        // draw one by one
                        DrawTilesChunk(d, x, y, Transperncy);
                    }
                    else
                    {
                        d.DrawBitmap(GetTilesChunkTexture(d, x, y),
                                     rect.X * TILE_SIZE - screen.X * Layer.ScrollingInfo[0].RelativeX / 0x100 + screen.X,
                                     rect.Y * TILE_SIZE - screen.Y * Layer.RelativeY / 0x100 + screen.Y,
                                     rect.Width * TILE_SIZE,
                                     rect.Height * TILE_SIZE,
                                     false,
                                     Transperncy);
                    }
                    DrawSelectedTiles(d, x, y, Transperncy);
                }
            }
        }
예제 #2
0
        public void DrawTile(DevicePanel d, ushort tile, int x, int y, bool selected, int Transperncy)
        {
            bool flipX = ((tile >> 10) & 1) == 1;
            bool flipY = ((tile >> 11) & 1) == 1;

            int tsx = 0;
            int tsy = (tile & 0x3ff);

            if (Editor.Instance.StageTiles.Image.W > 16)
            {
                tsx = (tile & 0x3ff) & 0x1F;
                tsy = (tile & 0x3ff) >> 5;
            }
            d.DrawBitmap(Editor.Instance.StageTiles.Image.GetTexture(d._device, new Rectangle(tsx * TILE_SIZE, tsy * TILE_SIZE, TILE_SIZE, TILE_SIZE), flipX, flipY),
                         x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE, selected, Transperncy);
            if (selected)
            {
                d.DrawLine(x * TILE_SIZE, y * TILE_SIZE, x * TILE_SIZE + TILE_SIZE, y * TILE_SIZE, System.Drawing.Color.Brown);
                d.DrawLine(x * TILE_SIZE, y * TILE_SIZE, x * TILE_SIZE, y * TILE_SIZE + TILE_SIZE, System.Drawing.Color.Brown);
                d.DrawLine(x * TILE_SIZE + TILE_SIZE, y * TILE_SIZE + TILE_SIZE, x * TILE_SIZE + TILE_SIZE, y * TILE_SIZE, System.Drawing.Color.Brown);
                d.DrawLine(x * TILE_SIZE + TILE_SIZE, y * TILE_SIZE + TILE_SIZE, x * TILE_SIZE, y * TILE_SIZE + TILE_SIZE, System.Drawing.Color.Brown);
            }
        }