sdvx: added WIP features - arena save, valgene, common.ts updates, webui features
This commit is contained in:
@@ -30,4 +30,172 @@ export function getRandomIntInclusive(min, max) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min + 1) + min); //The maximum is inclusive and the minimum is inclusive
|
||||
}
|
||||
|
||||
export const copyResourcesFromGame = async (data: {}) => {
|
||||
let resourceJsonData = JSON.parse(U.DecodeString(await IO.ReadFile('webui\\asset\\json\\data.json'), 'utf8'))
|
||||
let newNemsysData = []
|
||||
let newAPCardData = []
|
||||
let newSubBGData = []
|
||||
|
||||
// Copying new nemsys files from gamedata
|
||||
console.log("Copying new nemsys files from gamedata")
|
||||
let nemsysFiles = await IO.ReadDir(U.GetConfig('sdvx_eg_root_dir') + "\\data\\graphics\\game_nemsys")
|
||||
for await (const nemsys of nemsysFiles) {
|
||||
let fileToWrite = await IO.ReadFile(U.GetConfig('sdvx_eg_root_dir') + "\\data\\graphics\\game_nemsys\\" + nemsys.name)
|
||||
if(!IO.Exists('webui\\asset\\nemsys\\' + nemsys.name.substring(0, (nemsys.name.length - 4)) + ".png") && !IO.Exists('webui\\asset\\nemsys\\' + nemsys.name.substring(0, (nemsys.name.length - 4)) + ".jpg")) {
|
||||
IO.WriteFile('webui\\test_asset\\nemsys\\' + nemsys.name, fileToWrite)
|
||||
newNemsysData.push(nemsys.name)
|
||||
} else {
|
||||
console.log(nemsys.name + " exists")
|
||||
}
|
||||
}
|
||||
|
||||
newNemsysData.forEach(fileName => {
|
||||
if(parseInt(fileName.substring(7, 11))) {
|
||||
resourceJsonData.nemsys.push({"value": parseInt(fileName.substring(7, 11)), "name": fileName + " (please rename)"})
|
||||
}
|
||||
})
|
||||
|
||||
// Copying new appeal card files from gamedata
|
||||
console.log("Copying new appeal card files from gamedata")
|
||||
let apCardFiles = await IO.ReadDir(U.GetConfig('sdvx_eg_root_dir') + "\\data\\graphics\\ap_card")
|
||||
for await (const apCard of apCardFiles) {
|
||||
let fileToWrite = await IO.ReadFile(U.GetConfig('sdvx_eg_root_dir') + "\\data\\graphics\\ap_card\\" + apCard.name)
|
||||
if(!IO.Exists('webui\\asset\\ap_card\\' + apCard.name.substring(0, (apCard.name.length - 4)) + ".png") && !IO.Exists('webui\\asset\\ap_card\\' + apCard.name.substring(0, (apCard.name.length - 4)) + ".jpg")) {
|
||||
IO.WriteFile('webui\\test_asset\\ap_card\\' + apCard.name, fileToWrite)
|
||||
newAPCardData.push(apCard.name)
|
||||
} else {
|
||||
console.log(apCard.name + " exists")
|
||||
}
|
||||
}
|
||||
|
||||
// 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")
|
||||
for await (const subbg of subBGFiles) {
|
||||
let fileToWrite = await IO.ReadFile(U.GetConfig('sdvx_eg_root_dir') + "\\data\\graphics\\submonitor_bg\\" + subbg.name)
|
||||
if(!IO.Exists('webui\\asset\\submonitor_bg\\' + subbg.name.substring(0, (subbg.name.length - 4)) + ".png") && !IO.Exists('webui\\asset\\submonitor_bg\\' + subbg.name.substring(0, (subbg.name.length - 4)) + ".jpg")) {
|
||||
IO.WriteFile('webui\\test_asset\\submonitor_bg\\' + subbg.name, fileToWrite)
|
||||
newSubBGData.push(subbg.name)
|
||||
} else {
|
||||
console.log(subbg.name + " exists")
|
||||
}
|
||||
}
|
||||
|
||||
newSubBGData.forEach(fileName => {
|
||||
if(parseInt(fileName.substring(6, 10))) {
|
||||
resourceJsonData.subbg.push({"value": parseInt(fileName.substring(6, 10)), "name": fileName + " (please rename)"})
|
||||
}
|
||||
})
|
||||
|
||||
await IO.WriteFile('webui\\test_asset\\data.json', JSON.stringify(resourceJsonData))
|
||||
await IO.WriteFile('webui\\asset\\logs\\copyResourcesFromGame.json', JSON.stringify({
|
||||
nemsys: newNemsysData,
|
||||
apCard: newAPCardData,
|
||||
subbg: newSubBGData
|
||||
}))
|
||||
}
|
||||
|
||||
export const generateLatestMusicDBFile = async (data: {}) => {
|
||||
var version = '';
|
||||
IO.ReadFile(U.GetConfig('sdvx_eg_root_dir') + "\\prop\\ea3-config.xml").then(
|
||||
function(value){
|
||||
let configJson = U.parseXML(U.DecodeString(value, "shift_jis"), false)
|
||||
version = configJson['ea3']['soft']['ext']['@content'];
|
||||
},
|
||||
function(error){
|
||||
console.log(error)
|
||||
return null;
|
||||
}
|
||||
);
|
||||
var mdbJson;
|
||||
var mdbJsonFix = [];
|
||||
var mdbJsonFixFinal;
|
||||
var mdb = await IO.ReadFile(U.GetConfig('sdvx_eg_root_dir') + "\\data\\others\\music_db.xml").then(
|
||||
function(value){
|
||||
mdbJson = U.parseXML(U.DecodeString(value, "shift_jis"), false)
|
||||
try {
|
||||
mdbJson.mdb.music.forEach(musicValue => {
|
||||
if(parseInt(musicValue.info.distribution_date['@content'][0]) >= parseInt(version.substring(0,8))) {
|
||||
console.log("Found new song for version " + version + ": " + musicValue.info.title_name['@content'] + " (" + musicValue.info.distribution_date['@content'] + ")");
|
||||
}
|
||||
mdbJsonFix.push({
|
||||
'@id': musicValue['@attr'].id,
|
||||
'info': {
|
||||
'title_name': musicValue.info.title_name['@content'],
|
||||
'version': {
|
||||
'@__type': 'u8',
|
||||
'#text': musicValue.info.version['@content'][0].toString()
|
||||
},
|
||||
'inf_ver': {
|
||||
'@__type': 'u8',
|
||||
'#text': musicValue.info.inf_ver['@content'][0].toString()
|
||||
},
|
||||
'distribution_date' : {
|
||||
'#text': musicValue.info.distribution_date['@content'][0]
|
||||
}
|
||||
},
|
||||
'difficulty': {
|
||||
'novice': {
|
||||
'difnum': {
|
||||
'@__type': 'u8',
|
||||
'#text': musicValue.difficulty.novice.difnum['@content'][0].toString()
|
||||
}
|
||||
},
|
||||
'advanced': {
|
||||
'difnum': {
|
||||
'@__type': 'u8',
|
||||
'#text': musicValue.difficulty.advanced.difnum['@content'][0].toString()
|
||||
}
|
||||
},
|
||||
'exhaust': {
|
||||
'difnum': {
|
||||
'@__type': 'u8',
|
||||
'#text': musicValue.difficulty.exhaust.difnum['@content'][0].toString()
|
||||
}
|
||||
},
|
||||
'maximum': {
|
||||
'difnum': {
|
||||
'@__type': 'u8',
|
||||
'#text': musicValue.difficulty.maximum != undefined ? musicValue.difficulty.maximum.difnum['@content'][0].toString() : '0'
|
||||
}
|
||||
},
|
||||
'infinite': {
|
||||
'difnum': {
|
||||
'@__type': 'u8',
|
||||
'#text': musicValue.difficulty.infinite != undefined ? musicValue.difficulty.infinite.difnum['@content'][0].toString() : '0'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
try{
|
||||
mdbJsonFixFinal = {
|
||||
'mdb': {
|
||||
'version': version,
|
||||
'music': mdbJsonFix
|
||||
}
|
||||
};
|
||||
IO.WriteFile('webui\\asset\\json\\music_db.json', JSON.stringify(mdbJsonFixFinal));
|
||||
if(!IO.Exists('webui\\asset\\json\\music_db_' + version + '.json')){
|
||||
IO.WriteFile('webui\\asset\\json\\music_db_' + version + '.json', JSON.stringify(mdbJsonFixFinal));
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
return mdbJsonFixFinal;
|
||||
},
|
||||
function(error){
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
);
|
||||
console.log(mdb.mdb.version)
|
||||
return mdb;
|
||||
}
|
||||
Reference in New Issue
Block a user