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