webgal-parser 4.3.5 → 4.3.6
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/build/index.global.js +421 -421
- package/build/index.js +421 -421
- package/build/types/index.d.ts +10 -10
- package/build/types/interface/assets.d.ts +12 -12
- package/build/types/interface/runtimeInterface.d.ts +9 -9
- package/build/types/interface/sceneInterface.d.ts +91 -91
- package/build/types/sceneParser.d.ts +14 -14
- package/build/types/scriptParser/argsParser.d.ts +9 -9
- package/build/types/scriptParser/assetsScanner.d.ts +9 -9
- package/build/types/scriptParser/commandParser.d.ts +9 -9
- package/build/types/scriptParser/contentParser.d.ts +9 -9
- package/build/types/scriptParser/scriptParser.d.ts +9 -9
- package/build/types/scriptParser/subSceneScanner.d.ts +7 -7
- package/index.d.ts +10 -10
- package/index.js +421 -421
- package/interface/assets.d.ts +12 -12
- package/interface/assets.js +16 -16
- package/interface/runtimeInterface.d.ts +9 -9
- package/interface/runtimeInterface.js +2 -2
- package/interface/sceneInterface.d.ts +91 -91
- package/interface/sceneInterface.js +32 -32
- package/interface/sceneInterface.ts +1 -0
- package/package.json +1 -1
- package/sceneParser.d.ts +14 -14
- package/sceneParser.js +53 -53
- package/scriptParser/argsParser.d.ts +9 -9
- package/scriptParser/argsParser.js +70 -70
- package/scriptParser/assetsScanner.d.ts +9 -9
- package/scriptParser/assetsScanner.js +75 -75
- package/scriptParser/assetsScanner.ts +10 -2
- package/scriptParser/commandParser.d.ts +9 -9
- package/scriptParser/commandParser.js +60 -60
- package/scriptParser/contentParser.d.ts +9 -9
- package/scriptParser/contentParser.js +68 -68
- package/scriptParser/contentParser.ts +2 -0
- package/scriptParser/scriptParser.d.ts +9 -9
- package/scriptParser/scriptParser.js +81 -81
- package/scriptParser/subSceneScanner.d.ts +7 -7
- package/scriptParser/subSceneScanner.js +26 -26
- package/test/test.ts +1 -1
package/interface/assets.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 内置资源类型的枚举
|
|
3
|
-
*/
|
|
4
|
-
export declare enum fileType {
|
|
5
|
-
background = 0,
|
|
6
|
-
bgm = 1,
|
|
7
|
-
figure = 2,
|
|
8
|
-
scene = 3,
|
|
9
|
-
tex = 4,
|
|
10
|
-
vocal = 5,
|
|
11
|
-
video = 6
|
|
12
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 内置资源类型的枚举
|
|
3
|
+
*/
|
|
4
|
+
export declare enum fileType {
|
|
5
|
+
background = 0,
|
|
6
|
+
bgm = 1,
|
|
7
|
+
figure = 2,
|
|
8
|
+
scene = 3,
|
|
9
|
+
tex = 4,
|
|
10
|
+
vocal = 5,
|
|
11
|
+
video = 6
|
|
12
|
+
}
|
package/interface/assets.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.fileType = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 内置资源类型的枚举
|
|
6
|
-
*/
|
|
7
|
-
var fileType;
|
|
8
|
-
(function (fileType) {
|
|
9
|
-
fileType[fileType["background"] = 0] = "background";
|
|
10
|
-
fileType[fileType["bgm"] = 1] = "bgm";
|
|
11
|
-
fileType[fileType["figure"] = 2] = "figure";
|
|
12
|
-
fileType[fileType["scene"] = 3] = "scene";
|
|
13
|
-
fileType[fileType["tex"] = 4] = "tex";
|
|
14
|
-
fileType[fileType["vocal"] = 5] = "vocal";
|
|
15
|
-
fileType[fileType["video"] = 6] = "video";
|
|
16
|
-
})(fileType = exports.fileType || (exports.fileType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.fileType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 内置资源类型的枚举
|
|
6
|
+
*/
|
|
7
|
+
var fileType;
|
|
8
|
+
(function (fileType) {
|
|
9
|
+
fileType[fileType["background"] = 0] = "background";
|
|
10
|
+
fileType[fileType["bgm"] = 1] = "bgm";
|
|
11
|
+
fileType[fileType["figure"] = 2] = "figure";
|
|
12
|
+
fileType[fileType["scene"] = 3] = "scene";
|
|
13
|
+
fileType[fileType["tex"] = 4] = "tex";
|
|
14
|
+
fileType[fileType["vocal"] = 5] = "vocal";
|
|
15
|
+
fileType[fileType["video"] = 6] = "video";
|
|
16
|
+
})(fileType = exports.fileType || (exports.fileType = {}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 子场景结束后回到父场景的入口
|
|
3
|
-
* @interface sceneEntry
|
|
4
|
-
*/
|
|
5
|
-
export interface sceneEntry {
|
|
6
|
-
sceneName: string;
|
|
7
|
-
sceneUrl: string;
|
|
8
|
-
continueLine: number;
|
|
9
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 子场景结束后回到父场景的入口
|
|
3
|
+
* @interface sceneEntry
|
|
4
|
+
*/
|
|
5
|
+
export interface sceneEntry {
|
|
6
|
+
sceneName: string;
|
|
7
|
+
sceneUrl: string;
|
|
8
|
+
continueLine: number;
|
|
9
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 语句类型
|
|
3
|
-
*/
|
|
4
|
-
import { sceneEntry } from "./runtimeInterface";
|
|
5
|
-
import { fileType } from "./assets";
|
|
6
|
-
export declare enum commandType {
|
|
7
|
-
say = 0,
|
|
8
|
-
changeBg = 1,
|
|
9
|
-
changeFigure = 2,
|
|
10
|
-
bgm = 3,
|
|
11
|
-
video = 4,
|
|
12
|
-
pixi = 5,
|
|
13
|
-
pixiInit = 6,
|
|
14
|
-
intro = 7,
|
|
15
|
-
miniAvatar = 8,
|
|
16
|
-
changeScene = 9,
|
|
17
|
-
choose = 10,
|
|
18
|
-
end = 11,
|
|
19
|
-
setComplexAnimation = 12,
|
|
20
|
-
setFilter = 13,
|
|
21
|
-
label = 14,
|
|
22
|
-
jumpLabel = 15,
|
|
23
|
-
chooseLabel = 16,
|
|
24
|
-
setVar = 17,
|
|
25
|
-
if = 18,
|
|
26
|
-
callScene = 19,
|
|
27
|
-
showVars = 20,
|
|
28
|
-
unlockCg = 21,
|
|
29
|
-
unlockBgm = 22,
|
|
30
|
-
filmMode = 23,
|
|
31
|
-
setTextbox = 24,
|
|
32
|
-
setAnimation = 25
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 单个参数接口
|
|
36
|
-
* @interface arg
|
|
37
|
-
*/
|
|
38
|
-
export interface arg {
|
|
39
|
-
key: string;
|
|
40
|
-
value: string | boolean | number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 资源接口
|
|
44
|
-
* @interface IAsset
|
|
45
|
-
*/
|
|
46
|
-
export interface IAsset {
|
|
47
|
-
name: string;
|
|
48
|
-
type: fileType;
|
|
49
|
-
url: string;
|
|
50
|
-
lineNumber: number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* 单条语句接口
|
|
54
|
-
* @interface ISentence
|
|
55
|
-
*/
|
|
56
|
-
export interface ISentence {
|
|
57
|
-
command: commandType;
|
|
58
|
-
commandRaw: string;
|
|
59
|
-
content: string;
|
|
60
|
-
args: Array<arg>;
|
|
61
|
-
sentenceAssets: Array<IAsset>;
|
|
62
|
-
subScene: Array<string>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* 场景接口
|
|
66
|
-
* @interface IScene
|
|
67
|
-
*/
|
|
68
|
-
export interface IScene {
|
|
69
|
-
sceneName: string;
|
|
70
|
-
sceneUrl: string;
|
|
71
|
-
sentenceList: Array<ISentence>;
|
|
72
|
-
assetsList: Array<IAsset>;
|
|
73
|
-
subSceneList: Array<string>;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* 当前的场景数据
|
|
77
|
-
* @interface ISceneData
|
|
78
|
-
*/
|
|
79
|
-
export interface ISceneData {
|
|
80
|
-
currentSentenceId: number;
|
|
81
|
-
sceneStack: Array<sceneEntry>;
|
|
82
|
-
currentScene: IScene;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* 处理后的命令接口
|
|
86
|
-
* @interface parsedCommand
|
|
87
|
-
*/
|
|
88
|
-
export interface parsedCommand {
|
|
89
|
-
type: commandType;
|
|
90
|
-
additionalArgs: Array<arg>;
|
|
91
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 语句类型
|
|
3
|
+
*/
|
|
4
|
+
import { sceneEntry } from "./runtimeInterface";
|
|
5
|
+
import { fileType } from "./assets";
|
|
6
|
+
export declare enum commandType {
|
|
7
|
+
say = 0,
|
|
8
|
+
changeBg = 1,
|
|
9
|
+
changeFigure = 2,
|
|
10
|
+
bgm = 3,
|
|
11
|
+
video = 4,
|
|
12
|
+
pixi = 5,
|
|
13
|
+
pixiInit = 6,
|
|
14
|
+
intro = 7,
|
|
15
|
+
miniAvatar = 8,
|
|
16
|
+
changeScene = 9,
|
|
17
|
+
choose = 10,
|
|
18
|
+
end = 11,
|
|
19
|
+
setComplexAnimation = 12,
|
|
20
|
+
setFilter = 13,
|
|
21
|
+
label = 14,
|
|
22
|
+
jumpLabel = 15,
|
|
23
|
+
chooseLabel = 16,
|
|
24
|
+
setVar = 17,
|
|
25
|
+
if = 18,
|
|
26
|
+
callScene = 19,
|
|
27
|
+
showVars = 20,
|
|
28
|
+
unlockCg = 21,
|
|
29
|
+
unlockBgm = 22,
|
|
30
|
+
filmMode = 23,
|
|
31
|
+
setTextbox = 24,
|
|
32
|
+
setAnimation = 25
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 单个参数接口
|
|
36
|
+
* @interface arg
|
|
37
|
+
*/
|
|
38
|
+
export interface arg {
|
|
39
|
+
key: string;
|
|
40
|
+
value: string | boolean | number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 资源接口
|
|
44
|
+
* @interface IAsset
|
|
45
|
+
*/
|
|
46
|
+
export interface IAsset {
|
|
47
|
+
name: string;
|
|
48
|
+
type: fileType;
|
|
49
|
+
url: string;
|
|
50
|
+
lineNumber: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 单条语句接口
|
|
54
|
+
* @interface ISentence
|
|
55
|
+
*/
|
|
56
|
+
export interface ISentence {
|
|
57
|
+
command: commandType;
|
|
58
|
+
commandRaw: string;
|
|
59
|
+
content: string;
|
|
60
|
+
args: Array<arg>;
|
|
61
|
+
sentenceAssets: Array<IAsset>;
|
|
62
|
+
subScene: Array<string>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 场景接口
|
|
66
|
+
* @interface IScene
|
|
67
|
+
*/
|
|
68
|
+
export interface IScene {
|
|
69
|
+
sceneName: string;
|
|
70
|
+
sceneUrl: string;
|
|
71
|
+
sentenceList: Array<ISentence>;
|
|
72
|
+
assetsList: Array<IAsset>;
|
|
73
|
+
subSceneList: Array<string>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 当前的场景数据
|
|
77
|
+
* @interface ISceneData
|
|
78
|
+
*/
|
|
79
|
+
export interface ISceneData {
|
|
80
|
+
currentSentenceId: number;
|
|
81
|
+
sceneStack: Array<sceneEntry>;
|
|
82
|
+
currentScene: IScene;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 处理后的命令接口
|
|
86
|
+
* @interface parsedCommand
|
|
87
|
+
*/
|
|
88
|
+
export interface parsedCommand {
|
|
89
|
+
type: commandType;
|
|
90
|
+
additionalArgs: Array<arg>;
|
|
91
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.commandType = void 0;
|
|
4
|
-
var commandType;
|
|
5
|
-
(function (commandType) {
|
|
6
|
-
commandType[commandType["say"] = 0] = "say";
|
|
7
|
-
commandType[commandType["changeBg"] = 1] = "changeBg";
|
|
8
|
-
commandType[commandType["changeFigure"] = 2] = "changeFigure";
|
|
9
|
-
commandType[commandType["bgm"] = 3] = "bgm";
|
|
10
|
-
commandType[commandType["video"] = 4] = "video";
|
|
11
|
-
commandType[commandType["pixi"] = 5] = "pixi";
|
|
12
|
-
commandType[commandType["pixiInit"] = 6] = "pixiInit";
|
|
13
|
-
commandType[commandType["intro"] = 7] = "intro";
|
|
14
|
-
commandType[commandType["miniAvatar"] = 8] = "miniAvatar";
|
|
15
|
-
commandType[commandType["changeScene"] = 9] = "changeScene";
|
|
16
|
-
commandType[commandType["choose"] = 10] = "choose";
|
|
17
|
-
commandType[commandType["end"] = 11] = "end";
|
|
18
|
-
commandType[commandType["setComplexAnimation"] = 12] = "setComplexAnimation";
|
|
19
|
-
commandType[commandType["setFilter"] = 13] = "setFilter";
|
|
20
|
-
commandType[commandType["label"] = 14] = "label";
|
|
21
|
-
commandType[commandType["jumpLabel"] = 15] = "jumpLabel";
|
|
22
|
-
commandType[commandType["chooseLabel"] = 16] = "chooseLabel";
|
|
23
|
-
commandType[commandType["setVar"] = 17] = "setVar";
|
|
24
|
-
commandType[commandType["if"] = 18] = "if";
|
|
25
|
-
commandType[commandType["callScene"] = 19] = "callScene";
|
|
26
|
-
commandType[commandType["showVars"] = 20] = "showVars";
|
|
27
|
-
commandType[commandType["unlockCg"] = 21] = "unlockCg";
|
|
28
|
-
commandType[commandType["unlockBgm"] = 22] = "unlockBgm";
|
|
29
|
-
commandType[commandType["filmMode"] = 23] = "filmMode";
|
|
30
|
-
commandType[commandType["setTextbox"] = 24] = "setTextbox";
|
|
31
|
-
commandType[commandType["setAnimation"] = 25] = "setAnimation";
|
|
32
|
-
})(commandType = exports.commandType || (exports.commandType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.commandType = void 0;
|
|
4
|
+
var commandType;
|
|
5
|
+
(function (commandType) {
|
|
6
|
+
commandType[commandType["say"] = 0] = "say";
|
|
7
|
+
commandType[commandType["changeBg"] = 1] = "changeBg";
|
|
8
|
+
commandType[commandType["changeFigure"] = 2] = "changeFigure";
|
|
9
|
+
commandType[commandType["bgm"] = 3] = "bgm";
|
|
10
|
+
commandType[commandType["video"] = 4] = "video";
|
|
11
|
+
commandType[commandType["pixi"] = 5] = "pixi";
|
|
12
|
+
commandType[commandType["pixiInit"] = 6] = "pixiInit";
|
|
13
|
+
commandType[commandType["intro"] = 7] = "intro";
|
|
14
|
+
commandType[commandType["miniAvatar"] = 8] = "miniAvatar";
|
|
15
|
+
commandType[commandType["changeScene"] = 9] = "changeScene";
|
|
16
|
+
commandType[commandType["choose"] = 10] = "choose";
|
|
17
|
+
commandType[commandType["end"] = 11] = "end";
|
|
18
|
+
commandType[commandType["setComplexAnimation"] = 12] = "setComplexAnimation";
|
|
19
|
+
commandType[commandType["setFilter"] = 13] = "setFilter";
|
|
20
|
+
commandType[commandType["label"] = 14] = "label";
|
|
21
|
+
commandType[commandType["jumpLabel"] = 15] = "jumpLabel";
|
|
22
|
+
commandType[commandType["chooseLabel"] = 16] = "chooseLabel";
|
|
23
|
+
commandType[commandType["setVar"] = 17] = "setVar";
|
|
24
|
+
commandType[commandType["if"] = 18] = "if";
|
|
25
|
+
commandType[commandType["callScene"] = 19] = "callScene";
|
|
26
|
+
commandType[commandType["showVars"] = 20] = "showVars";
|
|
27
|
+
commandType[commandType["unlockCg"] = 21] = "unlockCg";
|
|
28
|
+
commandType[commandType["unlockBgm"] = 22] = "unlockBgm";
|
|
29
|
+
commandType[commandType["filmMode"] = 23] = "filmMode";
|
|
30
|
+
commandType[commandType["setTextbox"] = 24] = "setTextbox";
|
|
31
|
+
commandType[commandType["setAnimation"] = 25] = "setAnimation";
|
|
32
|
+
})(commandType = exports.commandType || (exports.commandType = {}));
|
package/package.json
CHANGED
package/sceneParser.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IAsset, IScene } from "./interface/sceneInterface";
|
|
2
|
-
import { fileType } from "./interface/assets";
|
|
3
|
-
/**
|
|
4
|
-
* 场景解析器
|
|
5
|
-
* @param rawScene 原始场景
|
|
6
|
-
* @param sceneName 场景名称
|
|
7
|
-
* @param sceneUrl 场景url
|
|
8
|
-
* @param assetsPrefetcher
|
|
9
|
-
* @param assetSetter
|
|
10
|
-
* @param ADD_NEXT_ARG_LIST
|
|
11
|
-
* @param SCRIPT_CONFIG
|
|
12
|
-
* @return {IScene} 解析后的场景
|
|
13
|
-
*/
|
|
14
|
-
export declare const sceneParser: (rawScene: string, sceneName: string, sceneUrl: string, assetsPrefetcher: (assetList: Array<IAsset>) => void, assetSetter: (fileName: string, assetType: fileType) => string, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any) => IScene;
|
|
1
|
+
import { IAsset, IScene } from "./interface/sceneInterface";
|
|
2
|
+
import { fileType } from "./interface/assets";
|
|
3
|
+
/**
|
|
4
|
+
* 场景解析器
|
|
5
|
+
* @param rawScene 原始场景
|
|
6
|
+
* @param sceneName 场景名称
|
|
7
|
+
* @param sceneUrl 场景url
|
|
8
|
+
* @param assetsPrefetcher
|
|
9
|
+
* @param assetSetter
|
|
10
|
+
* @param ADD_NEXT_ARG_LIST
|
|
11
|
+
* @param SCRIPT_CONFIG
|
|
12
|
+
* @return {IScene} 解析后的场景
|
|
13
|
+
*/
|
|
14
|
+
export declare const sceneParser: (rawScene: string, sceneName: string, sceneUrl: string, assetsPrefetcher: (assetList: Array<IAsset>) => void, assetSetter: (fileName: string, assetType: fileType) => string, ADD_NEXT_ARG_LIST: any, SCRIPT_CONFIG: any) => IScene;
|
package/sceneParser.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
exports.__esModule = true;
|
|
12
|
-
exports.sceneParser = void 0;
|
|
13
|
-
var scriptParser_1 = require("./scriptParser/scriptParser");
|
|
14
|
-
var __ = require("lodash");
|
|
15
|
-
/**
|
|
16
|
-
* 场景解析器
|
|
17
|
-
* @param rawScene 原始场景
|
|
18
|
-
* @param sceneName 场景名称
|
|
19
|
-
* @param sceneUrl 场景url
|
|
20
|
-
* @param assetsPrefetcher
|
|
21
|
-
* @param assetSetter
|
|
22
|
-
* @param ADD_NEXT_ARG_LIST
|
|
23
|
-
* @param SCRIPT_CONFIG
|
|
24
|
-
* @return {IScene} 解析后的场景
|
|
25
|
-
*/
|
|
26
|
-
var sceneParser = function (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
|
|
27
|
-
var rawSentenceList = rawScene.split("\n"); // 原始句子列表
|
|
28
|
-
// 去除冒号后的内容
|
|
29
|
-
// 去除分号后的内容
|
|
30
|
-
var rawSentenceListWithoutEmpty = rawSentenceList
|
|
31
|
-
.map(function (sentence) { return sentence.split(";")[0]; })
|
|
32
|
-
.filter(function (sentence) { return sentence.trim() !== ""; });
|
|
33
|
-
var assetsList = []; // 场景资源列表
|
|
34
|
-
var subSceneList = []; // 子场景列表
|
|
35
|
-
var sentenceList = rawSentenceListWithoutEmpty.map(function (sentence) {
|
|
36
|
-
var returnSentence = (0, scriptParser_1.scriptParser)(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
|
|
37
|
-
// 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
|
|
38
|
-
assetsList = __spreadArray(__spreadArray([], assetsList, true), returnSentence.sentenceAssets, true);
|
|
39
|
-
subSceneList = __spreadArray(__spreadArray([], subSceneList, true), returnSentence.subScene, true);
|
|
40
|
-
return returnSentence;
|
|
41
|
-
});
|
|
42
|
-
// 开始资源的预加载
|
|
43
|
-
assetsList = __.uniqWith(assetsList); // 去重
|
|
44
|
-
assetsPrefetcher(assetsList);
|
|
45
|
-
return {
|
|
46
|
-
sceneName: sceneName,
|
|
47
|
-
sceneUrl: sceneUrl,
|
|
48
|
-
sentenceList: sentenceList,
|
|
49
|
-
assetsList: assetsList,
|
|
50
|
-
subSceneList: subSceneList // 子场景列表
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
exports.sceneParser = sceneParser;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
exports.__esModule = true;
|
|
12
|
+
exports.sceneParser = void 0;
|
|
13
|
+
var scriptParser_1 = require("./scriptParser/scriptParser");
|
|
14
|
+
var __ = require("lodash");
|
|
15
|
+
/**
|
|
16
|
+
* 场景解析器
|
|
17
|
+
* @param rawScene 原始场景
|
|
18
|
+
* @param sceneName 场景名称
|
|
19
|
+
* @param sceneUrl 场景url
|
|
20
|
+
* @param assetsPrefetcher
|
|
21
|
+
* @param assetSetter
|
|
22
|
+
* @param ADD_NEXT_ARG_LIST
|
|
23
|
+
* @param SCRIPT_CONFIG
|
|
24
|
+
* @return {IScene} 解析后的场景
|
|
25
|
+
*/
|
|
26
|
+
var sceneParser = function (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
|
|
27
|
+
var rawSentenceList = rawScene.split("\n"); // 原始句子列表
|
|
28
|
+
// 去除冒号后的内容
|
|
29
|
+
// 去除分号后的内容
|
|
30
|
+
var rawSentenceListWithoutEmpty = rawSentenceList
|
|
31
|
+
.map(function (sentence) { return sentence.split(";")[0]; })
|
|
32
|
+
.filter(function (sentence) { return sentence.trim() !== ""; });
|
|
33
|
+
var assetsList = []; // 场景资源列表
|
|
34
|
+
var subSceneList = []; // 子场景列表
|
|
35
|
+
var sentenceList = rawSentenceListWithoutEmpty.map(function (sentence) {
|
|
36
|
+
var returnSentence = (0, scriptParser_1.scriptParser)(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
|
|
37
|
+
// 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
|
|
38
|
+
assetsList = __spreadArray(__spreadArray([], assetsList, true), returnSentence.sentenceAssets, true);
|
|
39
|
+
subSceneList = __spreadArray(__spreadArray([], subSceneList, true), returnSentence.subScene, true);
|
|
40
|
+
return returnSentence;
|
|
41
|
+
});
|
|
42
|
+
// 开始资源的预加载
|
|
43
|
+
assetsList = __.uniqWith(assetsList); // 去重
|
|
44
|
+
assetsPrefetcher(assetsList);
|
|
45
|
+
return {
|
|
46
|
+
sceneName: sceneName,
|
|
47
|
+
sceneUrl: sceneUrl,
|
|
48
|
+
sentenceList: sentenceList,
|
|
49
|
+
assetsList: assetsList,
|
|
50
|
+
subSceneList: subSceneList // 子场景列表
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.sceneParser = sceneParser;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { arg } from "../interface/sceneInterface";
|
|
2
|
-
import { fileType } from "../interface/assets";
|
|
3
|
-
/**
|
|
4
|
-
* 参数解析器
|
|
5
|
-
* @param argsRaw 原始参数字符串
|
|
6
|
-
* @param assetSetter
|
|
7
|
-
* @return {Array<arg>} 解析后的参数列表
|
|
8
|
-
*/
|
|
9
|
-
export declare function argsParser(argsRaw: string, assetSetter: (fileName: string, assetType: fileType) => string): Array<arg>;
|
|
1
|
+
import { arg } from "../interface/sceneInterface";
|
|
2
|
+
import { fileType } from "../interface/assets";
|
|
3
|
+
/**
|
|
4
|
+
* 参数解析器
|
|
5
|
+
* @param argsRaw 原始参数字符串
|
|
6
|
+
* @param assetSetter
|
|
7
|
+
* @return {Array<arg>} 解析后的参数列表
|
|
8
|
+
*/
|
|
9
|
+
export declare function argsParser(argsRaw: string, assetSetter: (fileName: string, assetType: fileType) => string): Array<arg>;
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.argsParser = void 0;
|
|
4
|
-
var assets_1 = require("../interface/assets");
|
|
5
|
-
/**
|
|
6
|
-
* 参数解析器
|
|
7
|
-
* @param argsRaw 原始参数字符串
|
|
8
|
-
* @param assetSetter
|
|
9
|
-
* @return {Array<arg>} 解析后的参数列表
|
|
10
|
-
*/
|
|
11
|
-
function argsParser(argsRaw, assetSetter) {
|
|
12
|
-
var returnArrayList = [];
|
|
13
|
-
// 处理参数
|
|
14
|
-
// 不要去空格
|
|
15
|
-
var newArgsRaw = argsRaw.replace(/ /g, " ");
|
|
16
|
-
// 分割参数列表
|
|
17
|
-
var rawArgsList = newArgsRaw.split(" -");
|
|
18
|
-
// 去除空字符串
|
|
19
|
-
rawArgsList = rawArgsList.filter(function (e) {
|
|
20
|
-
return e !== "";
|
|
21
|
-
});
|
|
22
|
-
rawArgsList.forEach(function (e) {
|
|
23
|
-
var argName = e.split("=")[0];
|
|
24
|
-
var argValue = e.split("=")[1];
|
|
25
|
-
// 判断是不是语音参数
|
|
26
|
-
if (e.match(/.ogg|.mp3|.wav/)) {
|
|
27
|
-
returnArrayList.push({
|
|
28
|
-
key: "vocal",
|
|
29
|
-
value: assetSetter(e, assets_1.fileType.vocal)
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// 判断是不是省略参数
|
|
34
|
-
if (argValue === undefined) {
|
|
35
|
-
returnArrayList.push({
|
|
36
|
-
key: argName,
|
|
37
|
-
value: true
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// 是字符串描述的布尔值
|
|
42
|
-
if (argValue === "true" || argValue === "false") {
|
|
43
|
-
returnArrayList.push({
|
|
44
|
-
key: argName,
|
|
45
|
-
value: argValue === "true"
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
// 是数字
|
|
50
|
-
if (!isNaN(Number(argValue))) {
|
|
51
|
-
returnArrayList.push({
|
|
52
|
-
key: argName,
|
|
53
|
-
value: Number(argValue)
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// 是普通参数
|
|
58
|
-
returnArrayList.push({
|
|
59
|
-
key: argName,
|
|
60
|
-
value: argValue
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return returnArrayList;
|
|
68
|
-
}
|
|
69
|
-
exports.argsParser = argsParser;
|
|
70
|
-
;
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.argsParser = void 0;
|
|
4
|
+
var assets_1 = require("../interface/assets");
|
|
5
|
+
/**
|
|
6
|
+
* 参数解析器
|
|
7
|
+
* @param argsRaw 原始参数字符串
|
|
8
|
+
* @param assetSetter
|
|
9
|
+
* @return {Array<arg>} 解析后的参数列表
|
|
10
|
+
*/
|
|
11
|
+
function argsParser(argsRaw, assetSetter) {
|
|
12
|
+
var returnArrayList = [];
|
|
13
|
+
// 处理参数
|
|
14
|
+
// 不要去空格
|
|
15
|
+
var newArgsRaw = argsRaw.replace(/ /g, " ");
|
|
16
|
+
// 分割参数列表
|
|
17
|
+
var rawArgsList = newArgsRaw.split(" -");
|
|
18
|
+
// 去除空字符串
|
|
19
|
+
rawArgsList = rawArgsList.filter(function (e) {
|
|
20
|
+
return e !== "";
|
|
21
|
+
});
|
|
22
|
+
rawArgsList.forEach(function (e) {
|
|
23
|
+
var argName = e.split("=")[0];
|
|
24
|
+
var argValue = e.split("=")[1];
|
|
25
|
+
// 判断是不是语音参数
|
|
26
|
+
if (e.match(/.ogg|.mp3|.wav/)) {
|
|
27
|
+
returnArrayList.push({
|
|
28
|
+
key: "vocal",
|
|
29
|
+
value: assetSetter(e, assets_1.fileType.vocal)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// 判断是不是省略参数
|
|
34
|
+
if (argValue === undefined) {
|
|
35
|
+
returnArrayList.push({
|
|
36
|
+
key: argName,
|
|
37
|
+
value: true
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// 是字符串描述的布尔值
|
|
42
|
+
if (argValue === "true" || argValue === "false") {
|
|
43
|
+
returnArrayList.push({
|
|
44
|
+
key: argName,
|
|
45
|
+
value: argValue === "true"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// 是数字
|
|
50
|
+
if (!isNaN(Number(argValue))) {
|
|
51
|
+
returnArrayList.push({
|
|
52
|
+
key: argName,
|
|
53
|
+
value: Number(argValue)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// 是普通参数
|
|
58
|
+
returnArrayList.push({
|
|
59
|
+
key: argName,
|
|
60
|
+
value: argValue
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return returnArrayList;
|
|
68
|
+
}
|
|
69
|
+
exports.argsParser = argsParser;
|
|
70
|
+
;
|