diff --git a/addons/EGFramework/Module/GenerateTools/DataGenerate/EGSvgGenerator.cs b/addons/EGFramework/Module/GenerateTools/DataGenerate/EGSvgGenerator.cs new file mode 100644 index 0000000..af3d19d --- /dev/null +++ b/addons/EGFramework/Module/GenerateTools/DataGenerate/EGSvgGenerator.cs @@ -0,0 +1,90 @@ +namespace EGFramework{ + public class EGSvgGenerator : IGenerateToolsInterface + { + public string SvgHeader { get ; private set;} + public const string SvgFooter = ""; + + public int Width { get; set; } + public int Height { get; set; } + public EGSvgViewBox ViewBox { get; set; } + + public EGSvgGenerator(int width, int height, EGSvgViewBox viewBox) + { + Width = width; + Height = height; + ViewBox = viewBox; + SvgHeader = $""; + } + + public void DrawCircle(float x, float y, float radius, string color) + { + // Implementation for drawing a circle in SVG format + string svgCircle = $""; + } + public void DrawEllipse(float cx, float cy, float rx, float ry, string color) + { + // Implementation for drawing an ellipse in SVG format + string svgEllipse = $""; + } + public void DrawPolygon(float[] points, string color) + { + // Implementation for drawing a polygon in SVG format + string svgPolygon = ""; + } + public void DrawPolyline(float[] points, string color) + { + // Implementation for drawing a polyline in SVG format + string svgPolyline = ""; + } + public void DrawPath(string d, string color) + { + // Implementation for drawing a path in SVG format + string svgPath = $""; + } + public void DrawRectangle(float x, float y, float width, float height, string color) + { + // Implementation for drawing a rectangle in SVG format + string svgRectangle = $""; + } + public void DrawLine(float x1, float y1, float x2, float y2, string color) + { + // Implementation for drawing a line in SVG format + string svgLine = $""; + } + public void DrawText(float x, float y, string text, string color) + { + // Implementation for drawing text in SVG format + string svgText = $"{text}"; + } + + + public string GenerateCode() + { + return typeof(T).Name; + } + } + public struct EGSvgViewBox { + public float X { get; set; } + public float Y { get; set; } + public float Width { get; set; } + public float Height { get; set; } + + public EGSvgViewBox(float x, float y, float width, float height) + { + X = x; + Y = y; + Width = width; + Height = height; + } + } +} \ No newline at end of file diff --git a/addons/EGFramework/Module/GenerateTools/DataInterface/ITableData.cs b/addons/EGFramework/Module/GenerateTools/DataInterface/ITableData.cs index 6ea0332..ac4fd99 100644 --- a/addons/EGFramework/Module/GenerateTools/DataInterface/ITableData.cs +++ b/addons/EGFramework/Module/GenerateTools/DataInterface/ITableData.cs @@ -1,18 +1,20 @@ -public interface ITableData -{ - /// - /// Get the data of the table. - /// - /// - string[][] GetTableData(); - /// - /// Get the header of the table. - /// - /// - string[] GetTableHeader(); -} +namespace EGFramework{ + public interface ITableData + { + /// + /// Get the data of the table. + /// + /// + string[][] GetTableData(); + /// + /// Get the header of the table. + /// + /// + string[] GetTableHeader(); + } -public interface ITableRowData -{ - string[] GetRowData(); + public interface ITableRowData + { + string[] GetRowData(); + } } \ No newline at end of file diff --git a/addons/EGFramework/Module/GenerateTools/GenerateToolsInterface.cs b/addons/EGFramework/Module/GenerateTools/GenerateToolsInterface.cs new file mode 100644 index 0000000..28b878e --- /dev/null +++ b/addons/EGFramework/Module/GenerateTools/GenerateToolsInterface.cs @@ -0,0 +1,6 @@ +namespace EGFramework{ + public interface IGenerateToolsInterface + { + public string GenerateCode(); + } +} \ No newline at end of file diff --git a/addons/EGFramework/Module/GenerateTools/PlatformGenerate/EGGodotUIGenerator.cs b/addons/EGFramework/Module/GenerateTools/PlatformGenerate/EGGodotUIGenerator.cs new file mode 100644 index 0000000..7c99432 --- /dev/null +++ b/addons/EGFramework/Module/GenerateTools/PlatformGenerate/EGGodotUIGenerator.cs @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Godot; + +namespace EGFramework{ + public static class EGGodotTableGenerator { + 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(); + if(s != null){ + label.Name = s; + label.Text = s; + }else{ + label.Name = "Null"; + label.Text = "Null"; + } + 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); + return Table; + } + public static VBoxContainer CreateTable(this Node self,IEnumerable tableData,string tableName = "ObjectTable",int limit = 0){ + VBoxContainer Table = new VBoxContainer(); + Table.Name = tableName; + MemberInfo[] propertyNames = typeof(T).GetProperties(); + MemberInfo[] fieldNames = typeof(T).GetFields(); + MemberInfo[] memberInfos = propertyNames.Concat(fieldNames).ToArray(); + string[] propertyName = new string[memberInfos.Length]; + int dataPointer = 0; + for (int i = 0; i < memberInfos.Length; i++) + { + propertyName[i] = memberInfos[i].Name; + } + Table.CreateRowData(propertyName,"Title"); + foreach (T t in tableData) + { + string[] s = t.GetType().GetProperties().Select(p => p.GetValue(t)?.ToString()).ToArray(); + string[] a = t.GetType().GetFields().Select(p => p.GetValue(t)?.ToString()).ToArray(); + string[] result = s.Concat(a).ToArray(); + Table.CreateRowData(result, "tableRowData"+dataPointer); + dataPointer++; + } + self.AddChild(Table); + return Table; + } + } +} \ No newline at end of file diff --git a/addons/EGFramework/Module/GenerateTools/PlatformInterface/IGodotTable.cs b/addons/EGFramework/Module/GenerateTools/PlatformInterface/IGodotTable.cs new file mode 100644 index 0000000..fa1f798 --- /dev/null +++ b/addons/EGFramework/Module/GenerateTools/PlatformInterface/IGodotTable.cs @@ -0,0 +1,3 @@ +namespace EGFramework{ + +} \ No newline at end of file diff --git a/addons/EGFramework/Module/NodeExtension/EGCreate.cs b/addons/EGFramework/Module/NodeExtension/EGCreate.cs index cad2cb4..91f4323 100644 --- a/addons/EGFramework/Module/NodeExtension/EGCreate.cs +++ b/addons/EGFramework/Module/NodeExtension/EGCreate.cs @@ -54,60 +54,6 @@ namespace EGFramework{ 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(); - if(s != null){ - label.Name = s; - label.Text = s; - }else{ - label.Name = "Null"; - label.Text = "Null"; - } - 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); - return Table; - } - public static VBoxContainer CreateTable(this Node self,IEnumerable tableData,string tableName = "ObjectTable",int limit = 0){ - VBoxContainer Table = new VBoxContainer(); - Table.Name = tableName; - MemberInfo[] propertyNames = typeof(T).GetProperties(); - MemberInfo[] fieldNames = typeof(T).GetFields(); - MemberInfo[] memberInfos = propertyNames.Concat(fieldNames).ToArray(); - string[] propertyName = new string[memberInfos.Length]; - int dataPointer = 0; - for (int i = 0; i < memberInfos.Length; i++) - { - propertyName[i] = memberInfos[i].Name; - } - Table.CreateRowData(propertyName,"Title"); - foreach (T t in tableData) - { - string[] s = t.GetType().GetProperties().Select(p => p.GetValue(t)?.ToString()).ToArray(); - string[] a = t.GetType().GetFields().Select(p => p.GetValue(t)?.ToString()).ToArray(); - string[] result = s.Concat(a).ToArray(); - Table.CreateRowData(result, "tableRowData"+dataPointer); - dataPointer++; - } - self.AddChild(Table); - return Table; - } public static Tree CreateTree(this Node self,string treeName = "Tree"){ Tree tree = new Tree(); tree.Name = treeName;