From 2be207f50190dc43b17d10efc3342d0fb39bd7f9 Mon Sep 17 00:00:00 2001 From: Haoyu Xu Date: Mon, 24 Feb 2025 19:43:59 +0800 Subject: [PATCH] fix: fixed several wallpaper enginer related issues --- apps/showcase/src/components/aklive2d.js | 5 ++--- apps/showcase/src/components/background.js | 9 ++------- apps/showcase/src/components/logo.js | 2 +- apps/showcase/src/components/music.js | 8 +++----- apps/showcase/src/components/player.js | 2 +- apps/showcase/src/components/voice.js | 9 +++++---- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/apps/showcase/src/components/aklive2d.js b/apps/showcase/src/components/aklive2d.js index e01bb9c..143fca2 100644 --- a/apps/showcase/src/components/aklive2d.js +++ b/apps/showcase/src/components/aklive2d.js @@ -221,15 +221,14 @@ export default class AKLive2D { ]) this.#music.link(this.#background) - this.#background.link(this.#music) this.#voice.link(this.#player) + this.#applyConfig() + this.#player.success() this.#voice.success() this.#music.success() this.#insight.success() - this.#applyConfig() - if ( this.#queries.has('aklive2d') || import.meta.env.MODE === 'development' diff --git a/apps/showcase/src/components/background.js b/apps/showcase/src/components/background.js index d938bec..f6c422a 100644 --- a/apps/showcase/src/components/background.js +++ b/apps/showcase/src/components/background.js @@ -24,7 +24,6 @@ export default class Background { useVideo: false, name: null, } - #musicObj constructor(el) { this.#parentEl = el @@ -59,10 +58,6 @@ export default class Background { this.resetVideo() } - link(musicObj) { - this.#musicObj = musicObj - } - get useVideo() { return this.#config.useVideo } @@ -113,8 +108,8 @@ export default class Background { set default(v) { this.#default.image = v - this.#musicObj.music = v - this.image = this.#default.location + this.#default.image + if (!this.#config.name) + this.image = this.#default.location + this.#default.image } set custom(v) { diff --git a/apps/showcase/src/components/logo.js b/apps/showcase/src/components/logo.js index 23b6112..6e1fa54 100644 --- a/apps/showcase/src/components/logo.js +++ b/apps/showcase/src/components/logo.js @@ -15,7 +15,7 @@ export default class Logo { #default = { location: `${import.meta.env.BASE_URL}assets/`, image: `${buildConfig.logo_filename}.png`, - useInvertFilter: buildConfig.invert_filter === 'true', + useInvertFilter: buildConfig.invert_filter, ratio: 61.8, opacity: 30, hidden: false, diff --git a/apps/showcase/src/components/music.js b/apps/showcase/src/components/music.js index 880b186..68b70e3 100644 --- a/apps/showcase/src/components/music.js +++ b/apps/showcase/src/components/music.js @@ -89,7 +89,6 @@ export default class Music { reset() { document.getElementById('custom-music').value = '' document.getElementById('custom-music-clear').disabled = true - this.#music.isUsingCustom = false this.#config.name = null if (this.#config.useMusic) { this.#playMusic() @@ -99,12 +98,11 @@ export default class Music { #setMusic(data, type) { this.#audio.loop.el.src = data this.#audio.loop.el.querySelector('source').type = type - this.#music.isUsingCustom = true this.#playMusic() } #playMusic() { - if (!this.#music.isUsingCustom) { + if (!this.#config.name) { const introOgg = this.#music.mapping[this.#music.current].intro const intro = `./assets/${this.#music.location}/${introOgg}` const loop = `./assets/${this.#music.location}/${this.#music.mapping[this.#music.current].loop}` @@ -179,13 +177,13 @@ export default class Music { } get isUsingCustom() { - return this.#music.isUsingCustom + return this.#config.name !== null } set music(name) { if (name !== null && name !== this.#music.current) { this.#music.current = name - if (this.#config.useMusic && !this.#music.isUsingCustom) { + if (this.#config.useMusic && !this.#config.name) { this.#audio.loop.el.pause() this.#audio.intro.el.pause() this.#playMusic() diff --git a/apps/showcase/src/components/player.js b/apps/showcase/src/components/player.js index 9ba5d0f..f94eb9c 100644 --- a/apps/showcase/src/components/player.js +++ b/apps/showcase/src/components/player.js @@ -116,7 +116,7 @@ export default class Player { document.dispatchEvent(Events.Ready.handler()) }, } - if (buildConfig.use_json === 'true') { + if (buildConfig.use_json) { playerConfig.jsonUrl = `./assets/${buildConfig.filename}.json` } else { playerConfig.skelUrl = `./assets/${buildConfig.filename}.skel` diff --git a/apps/showcase/src/components/voice.js b/apps/showcase/src/components/voice.js index e5c3a2d..d411dff 100644 --- a/apps/showcase/src/components/voice.js +++ b/apps/showcase/src/components/voice.js @@ -148,9 +148,10 @@ export default class Voice { return folders } - #getVoices() { - return this.#charwordTable.subtitleLangs[this.#config.subtitle.language] - .default + #getVoices(lang = null) { + return this.#charwordTable.subtitleLangs[ + lang ? lang : this.#config.subtitle.language + ].default } #playEntryVoice() { @@ -158,7 +159,7 @@ export default class Voice { } #playSpecialVoice(matcher) { - const voices = this.#getVoices() + const voices = this.#getVoices(buildConfig.voice_default_region) const voiceId = Object.keys(voices).find( (e) => voices[e].title === matcher )