diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index cb74284..f79963b 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -1085,7 +1085,7 @@ void Page::initializeFonts() } -void Page::launchEnter() +void Page::playSelect() { if(selectSoundChunk_) { @@ -1094,6 +1094,16 @@ void Page::launchEnter() } +bool Page::isSelectPlaying() +{ + if ( selectSoundChunk_ ) + { + return selectSoundChunk_->isPlaying(); + } + return false; +} + + void Page::reallocateMenuSpritePoints() { for(std::vector::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++) diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index f822780..dda6569 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -89,7 +89,8 @@ public: void allocateGraphicsMemory(); void deInitializeFonts( ); void initializeFonts( ); - void launchEnter(); + void playSelect(); + bool isSelectPlaying(); std::string getCollectionName(); void setMinShowTime(float value); float getMinShowTime(); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 7ae7351..760f772 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -136,9 +136,7 @@ int RetroFE::initialize( void *context ) void RetroFE::launchEnter( ) { - // Play launch sound - currentPage_->launchEnter( ); - + // Disable window focus SDL_SetWindowGrab(SDL::getWindow(), SDL_FALSE); // Free the textures, and optionally take down SDL @@ -615,13 +613,14 @@ void RetroFE::run( ) // Launching game; start onGameEnter animation case RETROFE_LAUNCH_ENTER: - currentPage_->enterGame( ); + currentPage_->enterGame( ); // Start onGameEnter animation + currentPage_->playSelect( ); // Play launch sound state = RETROFE_LAUNCH_REQUEST; break; // Wait for onGameEnter animation to finish; launch game; start onGameExit animation case RETROFE_LAUNCH_REQUEST: - if ( currentPage_->isIdle( ) ) + if ( currentPage_->isIdle( ) && !currentPage_->isSelectPlaying( ) ) { nextPageItem_ = currentPage_->getSelectedItem( ); launchEnter( ); diff --git a/RetroFE/Source/Sound/Sound.cpp b/RetroFE/Source/Sound/Sound.cpp index 02861c7..41fc1f1 100644 --- a/RetroFE/Source/Sound/Sound.cpp +++ b/RetroFE/Source/Sound/Sound.cpp @@ -21,6 +21,7 @@ Sound::Sound(std::string file, std::string altfile) : file_(file) , chunk_(NULL) + , channel_(-1) { if(!allocate()) { @@ -45,7 +46,7 @@ void Sound::play() { if(chunk_) { - (void)Mix_PlayChannel(-1, chunk_, 0); + channel_ = Mix_PlayChannel(-1, chunk_, 0); } } @@ -54,7 +55,8 @@ bool Sound::free() if(chunk_) { Mix_FreeChunk(chunk_); - chunk_ = NULL; + chunk_ = NULL; + channel_ = -1; } return true; @@ -69,3 +71,9 @@ bool Sound::allocate() return (chunk_ != NULL); } + + +bool Sound::isPlaying() +{ + return (channel_ != -1) && Mix_Playing(channel_); +} diff --git a/RetroFE/Source/Sound/Sound.h b/RetroFE/Source/Sound/Sound.h index 3f06682..140c0c3 100644 --- a/RetroFE/Source/Sound/Sound.h +++ b/RetroFE/Source/Sound/Sound.h @@ -25,7 +25,9 @@ public: void play(); bool allocate(); bool free(); + bool isPlaying(); private: std::string file_; - Mix_Chunk *chunk_; + Mix_Chunk *chunk_; + int channel_; }; diff --git a/RetroFE/Source/Version.cpp b/RetroFE/Source/Version.cpp index c23eba3..e013370 100644 --- a/RetroFE/Source/Version.cpp +++ b/RetroFE/Source/Version.cpp @@ -21,7 +21,7 @@ std::string retrofe_version_major = "0"; std::string retrofe_version_minor = "8"; -std::string retrofe_version_build = "13"; +std::string retrofe_version_build = "14"; std::string Version::getString( )