diff --git a/Example/SaveSystem/Script/ViewSaveSystem.cs b/Example/SaveSystem/Script/ViewSaveSystem.cs index 714ef34..323c241 100644 --- a/Example/SaveSystem/Script/ViewSaveSystem.cs +++ b/Example/SaveSystem/Script/ViewSaveSystem.cs @@ -37,6 +37,11 @@ namespace EGFramework.Examples.Test { // rowData2.Init(new Dictionary() { { "Name", "Z" }, { "Age", 1 } }); // EGodotEditParam editParam = container.CreateNode("editParam"); // editParam.Init(new KeyValuePair("数量",1)); + this.ExecuteAfterSecond(() => + { + this.EGAlert("-----~!"); + this.EGConfirm("fixed?", isconfirm => { GD.Print(isconfirm); }); + },1.0f); } public override void _ExitTree() diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs index 9be5002..f9cb052 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs @@ -6,45 +6,40 @@ namespace EGFramework.UI { public static void EGAlert(this Node self, string alertMsg, string title = "Alert") { - AcceptDialog acceptDialog = self.SingletoneNode("AlertDialog"); + AcceptDialog acceptDialog = self.PopupNode("AlertDialog"); acceptDialog.Title = title; acceptDialog.DialogText = alertMsg; - acceptDialog.PopupCentered(); } public static void EGConfirm(this Node self, string alertMsg, Action callback, string title = "Confirm") { - EGodotConfirmationDialog confirmDialog = self.SingletoneNode("ConfirmDialog"); + EGodotConfirmationDialog confirmDialog = self.PopupNode("ConfirmDialog"); confirmDialog.Title = title; confirmDialog.DialogText = alertMsg; - confirmDialog.PopupCentered(); confirmDialog.Init(callback); } public static void EGFileOpen(this Node self, string filePath, Action selectPath, string title = "Open a file") { - EGodotFileDialog fileDialog = self.SingletoneNode("FileDialog"); + EGodotFileDialog fileDialog = self.PopupNode("FileDialog"); fileDialog.Title = title; fileDialog.RootSubfolder = filePath; - fileDialog.PopupCentered(); fileDialog.InitFileSelect(selectPath); } public static void EGFileSave(this Node self, string filePath, Action selectPath, string title = "Save a file") { - EGodotFileDialog fileDialog = self.SingletoneNode("FileDialog"); + EGodotFileDialog fileDialog = self.PopupNode("FileDialog"); fileDialog.Title = title; fileDialog.RootSubfolder = filePath; - fileDialog.PopupCentered(); fileDialog.InitSaveFileSelect(selectPath); } public static void EGDocumentOpen(this Node self, string filePath, Action selectPath, string title = "FileSelect") { - EGodotFileDialog fileDialog = self.SingletoneNode("FileDialog"); + EGodotFileDialog fileDialog = self.PopupNode("FileDialog"); fileDialog.Title = title; fileDialog.RootSubfolder = filePath; - fileDialog.PopupCentered(); fileDialog.InitDirSelect(selectPath); } } diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotEditDialog.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotEditDialog.cs index e74e462..b2239a1 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotEditDialog.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotEditDialog.cs @@ -95,7 +95,7 @@ namespace EGFramework.UI { public static EGodotEditDialog EGEditDialog(this Node self, Dictionary data, Action> onDataEdit, string title = "Edit") { - EGodotEditDialog editDialog = self.SingletoneNode("FileDialog"); + EGodotEditDialog editDialog = self.SingletoneNode("Edit"); editDialog.InitDialog(data, onDataEdit, title); editDialog.PopupCentered(); return editDialog; diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs index 5c4e31a..9ca6917 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs @@ -13,9 +13,26 @@ namespace EGFramework{ public class EGSingletonNode : IEGFramework, IModule { public IOCContainer NodeContainer = new IOCContainer(); + public Queue WindowCache = new Queue(); + public Window CurrentWindow { set; get; } public void Init() { - + + } + + public void ReturnToLastWindow() + { + if (CurrentWindow != null && !CurrentWindow.Visible) + { + GD.Print("-----"); + if (this.WindowCache.Count > 0) + { + this.CurrentWindow.VisibilityChanged -= ReturnToLastWindow; + this.CurrentWindow.Hide(); + this.CurrentWindow = this.WindowCache.Dequeue(); + this.CurrentWindow?.PopupCentered(); + } + } } public IArchitecture GetArchitecture() @@ -27,21 +44,23 @@ namespace EGFramework{ public static class EGCanCreateNodeExtension { - public static TNode CreateNode(this Node self) where TNode : Node,new(){ + public static TNode CreateNode(this Node self) where TNode : Node, new() + { TNode nodeData = new TNode(); nodeData.Name = typeof(TNode).Name; self.AddChild(nodeData); return nodeData; } - public static TNode CreateNode(this Node self,string name) where TNode : Node,new(){ + public static TNode CreateNode(this Node self, string name) where TNode : Node, new() + { TNode nodeData = new TNode(); nodeData.Name = name; self.AddChild(nodeData); return nodeData; } - - public static TNode SingletoneNode(this Node self) where TNode : Node, new() + + public static TNode SingletoneNode(this Node self, string name) where TNode : Node, new() { TNode nodeData; if (EGArchitectureImplement.Interface.GetModule().NodeContainer.Get() != null) @@ -53,22 +72,41 @@ namespace EGFramework{ nodeData = self.GetTree().Root.CreateNode(); EGArchitectureImplement.Interface.GetModule().NodeContainer.Register(nodeData); } - nodeData.Name = typeof(TNode).Name; + nodeData.Name = name; return nodeData; } - public static TNode SingletoneNode(this Node self,string name) where TNode : Node, new() + + public static TWindowNode PopupNode(this Node self, string name) where TWindowNode : Window, new() { - TNode nodeData; - if (EGArchitectureImplement.Interface.GetModule().NodeContainer.Get() != null) + TWindowNode nodeData; + EGSingletonNode singletonNode = EGArchitectureImplement.Interface.GetModule(); + if (singletonNode.NodeContainer.Get() != null) { - nodeData = EGArchitectureImplement.Interface.GetModule().NodeContainer.Get(); + nodeData = singletonNode.NodeContainer.Get(); } else { - nodeData = self.GetTree().Root.CreateNode(); - EGArchitectureImplement.Interface.GetModule().NodeContainer.Register(nodeData); + nodeData = self.GetTree().Root.CreateNode(); + singletonNode.NodeContainer.Register(nodeData); } + singletonNode.WindowCache.Enqueue(nodeData); nodeData.Name = name; + // nodeData.CloseRequested += () => + // { + // if (!nodeData.Visible) + // { + // GD.Print("-----"); + // if (singletonNode.WindowCache.Count > 0) + // { + // singletonNode.CurrentWindow = singletonNode.WindowCache.Dequeue(); + // singletonNode.CurrentWindow?.PopupCentered(); + // } + // } + // }; + singletonNode.CurrentWindow?.Hide(); + nodeData.PopupCentered(); + singletonNode.CurrentWindow = nodeData; + // nodeData.VisibilityChanged += singletonNode.ReturnToLastWindow; return nodeData; } diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs index 7c953a0..b13c481 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs @@ -122,11 +122,15 @@ namespace EGFramework.UI ParamReadOnly.Text = pathSelect.Path; this.AddChild(ParamReadOnly); this.ParamOperate = new Button(); - ParamOperate.Name = "SelectBtn"; + ParamOperate.Name = "SelectBtn"; ParamOperate.Text = "Select file"; ParamOperate.SizeFlagsHorizontal = SizeFlags.ExpandFill; - ParamOperate.Pressed += () => { - this.EGFileOpen("res://", str => { ParamReadOnly.Text = str; }); + ParamOperate.Pressed += () => + { + this.EGFileOpen("res://", str => + { + ParamReadOnly.Text = str; + }); }; // ParamOperate.Pressed += this.AddChild(ParamOperate);