mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-09-22 22:27:56 +03:00
Rewrite MDB loading code to support loading .xml, .json or .b64 files. This applies to the default MDB (determined by the version of the game requesting it), or custom MDB if that setting is enabled. To use a custom MDB, enable it in Web UI, then place a custom.json, custom.xml or custom.b64 file in the data/mdb subfolder.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { getVersion } from "../utils";
|
||||
import { defaultProcessRawData, processDataBuilder } from "../data/mdb"
|
||||
import { CommonMusicDataField, readJSONOrXML, readXML } from "../data/mdb";
|
||||
import { CommonMusicDataField, findMDBFile, readMDBFile, loadSongsForGameVersion } from "../data/mdb";
|
||||
import Logger from "../utils/logger"
|
||||
|
||||
const logger = new Logger("MusicList")
|
||||
@@ -10,7 +9,9 @@ export const playableMusic: EPR = async (info, data, send) => {
|
||||
let music: CommonMusicDataField[] = [];
|
||||
try {
|
||||
if (U.GetConfig("enable_custom_mdb")) {
|
||||
music = (await defaultProcessRawData('data/mdb/custom.xml')).music
|
||||
let customMdb = findMDBFile("custom")
|
||||
|
||||
music = (await readMDBFile(customMdb)).music
|
||||
}
|
||||
} catch (e) {
|
||||
logger.warn("Read Custom MDB failed. Using default MDB as a fallback.")
|
||||
@@ -19,7 +20,7 @@ export const playableMusic: EPR = async (info, data, send) => {
|
||||
}
|
||||
|
||||
if (music.length == 0) {
|
||||
music = _.get(await processDataBuilder(version), 'music', []);
|
||||
music = (await loadSongsForGameVersion(version)).music
|
||||
}
|
||||
|
||||
await send.object({
|
||||
|
||||
Reference in New Issue
Block a user