16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 16:19:19 +02:00

configurable complex_sound stop during beginning behavior

This commit is contained in:
milek7
2017-08-25 20:24:06 +02:00
parent 73a1baf3f9
commit 59317743fa
3 changed files with 32 additions and 3 deletions

View File

@@ -204,6 +204,7 @@ int Global::iMWDdivider = 5;
opengl_light Global::DayLight; opengl_light Global::DayLight;
Global::soundmode_t Global::soundpitchmode = Global::linear; Global::soundmode_t Global::soundpitchmode = Global::linear;
Global::soundmode_t Global::soundgainmode = Global::linear; Global::soundmode_t Global::soundgainmode = Global::linear;
Global::soundstopmode_t Global::soundstopmode = Global::queue;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -571,6 +572,17 @@ void Global::ConfigParse(cParser &Parser)
else if (token == "compat") else if (token == "compat")
Global::soundgainmode = Global::compat; Global::soundgainmode = Global::compat;
} }
else if (token == "soundstopmode")
{
Parser.getTokens();
Parser >> token;
if (token == "queue")
Global::soundstopmode = Global::queue;
else if (token == "playstop")
Global::soundstopmode = Global::playstop;
else if (token == "stop")
Global::soundstopmode = Global::stop;
}
else if (token == "soundpitchmode") else if (token == "soundpitchmode")
{ {
Parser.getTokens(); Parser.getTokens();

View File

@@ -359,9 +359,18 @@ class Global
{ {
linear, linear,
scaled, scaled,
compat compat,
}; };
enum soundstopmode_t
{
queue,
playstop,
stop
};
static soundmode_t soundpitchmode; static soundmode_t soundpitchmode;
static soundmode_t soundgainmode; static soundmode_t soundgainmode;
static soundstopmode_t soundstopmode;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -440,7 +440,7 @@ void complex_sound::play()
void complex_sound::stop() void complex_sound::stop()
{ {
if (cs == state::main) if (cs == state::main || (Global::soundstopmode == Global::playstop && cs == state::premain))
{ {
alSourceRewind(id); alSourceRewind(id);
@@ -453,7 +453,15 @@ void complex_sound::stop()
cs = state::post; cs = state::post;
} }
else if (cs == state::premain) else if (cs == state::premain)
{
if (Global::soundstopmode == Global::queue)
cs = state::prepost; cs = state::prepost;
else if (Global::soundstopmode == Global::stop)
{
alSourceRewind(id);
cs = state::post;
}
}
} }
void complex_sound::update(float dt) void complex_sound::update(float dt)