From 1e56baaf8ccf02d3a0f8957ae773307a45890037 Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 20 Oct 2021 14:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 361 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 336 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 70e495b..9e5d2c0 100644 --- a/README.md +++ b/README.md @@ -109,15 +109,57 @@ luban支持在excel中解析任意复杂的数据结构,哪怕复杂如技能 支持 bool,int,float,string,text,datetime,vector2,vector3,vector4 等等类型,它们的填写跟常规认知一致。 -![pipeline](docs/images/examples/b_1.jpg) + +| x1 | x3 | x4 | x5 | x6 | x7 | s1 | s2&sep=# | v2 | v3 | v4 | t1 | +| - | - | - | - | - | - | - | - | - | - | - | - | +|bool|short|int|long|float|double|string|text |vector2|vector3|vector4|datetime| +|desc1|id|desc4|desc5|desc6|desc7|desc1|desc2 |desc2|desc3|desc4|desc1| +|false| 10| 100| 1000| 1.23| 1.2345|hello |key1#world1|1,2|1,2,3|1,2,3,4|1999-10-10 11:12:13| +|true | 20| 200| 1000| 1.23| 1.2345|world |key2#world2|1,2|1,2,3|1,2,3,4|1999-10-12 11:12:13| + ### 原生数据列表 array与list类型都能表示列表,它们区别在于array生成的代码为数组,而list生成代码为列表。例如"array,int"生成的c#代码类型为 int[],而"list,int"生成的c#代码类型为 List<int>。 -![pipeline](docs/images/examples/b_20.jpg) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
idarr1arr2arr3arr4
id + desc1desc2desc3&sep=|desc4
11,2,312xx|yyxxxzzz
22,43456aaaa|bbbb|ccccaaabbbccc
+ + ### 枚举 +以枚举名或者别名的方式填写枚举值。 ```xml @@ -127,22 +169,46 @@ array与list类型都能表示列表,它们区别在于array生成的代码为 ``` -![pipeline](docs/images/examples/a_10.jpg) +| id| quality| quality2 | +| - | - | - | +| 1| 白 | RED | +| 2| GREEN | 红 | +| 3| RED | WHITE | + + ### 嵌套子结构 经常会碰到,某个字段是结构,尤其这个结构在很多配置里都会复用。 -假设任务中包含一个 任务线索 字段 +假设任务中包含一个 奖励信息 字段 ```xml - - - - + + + + ``` -![pipeline](docs/images/examples/b_31.jpg) + + + + + + + + + + + + + + + + + +
idreward
idReward
1item11desc1
2item2100desc2
+ ### 简单结构列表 某个字段为结构列表的情形也很常见,比如说奖励信息列表包含多个奖励信息,每个奖励都有多个字段。 @@ -160,7 +226,35 @@ array与list类型都能表示列表,它们区别在于array生成的代码为
``` -![pipeline](docs/images/examples/b_41.jpg) + + + + + + + + + + + + + + + + + + + + + + + + + + + +
idrewards1rewards2&sep=,rewards3&sep=,|
idlist,Rewardlist,Rewardlist,Reward
1item11desc1item22desc2item1,1,desc1item2,2,desc2item3,3,desc3item1,1,desc1|item2,2,desc2
2item11desc1item1,1,desc1item2,2,desc2item1,1,desc1|item2,2,desc2|item3,1,desc3
+ ### 多行结构列表 有时候列表结构的每个结构字段较多,如果水平展开则占据太多列,不方便编辑,如果拆表,无论程序还是策划都不方便,此时可以使用多行模式。支持任意层次的多行结构列表(也即多行结构中的每个元素也可以是多行), name&multi_rows=1或者 *name 都可以表达一个多行解析的字段。 @@ -178,19 +272,81 @@ array与list类型都能表示列表,它们区别在于array生成的代码为 ``` -![pipeline](docs/images/examples/b_51.jpg) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
idname*stage2
intstringlist,Stage
iddescstage info
1task11stage1stage desc11,2,310011
2stage2stage desc21,2,310011
3stage3stage desc31,2,310021
2task21stage1stage desc11,2,310011
2stage2stage desc21,2,310021
+ ### 单例表 有一些配置全局只有一份,比如 公会模块的开启等级,背包初始大小,背包上限。此时使用单例表来配置这些数据比较合适。 -![pipeline](docs/images/examples/b_61.jpg) +| guld_open_level | bag_init_capacity | bag_max_capacity | newbie_tasks | +| - | - | - | - | +|int | int | int | list,int| +|desc1 | desc 2 | desc 3 | desc 4 | +|10 | 100| 500| 10001,10002 | + + ### 纵表 大多数表都是横表,即一行一个记录。有些表,比如单例表,如果纵着填,一行一个字段,会比较舒服。meta行添加 orientation=c 则使用纵表模式来填写内容。 上面的单例表,以纵表模式填如下。 -![pipeline](docs/images/examples/b_62.jpg) + + + + + + + + + + + + + + + + + + + + +
##orientation=c
guild_open_levelintdesc110
bag_init_capacityintdesc2100
bag_max_capacityintdesc3500
newbie_tasks1ist,intdesc410001,10002
### 引用检查 游戏配置中经常要填写诸如道具id之类的外键数据,这些数据必须是合法的id值,luban支持生成时检查id的合法性,如果有误,则打出警告。 @@ -205,7 +361,44 @@ array与list类型都能表示列表,它们区别在于array生成的代码为 ``` -![pipeline](docs/images/examples/b_71.jpg) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
iditem_iditemsrewardrewards&sep=,
intintint&ref=item.TbItemlist,int&ref=item.TbItemreward
iddesc1desc2desc3desc4
110011001,1002100110item11001,10,item11002,2,item2 +
210021003,1004,1005100210item21004,10,item41005,2,item51010,1,item10
+ ### 资源检查 @@ -213,7 +406,13 @@ array与list类型都能表示列表,它们区别在于array生成的代码为 对于这些字段添加属性 path=unity或者path=ue或path=normal;xxxx。 -![pipeline](docs/images/examples/b_81.jpg) +| id | icon | +| - | - | +| int | string&path=unity| +|id | icon desc | +| 1| Assets/UI/item1.jpg| +|2| Assets/UI/item2.jpg| + ### 分组导出 灵活的分组定义,不仅仅是client和server分组。支持以下分组粒度: @@ -225,18 +424,93 @@ array与list类型都能表示列表,它们区别在于array生成的代码为 开发期经常会制作一些仅供开发使用的配置,比如测试道具,比如自动化测试使用的配置,希望在正式发布时不导出这些数据。 -![pipeline](docs/images/examples/c_11.jpg) +|\_\_tag\_\_ | id | name | desc | +| - | - | - | - | +| | int | string | string | +| | id | desc1| desc2| +| | 1 | item1 | 永远导出 | +|##| 2 | item2 | 永远不导出 | +|no|3| item3| 永远不导出 | +|test| 4 | item4 | --export_exclude_tags test 时导出 | +|TEST| 5 | item5 | --export_exclude_tags test 时导出 | +|dev |6 | item6 | --export_exclude_tags dev 时导出 | +| | 7|item7| 永远导出 | + ## 高级特性 ### 层级标题头 (hierarchy title) 在多行数据或者深层次嵌套的数据中,如果数据字段较多,填写时不易区分子元素。luban提供层级标题实现深层次的子字段对应。以上面的多行数据列表为例。 -![pipeline](docs/images/examples/d_30.jpg) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
idnamestages
+ idnamedesclocationitem_idnum
+ intstringlist,Stage
+ iddesc1desc1desc2desc3desc4desc5desc6
+1task11stage1stage desc11,2,310011
2stage2stage desc21,2,310011
3stage3stage desc31,2,310021
2task21stage1stage desc11,2,310011
2stage2stage desc21,2,310021
### 可空数据类型 配置数据中经常有空值的语义需求,实际项目中往往混杂地使用0或-1表达空值,既不自然清晰也不统一。luban借鉴了c#中的可空变量的概念,特地提供可空数据支持。所有原生数据类型,以及enum、bean、和多态bean类型都有相应的可空数据类型。定义方式为 <类型名>?,与c#里的Nullable类型定义方式相同。例如 bool?,int?,long?,double?, EColor?, DemoType? -![pipeline](docs/images/examples/d_10.jpg) +|id|x1|x2|x3|x4|x5| +|-|-|-|-|-|-| +|int|bool?|int?|float?|datetime?|QualityType?| +|id|desc1|desc2|desc3|desc4|desc5| +|1|true|1|1.2|1999-09-09 10:10:10| RED| +|2|null|null|null|null|null| +|3| ||||| + ### 类型继承(inheritance) 支持OOP的类型继承体系,方便表达多类型的数据,常用于技能、AI等模块。类型继承是luban类型系统的灵魂,如果没有类型继承,不可能简洁地表达任意复杂数据结构,因而也不可能定义并且从配置中读取复杂的配置数据。 @@ -265,19 +539,53 @@ array与list类型都能表示列表,它们区别在于array生成的代码为 ``` + + + + + + + + + + + + + + + + + + + + + + + + + +
idshapes&sep=,
intlist,Shape
id shape desc
1Circle,10Rectangle,100,200 + +
2Circle,20Rectangle,100,200Line,5,8Parabola,15,30
-![pipeline](docs/images/examples/d_50.jpg) ### 字段默认值 我们希望excel中单元格留空时,该字段取指定值,而不是默认的false,0之类。通过定义字段的default=xxx属性来指定默认值。 如示例,id=2的记录,x1与x2皆为空,x1=0,x2=-1。 -![pipeline](docs/images/examples/d_60.jpg) +|id | x1 | x2&default=-1| +| - | - | - | +| int | int | int | +|id|desc1|desc2| +|1 | 10 |20| +|2| | | +|3| | 30| + ### 常量别名 -游戏里经常会出现一些常用的类似枚举的值,比如说 升级丹的 id,在很多地方都要填,如果直接它的道具 id,既不直观,也容易出错。 Luban 支持常量替换。对于需要常量替换的字段,添加 convert=”枚举类”。 如果填写的值是 枚举名或者别名,则替换为 相应的整数。否则 按照整数解析。 +游戏里经常会出现一些常用的类似枚举的值,比如说 升级丹的 id,在很多地方都要填,如果直接它的道具 id,既不直观,也容易出错。 Luban 支持常量替换。如示例,导出时SHENG_JI_DAN会被替换为11220304。 ``` xml @@ -286,10 +594,13 @@ array与list类型都能表示列表,它们区别在于array生成的代码为 ``` -![pipeline](docs/images/examples/d_20.jpg) - - -导出时,升级丹会被替换为11220304。 +|id| item_id | +| - | - | +|int| int&convert=EFunctionItemId| +|id| desc| +|1 | SHENG_JI_DAN| +|2| 进阶丹| +|3| 1001| ### 灵活的配置文件组织形式 支持以下几种组织形式,允许开发者根据情况灵活组织配置文件结构。例如可以一个表对应一个xlsx文件;可以多个表都放到同个xlsx文件;可以一个表对应多个xlsx文件;可以一个表对应一个目录。