12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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";
- var hashTable = new List<string>();
- 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 value, out var summary);
- if (string.IsNullOrEmpty(key))
- continue;
- if (hashTable.Contains(key))
- continue;
- writer.Summary(summary);
- writer.WriteLine($"public readonly static string {key} = \"{value}\";");
- hashTable.Add(key);
- }
- writer.EndBracket();
- }
- writer.EndBracket();
- }
- }
- private void GetKeyProperty(Row row, out string key, out string value, out string summary)
- {
- key = value = summary = string.Empty;
- foreach (var cell in row.Cells)
- {
- if ("target".Equals(cell.FieldInfo.FieldName, StringComparison.OrdinalIgnoreCase))
- {
- key = cell.Value.ToTitleCase();
- value = cell.Value;
- }
- else if ("id".Equals(cell.FieldInfo.FieldName, StringComparison.OrdinalIgnoreCase))
- {
- summary = cell.Value;
- }
- }
- }
- }
- }
|