diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index e069a75..ae650b1 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -1,4 +1,4 @@ - + net8.0 true diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn index fe00307..4514f01 100644 --- a/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditor.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=4 format=3 uid="uid://dn5brsxa6w3l6"] +[gd_scene load_steps=5 format=3 uid="uid://dn5brsxa6w3l6"] [ext_resource type="Script" path="res://src/game/ui/tileSetEditor/TileSetEditorPanel.cs" id="1_rgx4n"] [ext_resource type="Texture2D" uid="uid://cajcnlimvoxk" path="res://resource/sprite/ui/commonIcon/Back.png" id="2_naycu"] [ext_resource type="Texture2D" uid="uid://cat35d7ueu7gu" path="res://resource/sprite/ui/commonIcon/Save.png" id="3_bcuxk"] +[ext_resource type="Texture2D" uid="uid://bn47bmilcw4x0" path="res://resource/sprite/ui/commonIcon/Select2.png" id="4_t8bqb"] [node name="TileSetEditor" type="Control"] layout_mode = 3 @@ -74,28 +75,44 @@ size_flags_horizontal = 3 [node name="MarginContainer" type="MarginContainer" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot"] -layout_mode = 2 -offset_right = 213.0 -offset_bottom = 1010.0 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 size_flags_horizontal = 3 theme_override_constants/margin_left = 2 theme_override_constants/margin_top = 2 theme_override_constants/margin_right = 2 theme_override_constants/margin_bottom = 2 -[node name="GridContainer" type="ScrollContainer" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot/MarginContainer"] +[node name="ScrollContainer" type="ScrollContainer" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot/MarginContainer"] layout_mode = 2 -[node name="VBoxContainer" type="VBoxContainer" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot/MarginContainer/GridContainer"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="Tab" type="Button" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot/MarginContainer/GridContainer/VBoxContainer"] +[node name="Tab" type="Button" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot/MarginContainer/ScrollContainer"] custom_minimum_size = Vector2(0, 60) layout_mode = 2 -text = "纹理" +size_flags_horizontal = 3 +text = "页签" +flat = true + +[node name="Select" type="NinePatchRect" parent="Bg/VBoxContainer/HBoxContainer/LeftRoot/MarginContainer/ScrollContainer/Tab"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("4_t8bqb") +region_rect = Rect2(0, 0, 36, 36) +patch_margin_left = 3 +patch_margin_top = 3 +patch_margin_right = 3 +patch_margin_bottom = 3 [node name="RightRoot" type="Panel" parent="Bg/VBoxContainer/HBoxContainer"] +clip_children = 2 layout_mode = 2 size_flags_horizontal = 3 size_flags_stretch_ratio = 8.0 diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorImport.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorImport.tscn index 208baa3..a4491a0 100644 --- a/DungeonShooting_Godot/prefab/ui/TileSetEditorImport.tscn +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorImport.tscn @@ -8,6 +8,8 @@ anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 script = ExtResource("1_rkxih") [node name="ImportPreviewBg" type="ColorRect" parent="."] @@ -17,7 +19,6 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -mouse_filter = 2 color = Color(0.278431, 0.278431, 0.278431, 1) [node name="ImportButton" type="Button" parent="."] @@ -73,6 +74,7 @@ offset_bottom = 0.5 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 [node name="ImportPreview" type="Sprite2D" parent="Control"] diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorSegment.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorSegment.tscn new file mode 100644 index 0000000..985a78f --- /dev/null +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorSegment.tscn @@ -0,0 +1,71 @@ +[gd_scene load_steps=2 format=3 uid="uid://daias2tkvj20c"] + +[ext_resource type="Script" path="res://src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs" id="1_to1lc"] + +[node name="TileSetEditorSegment" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource("1_to1lc") + +[node name="HSplitContainer" type="HSplitContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Left" type="Panel" parent="HSplitContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 70.0 + +[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/Left"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 2 +theme_override_constants/margin_top = 2 +theme_override_constants/margin_right = 2 +theme_override_constants/margin_bottom = 2 + +[node name="LeftBg" type="ColorRect" parent="HSplitContainer/Left/MarginContainer"] +layout_mode = 2 +color = Color(0.203922, 0.203922, 0.203922, 1) + +[node name="TileTexture" type="TextureRect" parent="HSplitContainer/Left/MarginContainer/LeftBg"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -667.0 +offset_top = -538.0 +offset_right = 667.0 +offset_bottom = 538.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 4 + +[node name="Right" type="Panel" parent="HSplitContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 30.0 + +[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/Right"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 2 +theme_override_constants/margin_top = 2 +theme_override_constants/margin_right = 2 +theme_override_constants/margin_bottom = 2 diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn new file mode 100644 index 0000000..1d83eb1 --- /dev/null +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://dfqb73y4br8yd"] + +[ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs" id="1_6jjk7"] + +[node name="TileSetEditorTerrain" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource("1_6jjk7") diff --git a/DungeonShooting_Godot/src/framework/ui/UiBase.cs b/DungeonShooting_Godot/src/framework/ui/UiBase.cs index 17e6d7e..6c932ef 100644 --- a/DungeonShooting_Godot/src/framework/ui/UiBase.cs +++ b/DungeonShooting_Godot/src/framework/ui/UiBase.cs @@ -42,10 +42,17 @@ /// public IUiNode ParentNode { get; private set; } + /// + /// 是否是嵌套的子 Ui + /// + public bool IsNestedUi => ParentUi != null; + //开启的协程 private List _coroutineList; //嵌套打开的Ui列表 private HashSet _nestedUiSet; + //嵌套模式下是否打开Ui + private bool _nestedOpen; //当前Ui包含的 IUiNodeScript 接口, 关闭Ui是需要调用 IUiNodeScript.OnDestroy() private HashSet _nodeScripts; @@ -113,6 +120,7 @@ return; } + _nestedOpen = true; IsOpen = true; Visible = true; OnShowUi(); @@ -122,7 +130,10 @@ { foreach (var uiBase in _nestedUiSet) { - uiBase.ShowUi(); + if (uiBase._nestedOpen || uiBase.Visible) + { + uiBase.ShowUi(); + } } } } @@ -142,6 +153,7 @@ return; } + _nestedOpen = false; IsOpen = false; Visible = false; OnHideUi(); @@ -151,7 +163,11 @@ { foreach (var uiBase in _nestedUiSet) { - uiBase.HideUi(); + if (uiBase._nestedOpen) + { + uiBase.HideUi(); + uiBase._nestedOpen = true; + } } } } @@ -220,6 +236,7 @@ { var packedScene = ResourceManager.Load("res://" + GameConfig.UiPrefabDir + uiName + ".tscn"); var uiBase = packedScene.Instantiate(); + uiBase.Visible = false; uiBase.PrevUi = prevUi; AddChild(uiBase); RecordNestedUi(uiBase, null, UiManager.RecordType.Open); diff --git a/DungeonShooting_Godot/src/framework/ui/UiNode.cs b/DungeonShooting_Godot/src/framework/ui/UiNode.cs index f6e49c0..b5718be 100644 --- a/DungeonShooting_Godot/src/framework/ui/UiNode.cs +++ b/DungeonShooting_Godot/src/framework/ui/UiNode.cs @@ -43,6 +43,7 @@ { var packedScene = ResourceManager.Load("res://" + GameConfig.UiPrefabDir + uiName + ".tscn"); var uiBase = packedScene.Instantiate(); + uiBase.Visible = false; uiBase.PrevUi = prevUi; Instance.AddChild(uiBase); UiPanel.RecordNestedUi(uiBase, this, UiManager.RecordType.Open); diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index be86866..c35d34a 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -87,6 +87,8 @@ public const string prefab_ui_TileSetEditor_tscn = "res://prefab/ui/TileSetEditor.tscn"; public const string prefab_ui_TileSetEditorImport_tscn = "res://prefab/ui/TileSetEditorImport.tscn"; public const string prefab_ui_TileSetEditorProject_tscn = "res://prefab/ui/TileSetEditorProject.tscn"; + public const string prefab_ui_TileSetEditorSegment_tscn = "res://prefab/ui/TileSetEditorSegment.tscn"; + public const string prefab_ui_TileSetEditorTerrain_tscn = "res://prefab/ui/TileSetEditorTerrain.tscn"; public const string prefab_weapon_Weapon0001_tscn = "res://prefab/weapon/Weapon0001.tscn"; public const string prefab_weapon_Weapon0002_tscn = "res://prefab/weapon/Weapon0002.tscn"; public const string prefab_weapon_Weapon0003_tscn = "res://prefab/weapon/Weapon0003.tscn"; diff --git a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs index 5b9c65c..d24d818 100644 --- a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs +++ b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs @@ -31,6 +31,8 @@ public const string TileSetEditor = "TileSetEditor"; public const string TileSetEditorImport = "TileSetEditorImport"; public const string TileSetEditorProject = "TileSetEditorProject"; + public const string TileSetEditorSegment = "TileSetEditorSegment"; + public const string TileSetEditorTerrain = "TileSetEditorTerrain"; } /// @@ -1281,4 +1283,100 @@ return GetUiInstance(nameof(UI.TileSetEditorProject.TileSetEditorProject)); } + /// + /// 创建 TileSetEditorSegment, 并返回UI实例, 该函数不会打开 Ui + /// + public static UI.TileSetEditorSegment.TileSetEditorSegmentPanel Create_TileSetEditorSegment() + { + return CreateUi(UiNames.TileSetEditorSegment); + } + + /// + /// 打开 TileSetEditorSegment, 并返回UI实例 + /// + public static UI.TileSetEditorSegment.TileSetEditorSegmentPanel Open_TileSetEditorSegment() + { + return OpenUi(UiNames.TileSetEditorSegment); + } + + /// + /// 隐藏 TileSetEditorSegment 的所有实例 + /// + public static void Hide_TileSetEditorSegment() + { + var uiInstance = Get_TileSetEditorSegment_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.HideUi(); + } + } + + /// + /// 销毁 TileSetEditorSegment 的所有实例 + /// + public static void Destroy_TileSetEditorSegment() + { + var uiInstance = Get_TileSetEditorSegment_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.Destroy(); + } + } + + /// + /// 获取所有 TileSetEditorSegment 的实例, 如果没有实例, 则返回一个空数组 + /// + public static UI.TileSetEditorSegment.TileSetEditorSegmentPanel[] Get_TileSetEditorSegment_Instance() + { + return GetUiInstance(nameof(UI.TileSetEditorSegment.TileSetEditorSegment)); + } + + /// + /// 创建 TileSetEditorTerrain, 并返回UI实例, 该函数不会打开 Ui + /// + public static UI.TileSetEditorTerrain.TileSetEditorTerrainPanel Create_TileSetEditorTerrain() + { + return CreateUi(UiNames.TileSetEditorTerrain); + } + + /// + /// 打开 TileSetEditorTerrain, 并返回UI实例 + /// + public static UI.TileSetEditorTerrain.TileSetEditorTerrainPanel Open_TileSetEditorTerrain() + { + return OpenUi(UiNames.TileSetEditorTerrain); + } + + /// + /// 隐藏 TileSetEditorTerrain 的所有实例 + /// + public static void Hide_TileSetEditorTerrain() + { + var uiInstance = Get_TileSetEditorTerrain_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.HideUi(); + } + } + + /// + /// 销毁 TileSetEditorTerrain 的所有实例 + /// + public static void Destroy_TileSetEditorTerrain() + { + var uiInstance = Get_TileSetEditorTerrain_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.Destroy(); + } + } + + /// + /// 获取所有 TileSetEditorTerrain 的实例, 如果没有实例, 则返回一个空数组 + /// + public static UI.TileSetEditorTerrain.TileSetEditorTerrainPanel[] Get_TileSetEditorTerrain_Instance() + { + return GetUiInstance(nameof(UI.TileSetEditorTerrain.TileSetEditorTerrain)); + } + } diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditor.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditor.cs index 9ac15a4..cf59b45 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditor.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditor.cs @@ -104,21 +104,43 @@ } /// - /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.GridContainer.VBoxContainer.Tab + /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.ScrollContainer.Tab.Select + /// + public class Select : UiNode + { + public Select(TileSetEditorPanel uiPanel, Godot.NinePatchRect node) : base(uiPanel, node) { } + public override Select Clone() => new (UiPanel, (Godot.NinePatchRect)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.ScrollContainer.Tab /// public class Tab : UiNode { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.ScrollContainer.Select + /// + public Select L_Select + { + get + { + if (_L_Select == null) _L_Select = new Select(UiPanel, Instance.GetNode("Select")); + return _L_Select; + } + } + private Select _L_Select; + public Tab(TileSetEditorPanel uiPanel, Godot.Button node) : base(uiPanel, node) { } public override Tab Clone() => new (UiPanel, (Godot.Button)Instance.Duplicate()); } /// - /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.GridContainer.VBoxContainer + /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.ScrollContainer /// - public class VBoxContainer_1 : UiNode + public class ScrollContainer : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.GridContainer.Tab + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.Tab /// public Tab L_Tab { @@ -130,30 +152,8 @@ } private Tab _L_Tab; - public VBoxContainer_1(TileSetEditorPanel uiPanel, Godot.VBoxContainer node) : base(uiPanel, node) { } - public override VBoxContainer_1 Clone() => new (UiPanel, (Godot.VBoxContainer)Instance.Duplicate()); - } - - /// - /// 类型: , 路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.GridContainer - /// - public class GridContainer : UiNode - { - /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.VBoxContainer - /// - public VBoxContainer_1 L_VBoxContainer - { - get - { - if (_L_VBoxContainer == null) _L_VBoxContainer = new VBoxContainer_1(UiPanel, Instance.GetNode("VBoxContainer")); - return _L_VBoxContainer; - } - } - private VBoxContainer_1 _L_VBoxContainer; - - public GridContainer(TileSetEditorPanel uiPanel, Godot.ScrollContainer node) : base(uiPanel, node) { } - public override GridContainer Clone() => new (UiPanel, (Godot.ScrollContainer)Instance.Duplicate()); + public ScrollContainer(TileSetEditorPanel uiPanel, Godot.ScrollContainer node) : base(uiPanel, node) { } + public override ScrollContainer Clone() => new (UiPanel, (Godot.ScrollContainer)Instance.Duplicate()); } /// @@ -162,17 +162,17 @@ public class MarginContainer : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.GridContainer + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.ScrollContainer /// - public GridContainer L_GridContainer + public ScrollContainer L_ScrollContainer { get { - if (_L_GridContainer == null) _L_GridContainer = new GridContainer(UiPanel, Instance.GetNode("GridContainer")); - return _L_GridContainer; + if (_L_ScrollContainer == null) _L_ScrollContainer = new ScrollContainer(UiPanel, Instance.GetNode("ScrollContainer")); + return _L_ScrollContainer; } } - private GridContainer _L_GridContainer; + private ScrollContainer _L_ScrollContainer; public MarginContainer(TileSetEditorPanel uiPanel, Godot.MarginContainer node) : base(uiPanel, node) { } public override MarginContainer Clone() => new (UiPanel, (Godot.MarginContainer)Instance.Duplicate()); @@ -323,14 +323,19 @@ public Head S_Head => L_Bg.L_VBoxContainer.L_Head; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.GridContainer.VBoxContainer.Tab + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.ScrollContainer.Tab.Select /// - public Tab S_Tab => L_Bg.L_VBoxContainer.L_HBoxContainer.L_LeftRoot.L_MarginContainer.L_GridContainer.L_VBoxContainer.L_Tab; + public Select S_Select => L_Bg.L_VBoxContainer.L_HBoxContainer.L_LeftRoot.L_MarginContainer.L_ScrollContainer.L_Tab.L_Select; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.GridContainer + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.ScrollContainer.Tab /// - public GridContainer S_GridContainer => L_Bg.L_VBoxContainer.L_HBoxContainer.L_LeftRoot.L_MarginContainer.L_GridContainer; + public Tab S_Tab => L_Bg.L_VBoxContainer.L_HBoxContainer.L_LeftRoot.L_MarginContainer.L_ScrollContainer.L_Tab; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer.ScrollContainer + /// + public ScrollContainer S_ScrollContainer => L_Bg.L_VBoxContainer.L_HBoxContainer.L_LeftRoot.L_MarginContainer.L_ScrollContainer; /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer.HBoxContainer.LeftRoot.MarginContainer @@ -353,6 +358,11 @@ public HBoxContainer S_HBoxContainer => L_Bg.L_VBoxContainer.L_HBoxContainer; /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg.VBoxContainer + /// + public VBoxContainer S_VBoxContainer => L_Bg.L_VBoxContainer; + + /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditor.Bg /// public Bg S_Bg => L_Bg; diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs index 3996042..ee046a1 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs @@ -14,19 +14,45 @@ /// public Texture Texture; - private UiGrid _tabGrid; + /// + /// 背景颜色 + /// + public Color BgColor; + + /// + /// 页签对象 + /// + public UiGrid TabGrid { get; private set; } public override void OnCreateUi() { S_Back.Instance.Visible = PrevUi != null; S_Back.Instance.Pressed += OnBackClick; - _tabGrid = new UiGrid(S_Tab, typeof(object)); + TabGrid = new UiGrid(S_Tab, typeof(TileSetEditorTabCell)); + TabGrid.SetHorizontalExpand(true); + TabGrid.SetCellOffset(new Vector2I(0, 5)); + TabGrid.Add(new TileSetEditorTabData() + { + Text = "纹理", + UiName = UiManager.UiNames.TileSetEditorImport, + }); + TabGrid.Add(new TileSetEditorTabData() + { + Text = "图块", + UiName = UiManager.UiNames.TileSetEditorSegment, + }); + TabGrid.Add(new TileSetEditorTabData() + { + Text = "地形", + UiName = UiManager.UiNames.TileSetEditorTerrain, + }); + TabGrid.SelectIndex = 0; } public override void OnDestroyUi() { - _tabGrid.Destroy(); + TabGrid.Destroy(); } public void InitData(TileSetInfo tileSetInfo) diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorTabCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorTabCell.cs new file mode 100644 index 0000000..1afe775 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorTabCell.cs @@ -0,0 +1,30 @@ +namespace UI.TileSetEditor; + +public class TileSetEditorTabCell : UiCell +{ + private UiBase _uiInstance; + + public override void OnInit() + { + CellNode.L_Select.Instance.Visible = false; + } + + public override void OnSetData(TileSetEditorTabData data) + { + CellNode.Instance.Text = data.Text; + _uiInstance = CellNode.UiPanel.S_RightRoot.OpenNestedUi(data.UiName); + _uiInstance.HideUi(); + } + + public override void OnSelect() + { + CellNode.L_Select.Instance.Visible = true; + _uiInstance.ShowUi(); + } + + public override void OnUnSelect() + { + CellNode.L_Select.Instance.Visible = false; + _uiInstance.HideUi(); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs index 43caebc..c0a7961 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs @@ -14,7 +14,10 @@ public override void OnCreateUi() { _tileSetEditor = (TileSetEditor.TileSetEditorPanel)ParentUi; - _dragBinder = DragUiManager.BindDrag(S_ImportButton.Instance, OnDragCallback); + _tileSetEditor.BgColor = S_ImportPreviewBg.Instance.Color; + + _dragBinder = DragUiManager.BindDrag(S_ImportPreviewBg.Instance, OnDragCallback); + GetTree().Root.FilesDropped += OnFilesDropped; S_ImportButton.Instance.Pressed += OnImportButtonClick; S_ReimportButton.Instance.Pressed += OnReimportButtonClick; @@ -89,7 +92,11 @@ S_ImportColorPicker.Instance.GlobalPosition, S_ImportPreviewBg.Instance.Color, //设置颜色 - color => { S_ImportPreviewBg.Instance.Color = color; }, + color => + { + S_ImportPreviewBg.Instance.Color = color; + _tileSetEditor.BgColor = color; + }, //关闭窗口 () => { _isOpenColorPicker = false; } ); @@ -152,6 +159,7 @@ //隐藏导入文本和icon S_ImportLabel.Instance.Visible = false; S_ImportIcon.Instance.Visible = false; + S_ImportButton.Instance.Visible = false; } } diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegment.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegment.cs new file mode 100644 index 0000000..5d51354 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegment.cs @@ -0,0 +1,198 @@ +namespace UI.TileSetEditorSegment; + +/// +/// Ui代码, 该类是根据ui场景自动生成的, 请不要手动编辑该类, 以免造成代码丢失 +/// +public abstract partial class TileSetEditorSegment : UiBase +{ + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer + /// + public HSplitContainer L_HSplitContainer + { + get + { + if (_L_HSplitContainer == null) _L_HSplitContainer = new HSplitContainer((TileSetEditorSegmentPanel)this, GetNode("HSplitContainer")); + return _L_HSplitContainer; + } + } + private HSplitContainer _L_HSplitContainer; + + + public TileSetEditorSegment() : base(nameof(TileSetEditorSegment)) + { + } + + public sealed override void OnInitNestedUi() + { + + } + + /// + /// 类型: , 路径: TileSetEditorSegment.HSplitContainer.Left.MarginContainer.LeftBg.TileTexture + /// + public class TileTexture : UiNode + { + public TileTexture(TileSetEditorSegmentPanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { } + public override TileTexture Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorSegment.HSplitContainer.Left.MarginContainer.LeftBg + /// + public class LeftBg : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Left.MarginContainer.TileTexture + /// + public TileTexture L_TileTexture + { + get + { + if (_L_TileTexture == null) _L_TileTexture = new TileTexture(UiPanel, Instance.GetNode("TileTexture")); + return _L_TileTexture; + } + } + private TileTexture _L_TileTexture; + + public LeftBg(TileSetEditorSegmentPanel uiPanel, Godot.ColorRect node) : base(uiPanel, node) { } + public override LeftBg Clone() => new (UiPanel, (Godot.ColorRect)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorSegment.HSplitContainer.Left.MarginContainer + /// + public class MarginContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Left.LeftBg + /// + public LeftBg L_LeftBg + { + get + { + if (_L_LeftBg == null) _L_LeftBg = new LeftBg(UiPanel, Instance.GetNode("LeftBg")); + return _L_LeftBg; + } + } + private LeftBg _L_LeftBg; + + public MarginContainer(TileSetEditorSegmentPanel uiPanel, Godot.MarginContainer node) : base(uiPanel, node) { } + public override MarginContainer Clone() => new (UiPanel, (Godot.MarginContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorSegment.HSplitContainer.Left + /// + public class Left : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.MarginContainer + /// + public MarginContainer L_MarginContainer + { + get + { + if (_L_MarginContainer == null) _L_MarginContainer = new MarginContainer(UiPanel, Instance.GetNode("MarginContainer")); + return _L_MarginContainer; + } + } + private MarginContainer _L_MarginContainer; + + public Left(TileSetEditorSegmentPanel uiPanel, Godot.Panel node) : base(uiPanel, node) { } + public override Left Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorSegment.HSplitContainer.Right.MarginContainer + /// + public class MarginContainer_1 : UiNode + { + public MarginContainer_1(TileSetEditorSegmentPanel uiPanel, Godot.MarginContainer node) : base(uiPanel, node) { } + public override MarginContainer_1 Clone() => new (UiPanel, (Godot.MarginContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorSegment.HSplitContainer.Right + /// + public class Right : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.MarginContainer + /// + public MarginContainer_1 L_MarginContainer + { + get + { + if (_L_MarginContainer == null) _L_MarginContainer = new MarginContainer_1(UiPanel, Instance.GetNode("MarginContainer")); + return _L_MarginContainer; + } + } + private MarginContainer_1 _L_MarginContainer; + + public Right(TileSetEditorSegmentPanel uiPanel, Godot.Panel node) : base(uiPanel, node) { } + public override Right Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorSegment.HSplitContainer + /// + public class HSplitContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.Left + /// + public Left L_Left + { + get + { + if (_L_Left == null) _L_Left = new Left(UiPanel, Instance.GetNode("Left")); + return _L_Left; + } + } + private Left _L_Left; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorSegment.Right + /// + public Right L_Right + { + get + { + if (_L_Right == null) _L_Right = new Right(UiPanel, Instance.GetNode("Right")); + return _L_Right; + } + } + private Right _L_Right; + + public HSplitContainer(TileSetEditorSegmentPanel uiPanel, Godot.HSplitContainer node) : base(uiPanel, node) { } + public override HSplitContainer Clone() => new (UiPanel, (Godot.HSplitContainer)Instance.Duplicate()); + } + + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Left.MarginContainer.LeftBg.TileTexture + /// + public TileTexture S_TileTexture => L_HSplitContainer.L_Left.L_MarginContainer.L_LeftBg.L_TileTexture; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Left.MarginContainer.LeftBg + /// + public LeftBg S_LeftBg => L_HSplitContainer.L_Left.L_MarginContainer.L_LeftBg; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Left + /// + public Left S_Left => L_HSplitContainer.L_Left; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer.Right + /// + public Right S_Right => L_HSplitContainer.L_Right; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorSegment.HSplitContainer + /// + public HSplitContainer S_HSplitContainer => L_HSplitContainer; + +} diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs new file mode 100644 index 0000000..2170239 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs @@ -0,0 +1,34 @@ +using Godot; +using UI.TileSetEditor; + +namespace UI.TileSetEditorSegment; + +public partial class TileSetEditorSegmentPanel : TileSetEditorSegment +{ + + private TileSetEditorPanel _editorPanel; + + public override void OnCreateUi() + { + _editorPanel = (TileSetEditorPanel)ParentUi; + } + + public override void OnShowUi() + { + if (_editorPanel.Texture == null) + { + EditorWindowManager.ShowTips("警告", "请先导入纹理!", () => + { + _editorPanel.TabGrid.SelectIndex = 0; + }); + } + + S_LeftBg.Instance.Color = _editorPanel.BgColor; + } + + public override void OnDestroyUi() + { + + } + +} diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs new file mode 100644 index 0000000..d6a0e26 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs @@ -0,0 +1,19 @@ +namespace UI.TileSetEditorTerrain; + +/// +/// Ui代码, 该类是根据ui场景自动生成的, 请不要手动编辑该类, 以免造成代码丢失 +/// +public abstract partial class TileSetEditorTerrain : UiBase +{ + + public TileSetEditorTerrain() : base(nameof(TileSetEditorTerrain)) + { + } + + public sealed override void OnInitNestedUi() + { + + } + + +} diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs new file mode 100644 index 0000000..e7fcf6a --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs @@ -0,0 +1,18 @@ +using Godot; + +namespace UI.TileSetEditorTerrain; + +public partial class TileSetEditorTerrainPanel : TileSetEditorTerrain +{ + + public override void OnCreateUi() + { + + } + + public override void OnDestroyUi() + { + + } + +}