Example #1
0
 public override bool ReleaseTool(TileMouseEventArgs e)
 {
     CheckDirectionandDraw(e);
     _isLeftDown  = (e.LeftButton == MouseButtonState.Pressed);
     _isRightDown = (e.RightButton == MouseButtonState.Pressed);
     HistMan.AddBufferToHistory();
     return(true);
 }
Example #2
0
        public override bool PressTool(TileMouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                Flood(e.Tile);

                _renderer.UpdateWorldImage(new Int32Rect(minX, minY, maxX - minX + 1, maxY - minY + 1));
            }
            HistMan.AddBufferToHistory();
            return(true);
        }
Example #3
0
        public override bool ReleaseTool(TileMouseEventArgs e)
        {
            if (_startPoint != null)
            {
                DrawLine(e.Tile);
            }
            _isLeftDown  = (e.LeftButton == MouseButtonState.Pressed);
            _isRightDown = (e.RightButton == MouseButtonState.Pressed);

            HistMan.AddBufferToHistory();
            _startPoint = null;
            _endPoint   = null;
            return(true);
        }
Example #4
0
        public void PasteBufferIntoWorld(World world, ClipboardBuffer buffer, PointInt32 anchor)
        {
            for (int x = 0; x < buffer.Size.W; x++)
            {
                for (int y = 0; y < buffer.Size.H; y++)
                {
                    if (world.IsPointInWorld(x + anchor.X, y + anchor.Y))
                    {
                        HistMan.AddTileToBuffer(x + anchor.X, y + anchor.Y, ref world.Tiles[x + anchor.X, y + anchor.Y]);
                        Tile curTile = (Tile)buffer.Tiles[x, y].Clone();

                        // Remove overwritten chests data
                        if (world.Tiles[x + anchor.X, y + anchor.Y].Type == 21)
                        {
                            var data = world.GetChestAtTile(x + anchor.X, y + anchor.Y);
                            if (data != null)
                            {
                                world.Chests.Remove(data);
                            }
                        }

                        // Remove overwritten sign data
                        if (world.Tiles[x + anchor.X, y + anchor.Y].Type == 55 || world.Tiles[x + anchor.X, y + anchor.Y].Type == 85)
                        {
                            var data = world.GetSignAtTile(x + anchor.X, y + anchor.Y);
                            if (data != null)
                            {
                                world.Signs.Remove(data);
                            }
                        }


                        // Add new chest data
                        if (curTile.Type == 21)
                        {
                            if (world.GetChestAtTile(x + anchor.X, y + anchor.Y) == null)
                            {
                                var data = buffer.GetChestAtTile(x, y);
                                if (data != null) // allow? chest copying may not work...
                                {
                                    // Copied chest
                                    var newChest = Utility.DeepCopy(data);
                                    newChest.Location = new PointInt32(x + anchor.X, y + anchor.Y);
                                    world.Chests.Add(newChest);
                                }
                                else
                                {
                                    // Empty chest
                                    world.Chests.Add(new Chest(new PointInt32(x + anchor.X, y + anchor.Y)));
                                }
                            }
                        }

                        // Add new sign data
                        if (curTile.Type == 55 || curTile.Type == 85)
                        {
                            if (world.GetSignAtTile(x + anchor.X, y + anchor.Y) == null)
                            {
                                var data = buffer.GetSignAtTile(x, y);
                                if (data != null)
                                {
                                    // Copied sign
                                    var newSign = Utility.DeepCopy(data);
                                    newSign.Location = new PointInt32(x + anchor.X, y + anchor.Y);
                                    world.Signs.Add(newSign);
                                }
                                else
                                {
                                    world.Signs.Add(new Sign("", new PointInt32(x + anchor.X, y + anchor.Y)));
                                }
                            }
                        }

                        world.Tiles[x + anchor.X, y + anchor.Y] = curTile;
                    }
                }
            }

            HistMan.AddBufferToHistory();
        }