added ability to reference sound and videos in lua using variables: {TECHTREEPATH}, {SCENARIOPATH}, {TUTORIALPATH} example:

playStreamingSound('{SCENARIOPATH}/music/myambient.ogg')
This commit is contained in:
Mark Vejvoda
2013-05-28 02:54:23 +00:00
parent 7ee5d2b300
commit 72480bc576
5 changed files with 96 additions and 16 deletions

View File

@@ -43,6 +43,10 @@ namespace Shared{ namespace Util{
string Properties::applicationPath = "";
string Properties::gameVersion = "";
string Properties::techtreePath = "";
string Properties::scenarioPath = "";
string Properties::tutorialPath = "";
// =====================================================
// class Properties
// =====================================================
@@ -232,6 +236,10 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
#endif
mapTagReplacementValues["{TECHTREEPATH}"] = Properties::techtreePath;
mapTagReplacementValues["{SCENARIOPATH}"] = Properties::scenarioPath;
mapTagReplacementValues["{TUTORIALPATH}"] = Properties::tutorialPath;
mapTagReplacementValues["$GAMEVERSION"] = Properties::gameVersion;
//
@@ -258,7 +266,15 @@ bool Properties::applyTagsToValue(string &value, const std::map<string,string> *
if(mapTagReplacementValues != NULL) {
for(std::map<string,string>::const_iterator iterMap = mapTagReplacementValues->begin();
iterMap != mapTagReplacementValues->end(); ++iterMap) {
// if(value.find("{SCENARIOPATH}") != string::npos) {
// printf("\n\n** WILL REPLACE [%s]\n",value.c_str());
// replaceAll(value, "{SCENARIOPATH}", Properties::scenarioPath);
// printf("** REPLACED [%s]\n\n",value.c_str());
// }
// else {
replaceAll(value, iterMap->first, iterMap->second);
// }
}
}
else {
@@ -319,6 +335,14 @@ bool Properties::applyTagsToValue(string &value, const std::map<string,string> *
#endif
replaceAll(value, "{TECHTREEPATH}", Properties::techtreePath);
// if(value.find("{SCENARIOPATH}") != string::npos) {
// printf("\n\n** WILL REPLACE [%s]\n",value.c_str());
replaceAll(value, "{SCENARIOPATH}", Properties::scenarioPath);
// printf("** REPLACED [%s]\n\n",value.c_str());
// }
replaceAll(value, "{TUTORIALPATH}", Properties::tutorialPath);
replaceAll(value, "$GAMEVERSION", Properties::gameVersion);
}