Browse Source

add popup method

master
jkpete 1 month ago
parent
commit
4d1d119124
  1. 5
      Example/SaveSystem/Script/ViewSaveSystem.cs
  2. 15
      addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs
  3. 2
      addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotEditDialog.cs
  4. 62
      addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs
  5. 10
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs

5
Example/SaveSystem/Script/ViewSaveSystem.cs

@ -37,6 +37,11 @@ namespace EGFramework.Examples.Test { @@ -37,6 +37,11 @@ namespace EGFramework.Examples.Test {
// rowData2.Init(new Dictionary<string, object>() { { "Name", "Z" }, { "Age", 1 } });
// EGodotEditParam editParam = container.CreateNode<EGodotEditParam>("editParam");
// editParam.Init(new KeyValuePair<string, object>("数量",1));
this.ExecuteAfterSecond(() =>
{
this.EGAlert("-----~!");
this.EGConfirm("fixed?", isconfirm => { GD.Print(isconfirm); });
},1.0f);
}
public override void _ExitTree()

15
addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs

@ -6,45 +6,40 @@ namespace EGFramework.UI @@ -6,45 +6,40 @@ namespace EGFramework.UI
{
public static void EGAlert(this Node self, string alertMsg, string title = "Alert")
{
AcceptDialog acceptDialog = self.SingletoneNode<AcceptDialog>("AlertDialog");
AcceptDialog acceptDialog = self.PopupNode<AcceptDialog>("AlertDialog");
acceptDialog.Title = title;
acceptDialog.DialogText = alertMsg;
acceptDialog.PopupCentered();
}
public static void EGConfirm(this Node self, string alertMsg, Action<bool> callback, string title = "Confirm")
{
EGodotConfirmationDialog confirmDialog = self.SingletoneNode<EGodotConfirmationDialog>("ConfirmDialog");
EGodotConfirmationDialog confirmDialog = self.PopupNode<EGodotConfirmationDialog>("ConfirmDialog");
confirmDialog.Title = title;
confirmDialog.DialogText = alertMsg;
confirmDialog.PopupCentered();
confirmDialog.Init(callback);
}
public static void EGFileOpen(this Node self, string filePath, Action<string> selectPath, string title = "Open a file")
{
EGodotFileDialog fileDialog = self.SingletoneNode<EGodotFileDialog>("FileDialog");
EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog");
fileDialog.Title = title;
fileDialog.RootSubfolder = filePath;
fileDialog.PopupCentered();
fileDialog.InitFileSelect(selectPath);
}
public static void EGFileSave(this Node self, string filePath, Action<string> selectPath, string title = "Save a file")
{
EGodotFileDialog fileDialog = self.SingletoneNode<EGodotFileDialog>("FileDialog");
EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog");
fileDialog.Title = title;
fileDialog.RootSubfolder = filePath;
fileDialog.PopupCentered();
fileDialog.InitSaveFileSelect(selectPath);
}
public static void EGDocumentOpen(this Node self, string filePath, Action<string> selectPath, string title = "FileSelect")
{
EGodotFileDialog fileDialog = self.SingletoneNode<EGodotFileDialog>("FileDialog");
EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog");
fileDialog.Title = title;
fileDialog.RootSubfolder = filePath;
fileDialog.PopupCentered();
fileDialog.InitDirSelect(selectPath);
}
}

2
addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotEditDialog.cs

@ -95,7 +95,7 @@ namespace EGFramework.UI @@ -95,7 +95,7 @@ namespace EGFramework.UI
{
public static EGodotEditDialog EGEditDialog(this Node self, Dictionary<string, object> data, Action<Dictionary<string, object>> onDataEdit, string title = "Edit")
{
EGodotEditDialog editDialog = self.SingletoneNode<EGodotEditDialog>("FileDialog");
EGodotEditDialog editDialog = self.SingletoneNode<EGodotEditDialog>("Edit");
editDialog.InitDialog(data, onDataEdit, title);
editDialog.PopupCentered();
return editDialog;

62
addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs

@ -13,9 +13,26 @@ namespace EGFramework{ @@ -13,9 +13,26 @@ namespace EGFramework{
public class EGSingletonNode : IEGFramework, IModule
{
public IOCContainer NodeContainer = new IOCContainer();
public Queue<Window> WindowCache = new Queue<Window>();
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{ @@ -27,21 +44,23 @@ namespace EGFramework{
public static class EGCanCreateNodeExtension
{
public static TNode CreateNode<TNode>(this Node self) where TNode : Node,new(){
public static TNode CreateNode<TNode>(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<TNode>(this Node self,string name) where TNode : Node,new(){
public static TNode CreateNode<TNode>(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<TNode>(this Node self) where TNode : Node, new()
public static TNode SingletoneNode<TNode>(this Node self, string name) where TNode : Node, new()
{
TNode nodeData;
if (EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<TNode>() != null)
@ -53,22 +72,41 @@ namespace EGFramework{ @@ -53,22 +72,41 @@ namespace EGFramework{
nodeData = self.GetTree().Root.CreateNode<TNode>();
EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Register(nodeData);
}
nodeData.Name = typeof(TNode).Name;
nodeData.Name = name;
return nodeData;
}
public static TNode SingletoneNode<TNode>(this Node self,string name) where TNode : Node, new()
public static TWindowNode PopupNode<TWindowNode>(this Node self, string name) where TWindowNode : Window, new()
{
TNode nodeData;
if (EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<TNode>() != null)
TWindowNode nodeData;
EGSingletonNode singletonNode = EGArchitectureImplement.Interface.GetModule<EGSingletonNode>();
if (singletonNode.NodeContainer.Get<TWindowNode>() != null)
{
nodeData = EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<TNode>();
nodeData = singletonNode.NodeContainer.Get<TWindowNode>();
}
else
{
nodeData = self.GetTree().Root.CreateNode<TNode>();
EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Register(nodeData);
nodeData = self.GetTree().Root.CreateNode<TWindowNode>();
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;
}

10
addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs

@ -122,11 +122,15 @@ namespace EGFramework.UI @@ -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);

Loading…
Cancel
Save