|
@@ -0,0 +1,69 @@
|
|
|
+namespace etoy
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 客户端特殊定义脚本
|
|
|
+ /// guide_引导 target 目标key
|
|
|
+ /// </summary>
|
|
|
+ class CSharpGuideTargetKeyGenerater : IGenerater
|
|
|
+ {
|
|
|
+ private const string TableName = "guideStep";
|
|
|
+ private const string KeyName = "GuideTargetKey";
|
|
|
+
|
|
|
+ public void Generate(Context context)
|
|
|
+ {
|
|
|
+ var tables = context.Blackboard.Tables;
|
|
|
+ foreach (var table in tables)
|
|
|
+ {
|
|
|
+ if (table.Name.Equals(TableName, StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ GenGuideTargetKey(context, table);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GenGuideTargetKey(Context context, Table table)
|
|
|
+ {
|
|
|
+ var filePath = $"{context.Option.ClientCodeOutput}/{KeyName}.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($"生成引导UI对象Key");
|
|
|
+ writer.Bracket($"public static class {KeyName}");
|
|
|
+ {
|
|
|
+ for (int i = 0, rowCount = table.Rows.Count; i < rowCount; i++)
|
|
|
+ {
|
|
|
+ var row = table.Rows[i];
|
|
|
+ GetKeyProperty(row, out var key, out var summary);
|
|
|
+ if (string.IsNullOrEmpty(key))
|
|
|
+ continue;
|
|
|
+ writer.Summary(summary);
|
|
|
+ writer.WriteLine($"public readonly static string {key} = \"{key}\";");
|
|
|
+ }
|
|
|
+ writer.EndBracket();
|
|
|
+ }
|
|
|
+ writer.EndBracket();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GetKeyProperty(Row row, out string key, out string summary)
|
|
|
+ {
|
|
|
+ key = summary = string.Empty;
|
|
|
+ foreach (var cell in row.Cells)
|
|
|
+ {
|
|
|
+ if ("target".Equals(cell.FieldInfo.FieldName, StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ key = cell.Value.ToTitleCase();
|
|
|
+ }
|
|
|
+ else if ("id".Equals(cell.FieldInfo.FieldName, StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ summary = cell.Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|