diff --git a/DungeonShooting_Godot/src/framework/generator/ResourcePathGenerator.cs b/DungeonShooting_Godot/src/framework/generator/ResourcePathGenerator.cs index 350c142..4416ee1 100644 --- a/DungeonShooting_Godot/src/framework/generator/ResourcePathGenerator.cs +++ b/DungeonShooting_Godot/src/framework/generator/ResourcePathGenerator.cs @@ -19,7 +19,7 @@ //排除第一层的文件夹 private static string[] exclude = { - ".vscode", ".idea", ".git", ".import", ".mono", "android", "addons", ".godot" + ".vscode", ".idea", ".git", ".import", ".mono", "android", "addons", ".godot", ".vs" }; private static string currDir = System.Environment.CurrentDirectory; diff --git a/DungeonShooting_Godot/src/framework/generator/RoomPackGenerator.cs b/DungeonShooting_Godot/src/framework/generator/RoomPackGenerator.cs index ae872c9..5d3a4ce 100644 --- a/DungeonShooting_Godot/src/framework/generator/RoomPackGenerator.cs +++ b/DungeonShooting_Godot/src/framework/generator/RoomPackGenerator.cs @@ -13,7 +13,7 @@ /// public static class RoomPackGenerator { - private static string currDir = System.Environment.CurrentDirectory; + private static string _currDir = System.Environment.CurrentDirectory; /// /// 执行生成操作 @@ -110,8 +110,7 @@ private static string ToResPath(string path) { - var field = path.Substring(currDir.Length + 1); - field = field.Replace("\\", "/"); + var field = path.Replace("\\", "/"); return "res://" + field; } diff --git a/DungeonShooting_Godot/src/game/ui/editorTools/EditorToolsPanel.cs b/DungeonShooting_Godot/src/game/ui/editorTools/EditorToolsPanel.cs index 7938d55..1b35d41 100644 --- a/DungeonShooting_Godot/src/game/ui/editorTools/EditorToolsPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/editorTools/EditorToolsPanel.cs @@ -9,24 +9,56 @@ { //Tips 关闭回调 private Action _onTipsClose; + + //询问窗口关闭 + private Action _onConfirmClose; public override void OnShowUi(params object[] args) { + //tips + _onTipsClose = null; L_Tips.Instance.OkButtonText = "确定"; - L_Tips.Instance.CloseRequested += OnTipsCloseRequested; - L_ScrollContainer.L_MarginContainer.L_VBoxContainer.L_HBoxContainer3.L_Button.Instance.Pressed += OnCreateUI; + L_Tips.Instance.CloseRequested += OnTipsClose; + L_Tips.Instance.Confirmed += OnTipsClose; + L_Tips.Instance.Canceled += OnTipsClose; + + //confirm + _onConfirmClose = null; + L_Confirm.Instance.OkButtonText = "确定"; + L_Confirm.Instance.CancelButtonText = "取消"; + L_Confirm.Instance.Canceled += OnCanceled; + L_Confirm.Instance.CloseRequested += OnCanceled; + L_Confirm.Instance.Confirmed += OnConfirm; + + var container = L_ScrollContainer.L_MarginContainer.L_VBoxContainer; + //重新生成 ResourcePath + container.L_HBoxContainer.L_Button.Instance.Pressed += GenerateResourcePath; + //重新生成 RoomPack + container.L_HBoxContainer2.L_Button.Instance.Pressed += GenerateRoomPack; + //创建ui + container.L_HBoxContainer3.L_Button.Instance.Pressed += OnCreateUI; } public override void OnHideUi() { - L_Tips.Instance.CloseRequested -= OnTipsCloseRequested; - L_ScrollContainer.L_MarginContainer.L_VBoxContainer.L_HBoxContainer3.L_Button.Instance.Pressed -= OnCreateUI; + L_Tips.Instance.CloseRequested -= OnTipsClose; + L_Tips.Instance.Confirmed -= OnTipsClose; + L_Tips.Instance.Canceled -= OnTipsClose; + + L_Confirm.Instance.Canceled -= OnCanceled; + L_Confirm.Instance.CloseRequested -= OnCanceled; + L_Confirm.Instance.Confirmed -= OnConfirm; + + var container = L_ScrollContainer.L_MarginContainer.L_VBoxContainer; + container.L_HBoxContainer.L_Button.Instance.Pressed -= GenerateResourcePath; + container.L_HBoxContainer2.L_Button.Instance.Pressed -= GenerateRoomPack; + container.L_HBoxContainer3.L_Button.Instance.Pressed -= OnCreateUI; } /// /// Tips 关闭信号回调 /// - private void OnTipsCloseRequested() + private void OnTipsClose() { if (_onTipsClose != null) { @@ -34,6 +66,30 @@ _onTipsClose = null; } } + + /// + /// Confirm 确认信号回调 + /// + private void OnConfirm() + { + if (_onConfirmClose != null) + { + _onConfirmClose(true); + _onConfirmClose = null; + } + } + + /// + /// Confirm 取消信号回调 + /// + private void OnCanceled() + { + if (_onConfirmClose != null) + { + _onConfirmClose(false); + _onConfirmClose = null; + } + } /// /// 打开提示窗口, 并设置宽高 @@ -61,11 +117,7 @@ /// 当窗口关闭时的回调 public void ShowTips(string title, string message, Action onClose = null) { - var tips = L_Tips.Instance; - tips.Title = title; - tips.DialogText = message; - _onTipsClose = onClose; - tips.Show(); + ShowTips(title, message, 200, 124, onClose); } /// @@ -76,26 +128,64 @@ L_Tips.Instance.Hide(); _onTipsClose = null; } - - private void OnCreateUI() + + /// + /// 打开询问窗口, 并设置宽高 + /// + /// 窗口标题 + /// 显示内容 + /// 窗口宽度 + /// 窗口高度 + /// 当窗口关闭时的回调, 参数如果为 true 表示点击了确定按钮 + public void ShowConfirm(string title, string message, int width, int height, Action onClose = null) { - var text = L_ScrollContainer.L_MarginContainer.L_VBoxContainer.L_HBoxContainer3.L_LineEdit.Instance.Text; - GD.Print("ui名称: " + text); - ShowTips("创建Ui", "Ui名称: " + text, () => - { - GD.Print("关闭Tips"); - }); - } - - private void OnCloseCreateUiConfirm() - { - //L_CreateUiConfirm.Instance.Hide(); + var confirm = L_Confirm.Instance; + confirm.Size = new Vector2I(width, height); + confirm.Title = title; + confirm.DialogText = message; + _onConfirmClose = onClose; + confirm.Show(); } /// + /// 打开询问窗口 + /// + /// 窗口标题 + /// 显示内容 + /// 当窗口关闭时的回调, 参数如果为 true 表示点击了确定按钮 + public void ShowConfirm(string title, string message, Action onClose = null) + { + ShowConfirm(title, message, 200, 124, onClose); + } + + /// + /// 关闭询问窗口 + /// + public void CloseConfirm() + { + L_Confirm.Instance.Hide(); + _onConfirmClose = null; + } + + /// + /// 创建Ui + /// + private void OnCreateUI() + { + var text = L_ScrollContainer.L_MarginContainer.L_VBoxContainer.L_HBoxContainer3.L_LineEdit.Instance.Text; + ShowConfirm("提示", "是否创建UI:" + text, (result) => + { + if (result) + { + ShowTips("提示", "创建Ui成功!"); + } + }); + } + + /// /// 更新 ResourcePath /// - private void _on_Button_pressed() + private void GenerateResourcePath() { ResourcePathGenerator.Generate(); } @@ -103,7 +193,7 @@ /// /// 重新打包房间配置 /// - private void _on_Button2_pressed() + private void GenerateRoomPack() { RoomPackGenerator.Generate(); }