diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn index 4a5d838..d602c57 100644 --- a/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn @@ -16,7 +16,6 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_rgx4n") -Layer = null [node name="Bg" type="Panel" parent="."] layout_mode = 1 diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn index b343ece..edf1550 100644 --- a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn @@ -24,7 +24,6 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_6jjk7") -Layer = null [node name="VSplitContainer" type="VSplitContainer" parent="."] layout_mode = 1 @@ -166,7 +165,7 @@ anchors_preset = 0 offset_right = 16.0 offset_bottom = 16.0 -mouse_filter = 1 +mouse_filter = 2 [node name="CellTexture" type="Sprite2D" parent="VSplitContainer/PanelTop/HSplitContainer/TopBg/TerrainRoot/CellRoot/RightCell"] z_index = -1 diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot index 8fdcd2e..e571370 100644 --- a/DungeonShooting_Godot/project.godot +++ b/DungeonShooting_Godot/project.godot @@ -215,6 +215,11 @@ "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":4,"position":Vector2(185, 17),"global_position":Vector2(189, 58),"factor":1.0,"button_index":3,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } +mouse_right={ +"deadzone": 0.5, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(154, 20),"global_position":Vector2(158, 61),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null) +] +} [layer_names] diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json index df41fcb..3631e29 100644 --- a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json @@ -141,8 +141,8 @@ 80 ], "447": [ - 32, - 96 + 80, + 32 ], "62": [ 16, diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs index 99f6455..baa95f3 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs @@ -134,6 +134,7 @@ var sRightCell = cellRoot.L_RightCell; sRightCell.Instance.Position = texture.Position; var grid = CreateUiGrid(sRightCell, cellRoot.Instance); + grid.GridContainer.MouseFilter = MouseFilterEnum.Ignore; grid.SetCellOffset(Vector2I.Zero); grid.SetColumns(size.X); for (var y = 0; y < size.Y; y++) @@ -292,10 +293,10 @@ //清除所有绑定的Terrain if (index >= 0) { - TerrainGrid3x3.ForEach(cell => ((TerrainCell)cell).ClearCell()); - TerrainGridMiddle.ForEach(cell => ((TerrainCell)cell).ClearCell()); - TerrainGridFloor.ForEach(cell => ((TerrainCell)cell).ClearCell()); - TerrainGrid2x2.ForEach(cell => ((TerrainCell)cell).ClearCell()); + TerrainGrid3x3.ForEach(cell => ((TerrainCell)cell).ClearCellTexture()); + TerrainGridMiddle.ForEach(cell => ((TerrainCell)cell).ClearCellTexture()); + TerrainGridFloor.ForEach(cell => ((TerrainCell)cell).ClearCellTexture()); + TerrainGrid2x2.ForEach(cell => ((TerrainCell)cell).ClearCellTexture()); } S_TopBg.Instance.SetHoverCell(null); S_BottomBg.Instance.SetHoverCell(null); @@ -419,7 +420,7 @@ TerrainGrid3x3.ForEach(cell => { var terrainCell = (TerrainCell)cell; - terrainCell.ClearCell(); + terrainCell.ClearCellTexture(); if (terrainCell.ConnectMaskCell != null) { terrainCell.ConnectMaskCell.SetUseFlag(false); @@ -432,7 +433,7 @@ TerrainGrid2x2.ForEach(cell => { var terrainCell = (TerrainCell)cell; - terrainCell.ClearCell(); + terrainCell.ClearCellTexture(); if (terrainCell.ConnectMaskCell != null) { terrainCell.ConnectMaskCell.SetUseFlag(false); diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs index b78cd21..7ff2535 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs @@ -29,7 +29,6 @@ public override void OnInit() { _panel = CellNode.UiPanel; - CellNode.Instance.GuiInput += OnGuiInput; CellNode.Instance.Draw += OnDraw; } @@ -51,25 +50,21 @@ { CellNode.Instance.QueueRedraw(); } - - private void OnGuiInput(InputEvent @event) + + /// + /// 擦除当前选择的图块 + /// + public void EraseCell() { - if (IsPutDownTexture && @event is InputEventMouseButton mouseEvent) + var flag = IsPutDownTexture; + ClearCellTexture(); + if (flag) { - if (mouseEvent.ButtonIndex == MouseButton.Right && mouseEvent.Pressed) //右键擦除图块 + ClearTerrainBitData(); + if (ConnectMaskCell != null) { - CellNode.Instance.AcceptEvent(); - var flag = IsPutDownTexture; - ClearCell(); - if (flag) - { - ClearTerrainBitData(); - if (ConnectMaskCell != null) - { - ConnectMaskCell.SetUseFlag(false); - ConnectMaskCell.SetConnectTerrainCell(null); - } - } + ConnectMaskCell.SetUseFlag(false); + ConnectMaskCell.SetConnectTerrainCell(null); } } } @@ -90,7 +85,7 @@ /// /// 清除选中的cell /// - public void ClearCell() + public void ClearCellTexture() { CellNode.L_CellTexture.Instance.Texture = null; IsPutDownTexture = false; diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs index 4009d20..ca1fc31 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs @@ -34,32 +34,42 @@ public override void _Process(double delta) { - TerrainCell cell = null; + //鼠标悬停的图块 + TerrainCell hover = null; var _panel = UiNode.UiPanel; var terrain = _panel.CurrTerrain; if (terrain != null && _panel.S_TopBg.Instance.IsMouseInRect()) { if (terrain.TerrainType == 0) //选中47个Terrain { - cell = CalcMouseHoverCell(_panel.S_TerrainTexture1.Instance, _panel.TerrainGrid3x3); + hover = CalcMouseHoverCell(_panel.S_TerrainTexture1.Instance, _panel.TerrainGrid3x3); if (_panel.EditorPanel.TileSetSourceIndex == 0 && _panel.CurrTerrainIndex == 0) //选中Main Source { - if (cell == null) + if (hover == null) { - cell = CalcMouseHoverCell(_panel.S_TerrainTexture2.Instance, _panel.TerrainGridMiddle); + hover = CalcMouseHoverCell(_panel.S_TerrainTexture2.Instance, _panel.TerrainGridMiddle); } - if (cell == null) + if (hover == null) { - cell = CalcMouseHoverCell(_panel.S_TerrainTexture3.Instance, _panel.TerrainGridFloor); + hover = CalcMouseHoverCell(_panel.S_TerrainTexture3.Instance, _panel.TerrainGridFloor); } } } else //选中13格Terrain { - cell = CalcMouseHoverCell(_panel.S_TerrainTexture4.Instance, _panel.TerrainGrid2x2); + hover = CalcMouseHoverCell(_panel.S_TerrainTexture4.Instance, _panel.TerrainGrid2x2); } } - SetHoverCell(cell); + + if (hover != null && Input.IsActionJustPressed(InputAction.MouseRight)) + { + //右键擦除 + hover.EraseCell(); + } + else + { + SetHoverCell(hover); + } } ///