webgal-parser 4.3.13-9 → 4.4.3

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.
Files changed (42) hide show
  1. package/build/cjs/configParser/configParser.d.ts +1 -0
  2. package/build/cjs/index.d.ts +4 -3
  3. package/build/cjs/index.js +17 -3
  4. package/build/cjs/interface/sceneInterface.d.ts +3 -1
  5. package/build/cjs/parser4/index.d.ts +1 -0
  6. package/build/es/configParser/configParser.d.ts +1 -0
  7. package/build/es/index.d.ts +4 -3
  8. package/build/es/index.js +17 -3
  9. package/build/es/interface/sceneInterface.d.ts +3 -1
  10. package/build/es/parser4/index.d.ts +1 -0
  11. package/build/types/config/scriptConfig.d.ts +6 -0
  12. package/build/types/configParser/configParser.d.ts +1 -0
  13. package/build/types/index.d.ts +13 -0
  14. package/build/types/interface/assets.d.ts +12 -0
  15. package/build/types/interface/runtimeInterface.d.ts +9 -0
  16. package/build/types/interface/sceneInterface.d.ts +96 -0
  17. package/build/types/parser4/index.d.ts +1 -0
  18. package/build/types/sceneParser.d.ts +14 -0
  19. package/build/types/scriptParser/argsParser.d.ts +9 -0
  20. package/build/types/scriptParser/assetsScanner.d.ts +9 -0
  21. package/build/types/scriptParser/commandParser.d.ts +9 -0
  22. package/build/types/scriptParser/contentParser.d.ts +9 -0
  23. package/build/types/scriptParser/scriptParser.d.ts +9 -0
  24. package/build/types/scriptParser/subSceneScanner.d.ts +7 -0
  25. package/build/umd/index.global.js +1776 -0
  26. package/package.json +7 -4
  27. package/src/config/scriptConfig.ts +46 -46
  28. package/src/configParser/configParser.ts +4 -0
  29. package/src/index.ts +11 -6
  30. package/src/interface/assets.ts +12 -12
  31. package/src/interface/runtimeInterface.ts +9 -9
  32. package/src/interface/sceneInterface.ts +5 -3
  33. package/src/parser4/index.ts +158 -0
  34. package/src/sceneParser.ts +47 -47
  35. package/src/scriptParser/argsParser.ts +68 -62
  36. package/src/scriptParser/assetsScanner.ts +72 -72
  37. package/src/scriptParser/commandParser.ts +57 -57
  38. package/src/scriptParser/contentParser.ts +66 -66
  39. package/src/scriptParser/scriptParser.ts +87 -87
  40. package/src/scriptParser/subSceneScanner.ts +23 -23
  41. package/build/cjs/index.js.map +0 -1
  42. package/build/es/index.js.map +0 -1
@@ -1,72 +1,72 @@
1
- import { arg, commandType, IAsset } from '../interface/sceneInterface';
2
- import { fileType } from '../interface/assets';
3
-
4
- /**
5
- * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
6
- * @param command 语句类型
7
- * @param content 语句内容
8
- * @param args 参数列表
9
- * @return {Array<IAsset>} 语句携带的参数列表
10
- */
11
- export const assetsScanner = (command: commandType, content: string, args: Array<arg>): Array<IAsset> => {
12
- let hasVocalArg = false;
13
- const returnAssetsList: Array<IAsset> = [];
14
- if (command === commandType.say) {
15
- args.forEach((e) => {
16
- if (e.key === 'vocal') {
17
- hasVocalArg = true;
18
- returnAssetsList.push({
19
- name: e.value as string,
20
- url: e.value as string,
21
- lineNumber: 0,
22
- type: fileType.vocal,
23
- });
24
- }
25
- });
26
- }
27
- if (content === 'none' || content === '') {
28
- return returnAssetsList;
29
- }
30
- // 处理语句携带的资源
31
- if (command === commandType.changeBg) {
32
- returnAssetsList.push({
33
- name: content,
34
- url: content,
35
- lineNumber: 0,
36
- type: fileType.background,
37
- });
38
- }
39
- if (command === commandType.changeFigure) {
40
- returnAssetsList.push({
41
- name: content,
42
- url: content,
43
- lineNumber: 0,
44
- type: fileType.figure,
45
- });
46
- }
47
- if (command === commandType.miniAvatar) {
48
- returnAssetsList.push({
49
- name: content,
50
- url: content,
51
- lineNumber: 0,
52
- type: fileType.figure,
53
- });
54
- }
55
- if (command === commandType.video) {
56
- returnAssetsList.push({
57
- name: content,
58
- url: content,
59
- lineNumber: 0,
60
- type: fileType.video,
61
- });
62
- }
63
- if (command === commandType.bgm) {
64
- returnAssetsList.push({
65
- name: content,
66
- url: content,
67
- lineNumber: 0,
68
- type: fileType.bgm,
69
- });
70
- }
71
- return returnAssetsList;
72
- };
1
+ import { arg, commandType, IAsset } from '../interface/sceneInterface';
2
+ import { fileType } from '../interface/assets';
3
+
4
+ /**
5
+ * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
6
+ * @param command 语句类型
7
+ * @param content 语句内容
8
+ * @param args 参数列表
9
+ * @return {Array<IAsset>} 语句携带的参数列表
10
+ */
11
+ export const assetsScanner = (command: commandType, content: string, args: Array<arg>): Array<IAsset> => {
12
+ let hasVocalArg = false;
13
+ const returnAssetsList: Array<IAsset> = [];
14
+ if (command === commandType.say) {
15
+ args.forEach((e) => {
16
+ if (e.key === 'vocal') {
17
+ hasVocalArg = true;
18
+ returnAssetsList.push({
19
+ name: e.value as string,
20
+ url: e.value as string,
21
+ lineNumber: 0,
22
+ type: fileType.vocal,
23
+ });
24
+ }
25
+ });
26
+ }
27
+ if (content === 'none' || content === '') {
28
+ return returnAssetsList;
29
+ }
30
+ // 处理语句携带的资源
31
+ if (command === commandType.changeBg) {
32
+ returnAssetsList.push({
33
+ name: content,
34
+ url: content,
35
+ lineNumber: 0,
36
+ type: fileType.background,
37
+ });
38
+ }
39
+ if (command === commandType.changeFigure) {
40
+ returnAssetsList.push({
41
+ name: content,
42
+ url: content,
43
+ lineNumber: 0,
44
+ type: fileType.figure,
45
+ });
46
+ }
47
+ if (command === commandType.miniAvatar) {
48
+ returnAssetsList.push({
49
+ name: content,
50
+ url: content,
51
+ lineNumber: 0,
52
+ type: fileType.figure,
53
+ });
54
+ }
55
+ if (command === commandType.video) {
56
+ returnAssetsList.push({
57
+ name: content,
58
+ url: content,
59
+ lineNumber: 0,
60
+ type: fileType.video,
61
+ });
62
+ }
63
+ if (command === commandType.bgm) {
64
+ returnAssetsList.push({
65
+ name: content,
66
+ url: content,
67
+ lineNumber: 0,
68
+ type: fileType.bgm,
69
+ });
70
+ }
71
+ return returnAssetsList;
72
+ };
@@ -1,57 +1,57 @@
1
- import { commandType, parsedCommand } from "../interface/sceneInterface";
2
-
3
- /**
4
- * 处理命令
5
- * @param commandRaw
6
- * @param ADD_NEXT_ARG_LIST
7
- * @param SCRIPT_CONFIG
8
- * @return {parsedCommand} 处理后的命令
9
- */
10
- export const commandParser = (commandRaw: string, ADD_NEXT_ARG_LIST:any, SCRIPT_CONFIG:any): parsedCommand => {
11
- let returnCommand: parsedCommand = {
12
- type: commandType.say, // 默认是say
13
- additionalArgs: []
14
- };
15
- // 开始处理命令内容
16
- const type: commandType = getCommandType(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
17
- returnCommand.type = type;
18
- // 如果是对话,加上额外的参数
19
- if (type === commandType.say) {
20
- returnCommand.additionalArgs.push({
21
- key: "speaker",
22
- value: commandRaw
23
- });
24
- }
25
- returnCommand = addNextArg(returnCommand, type, ADD_NEXT_ARG_LIST);
26
- return returnCommand;
27
- };
28
-
29
- /**
30
- * 根据command原始值判断是什么命令
31
- * @param command command原始值
32
- * @param ADD_NEXT_ARG_LIST
33
- * @param SCRIPT_CONFIG
34
- * @return {commandType} 得到的command类型
35
- */
36
- function getCommandType(command: string, ADD_NEXT_ARG_LIST:any, SCRIPT_CONFIG:any): commandType {
37
- // if (command.match(/if/)) {
38
- // return commandType.if;
39
- // }
40
- const commandMap = new Map();
41
- SCRIPT_CONFIG.forEach((e:any) => {
42
- commandMap.set(e.scriptString, e.scriptType);
43
- });
44
- if (commandMap.has(command)) {
45
- return commandMap.get(command);
46
- } else return commandType.say;
47
- }
48
-
49
- function addNextArg(commandToParse: parsedCommand, thisCommandType: commandType, ADD_NEXT_ARG_LIST:any) {
50
- if (ADD_NEXT_ARG_LIST.includes(thisCommandType)) {
51
- commandToParse.additionalArgs.push({
52
- key: "next",
53
- value: true
54
- });
55
- }
56
- return commandToParse;
57
- }
1
+ import { commandType, parsedCommand } from "../interface/sceneInterface";
2
+
3
+ /**
4
+ * 处理命令
5
+ * @param commandRaw
6
+ * @param ADD_NEXT_ARG_LIST
7
+ * @param SCRIPT_CONFIG
8
+ * @return {parsedCommand} 处理后的命令
9
+ */
10
+ export const commandParser = (commandRaw: string, ADD_NEXT_ARG_LIST:any, SCRIPT_CONFIG:any): parsedCommand => {
11
+ let returnCommand: parsedCommand = {
12
+ type: commandType.say, // 默认是say
13
+ additionalArgs: []
14
+ };
15
+ // 开始处理命令内容
16
+ const type: commandType = getCommandType(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
17
+ returnCommand.type = type;
18
+ // 如果是对话,加上额外的参数
19
+ if (type === commandType.say) {
20
+ returnCommand.additionalArgs.push({
21
+ key: "speaker",
22
+ value: commandRaw
23
+ });
24
+ }
25
+ returnCommand = addNextArg(returnCommand, type, ADD_NEXT_ARG_LIST);
26
+ return returnCommand;
27
+ };
28
+
29
+ /**
30
+ * 根据command原始值判断是什么命令
31
+ * @param command command原始值
32
+ * @param ADD_NEXT_ARG_LIST
33
+ * @param SCRIPT_CONFIG
34
+ * @return {commandType} 得到的command类型
35
+ */
36
+ function getCommandType(command: string, ADD_NEXT_ARG_LIST:any, SCRIPT_CONFIG:any): commandType {
37
+ // if (command.match(/if/)) {
38
+ // return commandType.if;
39
+ // }
40
+ const commandMap = new Map();
41
+ SCRIPT_CONFIG.forEach((e:any) => {
42
+ commandMap.set(e.scriptString, e.scriptType);
43
+ });
44
+ if (commandMap.has(command)) {
45
+ return commandMap.get(command);
46
+ } else return commandType.say;
47
+ }
48
+
49
+ function addNextArg(commandToParse: parsedCommand, thisCommandType: commandType, ADD_NEXT_ARG_LIST:any) {
50
+ if (ADD_NEXT_ARG_LIST.includes(thisCommandType)) {
51
+ commandToParse.additionalArgs.push({
52
+ key: "next",
53
+ value: true
54
+ });
55
+ }
56
+ return commandToParse;
57
+ }
@@ -1,66 +1,66 @@
1
- import { commandType } from "../interface/sceneInterface";
2
- import { fileType } from "../interface/assets";
3
-
4
- /**
5
- * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
6
- * @param contentRaw 原始语句内容
7
- * @param type 语句类型
8
- * @param assetSetter
9
- * @return {string} 解析后的语句内容
10
- */
11
- export const contentParser = (contentRaw: string, type: commandType, assetSetter: any) => {
12
- if (contentRaw === "none" || contentRaw === "") {
13
- return "";
14
- }
15
- switch (type) {
16
- case commandType.playEffect:
17
- return assetSetter(contentRaw, fileType.vocal);
18
- case commandType.changeBg:
19
- return assetSetter(contentRaw, fileType.background);
20
- case commandType.changeFigure:
21
- return assetSetter(contentRaw, fileType.figure);
22
- case commandType.bgm:
23
- return assetSetter(contentRaw, fileType.bgm);
24
- case commandType.callScene:
25
- return assetSetter(contentRaw, fileType.scene);
26
- case commandType.changeScene:
27
- return assetSetter(contentRaw, fileType.scene);
28
- case commandType.miniAvatar:
29
- return assetSetter(contentRaw, fileType.figure);
30
- case commandType.video:
31
- return assetSetter(contentRaw, fileType.video);
32
- case commandType.choose:
33
- return getChooseContent(contentRaw, assetSetter);
34
- case commandType.unlockBgm:
35
- return assetSetter(contentRaw, fileType.bgm);
36
- case commandType.unlockCg:
37
- return assetSetter(contentRaw, fileType.background);
38
- default:
39
- return contentRaw;
40
- }
41
- };
42
-
43
- function getChooseContent(contentRaw: string, assetSetter: any): string {
44
- const chooseList = contentRaw.split("|");
45
- const chooseKeyList: Array<string> = [];
46
- const chooseValueList: Array<string> = [];
47
- for (const e of chooseList) {
48
- chooseKeyList.push(e.split(":")[0] ?? "");
49
- chooseValueList.push(e.split(":")[1] ?? "");
50
- }
51
- const parsedChooseList = chooseValueList.map((e) => {
52
- if (e.match(/\./)) {
53
- return assetSetter(e, fileType.scene);
54
- } else {
55
- return e;
56
- }
57
- });
58
- let ret = "";
59
- for (let i = 0; i < chooseKeyList.length; i++) {
60
- if (i !== 0) {
61
- ret = ret + "|";
62
- }
63
- ret = ret + `${chooseKeyList[i]}:${parsedChooseList[i]}`;
64
- }
65
- return ret;
66
- }
1
+ import { commandType } from "../interface/sceneInterface";
2
+ import { fileType } from "../interface/assets";
3
+
4
+ /**
5
+ * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
6
+ * @param contentRaw 原始语句内容
7
+ * @param type 语句类型
8
+ * @param assetSetter
9
+ * @return {string} 解析后的语句内容
10
+ */
11
+ export const contentParser = (contentRaw: string, type: commandType, assetSetter: any) => {
12
+ if (contentRaw === "none" || contentRaw === "") {
13
+ return "";
14
+ }
15
+ switch (type) {
16
+ case commandType.playEffect:
17
+ return assetSetter(contentRaw, fileType.vocal);
18
+ case commandType.changeBg:
19
+ return assetSetter(contentRaw, fileType.background);
20
+ case commandType.changeFigure:
21
+ return assetSetter(contentRaw, fileType.figure);
22
+ case commandType.bgm:
23
+ return assetSetter(contentRaw, fileType.bgm);
24
+ case commandType.callScene:
25
+ return assetSetter(contentRaw, fileType.scene);
26
+ case commandType.changeScene:
27
+ return assetSetter(contentRaw, fileType.scene);
28
+ case commandType.miniAvatar:
29
+ return assetSetter(contentRaw, fileType.figure);
30
+ case commandType.video:
31
+ return assetSetter(contentRaw, fileType.video);
32
+ case commandType.choose:
33
+ return getChooseContent(contentRaw, assetSetter);
34
+ case commandType.unlockBgm:
35
+ return assetSetter(contentRaw, fileType.bgm);
36
+ case commandType.unlockCg:
37
+ return assetSetter(contentRaw, fileType.background);
38
+ default:
39
+ return contentRaw;
40
+ }
41
+ };
42
+
43
+ function getChooseContent(contentRaw: string, assetSetter: any): string {
44
+ const chooseList = contentRaw.split("|");
45
+ const chooseKeyList: Array<string> = [];
46
+ const chooseValueList: Array<string> = [];
47
+ for (const e of chooseList) {
48
+ chooseKeyList.push(e.split(":")[0] ?? "");
49
+ chooseValueList.push(e.split(":")[1] ?? "");
50
+ }
51
+ const parsedChooseList = chooseValueList.map((e) => {
52
+ if (e.match(/\./)) {
53
+ return assetSetter(e, fileType.scene);
54
+ } else {
55
+ return e;
56
+ }
57
+ });
58
+ let ret = "";
59
+ for (let i = 0; i < chooseKeyList.length; i++) {
60
+ if (i !== 0) {
61
+ ret = ret + "|";
62
+ }
63
+ ret = ret + `${chooseKeyList[i]}:${parsedChooseList[i]}`;
64
+ }
65
+ return ret;
66
+ }
@@ -1,87 +1,87 @@
1
- import { arg, commandType, IAsset, ISentence, parsedCommand } from "../interface/sceneInterface";
2
- import { commandParser } from "./commandParser";
3
- import { argsParser } from "./argsParser";
4
- import { contentParser } from "./contentParser";
5
- import { assetsScanner } from "./assetsScanner";
6
- import { subSceneScanner } from "./subSceneScanner";
7
-
8
- /**
9
- * 语句解析器
10
- * @param sentenceRaw 原始语句
11
- * @param assetSetter
12
- * @param ADD_NEXT_ARG_LIST
13
- * @param SCRIPT_CONFIG
14
- */
15
- export const scriptParser = (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any): ISentence => {
16
- let command: commandType; // 默认为对话
17
- let content: string; // 语句内容
18
- let subScene: Array<string>; // 语句携带的子场景(可能没有)
19
- const args: Array<arg> = []; // 语句参数列表
20
- let sentenceAssets: Array<IAsset>; // 语句携带的资源列表
21
- let parsedCommand: parsedCommand; // 解析后的命令
22
- let commandRaw: string;
23
-
24
- // 正式开始解析
25
-
26
- // 去分号,前面已做,这里不再需要
27
- let newSentenceRaw = sentenceRaw.split(";")[0];
28
- if (newSentenceRaw === "") {
29
- // 注释提前返回
30
- return {
31
- command: commandType.comment, // 语句类型
32
- commandRaw: "comment", // 命令原始内容,方便调试
33
- content: sentenceRaw.split(";")[1] ?? "", // 语句内容
34
- args: [{ key: "next", value: true }], // 参数列表
35
- sentenceAssets: [], // 语句携带的资源列表
36
- subScene: [] // 语句携带的子场景
37
- };
38
- }
39
- // 截取命令
40
- const getCommandResult = /:/.exec(newSentenceRaw);
41
- /**
42
- * 拆分命令和语句,同时处理连续对话。
43
- */
44
- // 没有command,说明这是一条连续对话或单条语句
45
- if (getCommandResult === null) {
46
- commandRaw = newSentenceRaw;
47
- parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
48
- command = parsedCommand.type;
49
- for (const e of parsedCommand.additionalArgs) {
50
- // 由于是连续对话,所以我们去除 speaker 参数。
51
- if (command === commandType.say && e.key === "speaker") {
52
- continue;
53
- }
54
- args.push(e);
55
- }
56
- } else {
57
- commandRaw = newSentenceRaw.substring(0, getCommandResult.index);
58
- // 划分命令区域和content区域
59
- newSentenceRaw = newSentenceRaw.substring(getCommandResult.index + 1, newSentenceRaw.length);
60
- parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
61
- command = parsedCommand.type;
62
- for (const e of parsedCommand.additionalArgs) {
63
- args.push(e);
64
- }
65
- }
66
- // 截取参数区域
67
- const getArgsResult = / -/.exec(newSentenceRaw);
68
- // 获取到参数
69
- if (getArgsResult) {
70
- const argsRaw = newSentenceRaw.substring(getArgsResult.index, sentenceRaw.length);
71
- newSentenceRaw = newSentenceRaw.substring(0, getArgsResult.index);
72
- for (const e of argsParser(argsRaw, assetSetter)) {
73
- args.push(e);
74
- }
75
- }
76
- content = contentParser(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
77
- sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
78
- subScene = subSceneScanner(command, content); // 扫描语句携带子场景
79
- return {
80
- command: command, // 语句类型
81
- commandRaw: commandRaw, // 命令原始内容,方便调试
82
- content: content, // 语句内容
83
- args: args, // 参数列表
84
- sentenceAssets: sentenceAssets, // 语句携带的资源列表
85
- subScene: subScene // 语句携带的子场景
86
- };
87
- };
1
+ import { arg, commandType, IAsset, ISentence, parsedCommand } from "../interface/sceneInterface";
2
+ import { commandParser } from "./commandParser";
3
+ import { argsParser } from "./argsParser";
4
+ import { contentParser } from "./contentParser";
5
+ import { assetsScanner } from "./assetsScanner";
6
+ import { subSceneScanner } from "./subSceneScanner";
7
+
8
+ /**
9
+ * 语句解析器
10
+ * @param sentenceRaw 原始语句
11
+ * @param assetSetter
12
+ * @param ADD_NEXT_ARG_LIST
13
+ * @param SCRIPT_CONFIG
14
+ */
15
+ export const scriptParser = (sentenceRaw: string, assetSetter: any, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any): ISentence => {
16
+ let command: commandType; // 默认为对话
17
+ let content: string; // 语句内容
18
+ let subScene: Array<string>; // 语句携带的子场景(可能没有)
19
+ const args: Array<arg> = []; // 语句参数列表
20
+ let sentenceAssets: Array<IAsset>; // 语句携带的资源列表
21
+ let parsedCommand: parsedCommand; // 解析后的命令
22
+ let commandRaw: string;
23
+
24
+ // 正式开始解析
25
+
26
+ // 去分号,前面已做,这里不再需要
27
+ let newSentenceRaw = sentenceRaw.split(";")[0];
28
+ if (newSentenceRaw === "") {
29
+ // 注释提前返回
30
+ return {
31
+ command: commandType.comment, // 语句类型
32
+ commandRaw: "comment", // 命令原始内容,方便调试
33
+ content: sentenceRaw.split(";")[1] ?? "", // 语句内容
34
+ args: [{ key: "next", value: true }], // 参数列表
35
+ sentenceAssets: [], // 语句携带的资源列表
36
+ subScene: [] // 语句携带的子场景
37
+ };
38
+ }
39
+ // 截取命令
40
+ const getCommandResult = /:/.exec(newSentenceRaw);
41
+ /**
42
+ * 拆分命令和语句,同时处理连续对话。
43
+ */
44
+ // 没有command,说明这是一条连续对话或单条语句
45
+ if (getCommandResult === null) {
46
+ commandRaw = newSentenceRaw;
47
+ parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
48
+ command = parsedCommand.type;
49
+ for (const e of parsedCommand.additionalArgs) {
50
+ // 由于是连续对话,所以我们去除 speaker 参数。
51
+ if (command === commandType.say && e.key === "speaker") {
52
+ continue;
53
+ }
54
+ args.push(e);
55
+ }
56
+ } else {
57
+ commandRaw = newSentenceRaw.substring(0, getCommandResult.index);
58
+ // 划分命令区域和content区域
59
+ newSentenceRaw = newSentenceRaw.substring(getCommandResult.index + 1, newSentenceRaw.length);
60
+ parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
61
+ command = parsedCommand.type;
62
+ for (const e of parsedCommand.additionalArgs) {
63
+ args.push(e);
64
+ }
65
+ }
66
+ // 截取参数区域
67
+ const getArgsResult = / -/.exec(newSentenceRaw);
68
+ // 获取到参数
69
+ if (getArgsResult) {
70
+ const argsRaw = newSentenceRaw.substring(getArgsResult.index, sentenceRaw.length);
71
+ newSentenceRaw = newSentenceRaw.substring(0, getArgsResult.index);
72
+ for (const e of argsParser(argsRaw, assetSetter)) {
73
+ args.push(e);
74
+ }
75
+ }
76
+ content = contentParser(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
77
+ sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
78
+ subScene = subSceneScanner(command, content); // 扫描语句携带子场景
79
+ return {
80
+ command: command, // 语句类型
81
+ commandRaw: commandRaw, // 命令原始内容,方便调试
82
+ content: content, // 语句内容
83
+ args: args, // 参数列表
84
+ sentenceAssets: sentenceAssets, // 语句携带的资源列表
85
+ subScene: subScene // 语句携带的子场景
86
+ };
87
+ };
@@ -1,23 +1,23 @@
1
- /**
2
- * 扫描子场景
3
- * @param content 语句内容
4
- * @return {Array<string>} 子场景列表
5
- */
6
- import { commandType } from "../interface/sceneInterface";
7
-
8
- export const subSceneScanner = (command: commandType, content: string): Array<string> => {
9
- const subSceneList: Array<string> = [];
10
- if (command === commandType.changeScene || command === commandType.callScene) {
11
- subSceneList.push(content);
12
- }
13
- if (command === commandType.choose) {
14
- const chooseList = content.split("|");
15
- const chooseValue = chooseList.map((e) => e.split(":")[1] ?? "");
16
- chooseValue.forEach((e) => {
17
- if (e.match(/\./)) {
18
- subSceneList.push(e);
19
- }
20
- });
21
- }
22
- return subSceneList;
23
- };
1
+ /**
2
+ * 扫描子场景
3
+ * @param content 语句内容
4
+ * @return {Array<string>} 子场景列表
5
+ */
6
+ import { commandType } from "../interface/sceneInterface";
7
+
8
+ export const subSceneScanner = (command: commandType, content: string): Array<string> => {
9
+ const subSceneList: Array<string> = [];
10
+ if (command === commandType.changeScene || command === commandType.callScene) {
11
+ subSceneList.push(content);
12
+ }
13
+ if (command === commandType.choose) {
14
+ const chooseList = content.split("|");
15
+ const chooseValue = chooseList.map((e) => e.split(":")[1] ?? "");
16
+ chooseValue.forEach((e) => {
17
+ if (e.match(/\./)) {
18
+ subSceneList.push(e);
19
+ }
20
+ });
21
+ }
22
+ return subSceneList;
23
+ };