Exemple #1
0
 public void AddToUndoHistory(int[,] g = null)
 {
     if (inventoryMode == InventoryMode.Base)
     {
         return;
     }
     CurrentEditableGrid.AddToUndoHistory(g);
 }
Exemple #2
0
        public void PerformAction(GameTime gt, Controller.Action action)
        {
            if (mouse_move_is_selecting)
            {
                return;
            }
            int amount = 16;

            switch (action)
            {
            case Controller.Action.BOTTOM:
                Position += new Point(0, amount);
                break;

            case Controller.Action.TOP:
                Position += new Point(0, -amount);
                break;

            case Controller.Action.RIGHT:
                Position += new Point(amount, 0);
                break;

            case Controller.Action.LEFT:
                Position += new Point(-amount, 0);
                break;

            case Controller.Action.ZOOM_IN:
                if (TileSize < 32)
                {
                    TileSize++;
                }
                break;

            case Controller.Action.ZOOM_OUT:
                if (TileSize > 3)
                {
                    TileSize--;
                }
                break;

            case Controller.Action.BRUSH_PLUS:
                ShowBrush(gt);
                if (brush_size < 0x20)
                {
                    BrushSize++;
                }
                break;

            case Controller.Action.BRUSH_MINUS:
                ShowBrush(gt);
                if (brush_size > 1)
                {
                    BrushSize--;
                }
                break;

            case Controller.Action.FLIP_VERTICAL:
            case Controller.Action.FLIP_HORIZONTAL:
                ShowBrush(gt);
                bool vertical = action == Controller.Action.FLIP_VERTICAL;
                if (selectionGrid != null)
                {
                    for (int i = 0; i < selectionGrid.GetLength(0); i++)
                    {
                        for (int j = 0; j < selectionGrid.GetLength(1); j++)
                        {
                            if (vertical)
                            {
                                selectionGrid[i, j] = FlipVertically(selectionGrid[i, j]);
                            }
                            else
                            {
                                selectionGrid[i, j] = FlipHorizontally(selectionGrid[i, j]);
                            }
                        }
                    }
                    if (vertical)
                    {
                        selectionGrid = Utils.FlipVertically(selectionGrid);
                    }
                    else
                    {
                        selectionGrid = Utils.FlipHorizontally(selectionGrid);
                    }
                }
                break;

            case Controller.Action.TOGGLE_INVENTORY:
                if (type != Levels.MapType.Minimap)
                {
                    inventoryMode = inventoryMode == InventoryMode.Base ? InventoryMode.No : InventoryMode.Base;
                }
                break;

            case Controller.Action.TOGGLE_CUSTOM_INVENTORY:
                inventoryMode = inventoryMode == InventoryMode.Custom ? InventoryMode.No : InventoryMode.Custom;
                break;

            case Controller.Action.UNDO:
                if (inventoryMode != InventoryMode.Base)
                {
                    CurrentEditableGrid.Undo();
                }
                break;

            case Controller.Action.REDO:
                if (inventoryMode != InventoryMode.Base)
                {
                    CurrentEditableGrid.Redo();
                }
                break;

            case Controller.Action.FORCE_PALETTE:
                if (selectionGrid != null)
                {
                    for (int i = 0; i < selectionGrid.GetLength(0); i++)
                    {
                        for (int j = 0; j < selectionGrid.GetLength(1); j++)
                        {
                            selectionGrid[i, j] = ChangePalette(selectionGrid[i, j], sprites.SelectedSet);
                        }
                    }
                }
                break;
            }
        }