Skip to content

Commit

Permalink
fix(live): add builtin bgm bgm_event_meetup (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi authored Apr 22, 2024
1 parent fe0d92c commit 4db7a6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 7 additions & 2 deletions app/src/ts/renderer/mishiro-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 11 additions & 3 deletions app/src/ts/renderer/the-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}

Expand Down Expand Up @@ -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 })
}
}
Expand Down

0 comments on commit 4db7a6a

Please sign in to comment.