diff --git a/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn b/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn index f277c48..c8deb8e 100644 --- a/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn +++ b/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn @@ -15,6 +15,7 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_gtth6") +Layer = null [node name="VBoxContainer" type="VBoxContainer" parent="."] layout_mode = 1 @@ -73,6 +74,7 @@ theme_override_constants/margin_bottom = 2 [node name="Tab1" type="ColorRect" parent="VBoxContainer/Panel/MarginContainer"] +visible = false clip_children = 2 layout_mode = 2 color = Color(0.145098, 0.145098, 0.145098, 1) @@ -188,7 +190,6 @@ stretch_mode = 5 [node name="Tab3" type="Control" parent="VBoxContainer/Panel/MarginContainer"] -visible = false layout_mode = 2 script = ExtResource("5_ty17f") @@ -200,6 +201,52 @@ grow_horizontal = 2 grow_vertical = 2 -[node name="Label" type="Label" parent="VBoxContainer/Panel/MarginContainer/Tab3/ScrollContainer"] +[node name="CellButton" type="Button" parent="VBoxContainer/Panel/MarginContainer/Tab3/ScrollContainer"] +custom_minimum_size = Vector2(120, 170) layout_mode = 2 -text = "组合" + +[node name="PreviewImage" type="TextureRect" parent="VBoxContainer/Panel/MarginContainer/Tab3/ScrollContainer/CellButton"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 2.0 +offset_top = 2.0 +offset_right = -2.0 +offset_bottom = -52.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +expand_mode = 2 +stretch_mode = 5 + +[node name="CellName" type="Label" parent="VBoxContainer/Panel/MarginContainer/Tab3/ScrollContainer/CellButton"] +layout_mode = 1 +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -52.0 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_font_sizes/font_size = 16 +text = "名称" +horizontal_alignment = 1 +vertical_alignment = 1 +autowrap_mode = 2 +clip_text = true +text_overrun_behavior = 2 + +[node name="SelectTexture" type="NinePatchRect" parent="VBoxContainer/Panel/MarginContainer/Tab3/ScrollContainer/CellButton"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("5_f4thw") +region_rect = Rect2(0, 0, 36, 36) +patch_margin_left = 3 +patch_margin_top = 3 +patch_margin_right = 3 +patch_margin_bottom = 3 diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet1/TileSet.json b/DungeonShooting_Godot/resource/map/tileSet/TileSet1/TileSet.json index c5b0615..83eebd4 100644 --- a/DungeonShooting_Godot/resource/map/tileSet/TileSet1/TileSet.json +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet1/TileSet.json @@ -244,7 +244,176 @@ "Name": "Test1", "SourcePath": "resource/map/tileSet/TileSet1/Test1.png", "Terrain": [], - "Combination": [] + "Combination": [ + { + "Id": "638410898975140817", + "Name": "\u7EC4\u5408", + "Cells": [ + { + "X": 192, + "Y": 160 + }, + { + "X": 192, + "Y": 144 + }, + { + "X": 192, + "Y": 128 + }, + { + "X": 208, + "Y": 128 + }, + { + "X": 224, + "Y": 128 + }, + { + "X": 224, + "Y": 144 + }, + { + "X": 224, + "Y": 160 + }, + { + "X": 240, + "Y": 128 + }, + { + "X": 240, + "Y": 144 + }, + { + "X": 240, + "Y": 160 + }, + { + "X": 192, + "Y": 160 + }, + { + "X": 192, + "Y": 144 + }, + { + "X": 192, + "Y": 128 + }, + { + "X": 208, + "Y": 128 + }, + { + "X": 224, + "Y": 128 + }, + { + "X": 224, + "Y": 144 + }, + { + "X": 224, + "Y": 160 + }, + { + "X": 240, + "Y": 128 + }, + { + "X": 240, + "Y": 144 + }, + { + "X": 240, + "Y": 160 + } + ], + "Positions": [ + { + "X": 0, + "Y": 32 + }, + { + "X": 0, + "Y": 16 + }, + { + "X": 0, + "Y": 0 + }, + { + "X": 16, + "Y": 0 + }, + { + "X": 32, + "Y": 0 + }, + { + "X": 32, + "Y": 16 + }, + { + "X": 32, + "Y": 32 + }, + { + "X": 48, + "Y": 0 + }, + { + "X": 48, + "Y": 16 + }, + { + "X": 48, + "Y": 32 + }, + { + "X": 64, + "Y": 32 + }, + { + "X": 64, + "Y": 16 + }, + { + "X": 64, + "Y": 0 + }, + { + "X": 80, + "Y": 0 + }, + { + "X": 96, + "Y": 0 + }, + { + "X": 96, + "Y": 16 + }, + { + "X": 96, + "Y": 32 + }, + { + "X": 112, + "Y": 0 + }, + { + "X": 112, + "Y": 16 + }, + { + "X": 112, + "Y": 32 + } + ] + } + ] } ] } \ No newline at end of file diff --git a/DungeonShooting_Godot/scene/Main.tscn b/DungeonShooting_Godot/scene/Main.tscn index 346e221..698f3f2 100644 --- a/DungeonShooting_Godot/scene/Main.tscn +++ b/DungeonShooting_Godot/scene/Main.tscn @@ -39,5 +39,6 @@ process_callback = 0 editor_draw_drag_margin = true script = ExtResource("2_2j367") +RecoveryCoefficient = null [node name="GlobalNodeRoot" type="Node2D" parent="."] diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/CombinationCell.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/CombinationCell.cs new file mode 100644 index 0000000..b8ca7bd --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/CombinationCell.cs @@ -0,0 +1,44 @@ +namespace UI.MapEditorMapTile; + +public class CombinationCell : UiCell +{ + public override void OnInit() + { + CellNode.L_SelectTexture.Instance.Visible = false; + } + + public override void OnSetData(ImportCombinationData data) + { + CellNode.L_CellName.Instance.Text = data.CombinationInfo.Name; + CellNode.L_PreviewImage.Instance.Texture = data.PreviewTexture; + } + + public override void OnDisable() + { + if (Data.PreviewTexture != null) + { + Data.PreviewTexture.Dispose(); + Data.PreviewTexture = null; + } + } + + public override void OnDestroy() + { + if (Data.PreviewTexture != null) + { + Data.PreviewTexture.Dispose(); + Data.PreviewTexture = null; + } + } + + public override void OnSelect() + { + CellNode.L_SelectTexture.Instance.Visible = true; + + } + + public override void OnUnSelect() + { + CellNode.L_SelectTexture.Instance.Visible = false; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/CombinationTileTab.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/CombinationTileTab.cs index eca5a78..5daf432 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/CombinationTileTab.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/CombinationTileTab.cs @@ -7,15 +7,34 @@ /// public partial class CombinationTileTab : Control, IUiNodeScript { + public UiGrid Grid; private MapEditorMapTile.Tab3 _uiNode; public void SetUiNode(IUiNode uiNode) { _uiNode = (MapEditorMapTile.Tab3)uiNode; + Grid = _uiNode.UiPanel.CreateUiGrid(_uiNode.L_ScrollContainer.L_CellButton); + Grid.SetCellOffset(new Vector2I(5, 5)); + Grid.SetAutoColumns(true); + Grid.SetHorizontalExpand(true); } public void OnDestroy() { } + + /// + /// 刷新组合数据 + /// + public void RefreshCombination(TileSetSourceInfo sourceInfo) + { + Grid.RemoveAll(); + var src = sourceInfo.GetSourceImage(); + foreach (var combinationInfo in sourceInfo.Combination) + { + var previewImage = ImportCombinationData.GetPreviewTexture(src, combinationInfo.Cells, combinationInfo.Positions); + Grid.Add(new ImportCombinationData(ImageTexture.CreateFromImage(previewImage), combinationInfo)); + } + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTile.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTile.cs index 303fb6f..e6a7657 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTile.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTile.cs @@ -376,12 +376,78 @@ } /// - /// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.Label + /// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellButton.PreviewImage /// - public class Label_2 : UiNode + public class PreviewImage : UiNode { - public Label_2(MapEditorMapTilePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } - public override Label_2 Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + public PreviewImage(MapEditorMapTilePanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { } + public override PreviewImage Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellButton.CellName + /// + public class CellName : UiNode + { + public CellName(MapEditorMapTilePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override CellName Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellButton.SelectTexture + /// + public class SelectTexture : UiNode + { + public SelectTexture(MapEditorMapTilePanel uiPanel, Godot.NinePatchRect node) : base(uiPanel, node) { } + public override SelectTexture Clone() => new (UiPanel, (Godot.NinePatchRect)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellButton + /// + public class CellButton : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.PreviewImage + /// + public PreviewImage L_PreviewImage + { + get + { + if (_L_PreviewImage == null) _L_PreviewImage = new PreviewImage(UiPanel, Instance.GetNode("PreviewImage")); + return _L_PreviewImage; + } + } + private PreviewImage _L_PreviewImage; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellName + /// + public CellName L_CellName + { + get + { + if (_L_CellName == null) _L_CellName = new CellName(UiPanel, Instance.GetNode("CellName")); + return _L_CellName; + } + } + private CellName _L_CellName; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.SelectTexture + /// + public SelectTexture L_SelectTexture + { + get + { + if (_L_SelectTexture == null) _L_SelectTexture = new SelectTexture(UiPanel, Instance.GetNode("SelectTexture")); + return _L_SelectTexture; + } + } + private SelectTexture _L_SelectTexture; + + public CellButton(MapEditorMapTilePanel uiPanel, Godot.Button node) : base(uiPanel, node) { } + public override CellButton Clone() => new (UiPanel, (Godot.Button)Instance.Duplicate()); } /// @@ -390,17 +456,17 @@ public class ScrollContainer_1 : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.Label + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.CellButton /// - public Label_2 L_Label + public CellButton L_CellButton { get { - if (_L_Label == null) _L_Label = new Label_2(UiPanel, Instance.GetNode("Label")); - return _L_Label; + if (_L_CellButton == null) _L_CellButton = new CellButton(UiPanel, Instance.GetNode("CellButton")); + return _L_CellButton; } } - private Label_2 _L_Label; + private CellButton _L_CellButton; public ScrollContainer_1(MapEditorMapTilePanel uiPanel, Godot.ScrollContainer node) : base(uiPanel, node) { } public override ScrollContainer_1 Clone() => new (UiPanel, (Godot.ScrollContainer)Instance.Duplicate()); @@ -623,6 +689,26 @@ public Tab2 S_Tab2 => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab2; /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellButton.PreviewImage + /// + public PreviewImage S_PreviewImage => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab3.L_ScrollContainer.L_CellButton.L_PreviewImage; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellButton.CellName + /// + public CellName S_CellName => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab3.L_ScrollContainer.L_CellButton.L_CellName; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellButton.SelectTexture + /// + public SelectTexture S_SelectTexture => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab3.L_ScrollContainer.L_CellButton.L_SelectTexture; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3.ScrollContainer.CellButton + /// + public CellButton S_CellButton => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab3.L_ScrollContainer.L_CellButton; + + /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab3 /// public Tab3 S_Tab3 => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab3; diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs index c42fea6..42d90c6 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs @@ -81,6 +81,8 @@ S_Tab1.Instance.OnFocusClick(); //地形页签 S_Tab2.Instance.RefreshTerrain(sourceInfo); + //组合页签 + S_Tab3.Instance.RefreshCombination(sourceInfo); } EditorTileMap.SetCurrSourceIndex(SourceIndex); } diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/right/TileSelected.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/right/TileSelected.cs index 32a028d..5d546e2 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/right/TileSelected.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/right/TileSelected.cs @@ -34,7 +34,6 @@ { _rightBg.UiPanel.EditorPanel.TileSetSourceInfo.Combination.Add(data.CombinationInfo); Grid.Add(data); - Grid.Sort(); EventManager.EmitEvent(EventEnum.OnTileSetDirty); } }