diff --git a/Example/SaveSystem/Script/ViewSaveSystem.cs b/Example/SaveSystem/Script/ViewSaveSystem.cs index 125b505..21bee8c 100644 --- a/Example/SaveSystem/Script/ViewSaveSystem.cs +++ b/Example/SaveSystem/Script/ViewSaveSystem.cs @@ -17,6 +17,7 @@ namespace EGFramework.Examples.Test { public override void _Ready() { TestTree(); + TestTable(); } public override void _ExitTree() @@ -85,31 +86,18 @@ namespace EGFramework.Examples.Test { EGodotTable table = container.CreateNode("Default"); table.InitData(dataStudents); - EGSqliteSave SqliteTest = this.EGSave().Load("SaveData/test.db"); - // IEnumerable dataBaseKey = SqliteTest.GetKeys(); - // GD.Print(dataBaseKey); - // foreach (string data in dataBaseKey) - // { - // GD.Print(data); - // } - EGodotSaveTable PersonTable = container.CreateNode("SQLite"); - PersonTable.InitSaveData(SqliteTest); - PersonTable.InitData("person"); - - // EGodotTableRowData rowData = container.CreateNode("RowData"); - // rowData.Init(new Dictionary() { { "Name", "Tom" }, { "Age", 18 } }); - // EGodotRowData rowData2 = container.CreateNode("RowData2"); - // rowData2.Init(new Dictionary() { { "Name", "Z" }, { "Age", 1 } }); - // EGodotEditParam editParam = container.CreateNode("editParam"); - // editParam.Init(new KeyValuePair("数量",1)); + // EGSqliteSave SqliteTest = this.EGSave().Load("SaveData/test.db"); + // EGodotSaveTable PersonTable = container.CreateNode("SQLite"); + // PersonTable.InitSaveData(SqliteTest); + // PersonTable.InitData("person"); } } public struct DataStudent { + public int ID; public string Name { get; set; } public int Age; - public int ID; public EGPathSelect Path { set; get; } public DataStudent(string name, int age) { diff --git a/Manual/GenerateTools.md b/Manual/GenerateTools.md index 9e2df46..792b335 100644 --- a/Manual/GenerateTools.md +++ b/Manual/GenerateTools.md @@ -1,2 +1,99 @@ # GenerateTools使用手册 +> GenerateTools旨在生成任何应用程序中的组件,变量,对象,以及用到的一些流程等等。同时依赖于Save Tools强大的本地文件加载能力,Generate Tools可以通过配置各种文件实现界面的简单生成,菜单的生成,可编辑表格,可编辑项。 +> +> 再此之上,有些通用模板也会放在此工具下,方便扩展与生成。 + +```mermaid +mindmap + root((Generate-Tools)) + Code + SVG + Dialog + Basic + Confirm + Edit + File + UI + EditParam + Table + Menu + Tree + Inteface + Variant + Tree + Range + Select + Path + ReadOnly +``` + +## 📈生成一个可编辑表格 + +定义数据类,以学生信息为例 + +```csharp +public struct DataStudent +{ + public int ID; + public string Name { get; set; } + public int Age; + public EGPathSelect Path { set; get; } + public DataStudent(string name, int age) + { + Name = name; + Age = age; + ID = 0; + Path = new EGPathSelect(); + } +} +``` + +实例化一组学生信息对象列表,然后通过EGodotTable来对该列表进行初始化 + +```csharp +public void TestTable() +{ + container = this.GetNode("TabContainer"); + List dataStudents = new List(); + for (int stu = 0; stu < 10; stu++) + { + dataStudents.Add(new DataStudent("stu" + stu, 18)); + } + for (int stu = 0; stu < 11; stu++) + { + dataStudents.Add(new DataStudent("A" + stu, 20 + stu)); + } + EGodotTable table = container.CreateNode("Default"); + table.InitData(dataStudents); +} +``` + +运行结果如下 + +![GenerateTools_001](Img/GenerateTools_001.JPG) + +![GenerateTools_001](Img/GenerateTools_002.JPG) + +## 🌲生成一个树 + +定义一个Json,使用EGodotTree来对该Json进行初始化 + +```csharp +public void TestTree() +{ + string json = @"{ + 'CPU': 'Intel', + 'PSU': '500W', + 'My' : { + 'AA':'BB', + 'Date': 111 + } + }"; + container = this.GetNode("TabContainer"); + EGodotTree eGodotTree = container.CreateNode("TestTree"); + eGodotTree.InitByJson(json); +} +``` + +![GenerateTools_001](Img/GenerateTools_003.JPG) diff --git a/Manual/Img/GenerateTools_001.JPG b/Manual/Img/GenerateTools_001.JPG new file mode 100644 index 0000000..63d2307 Binary files /dev/null and b/Manual/Img/GenerateTools_001.JPG differ diff --git a/Manual/Img/GenerateTools_001.JPG.import b/Manual/Img/GenerateTools_001.JPG.import new file mode 100644 index 0000000..bcce452 --- /dev/null +++ b/Manual/Img/GenerateTools_001.JPG.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b2tuqm72haaab" +path="res://.godot/imported/GenerateTools_001.JPG-fef7115ccd57135de62d4bd2954db1db.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Manual/Img/GenerateTools_001.JPG" +dest_files=["res://.godot/imported/GenerateTools_001.JPG-fef7115ccd57135de62d4bd2954db1db.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Manual/Img/GenerateTools_002.JPG b/Manual/Img/GenerateTools_002.JPG new file mode 100644 index 0000000..03f7c6b Binary files /dev/null and b/Manual/Img/GenerateTools_002.JPG differ diff --git a/Manual/Img/GenerateTools_002.JPG.import b/Manual/Img/GenerateTools_002.JPG.import new file mode 100644 index 0000000..1824fe4 --- /dev/null +++ b/Manual/Img/GenerateTools_002.JPG.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c4fu1phlhotka" +path="res://.godot/imported/GenerateTools_002.JPG-7bb9bdf7b55c6f9bc9f2bca6dee8a982.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Manual/Img/GenerateTools_002.JPG" +dest_files=["res://.godot/imported/GenerateTools_002.JPG-7bb9bdf7b55c6f9bc9f2bca6dee8a982.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Manual/Img/GenerateTools_003.JPG b/Manual/Img/GenerateTools_003.JPG new file mode 100644 index 0000000..1beaebc Binary files /dev/null and b/Manual/Img/GenerateTools_003.JPG differ diff --git a/Manual/Img/GenerateTools_003.JPG.import b/Manual/Img/GenerateTools_003.JPG.import new file mode 100644 index 0000000..edc5a90 --- /dev/null +++ b/Manual/Img/GenerateTools_003.JPG.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://crtdss0o45blw" +path="res://.godot/imported/GenerateTools_003.JPG-f588ba68b13367797de19c266c495b79.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Manual/Img/GenerateTools_003.JPG" +dest_files=["res://.godot/imported/GenerateTools_003.JPG-f588ba68b13367797de19c266c495b79.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1