diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs index df25c45..7dce73c 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs @@ -14,46 +14,33 @@ namespace EGFramework.UI public static void EGConfirm(this Node self, string alertMsg, Action callback, string title = "Confirm") { - ConfirmationDialog confirmDialog = self.SingletoneNode("ConfirmDialog"); + EGodotConfirmationDialog confirmDialog = self.SingletoneNode("ConfirmDialog"); confirmDialog.Title = title; confirmDialog.DialogText = alertMsg; confirmDialog.PopupCentered(); - confirmDialog.Connect("confirmed", Callable.From(() => - { - callback(true); - })); - confirmDialog.Connect("canceled", Callable.From(() => - { - callback(false); - })); + confirmDialog.Init(callback); } - public static void EGFileSingleSelect(this Node self, string filePath, Action selectPath, string title = "FileSelect") - { - FileDialog fileDialog = self.SingletoneNode("FileDialog"); - fileDialog.Title = title; - fileDialog.Size = new Vector2I(480, 320); - fileDialog.FileMode = FileDialog.FileModeEnum.OpenFile; - fileDialog.RootSubfolder = filePath; - fileDialog.PopupCentered(); - fileDialog.Connect("file_selected", Callable.From(path => - { - selectPath(path); - })); - } + // public static void EGFileSingleSelect(this Node self, string filePath, Action selectPath, string title = "FileSelect") + // { + // FileDialog fileDialog = self.SingletoneNode("FileDialog"); + // fileDialog.Title = title; + // fileDialog.Size = new Vector2I(480, 320); + // fileDialog.FileMode = FileDialog.FileModeEnum.OpenFile; + // fileDialog.RootSubfolder = filePath; + // fileDialog.PopupCentered(); + // fileDialog.Connect("file_selected", Callable.From(selectPath)); + // } - public static void EGDocumentSelect(this Node self, string filePath, Action selectPath, string title = "FileSelect") - { - FileDialog fileDialog = self.SingletoneNode("FileDialog"); - fileDialog.Title = title; - fileDialog.Size = new Vector2I(480, 320); - fileDialog.FileMode = FileDialog.FileModeEnum.OpenDir; - fileDialog.RootSubfolder = filePath; - fileDialog.PopupCentered(); - fileDialog.Connect("file_selected", Callable.From(path => - { - selectPath(path); - })); - } + // public static void EGDocumentSelect(this Node self, string filePath, Action selectPath, string title = "FileSelect") + // { + // FileDialog fileDialog = self.SingletoneNode("FileDialog"); + // fileDialog.Title = title; + // fileDialog.Size = new Vector2I(480, 320); + // fileDialog.FileMode = FileDialog.FileModeEnum.OpenDir; + // fileDialog.RootSubfolder = filePath; + // fileDialog.PopupCentered(); + // fileDialog.Connect("file_selected", Callable.From(selectPath)); + // } } } diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotConfirmationDialog.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotConfirmationDialog.cs new file mode 100644 index 0000000..6537095 --- /dev/null +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotConfirmationDialog.cs @@ -0,0 +1,20 @@ +using System; +using Godot; + +namespace EGFramework.UI { + public partial class EGodotConfirmationDialog : ConfirmationDialog, IEGFramework + { + private EasyEventOnce OnConfirm { set; get; } = new EasyEventOnce(); + private bool IsInit { set; get; } = false; + public void Init(Action callback) + { + OnConfirm.Register(callback); + if (!IsInit) + { + this.Confirmed += () => OnConfirm.Invoke(true); + this.Canceled += () => OnConfirm.Invoke(false); + IsInit = true; + } + } + } +} diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs index 979b2ef..5c4e31a 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs @@ -50,7 +50,7 @@ namespace EGFramework{ } else { - nodeData = self.CreateNode(); + nodeData = self.GetTree().Root.CreateNode(); EGArchitectureImplement.Interface.GetModule().NodeContainer.Register(nodeData); } nodeData.Name = typeof(TNode).Name; @@ -65,7 +65,7 @@ namespace EGFramework{ } else { - nodeData = self.CreateNode(); + nodeData = self.GetTree().Root.CreateNode(); EGArchitectureImplement.Interface.GetModule().NodeContainer.Register(nodeData); } nodeData.Name = name; diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotSaveTable.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotSaveTable.cs index 918df6c..36e517a 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotSaveTable.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotSaveTable.cs @@ -7,5 +7,7 @@ namespace EGFramework.UI { public IEGSaveData SaveData { set; get; } public Dictionary TitleList { set; get; } = new Dictionary(); + + } } \ No newline at end of file diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTable.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTable.cs index a960e5c..70cce4a 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTable.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTable.cs @@ -101,7 +101,7 @@ namespace EGFramework.UI InitPageData(); } - public void InitPageData() + public virtual void InitPageData() { if (PageAdapter.CurrentPage <= 1) { @@ -122,6 +122,15 @@ namespace EGFramework.UI { this.EGEditDialog(data, rowData.OnDataEdit, "Modify"); }); + rowData.OnDelete.Register(() => + { + GD.Print("Delete : " + rowData.GetData()["Name"]); + this.TableData.Remove(rowData.GetData()); + PageAdapter.DataLength--; + PageAdapter.Reload(PageAdapter.DataLength, PageLimit); + InitPageData(); + OnPageChanged.Invoke(); + }); } } public void InitPageMenu() @@ -298,6 +307,7 @@ namespace EGFramework.UI { return this.CurrentPage == MaxPage; } + } } \ No newline at end of file diff --git a/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTableRowData.cs b/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTableRowData.cs index 82a1886..a6bb60b 100644 --- a/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTableRowData.cs +++ b/addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTableRowData.cs @@ -31,12 +31,14 @@ namespace EGFramework.UI{ Delete.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; Operate.AddChild(Delete); Modify.Connect("pressed", Callable.From(OnEdit)); - Delete.Connect("pressed", Callable.From(OnDelete.Invoke)); + Delete.Connect("pressed", Callable.From(OnDeleteSelf)); this.CustomMinimumSize = new Vector2(0, 32); } - public void OnEdit(){ - if(Data == null){ - return ; + public void OnEdit() + { + if (Data == null) + { + return; } OnModify.Invoke(Data); } @@ -56,5 +58,22 @@ namespace EGFramework.UI{ base.RefreshData(data); Operate.ToEnd(); } + public void OnDeleteSelf() + { + this.EGConfirm("Delete this data? this operate cannot be canceled.", e => + { + if (e) + { + OnDelete.Invoke(); + } + }, "Delete"); + } + + public override void _ExitTree() + { + Modify.Disconnect("pressed", Callable.From(OnEdit)); + Delete.Disconnect("pressed", Callable.From(OnDeleteSelf)); + base._ExitTree(); + } } } \ No newline at end of file