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

View File

@ -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();

View File

@ -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( );

View File

@ -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);
}
}
@ -55,6 +56,7 @@ bool Sound::free()
{
Mix_FreeChunk(chunk_);
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_);
}

View File

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

View File

@ -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( )