Update volume levels at client startup
Closes: https://github.com/arianne/stendhal/issues/722
This commit is contained in:
parent
52d1569418
commit
a899c8d0d4
2 changed files with 17 additions and 0 deletions
|
|
@ -132,6 +132,8 @@ export class Client {
|
|||
// alias for backward-compat until changed in all source
|
||||
stendhal.ui.gamewindow = stendhal.ui.viewport;
|
||||
stendhal.ui.soundMan = singletons.getSoundManager();
|
||||
// update sound levels from config at startup
|
||||
stendhal.ui.soundMan.onConfigUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -743,6 +743,21 @@ export class SoundManager {
|
|||
ui.onSoundUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be called when configuration values change.
|
||||
*/
|
||||
onConfigUpdate() {
|
||||
for (const layerName of ["master", ...this.layers]) {
|
||||
let vol = stendhal.config.getFloat("sound." + layerName + ".volume");
|
||||
if (typeof(vol) !== "number") {
|
||||
console.warn("Unrecognized volume value for layer \"" + layerName + "\":", vol);
|
||||
// default to 100%
|
||||
vol = 1.0;
|
||||
}
|
||||
this.setVolume(layerName, vol);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at startup to pre-cache certain sounds.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue