Exemplo n.º 1
0
        private Bitmap GetTileBitmap(int x, int y)
        {
            if (!showTiles)
            {
                return(null);
            }

            bitmap = new Bitmap(sizeModifier, sizeModifier);

            Map.Tile mapTile = activeMap[x, y];
            if (mapTile == null || mapTile.TileNumber <= 0)
            {
                return(null);
            }
            if (mapTile.TileNumber >= TileManager.Epf[0].max)
            {
                return(null);
            }

            Graphics graphics  = Graphics.FromImage(bitmap);
            Bitmap   tmpBitmap = ImageRenderer.Singleton.GetTileBitmap(mapTile.TileNumber);

            graphics.DrawImage(tmpBitmap, 0, 0);
            graphics.Dispose();
            return(bitmap);
        }
Exemplo n.º 2
0
        private void RefreshMapActionUI(IMapAction lastAction)
        {
            activeMap.IsModified = true;

            if (lastAction is MapActionResize)
            {
                SetImage(null);
                RenderMap();
                //UpdateMinimap(true, true);
            }
            if (lastAction is MapActionPasteTile || lastAction is MapActionPastePass)
            {
                Map.Tile tile = activeMap[lastAction.Tile.X, lastAction.Tile.Y];
                RenderSingleMapTile(lastAction.Tile.X, lastAction.Tile.Y, tile == null || tile.TileNumber == 0);
                pnlImage.Invalidate();
                UpdateMinimap(true, false);
            }
            else if (lastAction is MapActionPasteObject)
            {
                Map.Tile tile = activeMap[lastAction.Tile.X, lastAction.Tile.Y];
                for (int i = 0; i < 12; i++)
                {
                    if (lastAction.Tile.Y - i >= 0)
                    {
                        RenderSingleMapTile(lastAction.Tile.X, lastAction.Tile.Y - i,
                                            tile == null || tile.ObjectNumber == 0);
                    }
                }
                pnlImage.Invalidate();
                UpdateMinimap(true, false);
            }
        }
Exemplo n.º 3
0
        private Bitmap GetObjectBitmap(int x, int y)
        {
            if (!showObjects)
            {
                return(null);
            }

            bitmap = new Bitmap(sizeModifier, sizeModifier);
            Graphics graphics = Graphics.FromImage(bitmap);

            if (tileBitmap == null)
            {
                graphics.Clear(Color.DarkGreen);
            }

            for (int i = 0; i < 12; i++)
            {
                if ((i + y) >= activeMap.Size.Height)
                {
                    break;
                }

                Map.Tile mapTile = activeMap[x, y + i];
                if (mapTile == null || mapTile.ObjectNumber == 0)
                {
                    continue;
                }

                int objectNumber = mapTile.ObjectNumber;
                if (objectNumber < 0 || objectNumber >= TileManager.ObjectInfos.Length)
                {
                    continue;
                }

                int objectHeight = TileManager.ObjectInfos[objectNumber].Indices.Length;
                if (objectHeight <= i)
                {
                    continue;
                }

                int tile = TileManager.ObjectInfos[objectNumber].Indices[objectHeight - i - 1];
                if (bitmap == null)
                {
                    bitmap = ImageRenderer.Singleton.GetObjectBitmap(tile);
                }
                else
                {
                    //Graphics graphics = Graphics.FromImage(bitmap);
                    Bitmap tmpBitmap = ImageRenderer.Singleton.GetObjectBitmap(tile);
                    graphics.DrawImage(tmpBitmap, 0, 0);
                    //tmpBitmap.Dispose();
                    //graphics.Dispose();
                }
            }

            graphics.Dispose();
            return(bitmap);
        }
Exemplo n.º 4
0
        private void replaceTile(Map.Tile oldTile, Map.Tile newTile)
        {
            TileManager.SelectionType pasteSelection = new TileManager.SelectionType();

            for (int x = 0; x <= activeMap.Size.Width; x++)
            {
                for (int y = 0; y <= activeMap.Size.Width; y++)
                {
                    if ((activeMap[x, y] ?? Map.Tile.GetDefault()) == oldTile)
                    {
                        Paste(x, y, pasteSelection);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void pnlImage_MouseMove(object sender, MouseEventArgs e)
        {
            int newFocusedTileX = e.X / sizeModifier;
            int newFocusedTileY = e.Y / sizeModifier;

            if (newFocusedTileX >= activeMap.Size.Width || newFocusedTileY >= activeMap.Size.Height)
            {
                toolStripStatusLabel.Text = @"Outside of map";
            }

            bool refresh = (newFocusedTileX != focusedTile.X || newFocusedTileY != focusedTile.Y);

            if (refresh)
            {
                // Paint-like painting
                if (isMouseDown)
                {
                    pnlImage_MouseDown(sender, e);
                }

                focusedTile = new Point(newFocusedTileX, newFocusedTileY);
                pnlImage.Refresh();

                Map.Tile mapTile = activeMap[newFocusedTileX, newFocusedTileY];

                string message = string.Format("Focused tile: ({0}, {1})", newFocusedTileX, newFocusedTileY);
                if (mapTile == null)
                {
                    message += "    Pass = False";
                }
                else
                {
                    message += string.Format("Tile number: {0}    Object number: {1}    Pass: {2}", mapTile.TileNumber, mapTile.ObjectNumber, !mapTile.Passability);
                }

                toolStripStatusLabel.Text = message;
            }
        }
Exemplo n.º 6
0
        private void TogglePass(int tileX, int tileY)
        {
            Point passTile = new Point(tileX, tileY);

            if (lastPassToggled == passTile)
            {
                return;
            }
            lastPassToggled = passTile;

            if (activeMap[tileX, tileY] == null)
            {
                activeMap[tileX, tileY] = new Map.Tile(0, false, 0);
            }
            else
            {
                activeMap[tileX, tileY].Passability = !activeMap[tileX, tileY].Passability;
            }

            activeMap.IsModified = true;
            AddMapAction(new MapActionPastePass(new Point(tileX, tileY), (activeMap[tileX, tileY].Passability ? 0 : 1)));
            pnlImage.Invalidate();
            //RenderSingleMapTile(tileX, tileY, activeMap[tileX, tileY].TileNumber == 0);
        }
Exemplo n.º 7
0
        private void TogglePass(int tileX, int tileY)
        {
            Point passTile = new Point(tileX, tileY);
            if (lastPassToggled == passTile) return;
            lastPassToggled = passTile;

            if (activeMap[tileX, tileY] == null) activeMap[tileX, tileY] = new Map.Tile(0, false, 0);
            else activeMap[tileX, tileY].Passability = !activeMap[tileX, tileY].Passability;

            activeMap.IsModified = true;
            AddMapAction(new MapActionPastePass(new Point(tileX, tileY), (activeMap[tileX, tileY].Passability ? 0 : 1)));
            pnlImage.Invalidate();
            //RenderSingleMapTile(tileX, tileY, activeMap[tileX, tileY].TileNumber == 0);
        }
Exemplo n.º 8
0
        private void pnlImage_Paint(object sender, PaintEventArgs e)
        {
            //OnPaint(e);

            if (ShowGrid)
            {
                Pen penGrid = new Pen(Color.LightCyan, 1);
                for (int i = 0; i < activeMap.Size.Width; i++)
                {
                    for (int j = 0; j < activeMap.Size.Height; j++)
                    {
                        e.Graphics.DrawRectangle(penGrid, i * sizeModifier, j * sizeModifier, sizeModifier, sizeModifier);
                    }
                }
                penGrid.Dispose();
            }

            if (ShowPass)
            {
                Pen penRed   = new Pen(Color.Red, 2);
                Pen penGreen = new Pen(Color.Green, 2);
                for (int i = 0; i < activeMap.Size.Width; i++)
                {
                    for (int j = 0; j < activeMap.Size.Height; j++)
                    {
                        Map.Tile mapTile = activeMap[i, j];
                        e.Graphics.DrawRectangle((mapTile == null || mapTile.Passability) ? penRed : penGreen, i * sizeModifier + (sizeModifier * 5 / 12), j * sizeModifier + (sizeModifier * 5 / 12), (sizeModifier * 1 / 6), (sizeModifier * 1 / 6));
                    }
                }
                penGreen.Dispose();
                penRed.Dispose();
            }

            if (focusedTile.X >= 0 && focusedTile.Y >= 0 &&
                focusedTile.X < activeMap.Size.Width && focusedTile.Y < activeMap.Size.Height && copy)
            {
                Pen pen = new Pen(Color.Yellow, 2);
                if (copy)
                {
                    pen = new Pen(Color.Yellow, 2);
                }
                e.Graphics.DrawRectangle(pen, copyStartTile.X * sizeModifier, copyStartTile.Y * sizeModifier, sizeModifier + sizeModifier * (focusedTile.X - copyStartTile.X), sizeModifier + sizeModifier * (focusedTile.Y - copyStartTile.Y));
                pen.Dispose();
            }

            else if (focusedTile.X >= 0 && focusedTile.Y >= 0 &&
                     focusedTile.X < activeMap.Size.Width && focusedTile.Y < activeMap.Size.Height)
            {
                Pen pen = new Pen(Color.Green, 2);
                if (copy)
                {
                    pen = new Pen(Color.Yellow, 2);
                }
                e.Graphics.DrawRectangle(pen, focusedTile.X * sizeModifier, focusedTile.Y * sizeModifier, sizeModifier, sizeModifier);
                pen.Dispose();
            }


            if (pnlImage.Image == null && mapBitmapIsReady)
            {
                pnlImage.Image = mapBitmap;
                pnlImage.Invalidate();
                UpdateMinimap(true, true);
            }
        }