SquareChange denotes an undo/redo operation involving the changing of map squares.
In general this class should be run as part of a map tool that operates on squares. It should be constructed in Start() and applied to the undo/redo stack during End().
Inheritance: UndoStack.Change
Exemple #1
0
        public override void End(Point tile)
        {
            base.End(tile);

            EditorExtensionNode node = form.SelectedSquareType();
            if (node != null)
            {
                for (int y = border.Location.Y; y < border.Location.Y + border.Size.Height; ++y)
                {
                    for (int x = border.Location.X; x < border.Location.X + border.Size.Width; ++x)
                    {
                        if (fill ||
                            (x == border.Location.X || x == border.Location.X + border.Size.Width - 1 ||
                            y == border.Location.Y || y == border.Location.Y + border.Size.Height - 1))
                        {
                            AbstractSquare sq = (AbstractSquare)node.CreateInstance();
                            Vector3 loc = new Vector3(x + form.Map.View.x,
                                y + form.Map.View.y, form.Map.View.z);

                            change.AddOperation(form.Map.GetSafeSquare(loc), sq, loc);
                            form.Map.SetSquare(loc, sq);
                        }
                    }
                }
            }
            if (change.Count > 0)
                form.UndoRedo.AddChange(change);

            change = null;
            form.Map.ViewFrom(form.Map.View, true);
        }
Exemple #2
0
        public void End(Point tile)
        {
            if (region == null)
            {
                return;
            }

            EditorExtensionNode node = form.SelectedSquareType();

            if (node != null)
            {
                foreach (Point p in Line(start, tile))
                {
                    Vector3 loc = new Vector3(p.X + form.Map.View.X,
                                              p.Y + form.Map.View.Y, form.Map.View.Z);
                    AbstractSquare sq = (AbstractSquare)node.CreateInstance();
                    change.AddOperation(form.Map.GetSafeSquare(loc), sq, loc);
                    form.Map.SetSquare(loc, sq);
                }
            }
            if (change.Count > 0)
            {
                form.UndoRedo.AddChange(change);
            }

            change = null;

            region.Invalidate();

            region.Dispose();
            region = null;

            form.Map.ViewFrom(form.Map.View, true);
        }
Exemple #3
0
        public override void End(Point tile)
        {
            base.End(tile);

            EditorExtensionNode node = form.SelectedSquareType();

            if (node != null)
            {
                for (int y = border.Location.Y; y < border.Location.Y + border.Size.Height; ++y)
                {
                    for (int x = border.Location.X; x < border.Location.X + border.Size.Width; ++x)
                    {
                        if (fill ||
                            (x == border.Location.X || x == border.Location.X + border.Size.Width - 1 ||
                             y == border.Location.Y || y == border.Location.Y + border.Size.Height - 1))
                        {
                            AbstractSquare sq  = (AbstractSquare)node.CreateInstance();
                            Vector3        loc = new Vector3(x + form.Map.View.x,
                                                             y + form.Map.View.y, form.Map.View.z);

                            change.AddOperation(form.Map.GetSafeSquare(loc), sq, loc);
                            form.Map.SetSquare(loc, sq);
                        }
                    }
                }
            }
            if (change.Count > 0)
            {
                form.UndoRedo.AddChange(change);
            }

            change = null;
            form.Map.ViewFrom(form.Map.View, true);
        }
Exemple #4
0
        public void Start(Point tile)
        {
            region      = new EmptyControl(form.Map);
            region.Size = form.Map.Size;

            change = new SquareChange(form.Map);

            start = oldend = tile;
        }
Exemple #5
0
        public void Start(Point tile)
        {
            region = new EmptyControl(form.Map.Size, new Point(0, 0));
            change = new SquareChange(form.Map);

            form.Map.AddRegion(region);

            start = oldend = tile;
        }
Exemple #6
0
        public void End(Point tile)
        {
            Vector3 start = new Vector3(tile.X + form.Map.View.X,
                                        tile.Y + form.Map.View.Y, form.Map.View.Z);
            EditorExtensionNode node = form.SelectedSquareType();
            AbstractSquare      sq   = form.Map.GetSafeSquare(start);

            if (sq != null && node != null && !sq.GetType().Equals(node.Type))
            {
                foreach (Vector3 v in Flood(form.Map, start))
                {
                    AbstractSquare square = (AbstractSquare)node.CreateInstance();
                    change.AddOperation(form.Map.GetSafeSquare(v), square, v);
                    form.Map.SetSquare(v, square);
                }
            }
            form.Map.ViewFrom(form.Map.View, true);
            if (change.Count > 0)
            {
                form.UndoRedo.AddChange(change);
            }
            change = null;
        }
Exemple #7
0
        public void End(Point tile)
        {
            if (region == null)
                return;

            EditorExtensionNode node = form.SelectedSquareType();

            if (node != null)
            {
                foreach (Point p in Line(start, tile))
                {
                    Vector3 loc = new Vector3(p.X + form.Map.View.x,
                        p.Y + form.Map.View.y, form.Map.View.z);
                    AbstractSquare sq = (AbstractSquare)node.CreateInstance();
                    change.AddOperation(form.Map.GetSafeSquare(loc), sq, loc);
                    form.Map.SetSquare(loc,	sq);
                }
            }
            if (change.Count > 0)
                form.UndoRedo.AddChange(change);

            change = null;

            region.InvalidateTiles();

            region.Dispose();
            region = null;

            form.Map.ViewFrom(form.Map.View, true);
        }
Exemple #8
0
        public void Start(Point tile)
        {
            region = new EmptyControl(form.Map.Size, new Point(0,0));
            change = new SquareChange(form.Map);

            form.Map.AddRegion(region);

            start = oldend = tile;
        }
Exemple #9
0
 public void Start(Point tile)
 {
     change = new SquareChange(form.Map);
 }
Exemple #10
0
 public void Start(Point tile)
 {
     change = new SquareChange(form.Map);
     Run(tile);
     lastloc = tile;
 }
Exemple #11
0
 public void End(Point tile)
 {
     form.UndoRedo.AddChange(change);
     change = null;
     lastloc = new Point(-1, -1);
 }
Exemple #12
0
 public void End(Point tile)
 {
     form.UndoRedo.AddChange(change);
     change  = null;
     lastloc = new Point(-1, -1);
 }
Exemple #13
0
 public void Start(Point tile)
 {
     change = new SquareChange(form.Map);
     Run(tile);
     lastloc = tile;
 }
Exemple #14
0
 public override void Start(Point tile)
 {
     base.Start(tile);
     change = new SquareChange(form.Map);
 }
Exemple #15
0
 public override void Start(Point tile)
 {
     base.Start(tile);
     change = new SquareChange(form.Map);
 }