Fixed playing of select sound; it was not tested for completion before

launching the game.
This commit is contained in:
Pieter Hulshoff 2017-08-09 11:21:31 +02:00
parent 668b8badd9
commit c90b8990df
6 changed files with 31 additions and 11 deletions

View File

@ -1085,7 +1085,7 @@ void Page::initializeFonts()
} }
void Page::launchEnter() void Page::playSelect()
{ {
if(selectSoundChunk_) if(selectSoundChunk_)
{ {
@ -1094,6 +1094,16 @@ void Page::launchEnter()
} }
bool Page::isSelectPlaying()
{
if ( selectSoundChunk_ )
{
return selectSoundChunk_->isPlaying();
}
return false;
}
void Page::reallocateMenuSpritePoints() void Page::reallocateMenuSpritePoints()
{ {
for(std::vector<ScrollingList *>::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++) for(std::vector<ScrollingList *>::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++)

View File

@ -89,7 +89,8 @@ public:
void allocateGraphicsMemory(); void allocateGraphicsMemory();
void deInitializeFonts( ); void deInitializeFonts( );
void initializeFonts( ); void initializeFonts( );
void launchEnter(); void playSelect();
bool isSelectPlaying();
std::string getCollectionName(); std::string getCollectionName();
void setMinShowTime(float value); void setMinShowTime(float value);
float getMinShowTime(); float getMinShowTime();

View File

@ -136,9 +136,7 @@ int RetroFE::initialize( void *context )
void RetroFE::launchEnter( ) void RetroFE::launchEnter( )
{ {
// Play launch sound // Disable window focus
currentPage_->launchEnter( );
SDL_SetWindowGrab(SDL::getWindow(), SDL_FALSE); SDL_SetWindowGrab(SDL::getWindow(), SDL_FALSE);
// Free the textures, and optionally take down SDL // Free the textures, and optionally take down SDL
@ -615,13 +613,14 @@ void RetroFE::run( )
// Launching game; start onGameEnter animation // Launching game; start onGameEnter animation
case RETROFE_LAUNCH_ENTER: case RETROFE_LAUNCH_ENTER:
currentPage_->enterGame( ); currentPage_->enterGame( ); // Start onGameEnter animation
currentPage_->playSelect( ); // Play launch sound
state = RETROFE_LAUNCH_REQUEST; state = RETROFE_LAUNCH_REQUEST;
break; break;
// Wait for onGameEnter animation to finish; launch game; start onGameExit animation // Wait for onGameEnter animation to finish; launch game; start onGameExit animation
case RETROFE_LAUNCH_REQUEST: case RETROFE_LAUNCH_REQUEST:
if ( currentPage_->isIdle( ) ) if ( currentPage_->isIdle( ) && !currentPage_->isSelectPlaying( ) )
{ {
nextPageItem_ = currentPage_->getSelectedItem( ); nextPageItem_ = currentPage_->getSelectedItem( );
launchEnter( ); launchEnter( );

View File

@ -21,6 +21,7 @@
Sound::Sound(std::string file, std::string altfile) Sound::Sound(std::string file, std::string altfile)
: file_(file) : file_(file)
, chunk_(NULL) , chunk_(NULL)
, channel_(-1)
{ {
if(!allocate()) if(!allocate())
{ {
@ -45,7 +46,7 @@ void Sound::play()
{ {
if(chunk_) if(chunk_)
{ {
(void)Mix_PlayChannel(-1, chunk_, 0); channel_ = Mix_PlayChannel(-1, chunk_, 0);
} }
} }
@ -54,7 +55,8 @@ bool Sound::free()
if(chunk_) if(chunk_)
{ {
Mix_FreeChunk(chunk_); Mix_FreeChunk(chunk_);
chunk_ = NULL; chunk_ = NULL;
channel_ = -1;
} }
return true; return true;
@ -69,3 +71,9 @@ bool Sound::allocate()
return (chunk_ != NULL); return (chunk_ != NULL);
} }
bool Sound::isPlaying()
{
return (channel_ != -1) && Mix_Playing(channel_);
}

View File

@ -25,7 +25,9 @@ public:
void play(); void play();
bool allocate(); bool allocate();
bool free(); bool free();
bool isPlaying();
private: private:
std::string file_; std::string file_;
Mix_Chunk *chunk_; Mix_Chunk *chunk_;
int channel_;
}; };

View File

@ -21,7 +21,7 @@
std::string retrofe_version_major = "0"; std::string retrofe_version_major = "0";
std::string retrofe_version_minor = "8"; std::string retrofe_version_minor = "8";
std::string retrofe_version_build = "13"; std::string retrofe_version_build = "14";
std::string Version::getString( ) std::string Version::getString( )