mirror of
https://github.com/XProger/OpenLara.git
synced 2025-04-22 03:51:58 +02:00
pause game sounds in then inventory menu and while video playing
This commit is contained in:
parent
0637329934
commit
56de9ea649
@ -38,6 +38,9 @@ struct Camera : ICamera {
|
||||
}
|
||||
|
||||
void reset() {
|
||||
Sound::listener[cameraIndex].matrix.identity();
|
||||
Sound::listener[cameraIndex].matrix.translate(vec3(0x7FFFFFFF));
|
||||
|
||||
lookAngle = vec3(0.0f);
|
||||
|
||||
changeView(false);
|
||||
|
@ -683,6 +683,7 @@ struct Inventory {
|
||||
}
|
||||
|
||||
void startVideo() {
|
||||
applySounds(true);
|
||||
new Stream(playVideo ? TR::getGameVideo(game->getLevel()->id) : NULL, loadVideo, this);
|
||||
}
|
||||
|
||||
@ -826,6 +827,15 @@ struct Inventory {
|
||||
return false;
|
||||
}
|
||||
|
||||
void applySounds(bool pause) {
|
||||
for (int i = 0; i < Sound::channelsCount; i++)
|
||||
if (Sound::channels[i]->flags & Sound::PAN)
|
||||
if (pause)
|
||||
Sound::channels[i]->pause();
|
||||
else
|
||||
Sound::channels[i]->resume();
|
||||
}
|
||||
|
||||
void toggle(int playerIndex = 0, Page curPage = PAGE_INVENTORY, TR::Entity::Type type = TR::Entity::NONE) {
|
||||
if (titleTimer != 0.0f || (isActive() != active))
|
||||
return;
|
||||
@ -839,6 +849,8 @@ struct Inventory {
|
||||
active = !active;
|
||||
vec3 p;
|
||||
|
||||
applySounds(active);
|
||||
|
||||
if (curPage == PAGE_SAVEGAME) {
|
||||
phaseRing = active ? 1.0f : 0.0f;
|
||||
slot = 1;
|
||||
@ -1075,6 +1087,7 @@ struct Inventory {
|
||||
toggle(0, Inventory::PAGE_OPTION);
|
||||
}
|
||||
Input::reset();
|
||||
applySounds(false);
|
||||
}
|
||||
|
||||
void update() {
|
||||
|
17
src/sound.h
17
src/sound.h
@ -706,10 +706,12 @@ namespace Sound {
|
||||
int flags;
|
||||
int id;
|
||||
bool isPlaying;
|
||||
bool isPaused;
|
||||
bool stopAfterFade;
|
||||
|
||||
Sample(Decoder *decoder, float volume, float pitch, int flags, int id) : uniquePtr(NULL), decoder(decoder), volume(volume), volumeTarget(volume), volumeDelta(0.0f), pitch(pitch), flags(flags), id(id) {
|
||||
isPlaying = decoder != NULL;
|
||||
isPaused = false;
|
||||
}
|
||||
|
||||
Sample(Stream *stream, const vec3 *pos, float volume, float pitch, int flags, int id) : uniquePtr(pos), decoder(NULL), volume(volume), volumeTarget(volume), volumeDelta(0.0f), pitch(pitch), flags(flags), id(id) {
|
||||
@ -771,6 +773,7 @@ namespace Sound {
|
||||
delete stream;
|
||||
|
||||
isPlaying = decoder != NULL;
|
||||
isPaused = false;
|
||||
}
|
||||
|
||||
~Sample() {
|
||||
@ -807,6 +810,12 @@ namespace Sound {
|
||||
|
||||
bool render(Frame *frames, int count) {
|
||||
if (!isPlaying) return false;
|
||||
|
||||
if (isPaused) {
|
||||
memset(frames, 0, sizeof(Frame) * count);
|
||||
return true;
|
||||
}
|
||||
|
||||
// decode
|
||||
int i = 0;
|
||||
while (i < count) {
|
||||
@ -855,6 +864,14 @@ namespace Sound {
|
||||
void replay() {
|
||||
decoder->replay();
|
||||
}
|
||||
|
||||
void pause() {
|
||||
isPaused = true;
|
||||
}
|
||||
|
||||
void resume() {
|
||||
isPaused = false;
|
||||
}
|
||||
} *channels[SND_CHANNELS_MAX];
|
||||
int channelsCount;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user