Browse Source

fixed table

master
jkpete 3 months ago
parent
commit
68edad0a2d
  1. 11
      Example/SaveSystem/Scene/SaveSystem.tscn
  2. 20
      Example/SaveSystem/Script/ViewSaveSystem.cs
  3. 46
      addons/EGFramework/Module/NodeExtension/EGCreate.cs
  4. 2
      project.godot

11
Example/SaveSystem/Scene/SaveSystem.tscn

@ -10,10 +10,21 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_mtdgp") script = ExtResource("1_mtdgp")
[node name="TextureRect" type="TextureRect" parent="."] [node name="TextureRect" type="TextureRect" parent="."]
visible = false
layout_mode = 0 layout_mode = 0
offset_right = 40.0 offset_right = 40.0
offset_bottom = 40.0 offset_bottom = 40.0
texture = ExtResource("2_qt8hb") 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

20
Example/SaveSystem/Script/ViewSaveSystem.cs

@ -8,14 +8,32 @@ using Renci.SshNet;
namespace EGFramework.Examples.Test{ namespace EGFramework.Examples.Test{
public partial class ViewSaveSystem : Node,IEGFramework public partial class ViewSaveSystem : Node,IEGFramework
{ {
public string[][] DataList { get; set; }
public string[][] DataList2 { get; set; }
public override void _Ready() 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>("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>("TabContainer").CreateTable(DataList2,"Teacher");
} }
public override void _ExitTree() public override void _ExitTree()
{ {
} }
} }
} }

46
addons/EGFramework/Module/NodeExtension/EGCreate.cs

@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using Godot; using Godot;
using static Godot.GD; using static Godot.GD;
@ -34,15 +35,44 @@ namespace EGFramework{
return nodeData; return nodeData;
} }
public static TNode SingletonNode<TNode>(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){ public static void Alert(this Node self,string alertMsg){
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 = "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;
} }
} }
} }

2
project.godot

@ -12,7 +12,7 @@ config_version=5
config/name="EGFramework" config/name="EGFramework"
config/tags=PackedStringArray("official") 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/features=PackedStringArray("4.3", "C#", "GL Compatibility")
config/icon="res://EGFramework.svg" config/icon="res://EGFramework.svg"

Loading…
Cancel
Save