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:
parent
7ee5d2b300
commit
72480bc576
|
@ -140,6 +140,9 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
||||||
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
|
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
|
||||||
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
|
loadedFileList[path].push_back(make_pair(currentPath,currentPath));
|
||||||
|
|
||||||
|
Properties::setTechtreePath(currentPath);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("==> Set techtree path to [%s]\n",currentPath.c_str());
|
||||||
|
|
||||||
const XmlNode *techTreeNode= xmlTree.getRootNode();
|
const XmlNode *techTreeNode= xmlTree.getRootNode();
|
||||||
|
|
||||||
//attack types
|
//attack types
|
||||||
|
|
|
@ -55,6 +55,24 @@ Checksum Scenario::load(const string &path) {
|
||||||
Logger::getInstance().add(szBuf, true);
|
Logger::getInstance().add(szBuf, true);
|
||||||
|
|
||||||
bool isTutorial = Scenario::isGameTutorial(path);
|
bool isTutorial = Scenario::isGameTutorial(path);
|
||||||
|
|
||||||
|
//Properties::setTechtreePath();
|
||||||
|
|
||||||
|
string scenarioFolder = cutLastFile(formatPath(path));
|
||||||
|
scenarioFolder = cutLastFile(scenarioFolder);
|
||||||
|
endPathWithSlash(scenarioFolder);
|
||||||
|
|
||||||
|
if(isTutorial == false) {
|
||||||
|
Properties::setScenarioPath(scenarioFolder);
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("==> Set scenario path to [%s]\n",scenarioFolder.c_str());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Properties::setTutorialPath(scenarioFolder);
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("==> Set tutorial path to [%s]\n",scenarioFolder.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
Scenario::loadScenarioInfo(path, &info, isTutorial);
|
Scenario::loadScenarioInfo(path, &info, isTutorial);
|
||||||
|
|
||||||
//parse xml
|
//parse xml
|
||||||
|
|
|
@ -1496,38 +1496,50 @@ void World::giveAttackStoppedCommand(int unitId, const string &itemName, bool ig
|
||||||
void World::playStaticSound(const string &playSound) {
|
void World::playStaticSound(const string &playSound) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] playSound [%s]\n",__FILE__,__FUNCTION__,__LINE__,playSound.c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] playSound [%s]\n",__FILE__,__FUNCTION__,__LINE__,playSound.c_str());
|
||||||
|
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
string calculatedFilePath = playSound;
|
||||||
|
bool changed = Properties::applyTagsToValue(calculatedFilePath);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nPlay static sound changed: %d [%s] [%s]\n\n",changed, playSound.c_str(),calculatedFilePath.c_str());
|
||||||
|
|
||||||
if(staticSoundList.find(playSound) == staticSoundList.end()) {
|
if(staticSoundList.find(calculatedFilePath) == staticSoundList.end()) {
|
||||||
StaticSound *sound = new StaticSound();
|
StaticSound *sound = new StaticSound();
|
||||||
sound->load(playSound);
|
sound->load(calculatedFilePath);
|
||||||
staticSoundList[playSound] = sound;
|
staticSoundList[calculatedFilePath] = sound;
|
||||||
}
|
}
|
||||||
StaticSound *playSoundItem = staticSoundList[playSound];
|
StaticSound *playSoundItem = staticSoundList[calculatedFilePath];
|
||||||
|
|
||||||
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
soundRenderer.playFx(playSoundItem);
|
soundRenderer.playFx(playSoundItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::playStreamingSound(const string &playSound) {
|
void World::playStreamingSound(const string &playSound) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] playSound [%s]\n",__FILE__,__FUNCTION__,__LINE__,playSound.c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] playSound [%s]\n",__FILE__,__FUNCTION__,__LINE__,playSound.c_str());
|
||||||
|
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
string calculatedFilePath = playSound;
|
||||||
|
bool changed = Properties::applyTagsToValue(calculatedFilePath);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nPlay streaming sound changed: %d [%s] [%s]\n\n",changed, playSound.c_str(),calculatedFilePath.c_str());
|
||||||
|
|
||||||
if(streamSoundList.find(playSound) == streamSoundList.end()) {
|
if(streamSoundList.find(calculatedFilePath) == streamSoundList.end()) {
|
||||||
StrSound *sound = new StrSound();
|
StrSound *sound = new StrSound();
|
||||||
sound->open(playSound);
|
sound->open(calculatedFilePath);
|
||||||
sound->setNext(sound);
|
sound->setNext(sound);
|
||||||
streamSoundList[playSound] = sound;
|
streamSoundList[calculatedFilePath] = sound;
|
||||||
}
|
}
|
||||||
StrSound *playSoundItem = streamSoundList[playSound];
|
StrSound *playSoundItem = streamSoundList[calculatedFilePath];
|
||||||
|
|
||||||
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
soundRenderer.playMusic(playSoundItem);
|
soundRenderer.playMusic(playSoundItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::stopStreamingSound(const string &playSound) {
|
void World::stopStreamingSound(const string &playSound) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] playSound [%s]\n",__FILE__,__FUNCTION__,__LINE__,playSound.c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] playSound [%s]\n",__FILE__,__FUNCTION__,__LINE__,playSound.c_str());
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
|
||||||
|
|
||||||
if(streamSoundList.find(playSound) != streamSoundList.end()) {
|
string calculatedFilePath = playSound;
|
||||||
StrSound *playSoundItem = streamSoundList[playSound];
|
bool changed = Properties::applyTagsToValue(calculatedFilePath);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nStop streaming sound changed: %d [%s] [%s]\n\n",changed, playSound.c_str(),calculatedFilePath.c_str());
|
||||||
|
|
||||||
|
if(streamSoundList.find(calculatedFilePath) != streamSoundList.end()) {
|
||||||
|
StrSound *playSoundItem = streamSoundList[calculatedFilePath];
|
||||||
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
soundRenderer.stopMusic(playSoundItem);
|
soundRenderer.stopMusic(playSoundItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2545,15 +2557,27 @@ int World::getNextCommandGroupId() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::playStaticVideo(const string &playVideo) {
|
void World::playStaticVideo(const string &playVideo) {
|
||||||
this->game->playStaticVideo(playVideo);
|
string calculatedFilePath = playVideo;
|
||||||
|
bool changed = Properties::applyTagsToValue(calculatedFilePath);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nPlay static video changed: %d [%s] [%s]\n\n",changed, playVideo.c_str(),calculatedFilePath.c_str());
|
||||||
|
|
||||||
|
this->game->playStaticVideo(calculatedFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::playStreamingVideo(const string &playVideo) {
|
void World::playStreamingVideo(const string &playVideo) {
|
||||||
this->game->playStreamingVideo(playVideo);
|
string calculatedFilePath = playVideo;
|
||||||
|
bool changed = Properties::applyTagsToValue(calculatedFilePath);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nPlay streaming video changed: %d [%s] [%s]\n\n",changed, playVideo.c_str(),calculatedFilePath.c_str());
|
||||||
|
|
||||||
|
this->game->playStreamingVideo(calculatedFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::stopStreamingVideo(const string &playVideo) {
|
void World::stopStreamingVideo(const string &playVideo) {
|
||||||
this->game->stopStreamingVideo(playVideo);
|
string calculatedFilePath = playVideo;
|
||||||
|
bool changed = Properties::applyTagsToValue(calculatedFilePath);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nStop streaming video changed: %d [%s] [%s]\n\n",changed, playVideo.c_str(),calculatedFilePath.c_str());
|
||||||
|
|
||||||
|
this->game->stopStreamingVideo(calculatedFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::stopAllVideo() {
|
void World::stopAllVideo() {
|
||||||
|
|
|
@ -49,6 +49,10 @@ private:
|
||||||
static string applicationPath;
|
static string applicationPath;
|
||||||
static string gameVersion;
|
static string gameVersion;
|
||||||
|
|
||||||
|
static string techtreePath;
|
||||||
|
static string scenarioPath;
|
||||||
|
static string tutorialPath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void setApplicationPath(string value) { applicationPath=value; }
|
static void setApplicationPath(string value) { applicationPath=value; }
|
||||||
static string getApplicationPath() { return applicationPath; }
|
static string getApplicationPath() { return applicationPath; }
|
||||||
|
@ -56,6 +60,13 @@ public:
|
||||||
static void setGameVersion(string value) { gameVersion=value; }
|
static void setGameVersion(string value) { gameVersion=value; }
|
||||||
static string getGameVersion() { return gameVersion; }
|
static string getGameVersion() { return gameVersion; }
|
||||||
|
|
||||||
|
static void setTechtreePath(string value) { techtreePath=value; }
|
||||||
|
static string getTechtreePath() { return techtreePath; }
|
||||||
|
static void setScenarioPath(string value) { scenarioPath=value; }
|
||||||
|
static string getScenarioPath() { return scenarioPath; }
|
||||||
|
static void setTutorialPath(string value) { tutorialPath=value; }
|
||||||
|
static string getTutorialPath() { return tutorialPath; }
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void load(const string &path,bool clearCurrentProperties=true);
|
void load(const string &path,bool clearCurrentProperties=true);
|
||||||
void save(const string &path);
|
void save(const string &path);
|
||||||
|
|
|
@ -43,6 +43,10 @@ namespace Shared{ namespace Util{
|
||||||
string Properties::applicationPath = "";
|
string Properties::applicationPath = "";
|
||||||
string Properties::gameVersion = "";
|
string Properties::gameVersion = "";
|
||||||
|
|
||||||
|
string Properties::techtreePath = "";
|
||||||
|
string Properties::scenarioPath = "";
|
||||||
|
string Properties::tutorialPath = "";
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Properties
|
// class Properties
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -232,6 +236,10 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
mapTagReplacementValues["{TECHTREEPATH}"] = Properties::techtreePath;
|
||||||
|
mapTagReplacementValues["{SCENARIOPATH}"] = Properties::scenarioPath;
|
||||||
|
mapTagReplacementValues["{TUTORIALPATH}"] = Properties::tutorialPath;
|
||||||
|
|
||||||
mapTagReplacementValues["$GAMEVERSION"] = Properties::gameVersion;
|
mapTagReplacementValues["$GAMEVERSION"] = Properties::gameVersion;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -258,7 +266,15 @@ bool Properties::applyTagsToValue(string &value, const std::map<string,string> *
|
||||||
if(mapTagReplacementValues != NULL) {
|
if(mapTagReplacementValues != NULL) {
|
||||||
for(std::map<string,string>::const_iterator iterMap = mapTagReplacementValues->begin();
|
for(std::map<string,string>::const_iterator iterMap = mapTagReplacementValues->begin();
|
||||||
iterMap != mapTagReplacementValues->end(); ++iterMap) {
|
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);
|
replaceAll(value, iterMap->first, iterMap->second);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -319,6 +335,14 @@ bool Properties::applyTagsToValue(string &value, const std::map<string,string> *
|
||||||
|
|
||||||
#endif
|
#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);
|
replaceAll(value, "$GAMEVERSION", Properties::gameVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user