From 4db7a6afbe3d5509425d841708a17a4784e0a096 Mon Sep 17 00:00:00 2001 From: Toyo Li Date: Mon, 22 Apr 2024 23:18:31 +0800 Subject: [PATCH] fix(live): add builtin bgm bgm_event_meetup (#47) --- app/src/ts/renderer/mishiro-update.ts | 9 +++++++-- app/src/ts/renderer/the-player.ts | 14 +++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/ts/renderer/mishiro-update.ts b/app/src/ts/renderer/mishiro-update.ts index 0e5102e..7f25140 100644 --- a/app/src/ts/renderer/mishiro-update.ts +++ b/app/src/ts/renderer/mishiro-update.ts @@ -14,7 +14,7 @@ import { getMasterHash, openManifestDatabase, readMasterData } from './ipc-back' import type { MishiroConfig } from '../main/config' import { readAcb } from './audio' import type { BGM } from './back/resolve-audio-manifest' -import { error } from './log' +import { error, warn } from './log' const fs = window.node.fs // const path = window.node.path const { manifestPath, masterPath, bgmDir/* , iconDir */ } = getPath @@ -210,7 +210,12 @@ export default class extends Vue { // } if (masterData.eventHappening) { const eventHca = bgmDir(`bgm_event_${masterData.eventData.id}.hca`) - if (Number(masterData.eventData.type) !== 2 && Number(masterData.eventData.type) !== 6 && !fs.existsSync(eventHca)) { + const downloadBGMEventType = [1, 3, 4, 5, 7, 8] + const eventType = Number(masterData.eventData.type) + if (eventType > 9) { + warn(`Unknown event type: ${eventType}`) + } + if (downloadBGMEventType.includes(eventType) && !fs.existsSync(eventHca)) { const eventBgmHash = bgmManifest.filter(row => row.name === `b/bgm_event_${masterData.eventData.id}.acb`)[0].hash try { // let result = await downloader.download( diff --git a/app/src/ts/renderer/the-player.ts b/app/src/ts/renderer/the-player.ts index 60b64ab..3ad66f9 100644 --- a/app/src/ts/renderer/the-player.ts +++ b/app/src/ts/renderer/the-player.ts @@ -43,6 +43,9 @@ export const bgmList: BGMList = { }, rail: { src: getPath('../asset/bgm.asar/bgm_event_rail.hca') + }, + meetup: { + src: getPath('../asset/bgm.asar/bgm_event_meetup.hca') } } @@ -216,17 +219,22 @@ export default class extends Vue { break case 'live': if (this.$store.state.master.eventHappening) { - if (Number(this.eventInfo.type) === 2) { + const eventType = Number(this.eventInfo.type) + if (eventType === 2) { if (this.playing.src !== bgmList.caravan.src) { await this.play(bgmList.caravan) } - } else if (Number(this.eventInfo.type) === 6) { + } else if (eventType === 6) { if (this.playing.src !== bgmList.rail.src) { await this.play(bgmList.rail) } + } else if (eventType === 9) { + if (this.playing.src !== bgmList.meetup.src) { + await this.play(bgmList.meetup) + } } else { const eventBgmSrc = getPath(`../asset/bgm/bgm_event_${this.eventInfo.id}.hca`) - if (this.playing.src !== eventBgmSrc) { + if (this.playing.src !== eventBgmSrc && fs.existsSync(eventBgmSrc)) { this.event.$emit('liveSelect', { src: eventBgmSrc }) } }