From 150f003c5e6cbdedab60db92d5f4cb3bc0ab4bbf Mon Sep 17 00:00:00 2001 From: vvo <> Date: Thu, 29 Sep 2022 19:23:16 +0800 Subject: [PATCH] add BGM file copy + bat script for auto-extract and convert --- sdvx@asphyxia/README.md | 5 +- sdvx@asphyxia/bgm_convert.bat | 10 ++++ sdvx@asphyxia/utils.ts | 36 ++++++++++++++- .../webui/asset/js/updateResources.js | 46 +++++++++++++------ 4 files changed, 80 insertions(+), 17 deletions(-) create mode 100644 sdvx@asphyxia/bgm_convert.bat diff --git a/sdvx@asphyxia/README.md b/sdvx@asphyxia/README.md index fe174e4..7059761 100644 --- a/sdvx@asphyxia/README.md +++ b/sdvx@asphyxia/README.md @@ -1,6 +1,9 @@ Message from repo fork: -- Please always remember to update datecode before using [WebUI Resource Update](http://localhost:8083/plugin/sdvx@asphyxia/WebUI%20resource%20update) feature (or this plugin in general). +- I highly recommend using the stable version of the plugin. +- This version is only properly usable in proper arcade data, meaning no mods. - This is very work-in-progress. Please **BACK UP YOUR DATA** to prevent unwanted data loss (just in case) +- Please always remember to update datecode before using [WebUI Resource Update](/plugin/sdvx@asphyxia/WebUI%20resource%20update) feature (or this plugin in general). +- I won't update the text below lol ---------------------------- # SOUND VOLTEX diff --git a/sdvx@asphyxia/bgm_convert.bat b/sdvx@asphyxia/bgm_convert.bat new file mode 100644 index 0000000..c729ba3 --- /dev/null +++ b/sdvx@asphyxia/bgm_convert.bat @@ -0,0 +1,10 @@ +@echo off +for /f %%a in ('dir "webui\asset\audio\*.s3p" /s /b') do ( + echo "%%~fa" + s3p_extract %%~fa + ffmpeg -i "%%~fa.out\0.wma" -vn -ar 44100 -ac 2 -b:a 192k "%%~fa.out\..\0.mp3" + ffmpeg -i "%%~fa.out\1.wma" -vn -ar 44100 -ac 2 -b:a 192k "%%~fa.out\..\1.mp3" + rmdir /s /q "%%~fa.out" + del %%~fa +) +@echo on \ No newline at end of file diff --git a/sdvx@asphyxia/utils.ts b/sdvx@asphyxia/utils.ts index 2447ba8..8291fbe 100644 --- a/sdvx@asphyxia/utils.ts +++ b/sdvx@asphyxia/utils.ts @@ -37,6 +37,7 @@ export const copyResourcesFromGame = async (data: {}) => { let newNemsysData = [] let newAPCardData = [] let newSubBGData = [] + let newBGMData = [] // Copying new nemsys files from gamedata console.log("Copying new nemsys files from gamedata") @@ -70,6 +71,13 @@ export const copyResourcesFromGame = async (data: {}) => { } } + // Appeal card data registration to data.json not properly implemented yet, I don't quite understand how their IDs work + // newAPCardData.forEach(fileName => { + // if(parseInt(fileName.substring(6, 10))) { + // resourceJsonData.apCard.push({"value": parseInt(fileName.substring(6, 10)), "name": fileName + " (please rename)"}) + // } + // }) + // Copying new subbg files from gamedata console.log("Copying new subbg files from gamedata") let subBGFiles = await IO.ReadDir(U.GetConfig('sdvx_eg_root_dir') + "\\data\\graphics\\submonitor_bg") @@ -89,11 +97,37 @@ export const copyResourcesFromGame = async (data: {}) => { } }) + // Copying new bgm files from gamedata + console.log("Copying new bgm files from gamedata") + let bgmFiles = await IO.ReadDir(U.GetConfig('sdvx_eg_root_dir') + "\\data\\sound\\custom") + for await (const bgm of bgmFiles) { + if (bgm.name.substring(bgm.name.length-4, bgm.name.length) == '.s3p') { + let folderName = bgm.name.match(/(custom|special)_([0-9]*)/g)[0] + if(folderName != '') { + let fileToWrite = await IO.ReadFile(U.GetConfig('sdvx_eg_root_dir') + "\\data\\sound\\custom\\" + bgm.name) + if(!IO.Exists('webui\\asset\\audio\\' + folderName)) { + IO.WriteFile('webui\\asset\\audio\\' + folderName + '\\' + bgm.name, fileToWrite) + newBGMData.push(bgm.name) + } else { + console.log(bgm.name + " exists") + } + } + } + } + + newBGMData.forEach(fileName => { + let bgmId = fileName.match(/(?<=(custom|special)_)([0-9]*)/g)[0] + if(parseInt(bgmId)) { + resourceJsonData.bgm.push({"value": parseInt(bgmId), "name": fileName + " (please rename)"}) + } + }) + await IO.WriteFile('webui\\asset\\json\\data.json', JSON.stringify(resourceJsonData)) await IO.WriteFile('webui\\asset\\logs\\copyResourcesFromGame.json', JSON.stringify({ nemsys: newNemsysData, apCard: newAPCardData, - subbg: newSubBGData + subbg: newSubBGData, + bgm: newBGMData })) } diff --git a/sdvx@asphyxia/webui/asset/js/updateResources.js b/sdvx@asphyxia/webui/asset/js/updateResources.js index bcbb4e0..68119a5 100644 --- a/sdvx@asphyxia/webui/asset/js/updateResources.js +++ b/sdvx@asphyxia/webui/asset/js/updateResources.js @@ -29,21 +29,37 @@ $(document).ready(async function() { await emit("copyResourcesFromGame").then( function(response){ $.getJSON( "static/asset/logs/copyResourcesFromGame.json", function( data ) { - document.getElementById("logtextarea").textContent += 'New nemsys: \n' - $.each(data['nemsys'], function(key, val) { - document.getElementById("logtextarea").textContent += val + '\n' - }) - document.getElementById("logtextarea").textContent += '\n\n' - document.getElementById("logtextarea").textContent += 'New appeal cards: \n' - $.each(data['apCard'], function(key, val) { - document.getElementById("logtextarea").textContent += val + '\n' - }) - document.getElementById("logtextarea").textContent += '\n\n' - document.getElementById("logtextarea").textContent += 'New submonitor backgrounds: \n' - $.each(data['subbg'], function(key, val) { - document.getElementById("logtextarea").textContent += val + '\n' - }) - document.getElementById("logtextarea").textContent += '\n\n' + if(data['nemsys']) { + document.getElementById("logtextarea").textContent += 'New nemsys: \n' + $.each(data['nemsys'], function(key, val) { + document.getElementById("logtextarea").textContent += "- " + val + '\n' + }) + document.getElementById("logtextarea").textContent += '\n\n' + } + + if(data['apCard']) { + document.getElementById("logtextarea").textContent += 'New appeal cards: \n' + $.each(data['apCard'], function(key, val) { + document.getElementById("logtextarea").textContent += "- " + val + '\n' + }) + document.getElementById("logtextarea").textContent += '\n\n' + } + + if(data['subbg']) { + document.getElementById("logtextarea").textContent += 'New submonitor backgrounds: \n' + $.each(data['subbg'], function(key, val) { + document.getElementById("logtextarea").textContent += "- " + val + '\n' + }) + document.getElementById("logtextarea").textContent += '\n\n' + } + + if(data['bgm']) { + document.getElementById("logtextarea").textContent += 'New bgm: \n' + $.each(data['bgm'], function(key, val) { + document.getElementById("logtextarea").textContent += "- " + val + '\n' + }) + document.getElementById("logtextarea").textContent += '\n\n' + } }) }, function(error){