webgal-parser 4.3.2

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.
@@ -0,0 +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, SCRIPT_CONFIG): 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, SCRIPT_CONFIG): commandType {
37
+ // if (command.match(/if/)) {
38
+ // return commandType.if;
39
+ // }
40
+ const commandMap = new Map();
41
+ SCRIPT_CONFIG.forEach((e) => {
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) {
50
+ if (ADD_NEXT_ARG_LIST.includes(thisCommandType)) {
51
+ commandToParse.additionalArgs.push({
52
+ key: "next",
53
+ value: true
54
+ });
55
+ }
56
+ return commandToParse;
57
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.contentParser = void 0;
4
+ var sceneInterface_1 = require("../interface/sceneInterface");
5
+ var assets_1 = require("../interface/assets");
6
+ /**
7
+ * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
8
+ * @param contentRaw 原始语句内容
9
+ * @param type 语句类型
10
+ * @param assetSetter
11
+ * @return {string} 解析后的语句内容
12
+ */
13
+ var contentParser = function (contentRaw, type, assetSetter) {
14
+ if (contentRaw === "none" || contentRaw === "") {
15
+ return "";
16
+ }
17
+ switch (type) {
18
+ case sceneInterface_1.commandType.changeBg:
19
+ return assetSetter(contentRaw, assets_1.fileType.background);
20
+ case sceneInterface_1.commandType.changeFigure:
21
+ return assetSetter(contentRaw, assets_1.fileType.figure);
22
+ case sceneInterface_1.commandType.bgm:
23
+ return assetSetter(contentRaw, assets_1.fileType.bgm);
24
+ case sceneInterface_1.commandType.callScene:
25
+ return assetSetter(contentRaw, assets_1.fileType.scene);
26
+ case sceneInterface_1.commandType.changeScene:
27
+ return assetSetter(contentRaw, assets_1.fileType.scene);
28
+ case sceneInterface_1.commandType.miniAvatar:
29
+ return assetSetter(contentRaw, assets_1.fileType.figure);
30
+ case sceneInterface_1.commandType.video:
31
+ return assetSetter(contentRaw, assets_1.fileType.video);
32
+ case sceneInterface_1.commandType.choose:
33
+ return getChooseContent(contentRaw, assetSetter);
34
+ case sceneInterface_1.commandType.unlockBgm:
35
+ return assetSetter(contentRaw, assets_1.fileType.bgm);
36
+ case sceneInterface_1.commandType.unlockCg:
37
+ return assetSetter(contentRaw, assets_1.fileType.background);
38
+ default:
39
+ return contentRaw;
40
+ }
41
+ };
42
+ exports.contentParser = contentParser;
43
+ function getChooseContent(contentRaw, assetSetter) {
44
+ var chooseList = contentRaw.split("|");
45
+ var chooseKeyList = [];
46
+ var chooseValueList = [];
47
+ for (var _i = 0, chooseList_1 = chooseList; _i < chooseList_1.length; _i++) {
48
+ var e = chooseList_1[_i];
49
+ chooseKeyList.push(e.split(":")[0]);
50
+ chooseValueList.push(e.split(":")[1]);
51
+ }
52
+ var parsedChooseList = chooseValueList.map(function (e) {
53
+ if (e.match(/\./)) {
54
+ return assetSetter(e, assets_1.fileType.scene);
55
+ }
56
+ else {
57
+ return e;
58
+ }
59
+ });
60
+ var ret = "";
61
+ for (var i = 0; i < chooseKeyList.length; i++) {
62
+ if (i !== 0) {
63
+ ret = ret + "|";
64
+ }
65
+ ret = ret + "".concat(chooseKeyList[i], ":").concat(parsedChooseList[i]);
66
+ }
67
+ return ret;
68
+ }
@@ -0,0 +1,64 @@
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) => {
12
+ if (contentRaw === "none" || contentRaw === "") {
13
+ return "";
14
+ }
15
+ switch (type) {
16
+ case commandType.changeBg:
17
+ return assetSetter(contentRaw, fileType.background);
18
+ case commandType.changeFigure:
19
+ return assetSetter(contentRaw, fileType.figure);
20
+ case commandType.bgm:
21
+ return assetSetter(contentRaw, fileType.bgm);
22
+ case commandType.callScene:
23
+ return assetSetter(contentRaw, fileType.scene);
24
+ case commandType.changeScene:
25
+ return assetSetter(contentRaw, fileType.scene);
26
+ case commandType.miniAvatar:
27
+ return assetSetter(contentRaw, fileType.figure);
28
+ case commandType.video:
29
+ return assetSetter(contentRaw, fileType.video);
30
+ case commandType.choose:
31
+ return getChooseContent(contentRaw, assetSetter);
32
+ case commandType.unlockBgm:
33
+ return assetSetter(contentRaw, fileType.bgm);
34
+ case commandType.unlockCg:
35
+ return assetSetter(contentRaw, fileType.background);
36
+ default:
37
+ return contentRaw;
38
+ }
39
+ };
40
+
41
+ function getChooseContent(contentRaw: string, assetSetter): string {
42
+ const chooseList = contentRaw.split("|");
43
+ const chooseKeyList = [];
44
+ const chooseValueList = [];
45
+ for (const e of chooseList) {
46
+ chooseKeyList.push(e.split(":")[0]);
47
+ chooseValueList.push(e.split(":")[1]);
48
+ }
49
+ const parsedChooseList = chooseValueList.map((e) => {
50
+ if (e.match(/\./)) {
51
+ return assetSetter(e, fileType.scene);
52
+ } else {
53
+ return e;
54
+ }
55
+ });
56
+ let ret = "";
57
+ for (let i = 0; i < chooseKeyList.length; i++) {
58
+ if (i !== 0) {
59
+ ret = ret + "|";
60
+ }
61
+ ret = ret + `${chooseKeyList[i]}:${parsedChooseList[i]}`;
62
+ }
63
+ return ret;
64
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.scriptParser = void 0;
4
+ var sceneInterface_1 = require("../interface/sceneInterface");
5
+ var commandParser_1 = require("./commandParser");
6
+ var argsParser_1 = require("./argsParser");
7
+ var contentParser_1 = require("./contentParser");
8
+ var assetsScanner_1 = require("./assetsScanner");
9
+ var subSceneScanner_1 = require("./subSceneScanner");
10
+ /**
11
+ * 语句解析器
12
+ * @param sentenceRaw 原始语句
13
+ * @param assetSetter
14
+ * @param ADD_NEXT_ARG_LIST
15
+ * @param SCRIPT_CONFIG
16
+ */
17
+ var scriptParser = function (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
18
+ var command; // 默认为对话
19
+ var content; // 语句内容
20
+ var subScene; // 语句携带的子场景(可能没有)
21
+ var args = []; // 语句参数列表
22
+ var sentenceAssets; // 语句携带的资源列表
23
+ var parsedCommand; // 解析后的命令
24
+ var commandRaw;
25
+ // 正式开始解析
26
+ // 去分号,前面已做,这里不再需要
27
+ var newSentenceRaw = sentenceRaw;
28
+ // 截取命令
29
+ var getCommandResult = /:/.exec(newSentenceRaw);
30
+ /**
31
+ * 拆分命令和语句,同时处理连续对话。
32
+ */
33
+ // 没有command,说明这是一条连续对话或单条语句
34
+ if (getCommandResult === null) {
35
+ commandRaw = newSentenceRaw;
36
+ parsedCommand = (0, commandParser_1.commandParser)(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
37
+ command = parsedCommand.type;
38
+ for (var _i = 0, _a = parsedCommand.additionalArgs; _i < _a.length; _i++) {
39
+ var e = _a[_i];
40
+ // 由于是连续对话,所以我们去除 speaker 参数。
41
+ if (command === sceneInterface_1.commandType.say && e.key === "speaker") {
42
+ continue;
43
+ }
44
+ args.push(e);
45
+ }
46
+ }
47
+ else {
48
+ commandRaw = newSentenceRaw.substring(0, getCommandResult.index);
49
+ // 划分命令区域和content区域
50
+ newSentenceRaw = newSentenceRaw.substring(getCommandResult.index + 1, newSentenceRaw.length);
51
+ parsedCommand = (0, commandParser_1.commandParser)(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
52
+ command = parsedCommand.type;
53
+ for (var _b = 0, _c = parsedCommand.additionalArgs; _b < _c.length; _b++) {
54
+ var e = _c[_b];
55
+ args.push(e);
56
+ }
57
+ }
58
+ // 截取参数区域
59
+ var getArgsResult = / -/.exec(newSentenceRaw);
60
+ // 获取到参数
61
+ if (getArgsResult) {
62
+ var argsRaw = newSentenceRaw.substring(getArgsResult.index, sentenceRaw.length);
63
+ newSentenceRaw = newSentenceRaw.substring(0, getArgsResult.index);
64
+ for (var _d = 0, _e = (0, argsParser_1.argsParser)(argsRaw, assetSetter); _d < _e.length; _d++) {
65
+ var e = _e[_d];
66
+ args.push(e);
67
+ }
68
+ }
69
+ content = (0, contentParser_1.contentParser)(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
70
+ sentenceAssets = (0, assetsScanner_1.assetsScanner)(command, content, args); // 扫描语句携带资源
71
+ subScene = (0, subSceneScanner_1.subSceneScanner)(command, content); // 扫描语句携带子场景
72
+ return {
73
+ command: command,
74
+ commandRaw: commandRaw,
75
+ content: content,
76
+ args: args,
77
+ sentenceAssets: sentenceAssets,
78
+ subScene: subScene // 语句携带的子场景
79
+ };
80
+ };
81
+ exports.scriptParser = scriptParser;
@@ -0,0 +1,76 @@
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, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG): 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;
28
+ // 截取命令
29
+ const getCommandResult = /:/.exec(newSentenceRaw);
30
+ /**
31
+ * 拆分命令和语句,同时处理连续对话。
32
+ */
33
+ // 没有command,说明这是一条连续对话或单条语句
34
+ if (getCommandResult === null) {
35
+ commandRaw = newSentenceRaw;
36
+ parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
37
+ command = parsedCommand.type;
38
+ for (const e of parsedCommand.additionalArgs) {
39
+ // 由于是连续对话,所以我们去除 speaker 参数。
40
+ if (command === commandType.say && e.key === "speaker") {
41
+ continue;
42
+ }
43
+ args.push(e);
44
+ }
45
+ } else {
46
+ commandRaw = newSentenceRaw.substring(0, getCommandResult.index);
47
+ // 划分命令区域和content区域
48
+ newSentenceRaw = newSentenceRaw.substring(getCommandResult.index + 1, newSentenceRaw.length);
49
+ parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
50
+ command = parsedCommand.type;
51
+ for (const e of parsedCommand.additionalArgs) {
52
+ args.push(e);
53
+ }
54
+ }
55
+ // 截取参数区域
56
+ const getArgsResult = / -/.exec(newSentenceRaw);
57
+ // 获取到参数
58
+ if (getArgsResult) {
59
+ const argsRaw = newSentenceRaw.substring(getArgsResult.index, sentenceRaw.length);
60
+ newSentenceRaw = newSentenceRaw.substring(0, getArgsResult.index);
61
+ for (const e of argsParser(argsRaw, assetSetter)) {
62
+ args.push(e);
63
+ }
64
+ }
65
+ content = contentParser(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
66
+ sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
67
+ subScene = subSceneScanner(command, content); // 扫描语句携带子场景
68
+ return {
69
+ command: command, // 语句类型
70
+ commandRaw: commandRaw, // 命令原始内容,方便调试
71
+ content: content, // 语句内容
72
+ args: args, // 参数列表
73
+ sentenceAssets: sentenceAssets, // 语句携带的资源列表
74
+ subScene: subScene // 语句携带的子场景
75
+ };
76
+ };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.subSceneScanner = void 0;
4
+ /**
5
+ * 扫描子场景
6
+ * @param content 语句内容
7
+ * @return {Array<string>} 子场景列表
8
+ */
9
+ var sceneInterface_1 = require("../interface/sceneInterface");
10
+ var subSceneScanner = function (command, content) {
11
+ var subSceneList = [];
12
+ if (command === sceneInterface_1.commandType.changeScene || command === sceneInterface_1.commandType.callScene) {
13
+ subSceneList.push(content);
14
+ }
15
+ if (command === sceneInterface_1.commandType.choose) {
16
+ var chooseList = content.split('|');
17
+ var chooseValue = chooseList.map(function (e) { return e.split(':')[1]; });
18
+ chooseValue.forEach(function (e) {
19
+ if (e.match(/\./)) {
20
+ subSceneList.push(e);
21
+ }
22
+ });
23
+ }
24
+ return subSceneList;
25
+ };
26
+ exports.subSceneScanner = subSceneScanner;
@@ -0,0 +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
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.ADD_NEXT_ARG_LIST = exports.SCRIPT_CONFIG = void 0;
4
+ var sceneInterface_1 = require("../interface/sceneInterface");
5
+ exports.SCRIPT_CONFIG = [
6
+ { scriptString: 'intro', scriptType: sceneInterface_1.commandType.intro },
7
+ { scriptString: 'changeBg', scriptType: sceneInterface_1.commandType.changeBg },
8
+ { scriptString: 'changeFigure', scriptType: sceneInterface_1.commandType.changeFigure },
9
+ { scriptString: 'miniAvatar', scriptType: sceneInterface_1.commandType.miniAvatar },
10
+ { scriptString: 'changeScene', scriptType: sceneInterface_1.commandType.changeScene },
11
+ { scriptString: 'choose', scriptType: sceneInterface_1.commandType.choose },
12
+ { scriptString: 'end', scriptType: sceneInterface_1.commandType.end },
13
+ { scriptString: 'bgm', scriptType: sceneInterface_1.commandType.bgm },
14
+ { scriptString: 'playVideo', scriptType: sceneInterface_1.commandType.video },
15
+ {
16
+ scriptString: 'setComplexAnimation',
17
+ scriptType: sceneInterface_1.commandType.setComplexAnimation
18
+ },
19
+ { scriptString: 'setFilter', scriptType: sceneInterface_1.commandType.setFilter },
20
+ { scriptString: 'pixiInit', scriptType: sceneInterface_1.commandType.pixiInit },
21
+ { scriptString: 'pixiPerform', scriptType: sceneInterface_1.commandType.pixi },
22
+ { scriptString: 'label', scriptType: sceneInterface_1.commandType.label },
23
+ { scriptString: 'jumpLabel', scriptType: sceneInterface_1.commandType.jumpLabel },
24
+ { scriptString: 'setVar', scriptType: sceneInterface_1.commandType.setVar },
25
+ { scriptString: 'callScene', scriptType: sceneInterface_1.commandType.callScene },
26
+ { scriptString: 'showVars', scriptType: sceneInterface_1.commandType.showVars },
27
+ { scriptString: 'unlockCg', scriptType: sceneInterface_1.commandType.unlockCg },
28
+ { scriptString: 'unlockBgm', scriptType: sceneInterface_1.commandType.unlockBgm },
29
+ { scriptString: 'say', scriptType: sceneInterface_1.commandType.say },
30
+ { scriptString: 'filmMode', scriptType: sceneInterface_1.commandType.filmMode },
31
+ { scriptString: 'callScene', scriptType: sceneInterface_1.commandType.callScene },
32
+ { scriptString: 'setTextbox', scriptType: sceneInterface_1.commandType.setTextbox },
33
+ { scriptString: 'setAnimation', scriptType: sceneInterface_1.commandType.setAnimation },
34
+ ];
35
+ exports.ADD_NEXT_ARG_LIST = [
36
+ sceneInterface_1.commandType.bgm,
37
+ sceneInterface_1.commandType.pixi,
38
+ sceneInterface_1.commandType.pixiInit,
39
+ sceneInterface_1.commandType.label,
40
+ sceneInterface_1.commandType["if"],
41
+ sceneInterface_1.commandType.miniAvatar,
42
+ sceneInterface_1.commandType.setVar,
43
+ sceneInterface_1.commandType.unlockBgm,
44
+ sceneInterface_1.commandType.unlockCg,
45
+ sceneInterface_1.commandType.filmMode,
46
+ ];
@@ -0,0 +1,44 @@
1
+ import { commandType } from '../interface/sceneInterface';
2
+
3
+ export const SCRIPT_CONFIG = [
4
+ { scriptString: 'intro', scriptType: commandType.intro },
5
+ { scriptString: 'changeBg', scriptType: commandType.changeBg },
6
+ { scriptString: 'changeFigure', scriptType: commandType.changeFigure },
7
+ { scriptString: 'miniAvatar', scriptType: commandType.miniAvatar },
8
+ { scriptString: 'changeScene', scriptType: commandType.changeScene },
9
+ { scriptString: 'choose', scriptType: commandType.choose},
10
+ { scriptString: 'end', scriptType: commandType.end },
11
+ { scriptString: 'bgm', scriptType: commandType.bgm },
12
+ { scriptString: 'playVideo', scriptType: commandType.video },
13
+ {
14
+ scriptString: 'setComplexAnimation',
15
+ scriptType: commandType.setComplexAnimation,
16
+ },
17
+ { scriptString: 'setFilter', scriptType: commandType.setFilter },
18
+ { scriptString: 'pixiInit', scriptType: commandType.pixiInit },
19
+ { scriptString: 'pixiPerform', scriptType: commandType.pixi },
20
+ { scriptString: 'label', scriptType: commandType.label},
21
+ { scriptString: 'jumpLabel', scriptType: commandType.jumpLabel},
22
+ { scriptString: 'setVar', scriptType: commandType.setVar },
23
+ { scriptString: 'callScene', scriptType: commandType.callScene },
24
+ { scriptString: 'showVars', scriptType: commandType.showVars },
25
+ { scriptString: 'unlockCg', scriptType: commandType.unlockCg },
26
+ { scriptString: 'unlockBgm', scriptType: commandType.unlockBgm },
27
+ { scriptString: 'say', scriptType: commandType.say },
28
+ { scriptString: 'filmMode', scriptType: commandType.filmMode },
29
+ { scriptString: 'callScene', scriptType: commandType.callScene },
30
+ { scriptString: 'setTextbox', scriptType: commandType.setTextbox},
31
+ { scriptString: 'setAnimation', scriptType: commandType.setAnimation },
32
+ ];
33
+ export const ADD_NEXT_ARG_LIST = [
34
+ commandType.bgm,
35
+ commandType.pixi,
36
+ commandType.pixiInit,
37
+ commandType.label,
38
+ commandType.if,
39
+ commandType.miniAvatar,
40
+ commandType.setVar,
41
+ commandType.unlockBgm,
42
+ commandType.unlockCg,
43
+ commandType.filmMode,
44
+ ];
package/test/test.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var index_1 = require("../index");
4
+ var scriptConfig_1 = require("./scriptConfig");
5
+ var parser = new index_1.SceneParser(function (assetList) {
6
+ }, function (fileName, assetType) {
7
+ return fileName;
8
+ }, scriptConfig_1.ADD_NEXT_ARG_LIST, scriptConfig_1.SCRIPT_CONFIG);
9
+ var result = parser.parse("\n; \u521D\u59CB\u573A\u666F\uFF0C\u4EE5\u53CA\u7279\u6548\u6F14\u793A\nchangeBg:c4.jpg -next;\nunlockCg:c4.jpg -name=\u8857\u524D; \u89E3\u9501\u90E8\u5206CG\nunlockCg:xgmain.jpeg -name=\u661F\u5149\u5496\u5561\u9986\u4E0E\u6B7B\u795E\u4E4B\u8776;\nunlockBgm:s_Title.mp3 -name=Smiling-Swinging!!;\nWebGAL:\u7279\u6548\u7CFB\u7EDF\u662F3.9.2\u7248\u672C\u65B0\u5F15\u5165\u7684\u7CFB\u7EDF\uFF0C\u4F60\u60F3\u8981\u770B\u7279\u6548\u7684\u6F14\u793A\u5417\uFF1F;\nchoose:\u89C2\u770B\u7279\u6548\u6F14\u793A:demo|\u6211\u4E0D\u8981\u770B\u7279\u6548\uFF0C\u76F4\u63A5\u6765\u5427\uFF01:toStart;\nlabel:demo;\npixiInit;\npixiPerform:rain;\nWebGAL:\u73B0\u5728\u5C55\u793A\u7684\u662F\u4E0B\u96E8\u7684\u7279\u6548\u3002;\npixiInit;\npixiPerform:snow;\nWebGAL:\u73B0\u5728\u5C55\u793A\u7684\u662F\u4E0B\u96EA\u7684\u7279\u6548\u3002;\nsetTextbox:hide;\npixiInit;\nsetTextbox:on -next;\nWebGAL:\u7279\u6548\u7684\u6F14\u793A\u5DF2\u7ECF\u7ED3\u675F\uFF0C\u73B0\u5728\u6211\u4EEC\u6B63\u5F0F\u5F00\u59CB\u5427\uFF01;\n\n; \u6B63\u5F0F\u573A\u666F\nlabel:toStart;\nplayVideo:OP.mp4;\nchangeBg:c3.jpg -next;\nunlockCg:c3.jpg -name=cafe;\nchangeFigure:m2.png -left -next;\nbgm:cb1.mp3;\nunlockBgm:cb1.mp3 -name=\u3072\u3068\u3059\u3058\u306E\u5149\u660E;\nsetAnimation:enter-from-left -target=fig-left -next;\n\u7C73\u5496\u591A:\u86CB\u5305\u996D\u662F\u681E\u90A3\u505A\u7684\uFF0C\u4F46\u7EA2\u8336\u662F\u590F\u76EE\u6CE1\u7684\u3002 -v1.ogg;\n\u6602\u6674:......;\n\u987A\u4FBF\u95EE\u4E00\u4E0B\uFF0C\u4F60\u662F\u6253\u7B97\u505A\u4EC0\u4E48\u7684\uFF1F;\nchangeFigure:m1.png -left -next;\n\u7C73\u5496\u591A:\u5C31\u662F\u5012\u996E\u6599\u3002\u7136\u540E\u5496\u5561\u548C\u7EA2\u8336\u7684\u51B2\u6CE1\u65B9\u5F0F\u6211\u8FD8\u662F\u8BB0\u4F4F\u4E86\u7684\u3002 -v2.ogg;\n\u6602\u6674:\u8FD9\u3001\u8FD9\u6837\u4E48......;\n:\u8FD9\u732B\u722A\u5B50\u771F\u7684\u80FD\u6CE1\u8336\u4E48\u3002;\n\u62FF\u5F97\u4E86\u6C34\u58F6\u5417\uFF1F\u5C31\u51ED\u4ED6\u90A3\u4E2A\u8089\u7403\u722A\u5B50......;\n\u96BE\u9053\u8FD9\u4E9B\u4E5F\u662F\u51ED\u501F\u732B\u5996\u7684\u5947\u7279\u529B\u91CF\u505A\u5230\u7684\u5417\uFF1F;\nchangeFigure:none -left -next;\nchangeFigure:k1.png -next;\nsetAnimation:enter-from-bottom -target=fig-center -next;\n\u681E\u90A3:\u90A3\u4E48\uFF0C\u4F60\u60F3\u5148\u5C1D\u54EA\u4E2A\uFF1F -v3.ogg;\nchoose:\u54C1\u5C1D\u86CB\u5305\u996D:dbf|\u54C1\u5C1D\u7EA2\u8336:hc;\n\n; \u681E\u90A3\u9009\u9879\nlabel:dbf;\n\u6602\u6674:\u603B\u4E4B\uFF0C\u5148\u786E\u8BA4\u4E0B\u86CB\u5305\u996D\u7684\u5473\u9053\u5427;\nchangeFigure:k2.png -next;\n\u681E\u90A3:\u660E\u767D\u4E86\uFF0C\u4EA4\u7ED9\u6211\u5427 -v4.ogg;\nchangeFigure:none -next;\nchangeFigure:m2.png -left -next;\nchangeFigure:k3.png -right -next;\nsetAnimation:enter-from-left -target=fig-left -next;\nsetAnimation:enter-from-right -target=fig-right -next;\n\u681E\u90A3:\u90A3\u4E48\u7C73\u5496\u591A\u5148\u751F\uFF0C\u6211\u53BB\u505A\u4E00\u4E0B\u8BD5\u4F5C\u54C1 -v5.ogg;\n\u7C73\u5496\u591A:\u55EF\u3002\u53BB\u5427 -v6.ogg;\nchangeFigure:none -left -next;\nchangeFigure:none -right -next;\nchangeFigure:k4.png -next;\nsetAnimation:enter-from-bottom -target=fig-center -next;\n\u681E\u90A3:\u90A3\u4E48\u9AD8\u5CAD\u540C\u5B66\uFF0C\u6211\u4EEC\u79FB\u52A8\u5230\u53A8\u623F\u5427 -v7.ogg;\nchangeFigure:none -next;\nbgm:cb2.mp3;\nunlockBgm:cb2.mp3 -name=Tea Break;\nchangeBg:c2.jpg;\nunlockCg:c2.jpg -name=\u53A8\u623F;\nchangeFigure:k2.png -next;\n\u681E\u90A3:\u8BDD\u4E0D\u591A\u8BF4\u5F00\u59CB\u505A\u5427 -v8.ogg;\njumpLabel:end;\n\n; \u590F\u76EE\u9009\u9879\nlabel:hc;\nchangeFigure:none -next;\nchangeFigure:m1.png -left -next;\nchangeFigure:k1.png -right -next;\nsetAnimation:enter-from-left -target=fig-left -next;\nsetAnimation:enter-from-right -target=fig-right -next;\n\u7C73\u5496\u591A:\u90A3\u4E48\u5C31\u662F\uFF0C\u590F\u76EE\u4E86\u5427 -v9.ogg;\nchangeFigure:k6.png -right -next;\n\u681E\u90A3:\u5979\u521A\u53BB\u4F11\u606F\uFF0C\u8981\u4E0D\u8981\u6211\u53EB\u56DE\u6765\u5462\uFF1F -v10.ogg;\n\u6602\u6674:\u6CA1\u4E8B\uFF0C\u6211\u81EA\u5DF1\u53BB\u5427;\nchangeFigure:none -left -next;\nchangeFigure:none -right -next;\nbgm:cb2.mp3;\nchangeBg:c1.jpg -next;\nunlockCg:c1.jpg -name=\u4F11\u606F\u5BA4;\n:\u6211\u5148\u6572\u4E86\u6572\u95E8;\nminiAvatar:n1.png;\n\u590F\u76EE:\u54EA\u4F4D\uFF1F -v11.ogg;\n\u6602\u6674:\u6211\u662F\u9AD8\u5CAD\uFF0C\u53EF\u4EE5\u8FDB\u53BB\u5417\uFF1F;\n\u590F\u76EE:\u53EF\u4EE5\uFF0C\u6CA1\u95EE\u9898 -v12.ogg;\n\u6602\u6674:\u6253\u6405\u4E86;\nminiAvatar:none;\nchangeFigure:n4.png -next;\n\u6602\u6674:\u6253\u6405\u4F60\u4F11\u606F\u4E86;\n\u590F\u76EE:\u4E0D\u7528\u5728\u610F\uFF0C\u600E\u4E48\u4E86\uFF1F -v13.ogg;\nchangeFigure:n2.png -next;\n:\u5979\u5E76\u6CA1\u6709\u65E0\u7CBE\u6253\u91C7\uFF0C\u6BD4\u60F3\u8C61\u4E2D\u7CBE\u795E\u591A\u4E86;\n\u6602\u6674:\u95EE\u9053\u62FF\u624B\u83DC\u8C31\uFF0C\u5C31\u542C\u8BF4\u56DB\u5B63\u540C\u5B66\u6CE1\u7684\u7EA2\u8336\u5473\u9053\u4E0D\u9519\uFF0C\u6211\u4E5F\u60F3\u54C1\u5C1D\u4E00\u4E0B;\n\u590F\u76EE:\u660E\u767D\u4E86\uFF0C\u90A3\u6211\u4EEC\u56DE\u53BB\u5427 -v14.ogg;\njumpLabel:end;\n\n; \u7ED3\u675F\u573A\u666F\nlabel:end;\nchangeFigure:none -next;\nWebGAL:\u57FA\u7840\u6F14\u51FA\u7684\u5C55\u793A\u5DF2\u7ECF\u7ED3\u675F\u3002;\n", "test", "/test.txt");
10
+ console.log(result);
package/test/test.ts ADDED
@@ -0,0 +1,117 @@
1
+ import { SceneParser } from "../index";
2
+ import { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG } from "./scriptConfig";
3
+
4
+ const parser = new SceneParser((assetList) => {
5
+ }, (fileName, assetType) => {
6
+ return fileName;
7
+ }, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
8
+
9
+ const result = parser.parse(`
10
+ ; 初始场景,以及特效演示
11
+ changeBg:c4.jpg -next;
12
+ unlockCg:c4.jpg -name=街前; 解锁部分CG
13
+ unlockCg:xgmain.jpeg -name=星光咖啡馆与死神之蝶;
14
+ unlockBgm:s_Title.mp3 -name=Smiling-Swinging!!;
15
+ WebGAL:特效系统是3.9.2版本新引入的系统,你想要看特效的演示吗?;
16
+ choose:观看特效演示:demo|我不要看特效,直接来吧!:toStart;
17
+ label:demo;
18
+ pixiInit;
19
+ pixiPerform:rain;
20
+ WebGAL:现在展示的是下雨的特效。;
21
+ pixiInit;
22
+ pixiPerform:snow;
23
+ WebGAL:现在展示的是下雪的特效。;
24
+ setTextbox:hide;
25
+ pixiInit;
26
+ setTextbox:on -next;
27
+ WebGAL:特效的演示已经结束,现在我们正式开始吧!;
28
+
29
+ ; 正式场景
30
+ label:toStart;
31
+ playVideo:OP.mp4;
32
+ changeBg:c3.jpg -next;
33
+ unlockCg:c3.jpg -name=cafe;
34
+ changeFigure:m2.png -left -next;
35
+ bgm:cb1.mp3;
36
+ unlockBgm:cb1.mp3 -name=ひとすじの光明;
37
+ setAnimation:enter-from-left -target=fig-left -next;
38
+ 米咖多:蛋包饭是栞那做的,但红茶是夏目泡的。 -v1.ogg;
39
+ 昂晴:......;
40
+ 顺便问一下,你是打算做什么的?;
41
+ changeFigure:m1.png -left -next;
42
+ 米咖多:就是倒饮料。然后咖啡和红茶的冲泡方式我还是记住了的。 -v2.ogg;
43
+ 昂晴:这、这样么......;
44
+ :这猫爪子真的能泡茶么。;
45
+ 拿得了水壶吗?就凭他那个肉球爪子......;
46
+ 难道这些也是凭借猫妖的奇特力量做到的吗?;
47
+ changeFigure:none -left -next;
48
+ changeFigure:k1.png -next;
49
+ setAnimation:enter-from-bottom -target=fig-center -next;
50
+ 栞那:那么,你想先尝哪个? -v3.ogg;
51
+ choose:品尝蛋包饭:dbf|品尝红茶:hc;
52
+
53
+ ; 栞那选项
54
+ label:dbf;
55
+ 昂晴:总之,先确认下蛋包饭的味道吧;
56
+ changeFigure:k2.png -next;
57
+ 栞那:明白了,交给我吧 -v4.ogg;
58
+ changeFigure:none -next;
59
+ changeFigure:m2.png -left -next;
60
+ changeFigure:k3.png -right -next;
61
+ setAnimation:enter-from-left -target=fig-left -next;
62
+ setAnimation:enter-from-right -target=fig-right -next;
63
+ 栞那:那么米咖多先生,我去做一下试作品 -v5.ogg;
64
+ 米咖多:嗯。去吧 -v6.ogg;
65
+ changeFigure:none -left -next;
66
+ changeFigure:none -right -next;
67
+ changeFigure:k4.png -next;
68
+ setAnimation:enter-from-bottom -target=fig-center -next;
69
+ 栞那:那么高岭同学,我们移动到厨房吧 -v7.ogg;
70
+ changeFigure:none -next;
71
+ bgm:cb2.mp3;
72
+ unlockBgm:cb2.mp3 -name=Tea Break;
73
+ changeBg:c2.jpg;
74
+ unlockCg:c2.jpg -name=厨房;
75
+ changeFigure:k2.png -next;
76
+ 栞那:话不多说开始做吧 -v8.ogg;
77
+ jumpLabel:end;
78
+
79
+ ; 夏目选项
80
+ label:hc;
81
+ changeFigure:none -next;
82
+ changeFigure:m1.png -left -next;
83
+ changeFigure:k1.png -right -next;
84
+ setAnimation:enter-from-left -target=fig-left -next;
85
+ setAnimation:enter-from-right -target=fig-right -next;
86
+ 米咖多:那么就是,夏目了吧 -v9.ogg;
87
+ changeFigure:k6.png -right -next;
88
+ 栞那:她刚去休息,要不要我叫回来呢? -v10.ogg;
89
+ 昂晴:没事,我自己去吧;
90
+ changeFigure:none -left -next;
91
+ changeFigure:none -right -next;
92
+ bgm:cb2.mp3;
93
+ changeBg:c1.jpg -next;
94
+ unlockCg:c1.jpg -name=休息室;
95
+ :我先敲了敲门;
96
+ miniAvatar:n1.png;
97
+ 夏目:哪位? -v11.ogg;
98
+ 昂晴:我是高岭,可以进去吗?;
99
+ 夏目:可以,没问题 -v12.ogg;
100
+ 昂晴:打搅了;
101
+ miniAvatar:none;
102
+ changeFigure:n4.png -next;
103
+ 昂晴:打搅你休息了;
104
+ 夏目:不用在意,怎么了? -v13.ogg;
105
+ changeFigure:n2.png -next;
106
+ :她并没有无精打采,比想象中精神多了;
107
+ 昂晴:问道拿手菜谱,就听说四季同学泡的红茶味道不错,我也想品尝一下;
108
+ 夏目:明白了,那我们回去吧 -v14.ogg;
109
+ jumpLabel:end;
110
+
111
+ ; 结束场景
112
+ label:end;
113
+ changeFigure:none -next;
114
+ WebGAL:基础演出的展示已经结束。;
115
+ `, "test", "/test.txt");
116
+
117
+ console.log(result);
package/tsconfig.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
6
+ "allowJs": false,
7
+ "skipLibCheck": false,
8
+ "esModuleInterop": false,
9
+ "allowSyntheticDefaultImports": true,
10
+ "strict": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "module": "ESNext",
13
+ "moduleResolution": "Node",
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "noEmit": true,
17
+ "jsx": "react-jsx",
18
+ "paths": {
19
+ "@/*": ["./src/*"]
20
+ }
21
+ },
22
+ "include": [
23
+ "src"
24
+ ],
25
+ "references": [{ "path": "./tsconfig.node.json"}]
26
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "esnext",
5
+ "moduleResolution": "node"
6
+ },
7
+ "include": [
8
+ "vite.config.ts"
9
+ ]
10
+ }