volume load/save nitpicks

This commit is contained in:
uwaa 2025-01-11 13:45:23 +00:00
parent 2b0ed79d9d
commit daed10ba44

8
rot.js
View file

@ -76,7 +76,8 @@
} }
function volumeSet(number) { function volumeSet(number) {
localStorage.audiovolume = Math.round((audio.volume = number) * 100); audio.volume = number; //Set
localStorage.audiovolume = Math.round(number * 100); //Save
updateVolumeLabel(); updateVolumeLabel();
} }
function volumeAdd(number) { function volumeAdd(number) {
@ -248,7 +249,10 @@
audio.loop = true; audio.loop = true;
audio.id = "user-music"; audio.id = "user-music";
audio.style = "display:none;"; audio.style = "display:none;";
localStorage.audiovolume = (audio.volume = localStorage.audiovolume ? localStorage.audiovolume / 100 : 0.5) * 100; if (localStorage.audiovolume)
audio.volume = localStorage.audiovolume / 100; //Load volume
else
audio.volume = 0.2; //Default volume
//Initialize audio controls and event listeners //Initialize audio controls and event listeners
waitUntil("#music-controls").then((controls) => { waitUntil("#music-controls").then((controls) => {