Refactor platform UI and data flow across core pages
All checks were successful
Build Org Website / build (push) Successful in 50s

This commit is contained in:
gitea-actions
2026-07-30 12:22:44 +01:00
parent fe8acac707
commit a0c78929b3
45 changed files with 1168 additions and 348 deletions

27
assets/scripts/pages/princess-lima-audio.js Normal file → Executable file
View File

@@ -11,6 +11,7 @@
function create(getState) {
let scene = null;
let ambience = null;
let voice = null;
let unlocked = false;
function attach(nextScene, region) {
@@ -33,7 +34,7 @@
const enabled = Boolean(unlocked && state && state.settings.soundEnabled);
scene.sound.mute = !enabled;
if (ambience) {
ambience.setVolume((state.settings.master || 0) * (state.settings.music || 0));
ambience.setVolume(state ? (state.settings.master || 0) * (state.settings.music || 0) : 0);
if (enabled && !ambience.isPlaying) ambience.play();
if (!enabled && ambience.isPlaying) ambience.pause();
}
@@ -41,10 +42,29 @@
function play(key, volume) {
const state = getState();
if (!scene || !unlocked || !state.settings.soundEnabled || !scene.cache.audio.exists(key)) return;
if (!scene || !unlocked || !state || !state.settings.soundEnabled || !scene.cache.audio.exists(key)) return;
scene.sound.play(key, { volume: state.settings.master * state.settings.effects * (volume || 1) });
}
function playVoice(key) {
const state = getState();
stopVoice();
if (!scene || !unlocked || !state || !state.settings.soundEnabled || !state.settings.narrationEnabled
|| !scene.cache.audio.exists(key)) return null;
voice = scene.sound.add(key, { volume: state.settings.master * state.settings.voice });
voice.once("complete", () => { voice = null; });
voice.play();
return voice;
}
function stopVoice() {
if (voice) {
voice.stop();
voice.destroy();
}
voice = null;
}
function suspend() {
if (ambience && ambience.isPlaying) ambience.pause();
}
@@ -54,12 +74,13 @@
}
function stop() {
stopVoice();
if (ambience) ambience.stop();
ambience = null;
scene = null;
}
return Object.freeze({ attach, unlock, apply, play, suspend, resume, stop, isUnlocked: () => unlocked });
return Object.freeze({ attach, unlock, apply, play, playVoice, stopVoice, suspend, resume, stop, isUnlocked: () => unlocked });
}
root.PrincessLimaAudio = Object.freeze({ create, TRACKS });