[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:
parent
1b8467af22
commit
55a0cb0552
14
src/menu.c
14
src/menu.c
@ -206,6 +206,9 @@ void menu_small(void) {
|
|||||||
menu_isOpen(MENU_DEATH)))
|
menu_isOpen(MENU_DEATH)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* Pauses the players sounds. */
|
||||||
|
player_soundPause();
|
||||||
|
|
||||||
wid = window_create("Menu", -1, -1, MENU_WIDTH, MENU_HEIGHT);
|
wid = window_create("Menu", -1, -1, MENU_WIDTH, MENU_HEIGHT);
|
||||||
|
|
||||||
window_setCancel(wid, menu_small_close);
|
window_setCancel(wid, menu_small_close);
|
||||||
@ -232,6 +235,9 @@ static void menu_small_close(unsigned int wid, char* str) {
|
|||||||
(void)str;
|
(void)str;
|
||||||
window_destroy(wid);
|
window_destroy(wid);
|
||||||
menu_Close(MENU_SMALL);
|
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.
|
* @brief Open the information window.
|
||||||
*/
|
*/
|
||||||
void menu_info(void) {
|
void menu_info(void) {
|
||||||
@ -296,6 +300,9 @@ void menu_info(void) {
|
|||||||
/* Can't open menu twise. */
|
/* Can't open menu twise. */
|
||||||
if(menu_isOpen(MENU_INFO) || dialogue_isOpen()) return;
|
if(menu_isOpen(MENU_INFO) || dialogue_isOpen()) return;
|
||||||
|
|
||||||
|
/* Pauses the players sounds. */
|
||||||
|
player_soundPause();
|
||||||
|
|
||||||
wid = window_create("Info", -1, -1, INFO_WIDTH, INFO_HEIGHT);
|
wid = window_create("Info", -1, -1, INFO_WIDTH, INFO_HEIGHT);
|
||||||
|
|
||||||
/* Pilot generics. */
|
/* Pilot generics. */
|
||||||
@ -355,6 +362,9 @@ static void menu_info_close(unsigned int wid, char* str) {
|
|||||||
(void)str;
|
(void)str;
|
||||||
window_destroy(wid);
|
window_destroy(wid);
|
||||||
menu_Close(MENU_INFO);
|
menu_Close(MENU_INFO);
|
||||||
|
|
||||||
|
/* Resume player sounds. */
|
||||||
|
player_soundResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
32
src/player.c
32
src/player.c
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "SDL_mixer.h" /** @todo Remove dependency. */
|
||||||
|
|
||||||
#include "lephisto.h"
|
#include "lephisto.h"
|
||||||
#include "pilot.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);
|
player_message("You are going too fast to land on %s.", planet->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Stop acceleration / afterburning. */
|
/* Stop afterburning. */
|
||||||
player_accelOver();
|
|
||||||
player_afterburnOver();
|
player_afterburnOver();
|
||||||
|
|
||||||
/* Open land menu. */
|
/* Open land menu. */
|
||||||
|
player_soundPause();
|
||||||
land(planet);
|
land(planet);
|
||||||
|
player_soundResume();
|
||||||
} else {
|
} else {
|
||||||
/* Get nearest planet target. */
|
/* Get nearest planet target. */
|
||||||
if(cur_system->nplanets == 0) {
|
if(cur_system->nplanets == 0) {
|
||||||
@ -2171,6 +2173,8 @@ void player_afterburn(void) {
|
|||||||
sound_stopGroup(PLAYER_ENGINE_CHANNEL);
|
sound_stopGroup(PLAYER_ENGINE_CHANNEL);
|
||||||
sound_playGroup(PLAYER_ENGINE_CHANNEL,
|
sound_playGroup(PLAYER_ENGINE_CHANNEL,
|
||||||
player->afterburner->outfit->u.afb.sound, 0);
|
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_stopGroup(PLAYER_ENGINE_CHANNEL);
|
||||||
sound_playGroup(PLAYER_ENGINE_CHANNEL,
|
sound_playGroup(PLAYER_ENGINE_CHANNEL,
|
||||||
player->ship->sound, 0);
|
player->ship->sound, 0);
|
||||||
|
if(toolkit)
|
||||||
|
player_soundPause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2206,6 +2212,28 @@ void player_accelOver(void) {
|
|||||||
sound_stopGroup(PLAYER_ENGINE_CHANNEL);
|
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.
|
* @brief Target the nearest hostile enemy to the player.
|
||||||
*/
|
*/
|
||||||
|
@ -51,8 +51,11 @@ void player_message(const char* fmt, ...);
|
|||||||
void player_clear(void);
|
void player_clear(void);
|
||||||
void player_warp(const double x, const double y);
|
void player_warp(const double x, const double y);
|
||||||
const char* player_rating(void);
|
const char* player_rating(void);
|
||||||
|
/* Sounds. */
|
||||||
void player_playSound(int sound, int once);
|
void player_playSound(int sound, int once);
|
||||||
void player_stopSound(void);
|
void player_stopSound(void);
|
||||||
|
void player_soundPause(void);
|
||||||
|
void player_soundResume(void);
|
||||||
/* Cargo. */
|
/* Cargo. */
|
||||||
int player_outfitOwned(const char* outfitname);
|
int player_outfitOwned(const char* outfitname);
|
||||||
int player_cargoOwned(const char* commodityname);
|
int player_cargoOwned(const char* commodityname);
|
||||||
|
Loading…
Reference in New Issue
Block a user