feat(showcase): add remaining operator voices

This commit is contained in:
Haoyu Xu
2023-02-10 23:34:23 -05:00
parent 808d0ff6da
commit c7585f93a6
5 changed files with 151 additions and 17 deletions

View File

@@ -61,6 +61,7 @@ export default class Voice {
set useSubtitle(show) {
this.#useSubtitle = show
this.#el.hidden = !show
window.settings.functionInsights("useSubtitle")
}
get useSubtitle() {
@@ -71,6 +72,7 @@ export default class Voice {
* @param {boolean} show
*/
set useVoice(show) {
window.settings.functionInsights("useVoice")
this.#useVoice = show
this.#el.hidden = !show
this.#playEntryVoice()
@@ -89,6 +91,7 @@ export default class Voice {
set useVoiceActor(show) {
this.#useVoiceActor = show
document.getElementById('voice_actor_box').hidden = !show
window.settings.functionInsights("useVoiceActor")
}
get useVoiceActor() {
@@ -104,6 +107,7 @@ export default class Voice {
} else {
this.#subtitleLang = this.#defaultRegion
}
window.settings.functionInsights("subtitleLanguage")
}
get subtitleLanguage() {
@@ -140,6 +144,7 @@ export default class Voice {
#updateSubtitlePosition() {
window.settings.elementPosition(this.#el, this.#subtitleX, this.#subtitleY)
window.settings.functionInsights("subtitlePosition")
}
/**
@@ -151,6 +156,7 @@ export default class Voice {
} else {
this.#voiceLang = this.#defaultVoiceLang
}
window.settings.functionInsights("language")
const availableSubtitleLang = this.#getSubtitleLanguages()
if (!availableSubtitleLang.includes(this.#subtitleLang)) {
this.#subtitleLang = availableSubtitleLang[0]
@@ -174,6 +180,7 @@ export default class Voice {
this.#idleDuration = duration * 60 * 1000
this.#initIdleVoiceTimer()
}
window.settings.functionInsights("idleDuration")
}
get idleDuration() {
@@ -189,6 +196,7 @@ export default class Voice {
this.#nextDuration = duration * 60 * 1000
this.#initNextVoiceTimer()
}
window.settings.functionInsights("nextDuration")
}
get nextDuration() {
@@ -227,7 +235,7 @@ export default class Voice {
if (id === null) {
setTimeout(() => {
if (this.#isPlaying) return
this.#el.style.opacity = 1
this.#el.style.opacity = 0
}, 5 * 1000);
return
}
@@ -246,7 +254,7 @@ export default class Voice {
this.#lastVoiceId = this.#currentVoiceId
this.#currentVoiceId = id
this.#audioEl.src = `./assets/${this.#getVoiceFoler()
}/${id}.wav`
}/${id}.ogg`
let startPlayPromise = this.#audioEl.play()
if (startPlayPromise !== undefined) {
startPlayPromise
@@ -365,9 +373,11 @@ export default class Voice {
<div class="voice-triangle"></div>
</div>
</div>
<div class="voice-actor" id="voice_actor_box" hidden>
<span class="voice-actor-icon"></span>
<span id="voice_actor_name" class="voice-actor-name"></span>
<div id="voice_actor_box" hidden>
<div class="voice-actor">
<span class="voice-actor-icon"></span>
<span id="voice_actor_name" class="voice-actor-name"></span>
</div>
</div>
`
}

View File

@@ -44,6 +44,33 @@ window.wallpaperPropertyListener = {
window.settings.resetBackground()
}
}
if (properties.voicetitle) {
window.voice.useVoice = properties.voicetitle.value
}
if (properties.voicelanguage) {
window.voice.language = properties.voicelanguage.value
}
if (properties.voiceidle) {
window.voice.idleDuration = parseInt(properties.voiceidle.value)
}
if (properties.voicenext) {
window.voice.nextDuration = parseInt(properties.voicenext.value)
}
if (properties.voicesubtitle) {
window.voice.useSubtitle = properties.voicesubtitle.value
}
if (properties.voicesubtitlelanguage) {
window.voice.subtitleLanguage = properties.voicesubtitlelanguage.value
}
if (properties.voicesubtitlex) {
window.voice.subtitleX = properties.voicesubtitlex.value
}
if (properties.voicesubtitley) {
window.voice.subtitleY = properties.voicesubtitley.value
}
if (properties.voiceactor) {
window.voice.useVoiceActor = properties.voiceactor.value
}
if (properties.position) {
if (!properties.position.value) {
window.settings.positionReset()