Example #1
0
 public MassZmEditor(IContainsLayerInfo[] items, Board board, int zm)
 {
     InitializeComponent();
     this.items = items;
     this.board = board;
     zmInput.Value = zm;
 }
Example #2
0
        protected override void okButton_Click(object sender, EventArgs e)
        {
            Layer targetLayer = board.Layers[layerBox.SelectedIndex];
            int   zm          = (int)zmBox.SelectedItem;

            if (!LayerCapableOfHoldingSelectedItems(targetLayer))
            {
                MessageBox.Show("Error: Target layer cannot hold the selected items because they contain tiles with a tS different from the layer's", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            List <UndoRedoAction> actions       = new List <UndoRedoAction>();
            HashSet <int>         touchedLayers = new HashSet <int>();

            foreach (BoardItem item in items)
            {
                if (!(item is IContainsLayerInfo))
                {
                    continue;
                }
                IContainsLayerInfo li = (IContainsLayerInfo)item;
                int oldLayer          = li.LayerNumber;
                int oldZm             = li.PlatformNumber;
                touchedLayers.Add(oldLayer);
                li.LayerNumber    = targetLayer.LayerNumber;
                li.PlatformNumber = zm;
                actions.Add(UndoRedoManager.ItemLayerPlatChanged(li, new Tuple <int, int>(oldLayer, oldZm), new Tuple <int, int>(li.LayerNumber, li.PlatformNumber)));
            }
            if (actions.Count > 0)
            {
                board.UndoRedoMan.AddUndoBatch(actions);
            }
            touchedLayers.ToList().ForEach(x => board.Layers[x].RecheckTileSet());
            targetLayer.RecheckTileSet();
            InputHandler.ClearSelectedItems(board);
            Close();
        }
Example #3
0
 public static UndoRedoAction ItemLayerPlatChanged(IContainsLayerInfo item, Tuple<int, int> oldLayerPlat, Tuple<int, int> newLayerPlat)
 {
     return new UndoRedoAction(null, UndoRedoType.ItemLayerPlatChanged, oldLayerPlat, newLayerPlat, item);
 }
Example #4
0
 public static UndoRedoAction zMChanged(IContainsLayerInfo target, int oldZM, int newZM)
 {
     return new UndoRedoAction(null, UndoRedoType.zMChanged, oldZM, newZM, target);
 }
 public static UndoRedoAction zMChanged(IContainsLayerInfo target, int oldZM, int newZM)
 {
     return(new UndoRedoAction(null, UndoRedoType.zMChanged, oldZM, newZM, target));
 }
 public static UndoRedoAction ItemLayerPlatChanged(IContainsLayerInfo item, Tuple <int, int> oldLayerPlat, Tuple <int, int> newLayerPlat)
 {
     return(new UndoRedoAction(null, UndoRedoType.ItemLayerPlatChanged, oldLayerPlat, newLayerPlat, item));
 }
Example #7
0
        public void UndoRedo(HashSet <int> layersToRecheck)
        {
            Board board;

            switch (type)
            {
            case UndoRedoType.ItemDeleted:
                //item.Board.BoardItems.Add(item, true);
                item.InsertItem();
                break;

            case UndoRedoType.ItemAdded:
                item.RemoveItem(null);
                break;

            case UndoRedoType.ItemMoved:
                XNA.Point oldPos = (XNA.Point)ParamA;
                item.Move(oldPos.X, oldPos.Y);
                break;

            case UndoRedoType.ItemFlipped:
                ((IFlippable)item).Flip = !((IFlippable)item).Flip;
                break;

            case UndoRedoType.LineRemoved:
                board = ((MapleDot)ParamB).Board;
                if (ParamC is FootholdLine)
                {
                    board.BoardItems.FootholdLines.Add((FootholdLine)ParamC);
                }
                else if (ParamC is RopeLine)
                {
                    board.BoardItems.RopeLines.Add((RopeLine)ParamC);
                }
                else
                {
                    throw new Exception("wrong type at undoredo, lineremoved");
                }
                ((MapleLine)ParamC).FirstDot  = (MapleDot)ParamA;
                ((MapleLine)ParamC).SecondDot = (MapleDot)ParamB;
                ((MapleDot)ParamA).connectedLines.Add((MapleLine)ParamC);
                ((MapleDot)ParamB).connectedLines.Add((MapleLine)ParamC);
                break;

            case UndoRedoType.LineAdded:
                board = ((MapleDot)ParamB).Board;
                if (ParamC is FootholdLine)
                {
                    board.BoardItems.FootholdLines.Remove((FootholdLine)ParamC);
                }
                else if (ParamC is RopeLine)
                {
                    board.BoardItems.RopeLines.Remove((RopeLine)ParamC);
                }
                else
                {
                    throw new Exception("wrong type at undoredo, lineadded");
                }
                ((MapleLine)ParamC).Remove(false, null);
                break;

            case UndoRedoType.ToolTipLinked:
                ((ToolTipInstance)item).CharacterToolTip = null;
                ((ToolTipChar)ParamA).BoundTooltip       = null;
                break;

            case UndoRedoType.ToolTipUnlinked:
                ((ToolTipChar)ParamA).BoundTooltip = (ToolTipInstance)item;
                break;

            case UndoRedoType.BackgroundMoved:
                ((BackgroundInstance)item).BaseX = ((XNA.Point)ParamA).X;
                ((BackgroundInstance)item).BaseY = ((XNA.Point)ParamA).Y;
                break;

            case UndoRedoType.ItemsLinked:
                item.ReleaseItem((BoardItem)ParamA);
                break;

            case UndoRedoType.ItemsUnlinked:
                item.BindItem((BoardItem)ParamA, (Microsoft.Xna.Framework.Point)ParamB);
                break;

            case UndoRedoType.ItemsLayerChanged:
                InputHandler.ClearSelectedItems(((BoardItem)((List <IContainsLayerInfo>)ParamC)[0]).Board);
                foreach (IContainsLayerInfo layerInfoItem in (List <IContainsLayerInfo>)ParamC)
                {
                    layerInfoItem.LayerNumber = (int)ParamA;
                }
                ((BoardItem)((List <IContainsLayerInfo>)ParamC)[0]).Board.Layers[(int)ParamA].RecheckTileSet();
                ((BoardItem)((List <IContainsLayerInfo>)ParamC)[0]).Board.Layers[(int)ParamB].RecheckTileSet();
                break;

            case UndoRedoType.ItemLayerPlatChanged:
                Tuple <int, int>   oldLayerPlat = (Tuple <int, int>)ParamA;
                Tuple <int, int>   newLayerPlat = (Tuple <int, int>)ParamB;
                IContainsLayerInfo li           = (IContainsLayerInfo)ParamC;
                li.LayerNumber    = oldLayerPlat.Item1;
                li.PlatformNumber = oldLayerPlat.Item2;
                layersToRecheck.Add(oldLayerPlat.Item1);
                layersToRecheck.Add(newLayerPlat.Item1);
                break;

            case UndoRedoType.RopeAdded:
                ((Rope)ParamA).Remove(null);
                break;

            case UndoRedoType.RopeRemoved:
                ((Rope)ParamA).Create();
                break;

            case UndoRedoType.ItemZChanged:
                item.Z = (int)ParamA;
                item.Board.BoardItems.Sort();
                break;

            case UndoRedoType.VRChanged:
                //TODO
                break;

            case UndoRedoType.MapCenterChanged:
                //TODO
                break;

            case UndoRedoType.LayerTSChanged:
                string ts_old = (string)ParamA;
                string ts_new = (string)ParamB;
                Layer  l      = (Layer)ParamC;
                l.ReplaceTS(ts_old);
                break;

            case UndoRedoType.zMChanged:
                int zm_old = (int)ParamA;
                int zm_new = (int)ParamB;
                IContainsLayerInfo target = (IContainsLayerInfo)ParamC;
                target.PlatformNumber = zm_old;
                break;
            }
        }