From 2149bee87fbd19a9e1e6eb4d87e58271b1320a26 Mon Sep 17 00:00:00 2001 From: Tony Ribeiro Date: Thu, 19 Oct 2023 00:36:19 +0200 Subject: [PATCH] Add handling of multiple live2d asset per character --- src/assets.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/assets.js b/src/assets.js index 29792f982..96cc5d5d3 100644 --- a/src/assets.js +++ b/src/assets.js @@ -227,6 +227,24 @@ function registerEndpoints(app, jsonParser) { let output = []; try { if (fs.existsSync(folderPath) && fs.statSync(folderPath).isDirectory()) { + + // Live2d assets + if (category == "live2d") { + const folders = fs.readdirSync(folderPath) + for (let modelFolder of folders) { + const live2dModelPath = path.join(folderPath, modelFolder); + if (fs.statSync(live2dModelPath).isDirectory()) { + for (let file of fs.readdirSync(live2dModelPath)) { + console.debug(file) + if (file.includes("model")) + output.push([`${modelFolder}`,`/characters/${name}/${category}/${modelFolder}/${file}`]); + } + } + } + return response.send(output); + } + + // Other assets const files = fs.readdirSync(folderPath) .filter(filename => { return filename != ".placeholder"; @@ -234,7 +252,6 @@ function registerEndpoints(app, jsonParser) { for (let i of files) output.push(`/characters/${name}/${category}/${i}`); - } return response.send(output); }