Fixed console spam when music files are not installed

Closes #359
dev-mp
krzys-h 2014-11-02 13:33:37 +01:00
parent ec4b71eca2
commit 6d152d5aee
6 changed files with 38 additions and 4 deletions

View File

@ -181,6 +181,16 @@ bool ALSound::CacheMusic(const std::string &filename)
return false; return false;
} }
bool ALSound::IsCached(Sound sound)
{
return m_sounds.find(sound) != m_sounds.end();
}
bool ALSound::IsCachedMusic(const std::string &filename)
{
return m_music.find("music/"+filename) != m_music.end();
}
int ALSound::GetPriority(Sound sound) int ALSound::GetPriority(Sound sound)
{ {
if ( sound == SOUND_FLYh || if ( sound == SOUND_FLYh ||

View File

@ -53,6 +53,8 @@ public:
bool Create() override; bool Create() override;
bool Cache(Sound, const std::string &) override; bool Cache(Sound, const std::string &) override;
bool CacheMusic(const std::string &) override; bool CacheMusic(const std::string &) override;
bool IsCached(Sound) override;
bool IsCachedMusic(const std::string &) override;
bool GetEnable() override; bool GetEnable() override;

View File

@ -58,7 +58,7 @@ bool Buffer::LoadFromFile(std::string filename, Sound sound)
if (!file->IsOpen()) if (!file->IsOpen())
{ {
GetLogger()->Warn("Could not load file. Reason: %s\n", file->GetLastError().c_str()); GetLogger()->Warn("Could not load file %s. Reason: %s\n", filename.c_str(), file->GetLastError().c_str());
m_loaded = false; m_loaded = false;
return false; return false;
} }

View File

@ -72,6 +72,16 @@ bool CSoundInterface::CacheMusic(const std::string &bFile)
return true; return true;
} }
bool CSoundInterface::IsCached(Sound bSound)
{
return false;
}
bool CSoundInterface::IsCachedMusic(const std::string& bFile)
{
return false;
}
bool CSoundInterface::GetEnable() bool CSoundInterface::GetEnable()
{ {
return true; return true;

View File

@ -180,6 +180,18 @@ public:
* \return return true on success * \return return true on success
*/ */
virtual bool CacheMusic(const std::string &bFile); virtual bool CacheMusic(const std::string &bFile);
/** Function to check if sound effect file was cached.
* \param bSound - id of a sound effect file
* \return return true if the file was cached
*/
virtual bool IsCached(Sound bSound);
/** Function called to check if music file was cached.
* \param bFile - file to check
* \return return true if the file was cached
*/
virtual bool IsCachedMusic(const std::string &bFile);
/** Return if plugin is enabled /** Return if plugin is enabled
* \return return true if plugin is enabled * \return return true if plugin is enabled

View File

@ -707,7 +707,7 @@ void CMainDialog::ChangePhase(Phase phase)
m_phase != PHASE_SETUPcs && m_phase != PHASE_SETUPcs &&
m_phase != PHASE_SETUPss ) m_phase != PHASE_SETUPss )
{ {
if (!m_sound->IsPlayingMusic()) if (!m_sound->IsPlayingMusic() && m_sound->IsCachedMusic("Intro1.ogg"))
{ {
m_sound->PlayMusic("Intro1.ogg", false); m_sound->PlayMusic("Intro1.ogg", false);
} }
@ -733,7 +733,7 @@ void CMainDialog::ChangePhase(Phase phase)
} }
if ( m_phase == PHASE_TRAINER ) strcpy(m_sceneName, "exercises"); if ( m_phase == PHASE_TRAINER ) strcpy(m_sceneName, "exercises");
if ( m_phase == PHASE_DEFI ) strcpy(m_sceneName, "challenges" ); if ( m_phase == PHASE_DEFI ) strcpy(m_sceneName, "challenges");
if ( m_phase == PHASE_MISSION ) strcpy(m_sceneName, "missions"); if ( m_phase == PHASE_MISSION ) strcpy(m_sceneName, "missions");
if ( m_phase == PHASE_FREE ) strcpy(m_sceneName, "freemissions"); if ( m_phase == PHASE_FREE ) strcpy(m_sceneName, "freemissions");
if ( m_phase == PHASE_USER ) strcpy(m_sceneName, "custom"); if ( m_phase == PHASE_USER ) strcpy(m_sceneName, "custom");
@ -1760,7 +1760,7 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase != PHASE_SETUPcs && m_phase != PHASE_SETUPcs &&
m_phase != PHASE_SETUPss ) m_phase != PHASE_SETUPss )
{ {
if (!m_sound->IsPlayingMusic()) if (!m_sound->IsPlayingMusic() && m_sound->IsCachedMusic("Intro2.ogg"))
{ {
m_sound->PlayMusic("Intro2.ogg", true); m_sound->PlayMusic("Intro2.ogg", true);
} }