Browse Source

fixed popup bugs

master
jkpete 1 month ago
parent
commit
72eccbae0d
  1. 3
      Example/SaveSystem/Script/ViewSaveSystem.cs
  2. 58
      addons/EGFramework/Module/GenerateTools/Templete/Godot/EGCreate.cs

3
Example/SaveSystem/Script/ViewSaveSystem.cs

@ -39,8 +39,9 @@ namespace EGFramework.Examples.Test {
// editParam.Init(new KeyValuePair<string, object>("数量",1)); // editParam.Init(new KeyValuePair<string, object>("数量",1));
this.ExecuteAfterSecond(() => this.ExecuteAfterSecond(() =>
{ {
this.EGAlert("-----~!");
this.EGConfirm("fixed?", isconfirm => { GD.Print(isconfirm); }); this.EGConfirm("fixed?", isconfirm => { GD.Print(isconfirm); });
this.EGAlert("-----~!");
}, 1.0f); }, 1.0f);
} }

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

@ -13,24 +13,50 @@ namespace EGFramework{
public class EGSingletonNode : IEGFramework, IModule public class EGSingletonNode : IEGFramework, IModule
{ {
public IOCContainer NodeContainer = new IOCContainer(); public IOCContainer NodeContainer = new IOCContainer();
public Queue<Window> WindowCache = new Queue<Window>(); public Stack<Window> WindowCache = new Stack<Window>();
public Window CurrentWindow { set; get; } public Window CurrentWindow { set; get; }
private bool PopUpFlag { set; get; }
public void Init() public void Init()
{ {
} }
public void ReturnToLastWindow() public void PopupNode(Window window)
{
PopUpFlag = true;
if (CurrentWindow != null)
{
this.CurrentWindow.Hide();
CurrentWindow.VisibilityChanged -= OnPopUpUnitVisibleChanged;
WindowCache.Push(CurrentWindow);
}
window.PopupCentered();
this.CurrentWindow = window;
CurrentWindow.VisibilityChanged += OnPopUpUnitVisibleChanged;
GD.Print(WindowCache.Count);
PopUpFlag = false;
}
public void OnPopUpUnitVisibleChanged()
{ {
if (CurrentWindow != null && !CurrentWindow.Visible) if (CurrentWindow != null && !CurrentWindow.Visible && !PopUpFlag)
{ {
GD.Print("-----"); GD.Print("-----");
CurrentWindow.VisibilityChanged -= OnPopUpUnitVisibleChanged;
if (this.WindowCache.Count > 0) if (this.WindowCache.Count > 0)
{ {
this.CurrentWindow.VisibilityChanged -= ReturnToLastWindow; CurrentWindow.Hide();
this.CurrentWindow.Hide(); Window lastWindow = WindowCache.Pop();
this.CurrentWindow = this.WindowCache.Dequeue(); CurrentWindow = lastWindow;
this.CurrentWindow?.PopupCentered(); CurrentWindow.PopupCentered();
CurrentWindow.VisibilityChanged += OnPopUpUnitVisibleChanged;
}
else
{
CurrentWindow.Hide();
CurrentWindow = null;
} }
} }
} }
@ -89,24 +115,8 @@ namespace EGFramework{
nodeData = self.GetTree().Root.CreateNode<TWindowNode>(); nodeData = self.GetTree().Root.CreateNode<TWindowNode>();
singletonNode.NodeContainer.Register(nodeData); singletonNode.NodeContainer.Register(nodeData);
} }
singletonNode.WindowCache.Enqueue(nodeData); singletonNode.PopupNode(nodeData);
nodeData.Name = name; 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; return nodeData;
} }

Loading…
Cancel
Save