core_data.cpp: add function to play sounds

This function can be used to pass different arguments to it, so the
other play sfx functions (below it) can be removed.

(#63)
This commit is contained in:
andy5995
2018-02-21 09:10:15 -06:00
parent 1f1233e0db
commit c0006da18a
2 changed files with 28 additions and 0 deletions

View File

@@ -722,6 +722,32 @@ namespace Glest
return &clickSoundC;
}
StaticSound *CoreData::getSound (const std::string& iniPlaySoundVal)
{
int loadAttemptLookupKey = tsyst_COUNT + 6;
if (itemLoadAttempted.find (loadAttemptLookupKey) ==
itemLoadAttempted.end ())
{
itemLoadAttempted[loadAttemptLookupKey] = true;
try
{
static Config & config = Config::getInstance ();
iniPlaySound.load (config.getString (iniPlaySoundVal, ""));
}
catch (const megaglest_runtime_error & ex)
{
message (ex.what (),
GlobalStaticFlags::getIsNonGraphicalModeEnabled (),
tempDataLocation);
}
}
return &iniPlaySound;
}
StaticSound *CoreData::getAttentionSound ()
{
int loadAttemptLookupKey = tsyst_COUNT + 6;

View File

@@ -66,6 +66,7 @@ namespace Glest
StaticSound clickSoundA;
StaticSound clickSoundB;
StaticSound clickSoundC;
StaticSound iniPlaySound;
StaticSound attentionSound;
StaticSound newServerSound;
StaticSound highlightSound;
@@ -212,6 +213,7 @@ namespace Glest
StaticSound *getClickSoundA ();
StaticSound *getClickSoundB ();
StaticSound *getClickSoundC ();
StaticSound *getSound (const std::string& iniPlaySoundVal);
StaticSound *getAttentionSound ();
StaticSound *getNewServerSound ();
StaticSound *getHighlightSound ();