export-table-pulgin-csharp 1.1.164 → 1.1.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CSParseTool.d.ts +2 -0
- package/dist/CSParseTool.d.ts.map +1 -1
- package/dist/CSParseTool.js +4 -1
- package/dist/CSProtoParser.d.ts +22 -0
- package/dist/CSProtoParser.d.ts.map +1 -0
- package/dist/CSProtoParser.js +142 -0
- package/dist/ExportCSPlugin.d.ts +2 -1
- package/dist/ExportCSPlugin.d.ts.map +1 -1
- package/dist/ExportCSPlugin.js +50 -10
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/CSParseTool.ts +3 -0
- package/src/CSProtoParser.ts +120 -0
- package/src/ExportCSPlugin.ts +51 -10
- package/test/src0/ActivityTable.xlsx +0 -0
- package/test/src0/AnnouncementTable.xlsx +0 -0
- package/test/src0/AntiAddictionTable.xlsx +0 -0
- package/test/src0/BattleTable.xlsx +0 -0
- package/test/src0/BlackWhiteTable.xlsx +0 -0
- package/test/src0/BuffTable.xlsx +0 -0
- package/test/src0/CardTable.xlsx +0 -0
- package/test/src0/CommonQualityTable.xlsx +0 -0
- package/test/src0/CommonTipsTable.xlsx +0 -0
- package/test/src0/CommonValueTable.xlsx +0 -0
- package/test/src0/CommonVideoTable.xlsx +0 -0
- package/test/src0/CoopRuleTable.xlsx +0 -0
- package/test/src0/DefaultNameTable.xlsx +0 -0
- package/test/src0/EffectLoadTable.xlsx +0 -0
- package/test/src0/ErrorCodeTable.xlsx +0 -0
- package/test/src0/FAreaEffectTable.xlsx +0 -0
- package/test/src0/FHaloBuffTable.xlsx +0 -0
- package/test/src0/FiveAttributeTable.xlsx +0 -0
- package/test/src0/FlyerTable.xlsx +0 -0
- package/test/src0/FormationTable.xlsx +0 -0
- package/test/src0/GameUITable.xlsx +0 -0
- package/test/src0/GuildRuinsTable.xlsx +0 -0
- package/test/src0/GuildTable.xlsx +0 -0
- package/test/src0/HeadIconTable.xlsx +0 -0
- package/test/src0/InitialDataTable.xlsx +0 -0
- package/test/src0/ItemTable.xlsx +0 -0
- package/test/src0/LotteryPoolTable.xlsx +0 -0
- package/test/src0/MailTable.xlsx +0 -0
- package/test/src0/MatchTable.xlsx +0 -0
- package/test/src0/ModuleTable.xlsx +0 -0
- package/test/src0/MonsterTable.xlsx +0 -0
- package/test/src0/NotificationTable.xlsx +0 -0
- package/test/src0/PveAdventureTable.xlsx +0 -0
- package/test/src0/PveTable.xlsx +0 -0
- package/test/src0/PvpTable.xlsx +0 -0
- package/test/src0/RankTable.xlsx +0 -0
- package/test/src0/RecordTable.xlsx +0 -0
- package/test/src0/RedeemTable.xlsx +0 -0
- package/test/src0/RefinerTable.xlsx +0 -0
- package/test/src0/RobotServerConfigTable.xlsx +0 -0
- package/test/src0/ScreenAdaptTable.xlsx +0 -0
- package/test/src0/SeasonTimeTable.xlsx +0 -0
- package/test/src0/ServerTable.xlsx +0 -0
- package/test/src0/ShopTable.xlsx +0 -0
- package/test/src0/SkillTable.xlsx +0 -0
- package/test/src0/SpellTable.xlsx +0 -0
- package/test/src0/SpiritTable.xlsx +0 -0
- package/test/src0/StickerTable.xlsx +0 -0
- package/test/src0/SummonerTable.xlsx +0 -0
- package/test/src0/SutraStarTable.xlsx +0 -0
- package/test/src0/SutraSystemTable.xlsx +0 -0
- package/test/src0/SutraTable.xlsx +0 -0
- package/test/src0/SwitchTable.xlsx +0 -0
- package/test/src0/TaskAchieveTaskTable.xlsx +0 -0
- package/test/src0/TaskDayTaskTable.xlsx +0 -0
- package/test/src0/TaskSevenDayTaskTable.xlsx +0 -0
- package/test/src0/TaskTable.xlsx +0 -0
- package/test/src0/TipsTable.xlsx +0 -0
- package/test/src0/TowerTable.xlsx +0 -0
- package/test/src0/TutorialShowTable.xlsx +0 -0
- package/test/src0/TutorialTable.xlsx +0 -0
- package/test/src0/UnitAttributeTable.xlsx +0 -0
- package/test/src0//346/265/213/350/257/225/345/244/226/347/275/256/350/207/252/345/256/232/344/271/211/347/261/273/345/236/213.xlsx +0 -0
- package/test/testCSWithProto.bat +1 -0
package/dist/CSParseTool.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare function genTupleArrayValue(f: Field, content: string): {
|
|
|
13
13
|
export declare function ToNewTupleStatement(obj: ValueTuple): string;
|
|
14
14
|
export declare function ConvValue2Literal(value: any, t: FieldType, f: Field): string;
|
|
15
15
|
export declare let isSkipExportDefaults0: boolean;
|
|
16
|
+
export declare let isOverwriteWithProto: boolean;
|
|
17
|
+
export declare let overwriteWithProtoPath: string;
|
|
16
18
|
export declare let firstLetterUpper: (str: string) => string;
|
|
17
19
|
export declare let firstLetterLower: (str: string) => string;
|
|
18
20
|
export declare let convMemberName: (str: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CSParseTool.d.ts","sourceRoot":"","sources":["../src/CSParseTool.ts"],"names":[],"mappings":";AACA,OAAO,EAA0B,KAAK,EAA4D,SAAS,EAAwB,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGtK,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,GAAG,CAWpE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,GAAG,CA0CjE;AAED,MAAM,MAAM,UAAU,GAAG;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,GAAG,CAAC;CACZ,CAAA;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,UAAU,EAAE,CAAA;CAAE,GAAG,SAAS,CAoDlH;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,UAElD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAwE5E;AAED,eAAO,IAAI,qBAAqB,SAA0D,CAAA;AAE1F,eAAO,IAAI,gBAAgB,QAAkB,MAAM,WAElD,CAAC;AACF,eAAO,IAAI,gBAAgB,QAAkB,MAAM,WAElD,CAAC;AACF,eAAO,IAAI,cAAc,QAAkB,MAAM,WAEhD,CAAA;AACD,eAAO,IAAI,WAAW,QANuB,MAAM,WAMV,CAAA;AAEzC,eAAO,IAAI,mBAAmB,MAAgB,KAAK,WAclD,CAAA;AAED,eAAO,IAAI,YAAY,MAAgB,KAAK,wGAiD3C,CAAA;AAED,eAAO,IAAI,WAAW,MAAgB,KAAK,YAI1C,CAAA;AAED,eAAO,IAAI,kBAAkB,MAAgB,KAAK,WA+CjD,CAAA;AAED,eAAO,IAAI,4BAA4B,MAAgB,KAAK,WAiB3D,CAAA;AAED,eAAO,IAAI,cAAc,WAAqB,SAAS,EAAE,SAAS,KAAK,cAEtE,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAK,KAAK,KAAG,MAE/C,CAAA;AAED,eAAO,MAAM,QAAQ,MAAO,KAAK,WAEhC,CAAA;AAED,eAAO,MAAM,YAAY,MAAO,KAAK,aAEpC,CAAA;AAED,eAAO,MAAM,kBAAkB,MAAO,KAAK,sBAc1C,CAAA;AAED,eAAO,MAAM,wBAAwB,MAAO,KAAK,WAYhD,CAAA;AAED,wBAAgB,yBAAyB,WAQxC;AAED,eAAO,IAAI,WAAW,SAAwD,CAAA;AAC9E,eAAO,IAAI,eAAe,QAAgC,CAAA;AAE1D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAS7F"}
|
|
1
|
+
{"version":3,"file":"CSParseTool.d.ts","sourceRoot":"","sources":["../src/CSParseTool.ts"],"names":[],"mappings":";AACA,OAAO,EAA0B,KAAK,EAA4D,SAAS,EAAwB,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGtK,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,GAAG,CAWpE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,GAAG,CA0CjE;AAED,MAAM,MAAM,UAAU,GAAG;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,GAAG,CAAC;CACZ,CAAA;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,UAAU,EAAE,CAAA;CAAE,GAAG,SAAS,CAoDlH;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,UAElD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAwE5E;AAED,eAAO,IAAI,qBAAqB,SAA0D,CAAA;AAE1F,eAAO,IAAI,oBAAoB,SAAsB,CAAA;AACrD,eAAO,IAAI,sBAAsB,QAA+D,CAAA;AAEhG,eAAO,IAAI,gBAAgB,QAAkB,MAAM,WAElD,CAAC;AACF,eAAO,IAAI,gBAAgB,QAAkB,MAAM,WAElD,CAAC;AACF,eAAO,IAAI,cAAc,QAAkB,MAAM,WAEhD,CAAA;AACD,eAAO,IAAI,WAAW,QANuB,MAAM,WAMV,CAAA;AAEzC,eAAO,IAAI,mBAAmB,MAAgB,KAAK,WAclD,CAAA;AAED,eAAO,IAAI,YAAY,MAAgB,KAAK,wGAiD3C,CAAA;AAED,eAAO,IAAI,WAAW,MAAgB,KAAK,YAI1C,CAAA;AAED,eAAO,IAAI,kBAAkB,MAAgB,KAAK,WA+CjD,CAAA;AAED,eAAO,IAAI,4BAA4B,MAAgB,KAAK,WAiB3D,CAAA;AAED,eAAO,IAAI,cAAc,WAAqB,SAAS,EAAE,SAAS,KAAK,cAEtE,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,GAAG,KAAK,KAAK,KAAG,MAE/C,CAAA;AAED,eAAO,MAAM,QAAQ,MAAO,KAAK,WAEhC,CAAA;AAED,eAAO,MAAM,YAAY,MAAO,KAAK,aAEpC,CAAA;AAED,eAAO,MAAM,kBAAkB,MAAO,KAAK,sBAc1C,CAAA;AAED,eAAO,MAAM,wBAAwB,MAAO,KAAK,WAYhD,CAAA;AAED,wBAAgB,yBAAyB,WAQxC;AAED,eAAO,IAAI,WAAW,SAAwD,CAAA;AAC9E,eAAO,IAAI,eAAe,QAAgC,CAAA;AAE1D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAS7F"}
|
package/dist/CSParseTool.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.outputFileSync = exports.useMMPNamespace = exports.isEnableMMP = exports.GetUsingJsonToolNamespace = exports.convTupleArrayTypeDefine = exports.convTupleArrayType = exports.getDescripts = exports.getTitle = exports.genValue = exports.getFkFieldType = exports.getCustomFieldTypeAnnotation = exports.getFieldAnnotation = exports.isTypeArray = exports.getFieldType = exports.getFieldElementType = exports.convVarName = exports.convMemberName = exports.firstLetterLower = exports.firstLetterUpper = exports.isSkipExportDefaults0 = exports.ConvValue2Literal = exports.ToNewTupleStatement = exports.genTupleArrayValue = exports.ConvValue = exports.TryConvValue = void 0;
|
|
26
|
+
exports.outputFileSync = exports.useMMPNamespace = exports.isEnableMMP = exports.GetUsingJsonToolNamespace = exports.convTupleArrayTypeDefine = exports.convTupleArrayType = exports.getDescripts = exports.getTitle = exports.genValue = exports.getFkFieldType = exports.getCustomFieldTypeAnnotation = exports.getFieldAnnotation = exports.isTypeArray = exports.getFieldType = exports.getFieldElementType = exports.convVarName = exports.convMemberName = exports.firstLetterLower = exports.firstLetterUpper = exports.overwriteWithProtoPath = exports.isOverwriteWithProto = exports.isSkipExportDefaults0 = exports.ConvValue2Literal = exports.ToNewTupleStatement = exports.genTupleArrayValue = exports.ConvValue = exports.TryConvValue = void 0;
|
|
27
27
|
const export_table_lib_1 = require("export-table-lib");
|
|
28
28
|
const fs = __importStar(require("fs-extra"));
|
|
29
29
|
function TryConvValue(value, t, f) {
|
|
@@ -246,6 +246,9 @@ function ConvValue2Literal(value, t, f) {
|
|
|
246
246
|
}
|
|
247
247
|
exports.ConvValue2Literal = ConvValue2Literal;
|
|
248
248
|
exports.isSkipExportDefaults0 = process.argv.findIndex(v => v == "--SkipDefaults") >= 0;
|
|
249
|
+
let withProtoIndex = process.argv.findIndex(v => v == "--WithProto");
|
|
250
|
+
exports.isOverwriteWithProto = withProtoIndex >= 0;
|
|
251
|
+
exports.overwriteWithProtoPath = exports.isOverwriteWithProto ? process.argv[withProtoIndex + 1] : "";
|
|
249
252
|
let firstLetterUpper = function (str) {
|
|
250
253
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
251
254
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class FieldInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
isArray: boolean;
|
|
4
|
+
type: string;
|
|
5
|
+
csName: string;
|
|
6
|
+
csType: string;
|
|
7
|
+
setName(n: string): void;
|
|
8
|
+
setType(t: string): void;
|
|
9
|
+
getFieldType(): string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ClassInfo {
|
|
12
|
+
name: string;
|
|
13
|
+
type: "class" | "enum";
|
|
14
|
+
fields: FieldInfo[];
|
|
15
|
+
getFieldInfo(fieldName: string): FieldInfo | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare class CSProtoParser {
|
|
18
|
+
typeMap: Map<string, ClassInfo>;
|
|
19
|
+
parseProtoFile(filePath: string): void;
|
|
20
|
+
getClassInfo(className: string): ClassInfo | undefined;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=CSProtoParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CSProtoParser.d.ts","sourceRoot":"","sources":["../src/CSProtoParser.ts"],"names":[],"mappings":"AAUA,qBAAa,SAAS;IAClB,IAAI,EAAE,MAAM,CAAK;IACjB,OAAO,EAAE,OAAO,CAAQ;IACxB,IAAI,EAAE,MAAM,CAAK;IACjB,MAAM,EAAE,MAAM,CAAK;IACnB,MAAM,EAAE,MAAM,CAAK;IAEnB,OAAO,CAAC,CAAC,EAAE,MAAM;IAOjB,OAAO,CAAC,CAAC,EAAE,MAAM;IAWjB,YAAY;CAGf;AAED,qBAAa,SAAS;IAClB,IAAI,EAAE,MAAM,CAAK;IACjB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAU;IAChC,MAAM,EAAE,SAAS,EAAE,CAAK;IAExB,YAAY,CAAC,SAAS,EAAE,MAAM;CAIjC;AAED,qBAAa,aAAa;IACtB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAa;IAC5C,cAAc,CAAC,QAAQ,EAAE,MAAM;IA+D/B,YAAY,CAAC,SAAS,EAAE,MAAM;CAGjC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.CSProtoParser = exports.ClassInfo = exports.FieldInfo = void 0;
|
|
27
|
+
const fs = __importStar(require("fs-extra"));
|
|
28
|
+
const CSParseTool_1 = require("./CSParseTool");
|
|
29
|
+
let fieldTypeMap = {
|
|
30
|
+
["float"]: "float",
|
|
31
|
+
["double"]: "double",
|
|
32
|
+
["int32"]: "int",
|
|
33
|
+
["bool"]: "bool",
|
|
34
|
+
["bytes"]: "byte[]",
|
|
35
|
+
};
|
|
36
|
+
class FieldInfo {
|
|
37
|
+
name = "";
|
|
38
|
+
isArray = false;
|
|
39
|
+
type = "";
|
|
40
|
+
csName = "";
|
|
41
|
+
csType = "";
|
|
42
|
+
setName(n) {
|
|
43
|
+
this.name = n;
|
|
44
|
+
this.csName = (0, CSParseTool_1.firstLetterLower)(this.name.split("_")
|
|
45
|
+
.map(t => t.slice(0, 1).toUpperCase() + t.slice(1))
|
|
46
|
+
.join(""));
|
|
47
|
+
}
|
|
48
|
+
setType(t) {
|
|
49
|
+
this.type = t;
|
|
50
|
+
let internalType = fieldTypeMap[this.type];
|
|
51
|
+
if (internalType != undefined) {
|
|
52
|
+
this.csType = internalType;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.csType = t;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
getFieldType() {
|
|
59
|
+
return this.csType;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.FieldInfo = FieldInfo;
|
|
63
|
+
class ClassInfo {
|
|
64
|
+
name = "";
|
|
65
|
+
type = "class";
|
|
66
|
+
fields = [];
|
|
67
|
+
getFieldInfo(fieldName) {
|
|
68
|
+
return this.fields.find(field => field.csName == fieldName);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.ClassInfo = ClassInfo;
|
|
72
|
+
class CSProtoParser {
|
|
73
|
+
typeMap = new Map();
|
|
74
|
+
parseProtoFile(filePath) {
|
|
75
|
+
let content = fs.readFileSync(filePath, "utf-8");
|
|
76
|
+
let curClass = null;
|
|
77
|
+
let codeLines = content.split("\n");
|
|
78
|
+
let messageRegex = /message (\w+)/;
|
|
79
|
+
let enumRegex = /enum (\w+)/;
|
|
80
|
+
let structEndRegex = /^\}/;
|
|
81
|
+
let fieldRegex = /(?:(repeated) )?(\w+) (\w+)\s*=\s*\d+;/;
|
|
82
|
+
let codeLinesLen = codeLines.length;
|
|
83
|
+
let isInClass = false;
|
|
84
|
+
for (let i = 0; i < codeLinesLen; i++) {
|
|
85
|
+
let line = codeLines[i];
|
|
86
|
+
if (!isInClass) {
|
|
87
|
+
// check enter class
|
|
88
|
+
while (true) {
|
|
89
|
+
let m1 = line.match(messageRegex);
|
|
90
|
+
if (m1) {
|
|
91
|
+
let className = m1[1];
|
|
92
|
+
curClass = new ClassInfo();
|
|
93
|
+
console.log(`find class: ${className}`);
|
|
94
|
+
curClass.name = className;
|
|
95
|
+
curClass.type = "class";
|
|
96
|
+
this.typeMap.set(className, curClass);
|
|
97
|
+
isInClass = true;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
let m2 = line.match(enumRegex);
|
|
101
|
+
if (m2) {
|
|
102
|
+
let enumName = m2[1];
|
|
103
|
+
curClass = new ClassInfo();
|
|
104
|
+
curClass.name = enumName;
|
|
105
|
+
curClass.type = "enum";
|
|
106
|
+
this.typeMap.set(enumName, curClass);
|
|
107
|
+
isInClass = true;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// check leave class
|
|
115
|
+
let m3 = line.match(structEndRegex);
|
|
116
|
+
if (m3) {
|
|
117
|
+
curClass = null;
|
|
118
|
+
isInClass = false;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// parse class fields
|
|
122
|
+
let mField = line.match(fieldRegex);
|
|
123
|
+
if (mField) {
|
|
124
|
+
let isArray = mField[1] == "repeated";
|
|
125
|
+
let fieldType = mField[2];
|
|
126
|
+
let fieldName = mField[3];
|
|
127
|
+
let field = new FieldInfo();
|
|
128
|
+
field.setName(fieldName);
|
|
129
|
+
field.setType(fieldType);
|
|
130
|
+
field.isArray = isArray;
|
|
131
|
+
curClass.fields.push(field);
|
|
132
|
+
console.log(`find field: ${field.csName}, ${field.csType}, ${curClass.fields.length}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
getClassInfo(className) {
|
|
139
|
+
return this.typeMap.get(className);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.CSProtoParser = CSProtoParser;
|
package/dist/ExportCSPlugin.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { HandleSheetParams, PluginBase } from "export-table-lib";
|
|
1
|
+
import { HandleSheetParams, PluginBase, HandleBatchParams } from "export-table-lib";
|
|
2
2
|
export declare function export_stuff(paras: HandleSheetParams): string | null;
|
|
3
3
|
export declare class ExportPlugin extends PluginBase {
|
|
4
4
|
name: string;
|
|
5
5
|
tags: string[];
|
|
6
|
+
handleBatch(paras: HandleBatchParams): void;
|
|
6
7
|
handleSheet(paras: HandleSheetParams): string | null;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=ExportCSPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,
|
|
1
|
+
{"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAmD,MAAM,kBAAkB,CAAA;AAMtK,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA6QpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAI3C,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
|
package/dist/ExportCSPlugin.js
CHANGED
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExportPlugin = exports.export_stuff = void 0;
|
|
4
4
|
const export_table_lib_1 = require("export-table-lib");
|
|
5
5
|
const CSParseTool_1 = require("./CSParseTool");
|
|
6
|
+
const CSProtoParser_1 = require("./CSProtoParser");
|
|
7
|
+
let protoParser = new CSProtoParser_1.CSProtoParser();
|
|
6
8
|
function export_stuff(paras) {
|
|
7
|
-
let { datas, fields, inject, name, objects, packagename, tables, xxtea, exportNamespace, moreOptions, allTags, } = paras;
|
|
9
|
+
let { datas, fields, inject, name, objects, packagename, tables, table: { nameOrigin, }, xxtea, exportNamespace, moreOptions, allTags, } = paras;
|
|
8
10
|
let isSkipExportDefaults = !!(moreOptions?.SkipDefaults ?? false);
|
|
9
11
|
if (CSParseTool_1.isSkipExportDefaults0) {
|
|
10
12
|
isSkipExportDefaults = true;
|
|
@@ -21,17 +23,51 @@ function export_stuff(paras) {
|
|
|
21
23
|
customFields.push(f3);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
26
|
+
let isValidField;
|
|
27
|
+
let getFieldType2;
|
|
28
|
+
let classNameOrigin = (0, CSParseTool_1.firstLetterUpper)(nameOrigin);
|
|
29
|
+
if (CSParseTool_1.isOverwriteWithProto) {
|
|
30
|
+
let classInfo = protoParser.getClassInfo(classNameOrigin);
|
|
31
|
+
if (classInfo != null) {
|
|
32
|
+
for (let f of classInfo.fields) {
|
|
33
|
+
console.log(`${f.csName}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
isValidField = (f) => {
|
|
37
|
+
let fieldInfo = classInfo?.getFieldInfo(f.name);
|
|
38
|
+
console.log(`validf: ${f.name}, ${fieldInfo}`);
|
|
39
|
+
return fieldInfo == null;
|
|
40
|
+
};
|
|
41
|
+
getFieldType2 = (f) => {
|
|
42
|
+
let fieldInfo = classInfo?.getFieldInfo(f.name);
|
|
43
|
+
if (fieldInfo != null) {
|
|
44
|
+
let fieldName = fieldInfo.getFieldType();
|
|
45
|
+
return fieldName;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return (0, CSParseTool_1.getFieldType)(f);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
isValidField = (f) => true;
|
|
54
|
+
getFieldType2 = CSParseTool_1.getFieldType;
|
|
55
|
+
}
|
|
56
|
+
let validFields = fields.filter(f => isValidField(f));
|
|
57
|
+
let mmpPrefix = CSParseTool_1.isOverwriteWithProto ? "[MemoryPackable]" : "";
|
|
58
|
+
let extendClass = CSParseTool_1.isOverwriteWithProto ? ` : ${classNameOrigin}` : "";
|
|
59
|
+
let usingProtoNamespace = CSParseTool_1.isOverwriteWithProto ? "\nusing DXTS.BattleProto;" : "";
|
|
24
60
|
let isMMPEnabled = allTags.indexOf('csharp:mmp') != -1;
|
|
25
61
|
let mmpNamespace = isMMPEnabled ? CSParseTool_1.useMMPNamespace : "";
|
|
26
62
|
let temp = `
|
|
27
63
|
using System.Collections.Generic;
|
|
28
64
|
using System.Linq;
|
|
29
|
-
using System.Runtime.InteropServices
|
|
65
|
+
using System.Runtime.InteropServices;${usingProtoNamespace}
|
|
30
66
|
${mmpNamespace}
|
|
31
67
|
|
|
32
68
|
namespace ${exportNamespace}{
|
|
33
|
-
[System.Serializable]
|
|
34
|
-
public partial class ${RowClass} {
|
|
69
|
+
[System.Serializable]${mmpPrefix}
|
|
70
|
+
public partial class ${RowClass}${extendClass} {
|
|
35
71
|
|
|
36
72
|
public static List<${RowClass}> Configs = new List<${RowClass}>()
|
|
37
73
|
{
|
|
@@ -41,7 +77,7 @@ ${(0, export_table_lib_1.foreach)(datas, data => ` new ${RowClass}(${(0, export
|
|
|
41
77
|
};
|
|
42
78
|
|
|
43
79
|
public ${RowClass}() { }
|
|
44
|
-
public ${RowClass}(${(0, export_table_lib_1.st)(() => customFields.map(f => `${(
|
|
80
|
+
public ${RowClass}(${(0, export_table_lib_1.st)(() => customFields.map(f => `${getFieldType2(f)} ${(0, CSParseTool_1.convVarName)(f.name)}`).join(", "))})
|
|
45
81
|
{
|
|
46
82
|
${(0, export_table_lib_1.foreach)(customFields, f => ` this.${(0, CSParseTool_1.convMemberName)(f.name)} = ${(0, CSParseTool_1.convVarName)(f.name)};`)}
|
|
47
83
|
}
|
|
@@ -60,12 +96,12 @@ ${(0, export_table_lib_1.foreach)(customFields, f => ` this.${(0, CSParseTool_1
|
|
|
60
96
|
}
|
|
61
97
|
|
|
62
98
|
${(0, export_table_lib_1.cmm)( /**生成字段 */)}
|
|
63
|
-
${(0, export_table_lib_1.foreach)(
|
|
99
|
+
${(0, export_table_lib_1.foreach)(validFields, f => `
|
|
64
100
|
/// <summary>
|
|
65
101
|
${(0, export_table_lib_1.foreach)((0, CSParseTool_1.getDescripts)(f), line => ` /// ${line}`)}
|
|
66
102
|
/// </summary>
|
|
67
103
|
${(0, CSParseTool_1.getFieldAnnotation)(f)}
|
|
68
|
-
public ${(
|
|
104
|
+
public ${getFieldType2(f)} ${(0, CSParseTool_1.convMemberName)(f.name)};
|
|
69
105
|
|
|
70
106
|
${(0, export_table_lib_1.iff)(f.rawType.startsWith("@"), () => `
|
|
71
107
|
/// <summary>
|
|
@@ -78,7 +114,7 @@ ${(0, export_table_lib_1.foreach)((0, CSParseTool_1.getDescripts)(f), line => `
|
|
|
78
114
|
#region get字段
|
|
79
115
|
${(0, export_table_lib_1.foreach)(fields, f => {
|
|
80
116
|
if (f.nameOrigin != f.name) {
|
|
81
|
-
return ` public ${(
|
|
117
|
+
return ` public ${getFieldType2(f)} ${(0, CSParseTool_1.getTitle)(f).replace(" ", "_")} => ${(0, CSParseTool_1.convMemberName)(f.name)};`;
|
|
82
118
|
}
|
|
83
119
|
else {
|
|
84
120
|
return "";
|
|
@@ -92,7 +128,7 @@ ${(0, export_table_lib_1.foreach)(fields, f => {
|
|
|
92
128
|
let memberName = (0, CSParseTool_1.convMemberName)(f.name);
|
|
93
129
|
let paraName = (0, CSParseTool_1.convVarName)(memberName);
|
|
94
130
|
let tempDictByMemberName = `TempDictBy${memberName}`;
|
|
95
|
-
let memberType = (
|
|
131
|
+
let memberType = getFieldType2(f);
|
|
96
132
|
return `
|
|
97
133
|
protected static Dictionary<${memberType}, ${RowClass}> ${tempDictByMemberName};
|
|
98
134
|
public static ${RowClass} GetConfigBy${memberName}(${memberType} ${paraName})
|
|
@@ -120,7 +156,7 @@ ${(0, export_table_lib_1.foreach)(fields, f => {
|
|
|
120
156
|
let memberName = (0, CSParseTool_1.convMemberName)(f.name);
|
|
121
157
|
let paraName = (0, CSParseTool_1.convVarName)(memberName);
|
|
122
158
|
let tempRecordsDictByMemberName = `TempRecordsDictBy${memberName}`;
|
|
123
|
-
let memberType = (
|
|
159
|
+
let memberType = getFieldType2(f);
|
|
124
160
|
return `
|
|
125
161
|
protected static Dictionary<${memberType}, ${RowClass}[]> ${tempRecordsDictByMemberName};
|
|
126
162
|
public static ${RowClass}[] GetConfigsBy${memberName}(${memberType} ${paraName})
|
|
@@ -213,6 +249,10 @@ exports.export_stuff = export_stuff;
|
|
|
213
249
|
class ExportPlugin extends export_table_lib_1.PluginBase {
|
|
214
250
|
name = "csharp";
|
|
215
251
|
tags = ["cs"];
|
|
252
|
+
handleBatch(paras) {
|
|
253
|
+
console.log(`try parse proto: ${CSParseTool_1.overwriteWithProtoPath}`);
|
|
254
|
+
protoParser.parseProtoFile(CSParseTool_1.overwriteWithProtoPath);
|
|
255
|
+
}
|
|
216
256
|
handleSheet(paras) {
|
|
217
257
|
let content = export_stuff(paras);
|
|
218
258
|
if (content != null) {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { ExportLiteDBCSPlugin } from "./ExportLiteDBCSPlugin";
|
|
|
3
3
|
import { ExportLiteDBUJsonPlugin } from "./ExportLiteDBUnityCSJsonPlugin";
|
|
4
4
|
import { ExportUJsonPlugin } from "./ExportUnityCSJsonPlugin";
|
|
5
5
|
import { ExportUnityMMPPlugin } from "./ExportUnityMMPPlugin";
|
|
6
|
-
export declare const ExportPlugins: (ExportCSPlugin |
|
|
6
|
+
export declare const ExportPlugins: (ExportCSPlugin | ExportUJsonPlugin | ExportLiteDBCSPlugin | ExportLiteDBUJsonPlugin | ExportUnityMMPPlugin)[];
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "export-table-pulgin-csharp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.165",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@types/commander": "2.12.2",
|
|
15
15
|
"@types/node": "^17.0.18",
|
|
16
|
-
"export-table-lib": "^1.0.
|
|
16
|
+
"export-table-lib": "^1.0.68",
|
|
17
17
|
"fs": "^0.0.1-security",
|
|
18
18
|
"fs-extra": "^10.0.0",
|
|
19
19
|
"fse": "^4.0.1"
|
package/src/CSParseTool.ts
CHANGED
|
@@ -197,6 +197,9 @@ export function ConvValue2Literal(value: any, t: FieldType, f: Field): string {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
export let isSkipExportDefaults0 = process.argv.findIndex(v => v == "--SkipDefaults") >= 0
|
|
200
|
+
let withProtoIndex = process.argv.findIndex(v => v == "--WithProto")
|
|
201
|
+
export let isOverwriteWithProto = withProtoIndex >= 0
|
|
202
|
+
export let overwriteWithProtoPath = isOverwriteWithProto ? process.argv[withProtoIndex + 1] : ""
|
|
200
203
|
|
|
201
204
|
export let firstLetterUpper = function (str: string) {
|
|
202
205
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as fs from 'fs-extra';
|
|
2
|
+
import { firstLetterLower } from './CSParseTool';
|
|
3
|
+
|
|
4
|
+
let fieldTypeMap: { [key: string]: string } = {
|
|
5
|
+
["float"]: "float",
|
|
6
|
+
["double"]: "double",
|
|
7
|
+
["int32"]: "int",
|
|
8
|
+
["bool"]: "bool",
|
|
9
|
+
["bytes"]: "byte[]",
|
|
10
|
+
}
|
|
11
|
+
export class FieldInfo {
|
|
12
|
+
name: string = ""
|
|
13
|
+
isArray: boolean = false
|
|
14
|
+
type: string = ""
|
|
15
|
+
csName: string = ""
|
|
16
|
+
csType: string = ""
|
|
17
|
+
|
|
18
|
+
setName(n: string) {
|
|
19
|
+
this.name = n
|
|
20
|
+
|
|
21
|
+
this.csName = firstLetterLower(this.name.split("_")
|
|
22
|
+
.map(t => t.slice(0, 1).toUpperCase() + t.slice(1))
|
|
23
|
+
.join(""))
|
|
24
|
+
}
|
|
25
|
+
setType(t: string) {
|
|
26
|
+
this.type = t;
|
|
27
|
+
|
|
28
|
+
let internalType = fieldTypeMap[this.type]
|
|
29
|
+
if (internalType != undefined) {
|
|
30
|
+
this.csType = internalType
|
|
31
|
+
} else {
|
|
32
|
+
this.csType = t
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getFieldType() {
|
|
37
|
+
return this.csType
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class ClassInfo {
|
|
42
|
+
name: string = ""
|
|
43
|
+
type: "class" | "enum" = "class"
|
|
44
|
+
fields: FieldInfo[] = []
|
|
45
|
+
|
|
46
|
+
getFieldInfo(fieldName: string) {
|
|
47
|
+
return this.fields.find(field => field.csName == fieldName)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class CSProtoParser {
|
|
53
|
+
typeMap: Map<string, ClassInfo> = new Map();
|
|
54
|
+
parseProtoFile(filePath: string) {
|
|
55
|
+
let content = fs.readFileSync(filePath, "utf-8");
|
|
56
|
+
let curClass: ClassInfo | null = null
|
|
57
|
+
let codeLines = content.split("\n")
|
|
58
|
+
let messageRegex = /message (\w+)/
|
|
59
|
+
let enumRegex = /enum (\w+)/
|
|
60
|
+
let structEndRegex = /^\}/
|
|
61
|
+
let fieldRegex = /(?:(repeated) )?(\w+) (\w+)\s*=\s*\d+;/
|
|
62
|
+
let codeLinesLen = codeLines.length
|
|
63
|
+
let isInClass = false;
|
|
64
|
+
for (let i = 0; i < codeLinesLen; i++) {
|
|
65
|
+
let line = codeLines[i]
|
|
66
|
+
if (!isInClass) {
|
|
67
|
+
// check enter class
|
|
68
|
+
while (true) {
|
|
69
|
+
let m1 = line.match(messageRegex)
|
|
70
|
+
if (m1) {
|
|
71
|
+
let className = m1[1]
|
|
72
|
+
curClass = new ClassInfo()
|
|
73
|
+
console.log(`find class: ${className}`)
|
|
74
|
+
curClass.name = className
|
|
75
|
+
curClass.type = "class"
|
|
76
|
+
this.typeMap.set(className, curClass)
|
|
77
|
+
isInClass = true
|
|
78
|
+
break
|
|
79
|
+
}
|
|
80
|
+
let m2 = line.match(enumRegex)
|
|
81
|
+
if (m2) {
|
|
82
|
+
let enumName = m2[1]
|
|
83
|
+
curClass = new ClassInfo()
|
|
84
|
+
curClass.name = enumName
|
|
85
|
+
curClass.type = "enum"
|
|
86
|
+
this.typeMap.set(enumName, curClass)
|
|
87
|
+
isInClass = true
|
|
88
|
+
break
|
|
89
|
+
}
|
|
90
|
+
break
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
// check leave class
|
|
94
|
+
let m3 = line.match(structEndRegex)
|
|
95
|
+
if (m3) {
|
|
96
|
+
curClass = null
|
|
97
|
+
isInClass = false;
|
|
98
|
+
} else {
|
|
99
|
+
// parse class fields
|
|
100
|
+
let mField = line.match(fieldRegex)
|
|
101
|
+
if (mField) {
|
|
102
|
+
let isArray = mField[1] == "repeated"
|
|
103
|
+
let fieldType = mField[2]
|
|
104
|
+
let fieldName = mField[3]
|
|
105
|
+
let field = new FieldInfo()
|
|
106
|
+
field.setName(fieldName)
|
|
107
|
+
field.setType(fieldType)
|
|
108
|
+
field.isArray = isArray
|
|
109
|
+
curClass!.fields.push(field)
|
|
110
|
+
console.log(`find field: ${field.csName}, ${field.csType}, ${curClass!.fields.length}`)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
getClassInfo(className: string) {
|
|
118
|
+
return this.typeMap.get(className)
|
|
119
|
+
}
|
|
120
|
+
}
|
package/src/ExportCSPlugin.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, iff, FieldType, makeFirstLetterLower, DataTable } from "export-table-lib"
|
|
3
|
-
import { convMemberName, convTupleArrayType, convTupleArrayTypeDefine, convVarName, firstLetterUpper, genValue, getCustomFieldTypeAnnotation, getDescripts, getFieldAnnotation, getFieldType, getFkFieldType, getTitle, isSkipExportDefaults0, outputFileSync, useMMPNamespace } from
|
|
3
|
+
import { convMemberName, convTupleArrayType, convTupleArrayTypeDefine, convVarName, firstLetterUpper, genValue, getCustomFieldTypeAnnotation, getDescripts, getFieldAnnotation, getFieldType, getFkFieldType, getTitle, isOverwriteWithProto, isSkipExportDefaults0, outputFileSync, overwriteWithProtoPath, useMMPNamespace } from './CSParseTool';
|
|
4
4
|
import * as fs from "fs-extra"
|
|
5
|
+
import { CSProtoParser } from "./CSProtoParser";
|
|
6
|
+
let protoParser = new CSProtoParser()
|
|
5
7
|
|
|
6
8
|
export function export_stuff(paras: HandleSheetParams): string | null {
|
|
7
9
|
let {
|
|
@@ -12,6 +14,7 @@ export function export_stuff(paras: HandleSheetParams): string | null {
|
|
|
12
14
|
objects,
|
|
13
15
|
packagename,
|
|
14
16
|
tables,
|
|
17
|
+
table: { nameOrigin, },
|
|
15
18
|
xxtea,
|
|
16
19
|
exportNamespace,
|
|
17
20
|
moreOptions,
|
|
@@ -37,18 +40,52 @@ export function export_stuff(paras: HandleSheetParams): string | null {
|
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
|
|
44
|
+
let isValidField: (f: Field) => boolean
|
|
45
|
+
let getFieldType2: (f: Field) => string
|
|
46
|
+
let classNameOrigin = firstLetterUpper(nameOrigin)
|
|
47
|
+
if (isOverwriteWithProto) {
|
|
48
|
+
let classInfo = protoParser.getClassInfo(classNameOrigin)
|
|
49
|
+
if (classInfo != null) {
|
|
50
|
+
for (let f of classInfo.fields) {
|
|
51
|
+
console.log(`${f.csName}`)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
isValidField = (f: Field) => {
|
|
55
|
+
let fieldInfo = classInfo?.getFieldInfo(f.name)
|
|
56
|
+
console.log(`validf: ${f.name}, ${fieldInfo}`)
|
|
57
|
+
return fieldInfo == null
|
|
58
|
+
}
|
|
59
|
+
getFieldType2 = (f: Field) => {
|
|
60
|
+
let fieldInfo = classInfo?.getFieldInfo(f.name)
|
|
61
|
+
if (fieldInfo != null) {
|
|
62
|
+
let fieldName = fieldInfo.getFieldType()
|
|
63
|
+
return fieldName
|
|
64
|
+
} else {
|
|
65
|
+
return getFieldType(f);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
isValidField = (f: Field) => true;
|
|
70
|
+
getFieldType2 = getFieldType
|
|
71
|
+
}
|
|
72
|
+
let validFields = fields.filter(f => isValidField(f))
|
|
73
|
+
let mmpPrefix = isOverwriteWithProto ? "[MemoryPackable]" : ""
|
|
74
|
+
let extendClass = isOverwriteWithProto ? ` : ${classNameOrigin}` : ""
|
|
75
|
+
let usingProtoNamespace = isOverwriteWithProto ? "\nusing DXTS.BattleProto;" : ""
|
|
76
|
+
|
|
40
77
|
let isMMPEnabled = allTags.indexOf('csharp:mmp') != -1
|
|
41
78
|
let mmpNamespace = isMMPEnabled ? useMMPNamespace : ""
|
|
42
79
|
|
|
43
80
|
let temp = `
|
|
44
81
|
using System.Collections.Generic;
|
|
45
82
|
using System.Linq;
|
|
46
|
-
using System.Runtime.InteropServices
|
|
83
|
+
using System.Runtime.InteropServices;${usingProtoNamespace}
|
|
47
84
|
${mmpNamespace}
|
|
48
85
|
|
|
49
86
|
namespace ${exportNamespace}{
|
|
50
|
-
[System.Serializable]
|
|
51
|
-
public partial class ${RowClass} {
|
|
87
|
+
[System.Serializable]${mmpPrefix}
|
|
88
|
+
public partial class ${RowClass}${extendClass} {
|
|
52
89
|
|
|
53
90
|
public static List<${RowClass}> Configs = new List<${RowClass}>()
|
|
54
91
|
{
|
|
@@ -60,7 +97,7 @@ ${foreach(datas, data =>
|
|
|
60
97
|
};
|
|
61
98
|
|
|
62
99
|
public ${RowClass}() { }
|
|
63
|
-
public ${RowClass}(${st(() => customFields.map(f => `${
|
|
100
|
+
public ${RowClass}(${st(() => customFields.map(f => `${getFieldType2(f)} ${convVarName(f.name)}`).join(", "))})
|
|
64
101
|
{
|
|
65
102
|
${foreach(customFields, f =>
|
|
66
103
|
` this.${convMemberName(f.name)} = ${convVarName(f.name)};`
|
|
@@ -83,14 +120,14 @@ ${foreach(customFields, f =>
|
|
|
83
120
|
}
|
|
84
121
|
|
|
85
122
|
${cmm(/**生成字段 */)}
|
|
86
|
-
${foreach(
|
|
123
|
+
${foreach(validFields, f => `
|
|
87
124
|
/// <summary>
|
|
88
125
|
${foreach(getDescripts(f), line =>
|
|
89
126
|
` /// ${line}`
|
|
90
127
|
)}
|
|
91
128
|
/// </summary>
|
|
92
129
|
${getFieldAnnotation(f)}
|
|
93
|
-
public ${
|
|
130
|
+
public ${getFieldType2(f)} ${convMemberName(f.name)};
|
|
94
131
|
|
|
95
132
|
${iff(f.rawType.startsWith("@"), () => `
|
|
96
133
|
/// <summary>
|
|
@@ -106,7 +143,7 @@ ${foreach(getDescripts(f), line =>
|
|
|
106
143
|
#region get字段
|
|
107
144
|
${foreach(fields, f => {
|
|
108
145
|
if (f.nameOrigin != f.name) {
|
|
109
|
-
return ` public ${
|
|
146
|
+
return ` public ${getFieldType2(f)} ${getTitle(f).replace(" ", "_")} => ${convMemberName(f.name)};`
|
|
110
147
|
} else {
|
|
111
148
|
return ""
|
|
112
149
|
}
|
|
@@ -120,7 +157,7 @@ ${foreach(fields, f => {
|
|
|
120
157
|
let memberName = convMemberName(f.name);
|
|
121
158
|
let paraName = convVarName(memberName);
|
|
122
159
|
let tempDictByMemberName = `TempDictBy${memberName}`;
|
|
123
|
-
let memberType =
|
|
160
|
+
let memberType = getFieldType2(f);
|
|
124
161
|
return `
|
|
125
162
|
protected static Dictionary<${memberType}, ${RowClass}> ${tempDictByMemberName};
|
|
126
163
|
public static ${RowClass} GetConfigBy${memberName}(${memberType} ${paraName})
|
|
@@ -147,7 +184,7 @@ ${foreach(fields, f => {
|
|
|
147
184
|
let memberName = convMemberName(f.name);
|
|
148
185
|
let paraName = convVarName(memberName);
|
|
149
186
|
let tempRecordsDictByMemberName = `TempRecordsDictBy${memberName}`;
|
|
150
|
-
let memberType =
|
|
187
|
+
let memberType = getFieldType2(f);
|
|
151
188
|
return `
|
|
152
189
|
protected static Dictionary<${memberType}, ${RowClass}[]> ${tempRecordsDictByMemberName};
|
|
153
190
|
public static ${RowClass}[] GetConfigsBy${memberName}(${memberType} ${paraName})
|
|
@@ -243,6 +280,10 @@ export class ExportPlugin extends PluginBase {
|
|
|
243
280
|
name = "csharp"
|
|
244
281
|
tags: string[] = ["cs"]
|
|
245
282
|
|
|
283
|
+
handleBatch(paras: HandleBatchParams): void {
|
|
284
|
+
console.log(`try parse proto: ${overwriteWithProtoPath}`)
|
|
285
|
+
protoParser.parseProtoFile(overwriteWithProtoPath)
|
|
286
|
+
}
|
|
246
287
|
handleSheet(paras: HandleSheetParams) {
|
|
247
288
|
let content = export_stuff(paras)
|
|
248
289
|
if (content != null) {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
node E:\DATA\Projects\netease\quicktable\export-table\dist\launch.js export src dist --tags csharp:cs --libs E:\DATA\Projects\netease\quicktable --WithProto src/wasmproto.proto --scenes client %*
|