|
@@ -0,0 +1,71 @@
|
|
|
+
|
|
|
+namespace etoy
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 客户端特殊定义脚本
|
|
|
+ /// help_帮助转枚举HelpType
|
|
|
+ /// </summary>
|
|
|
+ class CSharpFunctionUnlockTypeGenerater : IGenerater
|
|
|
+ {
|
|
|
+ private const string TableName = "FunctionUnlock";
|
|
|
+ private const string EnumName = "EFunctionUnlockType";
|
|
|
+ public void Generate(Context context)
|
|
|
+ {
|
|
|
+ var tables = context.Blackboard.Tables;
|
|
|
+ foreach (var table in tables)
|
|
|
+ {
|
|
|
+ if (table.Name.Equals(TableName, StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ GenAttributeType(context, table);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void GenAttributeType(Context context, Table table)
|
|
|
+ {
|
|
|
+ var filePath = $"{context.Option.ClientCodeOutput}/{EnumName}.cs";
|
|
|
+
|
|
|
+ using var writer = new CodeWriter(filePath);
|
|
|
+ writer.WriteLine("// Generate By EToy");
|
|
|
+ writer.WriteLine("// Don't Edit It!!");
|
|
|
+ writer.WriteLine();
|
|
|
+ writer.Bracket("namespace XGame.Database");
|
|
|
+ {
|
|
|
+ writer.Summary($"{TableName} 转枚举 {EnumName}\nName : FunctionUnlock.Name \nValue : FunctionUnlock.Id");
|
|
|
+ writer.Bracket($"public enum {EnumName} : int");
|
|
|
+ {
|
|
|
+ for (int i = 0, rowCount = table.Rows.Count; i < rowCount; i++)
|
|
|
+ {
|
|
|
+ var row = table.Rows[i];
|
|
|
+ GetEnumProperty(row, out var name, out var value, out var summary);
|
|
|
+ if (string.IsNullOrEmpty(name)) continue;
|
|
|
+ writer.Summary(summary);
|
|
|
+ writer.WriteLine($"{name} = {value},");
|
|
|
+ }
|
|
|
+ writer.EndBracket();
|
|
|
+ }
|
|
|
+ writer.EndBracket();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GetEnumProperty(Row row, out string name, out string value, out string summary)
|
|
|
+ {
|
|
|
+ name = value = summary = string.Empty;
|
|
|
+ foreach(var cell in row.Cells)
|
|
|
+ {
|
|
|
+ if ("enumName".Equals(cell.FieldInfo.FieldName, StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ name = cell.Value.ToTitleCase();
|
|
|
+ }
|
|
|
+ else if ("id".Equals(cell.FieldInfo.FieldName, StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ value = cell.Value;
|
|
|
+ }
|
|
|
+ else if ("name".Equals(cell.FieldInfo.FieldName, StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ summary = cell.Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|