7 changed files with 202 additions and 131 deletions
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
using System; |
||||
using Godot; |
||||
namespace EGFramework.UI |
||||
{ |
||||
public static class EGBasicDialogExtension |
||||
{ |
||||
public static void EGAlert(this Node self, string alertMsg, string title = "Alert") |
||||
{ |
||||
AcceptDialog acceptDialog = self.SingletoneNode<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") |
||||
{ |
||||
ConfirmationDialog confirmDialog = self.SingletoneNode<ConfirmationDialog>("ConfirmDialog"); |
||||
confirmDialog.Title = title; |
||||
confirmDialog.DialogText = alertMsg; |
||||
confirmDialog.PopupCentered(); |
||||
confirmDialog.Connect("confirmed", Callable.From(() => |
||||
{ |
||||
callback(true); |
||||
})); |
||||
confirmDialog.Connect("canceled", Callable.From(() => |
||||
{ |
||||
callback(false); |
||||
})); |
||||
} |
||||
|
||||
public static void EGFileSingleSelect(this Node self, string filePath, Action<string> selectPath, string title = "FileSelect") |
||||
{ |
||||
FileDialog fileDialog = self.SingletoneNode<FileDialog>("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<string>(path => |
||||
{ |
||||
selectPath(path); |
||||
})); |
||||
} |
||||
|
||||
public static void EGDocumentSelect(this Node self, string filePath, Action<string> selectPath, string title = "FileSelect") |
||||
{ |
||||
FileDialog fileDialog = self.SingletoneNode<FileDialog>("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<string>(path => |
||||
{ |
||||
selectPath(path); |
||||
})); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using Godot; |
||||
using Mysqlx.Crud; |
||||
using static Godot.GD; |
||||
|
||||
namespace EGFramework{ |
||||
|
||||
public class EGSingletonNode : IEGFramework, IModule |
||||
{ |
||||
public IOCContainer NodeContainer = new IOCContainer(); |
||||
public void Init() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public IArchitecture GetArchitecture() |
||||
{ |
||||
return EGArchitectureImplement.Interface; |
||||
} |
||||
|
||||
} |
||||
|
||||
public static class EGCanCreateNodeExtension |
||||
{ |
||||
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(){ |
||||
TNode nodeData = new TNode(); |
||||
nodeData.Name = name; |
||||
self.AddChild(nodeData); |
||||
return nodeData; |
||||
} |
||||
|
||||
public static TNode SingletoneNode<TNode>(this Node self) where TNode : Node, new() |
||||
{ |
||||
TNode nodeData; |
||||
if (EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<TNode>() != null) |
||||
{ |
||||
nodeData = EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<TNode>(); |
||||
} |
||||
else |
||||
{ |
||||
nodeData = self.CreateNode<TNode>(); |
||||
EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Register(nodeData); |
||||
} |
||||
nodeData.Name = typeof(TNode).Name; |
||||
return nodeData; |
||||
} |
||||
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) |
||||
{ |
||||
nodeData = EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<TNode>(); |
||||
} |
||||
else |
||||
{ |
||||
nodeData = self.CreateNode<TNode>(); |
||||
EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Register(nodeData); |
||||
} |
||||
nodeData.Name = name; |
||||
return nodeData; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
using Godot; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public interface IEGRowData |
||||
{ |
||||
|
||||
} |
||||
public partial class EGRowData : PanelContainer, IEGFramework |
||||
{ |
||||
|
||||
public Button ItemHover { get; set; } |
||||
public ColorRect Line { get; set; } |
||||
public ColorRect BackGround { get; set; } |
||||
public HBoxContainer List { get; set; } |
||||
|
||||
protected Dictionary<string, object> Data { get; set; } |
||||
|
||||
public virtual void InitRowData(Dictionary<string,object> data){ |
||||
this.Data = data; |
||||
BackGround = new ColorRect(); |
||||
BackGround.Name = "BackGround"; |
||||
BackGround.Color = new Color(0.5f,0.5f,1f); |
||||
BackGround.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
BackGround.SizeFlagsVertical = SizeFlags.ExpandFill; |
||||
this.AddChild(BackGround); |
||||
List = new HBoxContainer(); |
||||
List.Name = "TableRow_"+Resource.GenerateSceneUniqueId(); |
||||
List.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
this.AddChild(List); |
||||
Line = new ColorRect(); |
||||
Line.Name = "Line"; |
||||
Line.Color = new Color(0.5f,0.5f,0.5f); |
||||
Line.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
Line.SizeFlagsVertical = Control.SizeFlags.ShrinkEnd; |
||||
Line.CustomMinimumSize = new Vector2(0,1); |
||||
this.AddChild(Line); |
||||
foreach(KeyValuePair<string,object> kv in data){ |
||||
this.List.AddChild(new Label(){ |
||||
Name = kv.Key, |
||||
Text = kv.Value.ToString(), |
||||
HorizontalAlignment = HorizontalAlignment.Center, |
||||
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill |
||||
}); |
||||
} |
||||
this.AddThemeStyleboxOverride("panel",new StyleBoxEmpty()); |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,84 +0,0 @@
@@ -1,84 +0,0 @@
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using Godot; |
||||
using Mysqlx.Crud; |
||||
using static Godot.GD; |
||||
|
||||
namespace EGFramework{ |
||||
|
||||
public class EGSingletonNode : IEGFramework, IModule |
||||
{ |
||||
public IOCContainer NodeContainer = new IOCContainer(); |
||||
public void Init() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public IArchitecture GetArchitecture() |
||||
{ |
||||
return EGArchitectureImplement.Interface; |
||||
} |
||||
|
||||
} |
||||
|
||||
public static class EGCanCreateNodeExtension |
||||
{ |
||||
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(){ |
||||
TNode nodeData = new TNode(); |
||||
nodeData.Name = name; |
||||
self.AddChild(nodeData); |
||||
return nodeData; |
||||
} |
||||
|
||||
public static void Alert(this Node self,string alertMsg,string title = "Alert"){ |
||||
AcceptDialog acceptDialog; |
||||
if(EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<AcceptDialog>()!=null){ |
||||
acceptDialog = EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<AcceptDialog>(); |
||||
}else{ |
||||
acceptDialog = self.CreateNode<AcceptDialog>(); |
||||
} |
||||
EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Register(acceptDialog); |
||||
acceptDialog.Name = "AlertDialog"; |
||||
acceptDialog.Title = title; |
||||
acceptDialog.DialogText = alertMsg; |
||||
acceptDialog.PopupCentered(); |
||||
} |
||||
|
||||
public static void Confirm(this Node self,string alertMsg,Action<bool> callback,string title = "Confirm"){ |
||||
ConfirmationDialog confirmDialog; |
||||
if(EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<ConfirmationDialog>()!=null){ |
||||
confirmDialog = EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<ConfirmationDialog>(); |
||||
}else{ |
||||
confirmDialog = self.CreateNode<ConfirmationDialog>(); |
||||
} |
||||
EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Register(confirmDialog); |
||||
confirmDialog.Name = "ConfirmDialog"; |
||||
confirmDialog.Title = title; |
||||
confirmDialog.DialogText = alertMsg; |
||||
confirmDialog.PopupCentered(); |
||||
confirmDialog.Connect("confirmed",Callable.From(() => { |
||||
callback(true); |
||||
})); |
||||
confirmDialog.Connect("canceled",Callable.From(() => { |
||||
callback(false); |
||||
})); |
||||
} |
||||
public static Tree CreateTree(this Node self,string treeName = "Tree"){ |
||||
Tree tree = new Tree(); |
||||
tree.Name = treeName; |
||||
self.AddChild(tree); |
||||
return tree; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue