From 25f44424508ccee384a1c7d2dc5cd73f95eb8bdd Mon Sep 17 00:00:00 2001 From: kwaroran Date: Mon, 19 Feb 2024 19:09:39 +0900 Subject: [PATCH] Add asset and video-img CBS --- src/ts/parser.ts | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/ts/parser.ts b/src/ts/parser.ts index 6e2d8f0f..feef69f4 100644 --- a/src/ts/parser.ts +++ b/src/ts/parser.ts @@ -85,19 +85,30 @@ async function parseAdditionalAssets(data:string, char:simpleCharacterArgument|c if(char.additionalAssets){ - let assetPaths:{[key:string]:string} = {} - let emoPaths:{[key:string]:string} = {} + let assetPaths:{[key:string]:{ + path:string + ext?:string + }} = {} + let emoPaths:{[key:string]:{ + path:string + }} = {} for(const asset of char.additionalAssets){ const assetPath = await getFileSrc(asset[1]) - assetPaths[asset[0].toLocaleLowerCase()] = assetPath + assetPaths[asset[0].toLocaleLowerCase()] = { + path: assetPath, + ext: asset[2] + } } if(char.emotionImages){ for(const emo of char.emotionImages){ const emoPath = await getFileSrc(emo[1]) - emoPaths[emo[0].toLocaleLowerCase()] = emoPath + emoPaths[emo[0].toLocaleLowerCase()] = { + path: emoPath, + } } } + const videoExtention = ['mp4', 'webm', 'avi', 'm4p', 'm4v'] data = data.replaceAll(assetRegex, (full:string, type:string, name:string) => { name = name.toLocaleLowerCase() if(type === 'emotion'){ @@ -114,18 +125,26 @@ async function parseAdditionalAssets(data:string, char:simpleCharacterArgument|c } switch(type){ case 'raw': - return path + return path.path case 'img': - return `${path}` + return `${path.path}` case 'video': - return `` + return `` + case 'video-img': + return `` case 'audio': - return `` + return `` case 'bg': if(mode === 'back'){ - return `
` + return `
` } break + case 'asset':{ + if(path.ext && videoExtention.includes(path.ext)){ + return `` + } + return `${path.path}` + } } return '' })