Exemplo n.º 1
0
 public virtual void OnClick()
 {
     EditorUI.currentSlotGroup = this.GetContextOpt(Cursor.MouseX, Cursor.MouseY);
     EditorTools.SetTileToolBySlotGroup(EditorUI.currentSlotGroup);
     EditorTools.UpdateHelperText();
     this.CloseMenu();
     DrawTracker.AttemptPlace((short)Cursor.TileGridX, (short)Cursor.TileGridY);
 }
Exemplo n.º 2
0
        public bool ConfirmPlace(short gridX, short gridY)
        {
            // Make sure deletion is in valid location:
            if (gridY < 0 || gridY > this.yCount)
            {
                return(false);
            }
            if (gridX < 0 || gridX > this.xCount)
            {
                return(false);
            }

            // Prevent repeat-draws on the same tile (e.g. within the last 100ms).
            if (!DrawTracker.AttemptPlace(gridX, gridY))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public void TileToolTick(short gridX, short gridY)
        {
            // Prevent drawing when a component is selected.
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // Make sure placement is in valid location:
            if (gridY < 0 || gridY > this.yCount)
            {
                return;
            }
            if (gridX < 0 || gridX > this.xCount)
            {
                return;
            }

            TileTool tool = EditorTools.tileTool;

            // Make sure the tile tool is set, or placement cannot occur:
            if (tool == null)
            {
                return;
            }

            // Check if AutoTile Tool is intended. Requires Control to be held down.
            if (Systems.input.LocalKeyDown(Keys.LeftControl))
            {
                // If left mouse button was just clicked, AutoTile is being activated.
                if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
                {
                    EditorTools.StartAutoTool(gridX, gridY);
                }
            }

            // If AutoTile Tool is active, run it's behavior:
            if (EditorTools.autoTool.IsActive)
            {
                // If left mouse was just released and AutoTile is active, place AutoTiles.
                if (Cursor.LeftMouseState == Cursor.MouseDownState.Released)
                {
                    EditorTools.autoTool.PlaceAutoTiles(this);
                }

                // If Control key is not held down, auto-tiles must be deactivated.
                else if (!Systems.input.LocalKeyDown(Keys.LeftControl))
                {
                    EditorTools.autoTool.ClearAutoTiles();
                }

                return;
            }

            // Left Mouse Button (Overwrite Current Tile)
            if (Cursor.mouseState.LeftButton == ButtonState.Pressed)
            {
                // Prevent repeat-draws on the same tile (e.g. within the last 100ms).
                if (!DrawTracker.AttemptPlace(gridX, gridY))
                {
                    return;
                }

                EditorPlaceholder ph = tool.CurrentPlaceholder;

                // Place Tile
                if (ph.tileId > 0)
                {
                    RoomFormat roomData = this.levelContent.data.rooms[this.roomID];

                    if (ph.layerEnum == LayerEnum.main)
                    {
                        // Check the Tile Limiter before placing the tile.
                        if (this.scene.limiter.AddLimitTile(this.scene.curRoomID, ph.tileId, ph.subType))
                        {
                            this.PlaceTile(roomData.main, ph.layerEnum, gridX, gridY, ph.tileId, ph.subType, null);
                        }

                        // If the Object Limiter failed, display the error message.
                        else
                        {
                            UIHandler.AddNotification(UIAlertType.Error, "Limit Reached", ObjectLimiter.LastFailMessage, 240);
                        }
                    }
                    else if (ph.layerEnum == LayerEnum.bg)
                    {
                        this.PlaceTile(roomData.bg, ph.layerEnum, gridX, gridY, ph.tileId, ph.subType, null);
                    }
                    else if (ph.layerEnum == LayerEnum.fg)
                    {
                        this.PlaceTile(roomData.fg, ph.layerEnum, gridX, gridY, ph.tileId, ph.subType, null);
                    }
                }

                // Place Object
                else if (ph.objectId > 0)
                {
                    // Check the Object Limiter before placing the tile.
                    if (this.scene.limiter.AddLimitObject(this.scene.curRoomID, ph.objectId))
                    {
                        this.PlaceTile(this.levelContent.data.rooms[this.roomID].obj, LayerEnum.obj, gridX, gridY, ph.objectId, ph.subType, null);
                    }

                    // If the Object Limiter failed, display the error message.
                    else
                    {
                        UIHandler.AddNotification(UIAlertType.Error, "Limit Reached", ObjectLimiter.LastFailMessage, 240);
                    }
                }

                return;
            }
        }