ensingm2 / SteamMonsterGameScript

A Javascript automator for the 2015 Summer Steam Monster Minigame
78 stars 29 forks source link

Spawned slaves will all play Music or SFX if master has them on when they are spawned. #41

Closed JimRaynor56 closed 9 years ago

JimRaynor56 commented 9 years ago

Suggested behavior would be to disable music and SFX before spawning slaves and then return them to their previous states.

EDIT: Based on further testing this suggested behavior may not work.

longzheng commented 9 years ago

The game seem sot use WebStorage to set the sound/music config

function ToggleSound()
{
    WebStorage.SetLocal('minigame_mute', !WebStorage.GetLocal('minigame_mute') );
}
CAudioManager.prototype.ToggleMusic = function( )
{
    WebStorage.SetLocal('minigame_mutemusic', !WebStorage.GetLocal('minigame_mutemusic') );

    if( !this.m_eleMusic )
        return;

    if( WebStorage.GetLocal('minigame_mutemusic') == true )
    {
        this.m_eleMusic.pause();
    } else {
        this.m_eleMusic.play();
    }
}

Which means there's no easy way to disable it per-window?

JimRaynor56 commented 9 years ago

If I have it disabled when they spawn I can re-enable it and nothing is played from the slave windows.

At least until a boss stage happens or new slaves are spawned. Then I run into the same issue of them all playing sound.

longzheng commented 9 years ago

If you nuke the g_rgSoundCache object, then the whole sound cache/object is gone.

ensingm2 commented 9 years ago

Yeah but you get spammed with error messages. I think I pushed as close to a fix as I can. Music pauses correctly on slave pages and doesn't disrupt master, but sfx rely on WebStorage which is shared between the windows, so I disable all.

Github takes a bit to update the raw slaveWindows.js file though so it might take a minute or two to take effect.

JimRaynor56 commented 9 years ago

That sounds like a good compromise. I imagine the majority of people won't notice this issue anyway because they leave music and SFX off.

JimRaynor56 commented 9 years ago

So c257f2cd338549216d75adaf585a9c177c957d6a does work, but as soon as you transition from a boss stage to a normal stage, or normal stage to a boss stage music is re-enabled.

longzheng commented 9 years ago

Should probably have as well

WebStorage.SetLocal('minigame_mutemusic', true);
ensingm2 commented 9 years ago

There's no good way to keep sound in one but not the other. I've just pushed something to disable all sfx and music as soon as slave windows are created.

If I set minigame_mute, no sfx play anywhere, if I don't, they play everywhere If I set minigame_mutemusic, the rest of the cache plays then the song abruptly ends If I don't set minigame_mutemusic but pause the music on one window, it only works until the song changes. If I delete the audio manager, the user gets spammed with error messages.

Sorry, but unless you find something else disabling everything is all I got. Closing.