[Add] Dirty hack to make sure engine sounds stop when toolkit is open.

Proper fix will involve fixing SDL_mixer stuff.
This commit is contained in:
Allanis 2014-05-21 21:30:28 +01:00
parent 1b8467af22
commit 55a0cb0552
3 changed files with 45 additions and 4 deletions

View File

@ -206,6 +206,9 @@ void menu_small(void) {
menu_isOpen(MENU_DEATH)))
return;
/* Pauses the players sounds. */
player_soundPause();
wid = window_create("Menu", -1, -1, MENU_WIDTH, MENU_HEIGHT);
window_setCancel(wid, menu_small_close);
@ -232,6 +235,9 @@ static void menu_small_close(unsigned int wid, char* str) {
(void)str;
window_destroy(wid);
menu_Close(MENU_SMALL);
/* Resume player sounds. */
player_soundResume();
}
/**
@ -284,8 +290,6 @@ static void exit_game(void) {
}
/**
* @fn void menu_info(void)
*
* @brief Open the information window.
*/
void menu_info(void) {
@ -296,6 +300,9 @@ void menu_info(void) {
/* Can't open menu twise. */
if(menu_isOpen(MENU_INFO) || dialogue_isOpen()) return;
/* Pauses the players sounds. */
player_soundPause();
wid = window_create("Info", -1, -1, INFO_WIDTH, INFO_HEIGHT);
/* Pilot generics. */
@ -355,6 +362,9 @@ static void menu_info_close(unsigned int wid, char* str) {
(void)str;
window_destroy(wid);
menu_Close(MENU_INFO);
/* Resume player sounds. */
player_soundResume();
}
/**

View File

@ -5,6 +5,7 @@
*/
#include <stdlib.h>
#include "SDL_mixer.h" /** @todo Remove dependency. */
#include "lephisto.h"
#include "pilot.h"
@ -2007,12 +2008,13 @@ void player_land(void) {
player_message("You are going too fast to land on %s.", planet->name);
return;
}
/* Stop acceleration / afterburning. */
player_accelOver();
/* Stop afterburning. */
player_afterburnOver();
/* Open land menu. */
player_soundPause();
land(planet);
player_soundResume();
} else {
/* Get nearest planet target. */
if(cur_system->nplanets == 0) {
@ -2171,6 +2173,8 @@ void player_afterburn(void) {
sound_stopGroup(PLAYER_ENGINE_CHANNEL);
sound_playGroup(PLAYER_ENGINE_CHANNEL,
player->afterburner->outfit->u.afb.sound, 0);
if(toolkit)
player_soundPause();
}
}
@ -2195,6 +2199,8 @@ void player_accel(double acc) {
sound_stopGroup(PLAYER_ENGINE_CHANNEL);
sound_playGroup(PLAYER_ENGINE_CHANNEL,
player->ship->sound, 0);
if(toolkit)
player_soundPause();
}
}
@ -2206,6 +2212,28 @@ void player_accelOver(void) {
sound_stopGroup(PLAYER_ENGINE_CHANNEL);
}
/**
* @brief Pause the ship's sounds.
*
* @todo Not use hardcoded PLAYER_ENGINE_CHANNEL sound... Ideally add support
* for pausing/resuming groups in SDL_Mixer.
*/
void player_soundPause(void) {
if(!Mix_Paused(0))
Mix_Pause(0);
}
/**
* @brief Resumes the ships sounds.
*
* @todo Not use hardcoded PLAYER_ENGINE_CHANNEL sound... Ideally add support
* for pausing/resuming groups in SDL_Mixer.
*/
void player_soundResume(void) {
if(Mix_Paused(0))
Mix_Resume(0);
}
/**
* @brief Target the nearest hostile enemy to the player.
*/

View File

@ -51,8 +51,11 @@ void player_message(const char* fmt, ...);
void player_clear(void);
void player_warp(const double x, const double y);
const char* player_rating(void);
/* Sounds. */
void player_playSound(int sound, int once);
void player_stopSound(void);
void player_soundPause(void);
void player_soundResume(void);
/* Cargo. */
int player_outfitOwned(const char* outfitname);
int player_cargoOwned(const char* commodityname);