plugins/nostalgia@asphyxia/index.ts
2026-06-28 16:13:47 +07:00

46 lines
1.7 KiB
TypeScript

import { get_common_info, get_music_info } from "./handler/common";
import { get_musicdata, get_playdata, regist_playdata, set_stage_result, set_total_result } from "./handler/player"
import { fixIndexBug } from "./handler/webui";
export function register() {
R.GameCode('PAN');
R.WebUIEvent("nosFixIndexBug", fixIndexBug)
const MultiRoute = (method: string, handler: EPR | boolean) => {
// Helper for register multiple versions.
R.Route(method, handler); // First version and Forte.
R.Route(`op2_${method}`, handler);
R.Route(`op3_${method}`, handler);
};
const CommonRoute = (method: string, handler: EPR | boolean) =>
MultiRoute(`common.${method}`, handler)
const PlayerRoute = (method: string, handler: EPR | boolean) =>
MultiRoute(`player.${method}`, handler)
const PcbRoute = (method: string, handler: EPR | boolean) =>
MultiRoute(`pcb.${method}`, handler)
// Common
CommonRoute('get_common_info', get_common_info);
CommonRoute('get_music_info', get_music_info);
// Player
PlayerRoute('get_musicdata', get_musicdata)
PlayerRoute('get_playdata', get_playdata)
PlayerRoute('regist_playdata', regist_playdata)
PlayerRoute('set_total_result', set_total_result)
PlayerRoute('set_stage_result', set_stage_result)
// Test Menu
PcbRoute('report_testmode_settings', true)
R.Unhandled(async (info, data, send) => {
if (["eventlog"].includes(info.module)) return;
console.error(`Received Unhandled Response on ${info.method} by ${info.model}/${info.module}`)
console.error(`Received Request: ${JSON.stringify(data, null, 4)}`)
})
}