Exemplo n.º 1
0
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selection.StartDrag.X != -1 && selection.StartDrag.Y != -1 && selection.StopDrag.X != -1 && selection.StopDrag.Y != -1)
            {
                clipboard = new Model.Clipboard();

                if (selection.BottomRightX > map_width)
                {
                    selection.BottomRightX = map_width;
                }
                if (selection.BottomRightY > map_height)
                {
                    selection.BottomRightY = map_height;
                }

                int newX = 0;
                int newY = 0;
                for (int i = selection.TopLeftX; i < selection.BottomRightX; i++)
                {   // copy selected tiles
                    for (int j = selection.TopLeftY; j < selection.BottomRightY; j++)
                    {
                        clipboard.Data.Add(new Model.ClipboardNode(newX, newY, map[i, j]));
                        newY++;
                    }
                    newX++;
                }

                clipboard.Width  = selection.BottomRightX - selection.TopLeftX;
                clipboard.Height = selection.BottomRightY - selection.TopLeftY;

                pasteToolStripMenuItem.Enabled = true;
            }
        }
Exemplo n.º 2
0
        private void Init()
        {
            // add event handlers
            pbMap.MouseDown  += new MouseEventHandler(mapPicBox_MouseDown);
            pbMap.MouseMove  += new MouseEventHandler(mapPicBox_MouseMove);
            pbMap.MouseHover += new EventHandler(mapPicBox_MouseHover);
            pbMap.MouseUp    += new MouseEventHandler(mapPicBox_MouseUp);
            this.KeyDown     += new KeyEventHandler(MapEditor_KeyDown);
            this.KeyPreview   = true;
            FormClosing      += new FormClosingEventHandler(MapEditor_FormClosing);

            // create tooltips for tools
            ToolTip toolTips = new ToolTip();

            toolTips.AutoPopDelay = 5000;
            toolTips.InitialDelay = 1000;
            toolTips.ReshowDelay  = 500;
            toolTips.ShowAlways   = true;
            toolTips.SetToolTip(btnToolSelection, "Selection(S)");
            toolTips.SetToolTip(btnToolBrush, "Brush(B)");
            toolTips.SetToolTip(btnToolEraser, "Eraser(E)");
            toolTips.SetToolTip(btnToolFill, "Fill(F)");
            toolTips.SetToolTip(btnToolSelectTile, "Select Tile(T)");

            // initialized some variables
            grid_on          = true;
            show_walkable_on = false;
            isIsometric      = false;
            choosingPlayer   = false;
            choosingPlayer   = false;
            choosingBomb     = false;
            choosingCoin     = false;
            choosingBullet   = false;

            selected_tile = null;
            selection     = new Controller.SelectionTool();

            // select brush as default tool
            SelectTool(ToolType.selection);

            backup_map = new Model.Map();

            undo = new Stack <Model.HistoryNode>();
            undoToolStripMenuItem.Enabled = false;

            redo = new Stack <Model.HistoryNode>();
            redoToolStripMenuItem.Enabled = false;

            clipboard = new Model.Clipboard();
            pasteToolStripMenuItem.Enabled = false;

            saveMapToolStripMenuItem.Enabled = false;

            tile_library = new Model.Tile[0];

            playerCount   = 0;
            monstersCount = 0;
            bombsCount    = 0;
            coinsCount    = 0;
            bulletsCount  = 0;

            player   = new Model.Player();
            monsters = new List <Model.MapMonster>();
            bombs    = new List <Model.MapBomb>();
            coins    = new List <Model.MapCoinGift>();
            bullets  = new List <Model.MapBulletGift>();

            codesGenerator = new Controller.CodesGenerator(map, map_name, map_width, map_height,
                                                           tile_library, tile_width, tile_height,
                                                           tbCode,
                                                           player, monsters, coins, bullets, bombs);
        }
Exemplo n.º 3
0
        private void Init()
        {
            // add event handlers
            pbMap.MouseDown += new MouseEventHandler(mapPicBox_MouseDown);
            pbMap.MouseMove += new MouseEventHandler(mapPicBox_MouseMove);
            pbMap.MouseHover += new EventHandler(mapPicBox_MouseHover);
            pbMap.MouseUp += new MouseEventHandler(mapPicBox_MouseUp);
            this.KeyDown += new KeyEventHandler(MapEditor_KeyDown);
            this.KeyPreview = true;
            FormClosing += new FormClosingEventHandler(MapEditor_FormClosing);

            // create tooltips for tools
            ToolTip toolTips = new ToolTip();
            toolTips.AutoPopDelay = 5000;
            toolTips.InitialDelay = 1000;
            toolTips.ReshowDelay = 500;
            toolTips.ShowAlways = true;
            toolTips.SetToolTip(btnToolSelection, "Selection(S)");
            toolTips.SetToolTip(btnToolBrush, "Brush(B)");
            toolTips.SetToolTip(btnToolEraser, "Eraser(E)");
            toolTips.SetToolTip(btnToolFill, "Fill(F)");
            toolTips.SetToolTip(btnToolSelectTile, "Select Tile(T)");

            // initialized some variables
            grid_on = true;
            show_walkable_on = false;
            isIsometric = false;
            choosingPlayer = false;
            choosingPlayer = false;
            choosingBomb = false;
            choosingCoin = false;
            choosingBullet = false;

            selected_tile = null;
            selection = new Controller.SelectionTool();

            // select brush as default tool
            SelectTool(ToolType.selection);

            backup_map = new Model.Map();

            undo = new Stack<Model.HistoryNode>();
            undoToolStripMenuItem.Enabled = false;

            redo = new Stack<Model.HistoryNode>();
            redoToolStripMenuItem.Enabled = false;

            clipboard = new Model.Clipboard();
            pasteToolStripMenuItem.Enabled = false;

            saveMapToolStripMenuItem.Enabled = false;

            tile_library = new Model.Tile[0];

            playerCount = 0;
            monstersCount = 0;
            bombsCount = 0;
            coinsCount = 0;
            bulletsCount = 0;

            player = new Model.Player();
            monsters = new List<Model.Monster>();
            bombs = new List<Model.Bomb>();
            coins = new List<Model.CoinGift>();
            bullets = new List<Model.BulletGift>();

            codesGenerator = new Controller.CodesGenerator(map, map_name, map_width, map_height,
                tile_library, tile_width, tile_height,
                tbCode,
                player, monsters, coins, bullets, bombs);
        }
Exemplo n.º 4
0
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selection.StartDrag.X != -1 && selection.StartDrag.Y != -1 && selection.StopDrag.X != -1 && selection.StopDrag.Y != -1)
            {
                clipboard = new Model.Clipboard();

                if (selection.BottomRightX > map_width)
                    selection.BottomRightX = map_width;
                if (selection.BottomRightY > map_height)
                    selection.BottomRightY = map_height;

                int newX = 0;
                int newY = 0;
                for (int i = selection.TopLeftX; i < selection.BottomRightX; i++)
                {   // copy selected tiles
                    for (int j = selection.TopLeftY; j < selection.BottomRightY; j++)
                    {
                        clipboard.Data.Add(new Model.ClipboardNode(newX, newY, map[i, j]));
                        newY++;
                    }
                    newX++;
                }

                clipboard.Width = selection.BottomRightX - selection.TopLeftX;
                clipboard.Height = selection.BottomRightY - selection.TopLeftY;

                pasteToolStripMenuItem.Enabled = true;
            }
        }