mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-03-21 17:34:46 -05:00
Initial MDB Parser for Forte support.
This commit is contained in:
parent
cf15744a8b
commit
82439eb1fb
3
nostalgia@asphyxia/data/.gitignore
vendored
Normal file
3
nostalgia@asphyxia/data/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
*.json
|
||||
!forte_mdb.json
|
||||
forte_mdb.xml
|
||||
104
nostalgia@asphyxia/data/ForteMusic.ts
Normal file
104
nostalgia@asphyxia/data/ForteMusic.ts
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
export async function processData() {
|
||||
return await readJSONOrXML("data/forte_mdb.json", "data/forte_mdb.xml")
|
||||
}
|
||||
|
||||
export async function processMdbData(path: string): Promise<CommonMusicData> {
|
||||
const data = await readXML(path);
|
||||
const attr = $(data).attr("music_list");
|
||||
const mdb = $(data).elements("music_list.music_spec");
|
||||
const music: CommonMusicDataField[] = [];
|
||||
for (const m of mdb) {
|
||||
music.push(K.ATTR({ index: m.attr().index }, {
|
||||
basename: K.ITEM("str", m.str("basename")),
|
||||
title: K.ITEM("str", m.str("title", "title")),
|
||||
title_kana: K.ITEM("str", m.str("title_kana", "title_kana")),
|
||||
artist: K.ITEM("str", m.str("artist", "artist")),
|
||||
artist_kana: K.ITEM("str", m.str("artist_kana", "artist_kana")),
|
||||
priority: K.ITEM("s8", m.number("priority")),
|
||||
category_flag: K.ARRAY("s32", m.numbers("category_flag")),
|
||||
primary_category: K.ITEM("s8", m.number("primary_category")),
|
||||
level_normal: K.ITEM("s8", m.number("level_normal")),
|
||||
level_hard: K.ITEM("s8", m.number("level_hard")),
|
||||
level_extreme: K.ITEM("s8", m.number("level_extreme")),
|
||||
demo_popular: K.ITEM("bool", m.bool("demo_popular")),
|
||||
demo_bemani: K.ITEM("bool", m.bool("demo_bemani")),
|
||||
destination_j: K.ITEM("bool", true),
|
||||
destination_a: K.ITEM("bool", true),
|
||||
destination_y: K.ITEM("bool", true),
|
||||
destination_k: K.ITEM("bool", true),
|
||||
offline: K.ITEM("bool", m.bool("offline")),
|
||||
unlock_type: K.ITEM("s8", m.number("unlock_type") == 3 ? 1 : m.number("unlock_type")),
|
||||
volume_bgm: K.ITEM("s8", m.number("volume_bgm")),
|
||||
volume_key: K.ITEM("s8", m.number("volume_key")),
|
||||
start_date: K.ITEM("str", m.str("start_date")),
|
||||
end_date: K.ITEM("str", "9999-12-31 23:59"),
|
||||
description: K.ITEM("str", m.str("description", "description"))
|
||||
}));
|
||||
}
|
||||
return K.ATTR({
|
||||
release_code: attr.release_code,
|
||||
revision: attr.revision,
|
||||
}, {
|
||||
music_spec: music,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export interface CommonMusicDataField {
|
||||
basename: KITEM<"str">;
|
||||
title: KITEM<"str">;
|
||||
title_kana: KITEM<"str">;
|
||||
artist: KITEM<"str">;
|
||||
artist_kana: KITEM<"str">
|
||||
priority: KITEM<"s8">;
|
||||
category_flag: KARRAY<"s32">;
|
||||
primary_category: KITEM<"s8">;
|
||||
level_normal: KITEM<"s8">;
|
||||
level_hard: KITEM<"s8">;
|
||||
level_extreme: KITEM<"s8">;
|
||||
demo_popular: KITEM<"bool">;
|
||||
demo_bemani: KITEM<"bool">
|
||||
destination_j: KITEM<"bool">;
|
||||
destination_a: KITEM<"bool">;
|
||||
destination_y: KITEM<"bool">;
|
||||
destination_k: KITEM<"bool">;
|
||||
unlock_type: KITEM<"s8">;
|
||||
offline: KITEM<"bool">;
|
||||
volume_bgm: KITEM<"s8">;
|
||||
volume_key: KITEM<"s8">;
|
||||
start_date: KITEM<"str">;
|
||||
end_date: KITEM<"str">;
|
||||
description: KITEM<"str">;
|
||||
}
|
||||
|
||||
interface CommonMusicData {
|
||||
"@attr": {
|
||||
revision: string,
|
||||
release_code: string
|
||||
}
|
||||
music_spec: CommonMusicDataField[]
|
||||
}
|
||||
|
||||
export async function readXML(path: string) {
|
||||
const xml = await IO.ReadFile(path, 'utf-8');
|
||||
const json = U.parseXML(xml, false)
|
||||
return json
|
||||
}
|
||||
|
||||
export async function readJSON(path: string) {
|
||||
const str = await IO.ReadFile(path, 'utf-8');
|
||||
const json = JSON.parse(str)
|
||||
return json
|
||||
}
|
||||
|
||||
|
||||
export async function readJSONOrXML(jsonPath: string, xmlPath: string): Promise<CommonMusicData> {
|
||||
if (!IO.Exists(jsonPath)) {
|
||||
const data = await processMdbData(xmlPath)
|
||||
await IO.WriteFile(jsonPath, JSON.stringify(data))
|
||||
return data
|
||||
} else {
|
||||
const json = JSON.parse(await IO.ReadFile(jsonPath, 'utf-8'))
|
||||
return json
|
||||
}
|
||||
}
|
||||
1
nostalgia@asphyxia/data/forte_mdb.json
Normal file
1
nostalgia@asphyxia/data/forte_mdb.json
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,5 @@
|
|||
import * as path from "path";
|
||||
import { processData } from "../data/ForteMusic";
|
||||
|
||||
export const permitted_list = {
|
||||
flag: [
|
||||
|
|
@ -9,10 +10,18 @@ export const permitted_list = {
|
|||
],
|
||||
};
|
||||
|
||||
export const forte_permitted_list = {
|
||||
flag: [
|
||||
K.ARRAY('s32', Array(32).fill(-1), { sheet_type: '0' }),
|
||||
K.ARRAY('s32', Array(32).fill(-1), { sheet_type: '1' }),
|
||||
K.ARRAY('s32', Array(32).fill(-1), { sheet_type: '2' }),
|
||||
],
|
||||
}
|
||||
|
||||
async function ReadData(filename: string) {
|
||||
const xml = await IO.ReadFile(`data/${filename}.xml`, { encoding: 'utf-8'});
|
||||
const json = U.parseXML(xml, false)
|
||||
return json
|
||||
const xml = await IO.ReadFile(`data/${filename}.xml`, { encoding: 'utf-8' });
|
||||
const json = U.parseXML(xml, false)
|
||||
return json
|
||||
}
|
||||
|
||||
async function processIslandData() {
|
||||
|
|
@ -56,7 +65,7 @@ async function processCourseData() {
|
|||
return { course_data: courseData };
|
||||
}
|
||||
|
||||
export const get_common_info = async (req, data, send) => {
|
||||
export const get_common_info = async (info, data, send) => {
|
||||
send.object({
|
||||
permitted_list,
|
||||
olupdate: {
|
||||
|
|
@ -65,10 +74,12 @@ export const get_common_info = async (req, data, send) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const get_music_info: EPR = async (req, data, send) => {
|
||||
export const get_music_info: EPR = async (info, data, send) => {
|
||||
const isForte = !info.method.includes("op")
|
||||
|
||||
const music_spec: any = [];
|
||||
for (let i = 1; i < 400; ++i) {
|
||||
music_spec.push(K.ATTR({ index: `${i}`}, {
|
||||
music_spec.push(K.ATTR({ index: `${i}` }, {
|
||||
jk_jpn: K.ITEM('bool', 1),
|
||||
jk_asia: K.ITEM('bool', 1),
|
||||
jk_kor: K.ITEM('bool', 1),
|
||||
|
|
@ -83,18 +94,24 @@ export const get_music_info: EPR = async (req, data, send) => {
|
|||
}));
|
||||
}
|
||||
|
||||
send.object({
|
||||
permitted_list,
|
||||
const versionObject = isForte
|
||||
? {
|
||||
permitted_list: forte_permitted_list,
|
||||
music_list: await processData() }
|
||||
: {
|
||||
permitted_list,
|
||||
island_data_list: await processIslandData(),
|
||||
course_data_list: await processCourseData(),
|
||||
|
||||
island_data_list: await processIslandData(),
|
||||
course_data_list: await processCourseData(),
|
||||
|
||||
overwrite_music_list: K.ATTR({
|
||||
overwrite_music_list: K.ATTR({
|
||||
revision: '16706',
|
||||
release_code: '2019100200',
|
||||
}, {
|
||||
music_spec: music_spec,
|
||||
}),
|
||||
music_spec: music_spec,
|
||||
}),
|
||||
};
|
||||
send.object({
|
||||
...versionObject,
|
||||
|
||||
gamedata_flag_list: {
|
||||
event: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user