diff --git a/Example/SaveSystem/Scene/SaveSystem.tscn b/Example/SaveSystem/Scene/SaveSystem.tscn index f30cd28..9f3c708 100644 --- a/Example/SaveSystem/Scene/SaveSystem.tscn +++ b/Example/SaveSystem/Scene/SaveSystem.tscn @@ -10,10 +10,21 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 script = ExtResource("1_mtdgp") [node name="TextureRect" type="TextureRect" parent="."] +visible = false layout_mode = 0 offset_right = 40.0 offset_bottom = 40.0 texture = ExtResource("2_qt8hb") + +[node name="TabContainer" type="TabContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/Example/SaveSystem/Script/ViewSaveSystem.cs b/Example/SaveSystem/Script/ViewSaveSystem.cs index 738e18b..9a8ad30 100644 --- a/Example/SaveSystem/Script/ViewSaveSystem.cs +++ b/Example/SaveSystem/Script/ViewSaveSystem.cs @@ -8,14 +8,32 @@ using Renci.SshNet; namespace EGFramework.Examples.Test{ public partial class ViewSaveSystem : Node,IEGFramework { + public string[][] DataList { get; set; } + public string[][] DataList2 { get; set; } public override void _Ready() { - + DataList = new string[3][]; + string[] a = {"Name","Age"}; + DataList[0] = a; + string[] b = {"Tom","18"}; + DataList[1] = b; + string[] c = {"Jerry","20"}; + DataList[2] = c; + this.GetNode("TabContainer").CreateTable(DataList,"Student"); + DataList2 = new string[3][]; + string[] d = {"Name","Age"}; + DataList2[0] = d; + string[] e = {"Jim","60"}; + DataList2[1] = e; + string[] f = {"Bob","50"}; + DataList2[2] = f; + this.GetNode("TabContainer").CreateTable(DataList2,"Teacher"); } public override void _ExitTree() { } + } } \ No newline at end of file diff --git a/addons/EGFramework/Module/NodeExtension/EGCreate.cs b/addons/EGFramework/Module/NodeExtension/EGCreate.cs index 31ac00c..f5a4c51 100644 --- a/addons/EGFramework/Module/NodeExtension/EGCreate.cs +++ b/addons/EGFramework/Module/NodeExtension/EGCreate.cs @@ -1,3 +1,4 @@ +using System.Runtime.CompilerServices; using Godot; using static Godot.GD; @@ -33,16 +34,45 @@ namespace EGFramework{ self.AddChild(nodeData); return nodeData; } - - public static TNode SingletonNode(this Node self) where TNode : Node,new(){ - TNode nodeData = new TNode(); - nodeData.Name = typeof(TNode).Name; - self.AddChild(nodeData); - return nodeData; - } public static void Alert(this Node self,string alertMsg){ - + AcceptDialog acceptDialog; + if(EGArchitectureImplement.Interface.GetModule().NodeContainer.Get()!=null){ + acceptDialog = EGArchitectureImplement.Interface.GetModule().NodeContainer.Get(); + }else{ + acceptDialog = self.CreateNode(); + } + EGArchitectureImplement.Interface.GetModule().NodeContainer.Register(acceptDialog); + acceptDialog.Name = "AlertDialog"; + acceptDialog.Title = "Alert"; + acceptDialog.DialogText = alertMsg; + acceptDialog.PopupCentered(); + } + public static HBoxContainer CreateRowData(this Node self,string[] titleList,string rowName = "RowData"){ + HBoxContainer RowData = new HBoxContainer(); + RowData.Name = rowName; + foreach(string s in titleList){ + Label label = new Label(); + label.Name = s; + label.Text = s; + label.HorizontalAlignment = HorizontalAlignment.Center; + label.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; + RowData.AddChild(label); + } + self.AddChild(RowData); + return RowData; + } + public static VBoxContainer CreateTable(this Node self,string[][] tableStr,string tableName = "Table"){ + VBoxContainer Table = new VBoxContainer(); + Table.Name = tableName; + int dataPointer = 0; + foreach(string[] s in tableStr){ + Table.CreateRowData(s,"tableRowData"+dataPointer); + dataPointer++; + } + self.AddChild(Table); + EG.Print("CreateTable",tableStr.Length); + return Table; } } } diff --git a/project.godot b/project.godot index 94b7d90..48e37ed 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="EGFramework" config/tags=PackedStringArray("official") -run/main_scene="res://Example/LocalMediaViewer/LocalMediaViewer.tscn" +run/main_scene="res://Example/SaveSystem/Scene/SaveSystem.tscn" config/features=PackedStringArray("4.3", "C#", "GL Compatibility") config/icon="res://EGFramework.svg"