diff --git a/DungeonShooting_Godot/prefab/ui/EditorWindow.tscn b/DungeonShooting_Godot/prefab/ui/EditorWindow.tscn new file mode 100644 index 0000000..5c70ba8 --- /dev/null +++ b/DungeonShooting_Godot/prefab/ui/EditorWindow.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=2 format=3 uid="uid://bw342xeqc5div"] + +[ext_resource type="Script" path="res://src/game/ui/editorWindow/EditorWindowPanel.cs" id="1_bfitg"] + +[node name="EditorWindow" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource("1_bfitg") +Layer = 3 + +[node name="Window" type="Window" parent="."] +title = "标题" +initial_position = 1 +size = Vector2i(500, 350) +visible = false +min_size = Vector2i(500, 350) +theme_override_constants/title_height = 33 + +[node name="Panel" type="Panel" parent="Window"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="Window/Panel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Body" type="MarginContainer" parent="Window/Panel/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="HBoxContainer" type="HBoxContainer" parent="Window/Panel/VBoxContainer"] +custom_minimum_size = Vector2(0, 70) +layout_mode = 2 + +[node name="CustomButton" type="CenterContainer" parent="Window/Panel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Button" type="Button" parent="Window/Panel/VBoxContainer/HBoxContainer/CustomButton"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "确定" diff --git a/DungeonShooting_Godot/prefab/ui/MapEditorCreateRoom.tscn b/DungeonShooting_Godot/prefab/ui/MapEditorCreateRoom.tscn index 6012bae..1888357 100644 --- a/DungeonShooting_Godot/prefab/ui/MapEditorCreateRoom.tscn +++ b/DungeonShooting_Godot/prefab/ui/MapEditorCreateRoom.tscn @@ -11,3 +11,27 @@ grow_vertical = 2 script = ExtResource("1_dep3f") Layer = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="RoomNameLabel" type="Label" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 20.0 +text = "房间名称:" +horizontal_alignment = 2 +vertical_alignment = 1 + +[node name="RoomNameInput" type="LineEdit" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 80.0 diff --git a/DungeonShooting_Godot/src/framework/ui/UiBase.cs b/DungeonShooting_Godot/src/framework/ui/UiBase.cs index 32851ee..de390b5 100644 --- a/DungeonShooting_Godot/src/framework/ui/UiBase.cs +++ b/DungeonShooting_Godot/src/framework/ui/UiBase.cs @@ -16,18 +16,6 @@ public UiLayer Layer = UiLayer.Middle; /// - /// Ui 模式, 单例/正常模式 - /// - [Export] - public UiMode Mode = UiMode.Normal; - - /// - /// 阻止下层 Ui 点击 - /// - [Export] - public bool KeepOut = false; - - /// /// ui名称 /// public string UiName { get; } diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 6ccbe64..c694463 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -49,6 +49,7 @@ public const string prefab_test_TestActivity_tscn = "res://prefab/test/TestActivity.tscn"; public const string prefab_ui_BottomTips_tscn = "res://prefab/ui/BottomTips.tscn"; public const string prefab_ui_EditorTools_tscn = "res://prefab/ui/EditorTools.tscn"; + public const string prefab_ui_EditorWindow_tscn = "res://prefab/ui/EditorWindow.tscn"; public const string prefab_ui_Loading_tscn = "res://prefab/ui/Loading.tscn"; public const string prefab_ui_Main_tscn = "res://prefab/ui/Main.tscn"; public const string prefab_ui_MapEditor_tscn = "res://prefab/ui/MapEditor.tscn"; @@ -57,7 +58,6 @@ public const string prefab_ui_MapEditorTools_tscn = "res://prefab/ui/MapEditorTools.tscn"; public const string prefab_ui_RoomUI_tscn = "res://prefab/ui/RoomUI.tscn"; public const string prefab_ui_Settlement_tscn = "res://prefab/ui/Settlement.tscn"; - public const string prefab_ui_TestUi_tscn = "res://prefab/ui/TestUi.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 f1444e5..d0908ef 100644 --- a/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs +++ b/DungeonShooting_Godot/src/game/manager/UiManager_Methods.cs @@ -8,6 +8,7 @@ { public const string BottomTips = "BottomTips"; public const string EditorTools = "EditorTools"; + public const string EditorWindow = "EditorWindow"; public const string Loading = "Loading"; public const string Main = "Main"; public const string MapEditor = "MapEditor"; @@ -99,6 +100,46 @@ } /// + /// 打开 EditorWindow, 并返回UI实例 + /// + public static UI.EditorWindow.EditorWindowPanel Open_EditorWindow() + { + return OpenUi(UiName.EditorWindow); + } + + /// + /// 隐藏 EditorWindow 的所有实例 + /// + public static void Hide_EditorWindow() + { + var uiInstance = Get_EditorWindow_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.HideUi(); + } + } + + /// + /// 销毁 EditorWindow 的所有实例 + /// + public static void Dispose_EditorWindow() + { + var uiInstance = Get_EditorWindow_Instance(); + foreach (var uiPanel in uiInstance) + { + uiPanel.DisposeUi(); + } + } + + /// + /// 获取所有 EditorWindow 的实例, 如果没有实例, 则返回一个空数组 + /// + public static UI.EditorWindow.EditorWindowPanel[] Get_EditorWindow_Instance() + { + return GetUiInstance(nameof(UI.EditorWindow.EditorWindow)); + } + + /// /// 打开 Loading, 并返回UI实例 /// public static UI.Loading.LoadingPanel Open_Loading() diff --git a/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindow.cs b/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindow.cs new file mode 100644 index 0000000..cb6442d --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindow.cs @@ -0,0 +1,207 @@ +namespace UI.EditorWindow; + +/// +/// Ui代码, 该类是根据ui场景自动生成的, 请不要手动编辑该类, 以免造成代码丢失 +/// +public abstract partial class EditorWindow : UiBase +{ + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorWindow.Window + /// + public Window L_Window + { + get + { + if (_L_Window == null) _L_Window = new Window(this, GetNodeOrNull("Window")); + return _L_Window; + } + } + private Window _L_Window; + + + public EditorWindow() : base(nameof(EditorWindow)) + { + } + + public sealed override void OnInitNestedUi() + { + } + + /// + /// 类型: , 路径: EditorWindow.Window.Panel.VBoxContainer.Body + /// + public class Body : UiNode + { + public Body(EditorWindow uiPanel, Godot.MarginContainer node) : base(uiPanel, node) { } + public override Body Clone() => new (UiPanel, (Godot.MarginContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorWindow.Window.Panel.VBoxContainer.HBoxContainer.CustomButton.Button + /// + public class Button : UiNode + { + public Button(EditorWindow uiPanel, Godot.Button node) : base(uiPanel, node) { } + public override Button Clone() => new (UiPanel, (Godot.Button)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorWindow.Window.Panel.VBoxContainer.HBoxContainer.CustomButton + /// + public class CustomButton : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorWindow.Window.Panel.VBoxContainer.HBoxContainer.Button + /// + public Button L_Button + { + get + { + if (_L_Button == null) _L_Button = new Button(UiPanel, Instance.GetNodeOrNull("Button")); + return _L_Button; + } + } + private Button _L_Button; + + public CustomButton(EditorWindow uiPanel, Godot.CenterContainer node) : base(uiPanel, node) { } + public override CustomButton Clone() => new (UiPanel, (Godot.CenterContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorWindow.Window.Panel.VBoxContainer.HBoxContainer + /// + public class HBoxContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorWindow.Window.Panel.VBoxContainer.CustomButton + /// + public CustomButton L_CustomButton + { + get + { + if (_L_CustomButton == null) _L_CustomButton = new CustomButton(UiPanel, Instance.GetNodeOrNull("CustomButton")); + return _L_CustomButton; + } + } + private CustomButton _L_CustomButton; + + public HBoxContainer(EditorWindow uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorWindow.Window.Panel.VBoxContainer + /// + public class VBoxContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorWindow.Window.Panel.Body + /// + public Body L_Body + { + get + { + if (_L_Body == null) _L_Body = new Body(UiPanel, Instance.GetNodeOrNull("Body")); + return _L_Body; + } + } + private Body _L_Body; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorWindow.Window.Panel.HBoxContainer + /// + public HBoxContainer L_HBoxContainer + { + get + { + if (_L_HBoxContainer == null) _L_HBoxContainer = new HBoxContainer(UiPanel, Instance.GetNodeOrNull("HBoxContainer")); + return _L_HBoxContainer; + } + } + private HBoxContainer _L_HBoxContainer; + + public VBoxContainer(EditorWindow uiPanel, Godot.VBoxContainer node) : base(uiPanel, node) { } + public override VBoxContainer Clone() => new (UiPanel, (Godot.VBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorWindow.Window.Panel + /// + public class Panel : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorWindow.Window.VBoxContainer + /// + public VBoxContainer L_VBoxContainer + { + get + { + if (_L_VBoxContainer == null) _L_VBoxContainer = new VBoxContainer(UiPanel, Instance.GetNodeOrNull("VBoxContainer")); + return _L_VBoxContainer; + } + } + private VBoxContainer _L_VBoxContainer; + + public Panel(EditorWindow uiPanel, Godot.Panel node) : base(uiPanel, node) { } + public override Panel Clone() => new (UiPanel, (Godot.Panel)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: EditorWindow.Window + /// + public class Window : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: EditorWindow.Panel + /// + public Panel L_Panel + { + get + { + if (_L_Panel == null) _L_Panel = new Panel(UiPanel, Instance.GetNodeOrNull("Panel")); + return _L_Panel; + } + } + private Panel _L_Panel; + + public Window(EditorWindow uiPanel, Godot.Window node) : base(uiPanel, node) { } + public override Window Clone() => new (UiPanel, (Godot.Window)Instance.Duplicate()); + } + + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorWindow.Window.Panel.VBoxContainer.Body + /// + public Body S_Body => L_Window.L_Panel.L_VBoxContainer.L_Body; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorWindow.Window.Panel.VBoxContainer.HBoxContainer.CustomButton.Button + /// + public Button S_Button => L_Window.L_Panel.L_VBoxContainer.L_HBoxContainer.L_CustomButton.L_Button; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorWindow.Window.Panel.VBoxContainer.HBoxContainer.CustomButton + /// + public CustomButton S_CustomButton => L_Window.L_Panel.L_VBoxContainer.L_HBoxContainer.L_CustomButton; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorWindow.Window.Panel.VBoxContainer.HBoxContainer + /// + public HBoxContainer S_HBoxContainer => L_Window.L_Panel.L_VBoxContainer.L_HBoxContainer; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorWindow.Window.Panel.VBoxContainer + /// + public VBoxContainer S_VBoxContainer => L_Window.L_Panel.L_VBoxContainer; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorWindow.Window.Panel + /// + public Panel S_Panel => L_Window.L_Panel; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: EditorWindow.Window + /// + public Window S_Window => L_Window; + +} diff --git a/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindowPanel.cs b/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindowPanel.cs new file mode 100644 index 0000000..ba06445 --- /dev/null +++ b/DungeonShooting_Godot/src/game/ui/editorWindow/EditorWindowPanel.cs @@ -0,0 +1,53 @@ +using Godot; + +namespace UI.EditorWindow; + +public partial class EditorWindowPanel : EditorWindow +{ + + public override void OnCreateUi() + { + + } + + public override void OnDisposeUi() + { + + } + + /// + /// 打开子Ui并放入 Body 节点中 + /// + /// Ui名称 + public UiBase OpenBody(string uiName) + { + var nestedUi = S_Body.OpenNestedUi(uiName); + S_Window.Instance.Popup(); + return nestedUi; + } + + /// + /// 打开子Ui并放入 Body 节点中 + /// + /// Ui名称 + public T OpenBody(string uiName) where T : UiBase + { + return (T)OpenBody(uiName); + } + + /// + /// 设置标题 + /// + public void SetWindowTitle(string title) + { + S_Window.Instance.Title = title; + } + + /// + /// 设置窗体大小 + /// + public void SetWindowSize(Vector2I size) + { + S_Window.Instance.Size = size; + } +} diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorCreateRoom/MapEditorCreateRoom.cs b/DungeonShooting_Godot/src/game/ui/mapEditorCreateRoom/MapEditorCreateRoom.cs index 3290400..ac8225f 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorCreateRoom/MapEditorCreateRoom.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorCreateRoom/MapEditorCreateRoom.cs @@ -5,6 +5,19 @@ /// public abstract partial class MapEditorCreateRoom : UiBase { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorCreateRoom.VBoxContainer + /// + public VBoxContainer L_VBoxContainer + { + get + { + if (_L_VBoxContainer == null) _L_VBoxContainer = new VBoxContainer(this, GetNodeOrNull("VBoxContainer")); + return _L_VBoxContainer; + } + } + private VBoxContainer _L_VBoxContainer; + public MapEditorCreateRoom() : base(nameof(MapEditorCreateRoom)) { @@ -14,5 +27,100 @@ { } + /// + /// 类型: , 路径: MapEditorCreateRoom.VBoxContainer.HBoxContainer.RoomNameLabel + /// + public class RoomNameLabel : UiNode + { + public RoomNameLabel(MapEditorCreateRoom uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override RoomNameLabel Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: MapEditorCreateRoom.VBoxContainer.HBoxContainer.RoomNameInput + /// + public class RoomNameInput : UiNode + { + public RoomNameInput(MapEditorCreateRoom uiPanel, Godot.LineEdit node) : base(uiPanel, node) { } + public override RoomNameInput Clone() => new (UiPanel, (Godot.LineEdit)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: MapEditorCreateRoom.VBoxContainer.HBoxContainer + /// + public class HBoxContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorCreateRoom.VBoxContainer.RoomNameLabel + /// + public RoomNameLabel L_RoomNameLabel + { + get + { + if (_L_RoomNameLabel == null) _L_RoomNameLabel = new RoomNameLabel(UiPanel, Instance.GetNodeOrNull("RoomNameLabel")); + return _L_RoomNameLabel; + } + } + private RoomNameLabel _L_RoomNameLabel; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorCreateRoom.VBoxContainer.RoomNameInput + /// + public RoomNameInput L_RoomNameInput + { + get + { + if (_L_RoomNameInput == null) _L_RoomNameInput = new RoomNameInput(UiPanel, Instance.GetNodeOrNull("RoomNameInput")); + return _L_RoomNameInput; + } + } + private RoomNameInput _L_RoomNameInput; + + public HBoxContainer(MapEditorCreateRoom uiPanel, Godot.HBoxContainer node) : base(uiPanel, node) { } + public override HBoxContainer Clone() => new (UiPanel, (Godot.HBoxContainer)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: MapEditorCreateRoom.VBoxContainer + /// + public class VBoxContainer : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorCreateRoom.HBoxContainer + /// + public HBoxContainer L_HBoxContainer + { + get + { + if (_L_HBoxContainer == null) _L_HBoxContainer = new HBoxContainer(UiPanel, Instance.GetNodeOrNull("HBoxContainer")); + return _L_HBoxContainer; + } + } + private HBoxContainer _L_HBoxContainer; + + public VBoxContainer(MapEditorCreateRoom uiPanel, Godot.VBoxContainer node) : base(uiPanel, node) { } + public override VBoxContainer Clone() => new (UiPanel, (Godot.VBoxContainer)Instance.Duplicate()); + } + + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorCreateRoom.VBoxContainer.HBoxContainer.RoomNameLabel + /// + public RoomNameLabel S_RoomNameLabel => L_VBoxContainer.L_HBoxContainer.L_RoomNameLabel; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorCreateRoom.VBoxContainer.HBoxContainer.RoomNameInput + /// + public RoomNameInput S_RoomNameInput => L_VBoxContainer.L_HBoxContainer.L_RoomNameInput; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorCreateRoom.VBoxContainer.HBoxContainer + /// + public HBoxContainer S_HBoxContainer => L_VBoxContainer.L_HBoxContainer; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorCreateRoom.VBoxContainer + /// + public VBoxContainer S_VBoxContainer => L_VBoxContainer; } diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorCreateRoom/MapEditorCreateRoomPanel.cs b/DungeonShooting_Godot/src/game/ui/mapEditorCreateRoom/MapEditorCreateRoomPanel.cs index 81fcff8..087d66a 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorCreateRoom/MapEditorCreateRoomPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorCreateRoom/MapEditorCreateRoomPanel.cs @@ -7,17 +7,17 @@ public override void OnCreateUi() { - //S_ConfirmationDialog.Instance.Title = "创建地牢房间"; + } public override void OnShowUi() { - //S_ConfirmationDialog.Instance.VisibilityChanged += OnVisibilityChanged; + } public override void OnHideUi() { - //S_ConfirmationDialog.Instance.VisibilityChanged -= OnVisibilityChanged; + } public override void OnDisposeUi() diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorProject/MapEditorProjectPanel.cs b/DungeonShooting_Godot/src/game/ui/mapEditorProject/MapEditorProjectPanel.cs index c9d36d6..27030cf 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorProject/MapEditorProjectPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorProject/MapEditorProjectPanel.cs @@ -111,6 +111,9 @@ //创建地牢房间按钮点击 private void OnCreateRoomClick() { - UiManager.Open_MapEditorCreateRoom(); + var window = UiManager.Open_EditorWindow(); + window.SetWindowTitle("创建地牢房间"); + window.SetWindowSize(new Vector2I(1000, 800)); + window.OpenBody(UiManager.UiName.MapEditorCreateRoom); } }