Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/parser/src/scriptParser/argsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export function argsParser(
argValue = undefined;
}
// 判断是不是语音参数
if (argName.toLowerCase().match(/.ogg|.mp3|.wav|.opus/)) {
const isVocalShorthand =
argValue === undefined &&
(/\.(?:ogg|mp3|wav|opus)$/i.test(argName) || /(?<!\\)\{.+?\}/.test(argName));
if (isVocalShorthand) {
returnArrayList.push({
key: 'vocal',
value: assetSetter(e, fileType.vocal),
Expand Down
13 changes: 13 additions & 0 deletions packages/parser/test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ test("args", async () => {
expectSentenceIn(result.sentenceList, expectSentenceItem);
});

test("interpolated vocal shorthand", () => {
const parser = new SceneParser(() => {}, (fileName, assetType) => {
return assetType === fileType.vocal ? `./game/vocal/${fileName}` : fileName;
}, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);

const result = parser.parse('Narrator:Line -{voiceFile};', "vocal", "/vocal.txt");

expect(result.sentenceList[0].args).toContainEqual({
key: 'vocal',
value: './game/vocal/{voiceFile}',
});
});

test("choose", async () => {

const sceneRaw = await fsp.readFile('test/test-resources/choose.txt');
Expand Down