重新优化了NodeModel类;从硬编码类型改为“注册/获取”的方式,为下一步解耦Workbench与节点UI做准备。

新增了“全局数据节点”;保存项目文件时,不同节点可以使用自定义数据保存自身独特的数据,不再借用“方法参数”。
重新设计了运行时的环境输出;增量式生成器现在可以选择在属性变更的前后时间点插入自定义代码;重写了加载项目、保存项目的方法。
This commit is contained in:
fengjiayi
2024-12-12 20:31:50 +08:00
parent dbbaa10cc0
commit 49603bb58f
40 changed files with 999 additions and 681 deletions

View File

@@ -69,9 +69,14 @@ namespace Serein.Library
public bool IsProtection = false;
/// <summary>
/// 自定义代码
/// 自定义代码(属性变更前)
/// </summary>
public string CustomCode = null;
public string CustomCodeAtStart = null;
/// <summary>
/// 自定义代码(属性变更后)
/// </summary>
public string CustomCodeAtEnd = null;
}

View File

@@ -175,6 +175,12 @@ namespace Serein.Library.NodeGenerator
sb.AppendLine(" {");
sb.AppendLine($" if ({fieldName} {(isProtection ? "== default" : "!= value")})"); // 非保护的Setter
sb.AppendLine(" {");
if (attributeInfo.Search(nameof(PropertyInfo), nameof(PropertyInfo.CustomCodeAtStart), value => !string.IsNullOrEmpty(value))) // 自定义代码
{
var customCode = attributeInfo[nameof(PropertyInfo)][nameof(PropertyInfo.CustomCodeAtStart)] as string;
customCode = customCode.Trim().Substring(1, customCode.Length - 2);
sb.AddCode(5, $"{customCode} // 添加的自定义代码");
}
sb.AppendLine($" SetProperty<{fieldType}>(ref {fieldName}, value); // 通知UI属性发生改变了");
if (attributeInfo.Search(nameof(PropertyInfo), nameof(PropertyInfo.IsPrint), value => bool.Parse(value))) // 是否打印
{
@@ -211,9 +217,9 @@ namespace Serein.Library.NodeGenerator
}
}
if (attributeInfo.Search(nameof(PropertyInfo), nameof(PropertyInfo.CustomCode), value => !string.IsNullOrEmpty(value))) // 是否打印
if (attributeInfo.Search(nameof(PropertyInfo), nameof(PropertyInfo.CustomCodeAtEnd), value => !string.IsNullOrEmpty(value))) // 自定义代码
{
var customCode = attributeInfo[nameof(PropertyInfo)][nameof(PropertyInfo.CustomCode)] as string;
var customCode = attributeInfo[nameof(PropertyInfo)][nameof(PropertyInfo.CustomCodeAtEnd)] as string;
customCode = customCode.Trim().Substring(1, customCode.Length - 2);
sb.AddCode(5, $"{customCode} // 添加的自定义代码");
}