Skip to content

Commit

Permalink
更新xresloader 2.1.0 的插件支持文档和GUI事件文档
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Apr 18, 2019
1 parent bdad24e commit c487f4e
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 34 deletions.
16 changes: 11 additions & 5 deletions source/sample/quick_start/sample-conf/kind.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
syntax = "proto3";

import "xresloader.proto";
import "xresloader_ue.proto";

message role_upgrade_cfg {
uint32 Id = 1;
uint32 Level = 2;
uint32 CostType = 3;
int32 CostValue = 4;
int32 ScoreAdd = 5;
uint32 Id = 1;
uint32 Level = 2;
uint32 CostType = 3 [
(org.xresloader.verifier) = "cost_type",
(org.xresloader.field_description) = "Refer to cost_type"
];
int32 CostValue = 4;
int32 ScoreAdd = 5;
}
88 changes: 70 additions & 18 deletions source/sample/xresconv_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,80 @@

<gui>
<!--
set_name标签用于GUI工具修改树形节点的显示数据,便于策划核对具体的表名。
传入的参数结构是,如下。修改里面的数据可以改变显示的内容。
item_data: {
id: ID,
file: 文件名,
scheme: 涉及的scheme表名称,
name: 该条目名称,
cat: 该条目的分类,
options: [ 选项列表 ],
desc: 描述信息,
scheme_data: { 转换规则数据 }
set_name标签用于GUI工具生成每个树形节点时执行的事件(nodejs)脚本,可以用于修改显示数据,便于策划核对具体的表名。
传入的参数结构如下。修改里面的数据可以改变显示的内容。
{
item_data: {
id: id,
file: "数据源文件",
scheme: "数据源scheme表名",
name: "描述名称",
cat: "分类名称",
options: ["额外选项"],
desc: "描述信息",
scheme_data: {"元数据Key": "元数据Value"}
}
}
-->
<set_name desc="这个脚本用于GUI工具修改树形节点的显示数据,便于策划核对具体的表名">
(function(item_data){
if (item_data.file) {
// 这个示例是给显示名称附加不带后缀的文件名
item_data.name += " (" + item_data.file.match(/([^.]+)\.\w+$/)[1] + ")"
}
return item_data;
})
if (item_data.file) {
// 这个示例是给显示名称附加不带后缀的文件名
item_data.name += " (" + item_data.file.match(/([^.]+)\.\w+$/)[1] + ")"
}
return item_data;
</set_name>

<!--
on_before_convert和on_after_convert标签用于GUI工具执行转表前和后执行一段(nodejs)脚本,方便用于一些自动化功能的集成。
传入的参数结构如下:
{
work_dir: "执行xresloader的工作目录",
xresloader_path: "xresloader目录",
global_options: {"全局选项": "VALUE"},
selected_nodes: ["选中要执行转表的节点集合"],
run_seq: "执行序号",
alert_warning: function(content, title, options) {}, // 警告弹框, options 结构是 {yes: 点击是按钮回调, no: 点击否按钮回调, on_close: 关闭后回调}
alert_error: function(content, title) {}, // 错误弹框
log_info: function (content) {}, // 打印info日志
log_error: function (content) {}, // 打印info日志
resolve: function (value) {}, // 通知上层执行结束,相当于Promise的resolve
reject: function(reason) {}, // 通知上层执行失败,相当于Promise的reject
require: function (name) {} // 相当于 nodejs的 require(name) 用于导入nodejs 模块
}
-->
<on_before_convert type="text/javascript" timeout="15000" description="事件执行结束必须调用resolve(value)或reject(reason)函数,以触发进行下一步">
// 这里可以执行nodejs代码,比如下面是Windows平台执行 echo work_dir
var os = require("os");
var spawn = require("child_process").spawn;
if (os.type().substr(0, 7).toLowerCase() == "windows") {
var exec = spawn("cmd.exe", ["/c", "echo " + work_dir], {
cwd: work_dir,
encoding: 'utf-8'
});
exec.stdout.on("data", function(data) {
log_info(data);
});
exec.stderr.on("data", function(data) {
log_error(data);
});
exec.on("error", function(data) {
log_error(data.toString());
reject("执行失败" + data.toString());
});
exec.on("exit", function(code) {
if (code === 0) {
resolve();
} else {
reject("执行失败");
}
});
} else {
resolve();
}
</on_before_convert>
<on_after_convert type="text/javascript" timeout="60000" description="事件执行结束必须调用resolve(value)或reject(reason)函数,以触发进行下一步">
// 同上
</on_after_convert>
</gui>

<groups desc="分组信息,保留,暂未被使用">
Expand Down
35 changes: 35 additions & 0 deletions source/users/advance_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,41 @@
使用 ``skill_effect`` 转出如上的表, ``属性`` 这个字段的验证器设为了 ``unit_attribute`` ,``attr_type`` 的类型是int32。
这时在转出数据的时候,转出的数据是 ``unit_attribute.hp`` 的字段编号 ``1`` 。

Protobuf 插件支持
---------------------------------------------

Protobuf插件 - Message插件
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

项目中可以导入 [header/extensions](header/extensions) 目录, 然后通过导入 [header/v2](header/extensions/v2) 或 [header/v2](header/extensions/v3) 中的相应proto文件来支持额外的插件扩展支持。

+--------------------------------+----------------------------------------------+
| 插件名称 | 插件功能 |
+================================+==============================================+
| org.xresloader.msg_description | 消息体描述信息,会写入输出的header中和代码中 |
+--------------------------------+----------------------------------------------+
| org.xresloader.ue.helper | 生成UE Utility代码的类名后缀 |
+--------------------------------+----------------------------------------------+

比如 `xresloader sample`_ 里, ``proto_v3/kind.proto`` 内的 ``arr_in_arr_cfg`` 这一列配置了相关字段,会影响到一些输出。

Protobuf插件 - Field插件
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

+----------------------------------+--------------------------------------------------------------------------------------------------------------------+
| 插件名称 | 插件功能 |
+==================================+====================================================================================================================+
| org.xresloader.field_description | 字段描述信息,会写入输出的header中和代码中 |
+----------------------------------+--------------------------------------------------------------------------------------------------------------------+
| org.xresloader.verifier | 字段描述信息,会写入输出的header中和代码中 |
+----------------------------------+--------------------------------------------------------------------------------------------------------------------+
| org.xresloader.ue.key_tag | 生成UE代码时,如果需要支持多个Key组合成一个Name,用这个字段指定系数(必须大于0) |
+----------------------------------+--------------------------------------------------------------------------------------------------------------------+
| org.xresloader.ue.ueTypeName | 生成UE代码时,如果指定了这个字段,那么生成的字段类型将是 ```TSoftObjectPtr<ueTypeName>``` , 并且支持蓝图中直接引用 |
+----------------------------------+--------------------------------------------------------------------------------------------------------------------+

比如 `xresloader sample`_ 里, ``proto_v3/kind.proto`` 内的 ``role_upgrade_cfg.CostType`` 这一列配置验证器引射到协议的 ``cost_type`` 和 协议描述字段。

仅导出部分字段
---------------------------------------------

Expand Down
51 changes: 40 additions & 11 deletions source/users/xresconv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,51 @@
+ ``//root/list/item/option`` : 运行 `xresloader`_ 的额外附加参数(详见 :doc:`./xresloader_core` )。比如使用 ``--enable-empty-list`` 可以不移除Excel里的空数据,仅对这个条目生效。可多个。


其他得配置看内容应该比较容易理解,唯一有个仅用于 `GUI工具 <xresconv-gui>`_ 的配置: ``//root/gui/set_name`` 需要特别说明一下。
这是里面必须是一个有效的javascript函数,参数只有一个,结构是
GUI批量转表工具的特殊事件
---------------------------------------------

其他得配置看内容应该比较容易理解,但是 `GUI工具 <xresconv-gui>`_ 还有一些额外的配置,遍域用来做工具集成,需要特别说明一下

第一个是 ``//root/gui/set_name`` 这是里面必须是一个有效的nodejs代码,传入的参数是:

.. code-block:: javascript
{
id: "ID",
file: "文件名",
scheme: "涉及的scheme表名称",
name: "该条目名称,将显示在GUI得树形展示区",
cat: "该条目的分类",
options: [ "选项列表,对应option配置" ],
desc: 描述信息,
scheme_data: { "转换规则数据,对应scheme和default_scheme配置" }
item_data: {
id: "条目ID",
file: "数据源文件",
scheme: "数据源scheme表名",
name: "描述名称",
cat: "分类名称",
options: ["额外选项"],
desc: "描述信息",
scheme_data: {"元数据Key": "元数据Value"}
}
}
这个结构。在 `GUI工具 <xresconv-gui>`_ 显示每个条目的时候会运行这个函数并传入上述结构,在函数离我们可以通过改变 ``name`` 和 ``desc`` 来改变 `GUI工具 <xresconv-gui>`_ 工具的显示内容。
这个结构。在 `GUI工具 <xresconv-gui>`_ 显示每个条目的时候会运行这个函数并传入上述结构,在函数里我们可以通过改变 ``name`` 和 ``desc`` 来改变 `GUI工具 <xresconv-gui>`_ 工具的显示内容。

比如 `批量转表配置模板仓库-xresconv-conf <xresconv-conf>`_ 中的 ``sample.xml`` 文件,我们给所有条目的名字附加上了不带后缀的文件名。

另外还有 ``//root/gui/on_before_convert`` 和 ``//root/gui/on_after_convert`` ,用于在开始转表流程的前和后执行自定义脚本,便于流程集成。
在这是里面必须是一个有效的nodejs代码,其中 ``//root/gui/on_before_convert[timeout]`` 和 ``//root/gui/on_after_convert[timeout]`` 可以用于控制超时时间,单位是毫秒。
传入的参数是:

.. code-block:: javascript
{
work_dir: "执行xresloader的工作目录",
xresloader_path: "xresloader目录",
global_options: {"全局选项": "VALUE"},
selected_nodes: ["选中要执行转表的节点集合"],
run_seq: "执行序号",
alert_warning: function(content, title, options) {}, // 警告弹框, options 结构是 {yes: 点击是按钮回调, no: 点击否按钮回调, on_close: 关闭后回调}
alert_error: function(content, title) {}, // 错误弹框
log_info: function (content) {}, // 打印info日志
log_error: function (content) {}, // 打印info日志
resolve: function (value) {}, // 通知上层执行结束,相当于Promise的resolve
reject: function(reason) {}, // 通知上层执行失败,相当于Promise的reject
require: function (name) {} // 相当于 nodejs的 require(name) 用于导入nodejs 模块
}
在 `批量转表配置模板仓库-xresconv-conf <xresconv-conf>`_ 中的 ``sample.xml`` 文件中也有示例。

0 comments on commit c487f4e

Please sign in to comment.