- added support for custom music on battle end screen:
look for music in the following order: 1. check faction xml file for the following attributes (depends on win/lose) on the faction tag: faction-battle-end-win-music="<path to music>" faction-battle-end-lose-music="<path to music>" if not defined 2. check the faction folder for the files: battle_end_win_music.* battle_end_lose_music.* if not found check the data/core/menu/music/ paths for: battle_end_win.* battle_end_lose.*
This commit is contained in:
parent
3ede912b9a
commit
75011d84d5
|
@ -83,8 +83,10 @@ CoreData::CoreData() {
|
||||||
|
|
||||||
battleEndWinVideoFilename="";
|
battleEndWinVideoFilename="";
|
||||||
battleEndWinVideoFilenameFallback="";
|
battleEndWinVideoFilenameFallback="";
|
||||||
|
battleEndWinMusicFilename="";
|
||||||
battleEndLoseVideoFilename="";
|
battleEndLoseVideoFilename="";
|
||||||
battleEndLoseVideoFilenameFallback="";
|
battleEndLoseVideoFilenameFallback="";
|
||||||
|
battleEndLoseMusicFilename="";
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreData::~CoreData() {
|
CoreData::~CoreData() {
|
||||||
|
@ -483,6 +485,7 @@ void CoreData::load() {
|
||||||
|
|
||||||
battleEndWinVideoFilename = config.getString("BattleEndWinVideoURL","");
|
battleEndWinVideoFilename = config.getString("BattleEndWinVideoURL","");
|
||||||
battleEndWinVideoFilenameFallback = config.getString("BattleEndWinVideoURLFallback","");
|
battleEndWinVideoFilenameFallback = config.getString("BattleEndWinVideoURLFallback","");
|
||||||
|
|
||||||
if(battleEndWinVideoFilename == "") {
|
if(battleEndWinVideoFilename == "") {
|
||||||
string battleEndWinVideoPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/battle_end_win.*";
|
string battleEndWinVideoPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/battle_end_win.*";
|
||||||
vector<string> battleEndWinVideos;
|
vector<string> battleEndWinVideos;
|
||||||
|
@ -515,8 +518,42 @@ void CoreData::load() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
battleEndWinMusicFilename = config.getString("BattleEndWinMusicFilename","");
|
||||||
|
if(battleEndWinMusicFilename == "") {
|
||||||
|
string battleEndWinPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/music/battle_end_win.*";
|
||||||
|
vector<string> battleEndWinMusic;
|
||||||
|
findAll(battleEndWinPath, battleEndWinMusic, false, false);
|
||||||
|
for(int i = 0; i < battleEndWinMusic.size(); ++i) {
|
||||||
|
string music = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/music/" + battleEndWinMusic[i];
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Checking if battle end win music [%s] exists\n",music.c_str());
|
||||||
|
|
||||||
|
if(fileExists(music)) {
|
||||||
|
battleEndWinMusicFilename = music;
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FOUND battle end win music [%s] will use this file\n",music.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(battleEndWinMusicFilename == "") {
|
||||||
|
battleEndWinPath = data_path + "data/core/menu/music/battle_end_win.*";
|
||||||
|
battleEndWinMusic.clear();
|
||||||
|
findAll(battleEndWinPath, battleEndWinMusic, false, false);
|
||||||
|
for(int i = 0; i < battleEndWinMusic.size(); ++i) {
|
||||||
|
string music = data_path + "data/core/menu/music/" + battleEndWinMusic[i];
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Checking if battle end win music [%s] exists\n",music.c_str());
|
||||||
|
|
||||||
|
if(fileExists(music)) {
|
||||||
|
battleEndWinMusicFilename = music;
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FOUND battle end music win [%s] will use this file\n",music.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
battleEndLoseVideoFilename = config.getString("BattleEndLoseVideoURL","");
|
battleEndLoseVideoFilename = config.getString("BattleEndLoseVideoURL","");
|
||||||
battleEndLoseVideoFilenameFallback = config.getString("BattleEndLoseVideoURLFallback","");
|
battleEndLoseVideoFilenameFallback = config.getString("BattleEndLoseVideoURLFallback","");
|
||||||
|
|
||||||
if(battleEndLoseVideoFilename == "") {
|
if(battleEndLoseVideoFilename == "") {
|
||||||
string battleEndLoseVideoPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/battle_end_lose.*";
|
string battleEndLoseVideoPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/battle_end_lose.*";
|
||||||
vector<string> battleEndLoseVideos;
|
vector<string> battleEndLoseVideos;
|
||||||
|
@ -549,6 +586,38 @@ void CoreData::load() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
battleEndLoseMusicFilename = config.getString("BattleEndLoseMusicFilename","");
|
||||||
|
if(battleEndLoseMusicFilename == "") {
|
||||||
|
string battleEndLosePath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/music/battle_end_lose.*";
|
||||||
|
vector<string> battleEndLoseMusic;
|
||||||
|
findAll(battleEndLosePath, battleEndLoseMusic, false, false);
|
||||||
|
for(int i = 0; i < battleEndLoseMusic.size(); ++i) {
|
||||||
|
string music = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/music/" + battleEndLoseMusic[i];
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Checking if battle end lose music [%s] exists\n",music.c_str());
|
||||||
|
|
||||||
|
if(fileExists(music)) {
|
||||||
|
battleEndLoseMusicFilename = music;
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FOUND battle end lose music [%s] will use this file\n",music.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(battleEndLoseMusicFilename == "") {
|
||||||
|
battleEndLosePath = data_path + "data/core/menu/music/battle_end_lose.*";
|
||||||
|
battleEndLoseMusic.clear();
|
||||||
|
findAll(battleEndLosePath, battleEndLoseMusic, false, false);
|
||||||
|
for(int i = 0; i < battleEndLoseMusic.size(); ++i) {
|
||||||
|
string music = data_path + "data/core/menu/music/" + battleEndLoseMusic[i];
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Checking if battle end lose music [%s] exists\n",music.c_str());
|
||||||
|
|
||||||
|
if(fileExists(music)) {
|
||||||
|
battleEndLoseMusicFilename = music;
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FOUND battle end music lose [%s] will use this file\n",music.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,12 +91,17 @@ private:
|
||||||
|
|
||||||
string introVideoFilename;
|
string introVideoFilename;
|
||||||
string introVideoFilenameFallback;
|
string introVideoFilenameFallback;
|
||||||
|
|
||||||
string mainMenuVideoFilename;
|
string mainMenuVideoFilename;
|
||||||
string mainMenuVideoFilenameFallback;
|
string mainMenuVideoFilenameFallback;
|
||||||
|
|
||||||
string battleEndWinVideoFilename;
|
string battleEndWinVideoFilename;
|
||||||
string battleEndWinVideoFilenameFallback;
|
string battleEndWinVideoFilenameFallback;
|
||||||
|
string battleEndWinMusicFilename;
|
||||||
|
|
||||||
string battleEndLoseVideoFilename;
|
string battleEndLoseVideoFilename;
|
||||||
string battleEndLoseVideoFilenameFallback;
|
string battleEndLoseVideoFilenameFallback;
|
||||||
|
string battleEndLoseMusicFilename;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -200,6 +205,8 @@ public:
|
||||||
string getBattleEndVideoFilenameFallback(bool won) const { return won == true ? battleEndWinVideoFilenameFallback : battleEndLoseVideoFilenameFallback; }
|
string getBattleEndVideoFilenameFallback(bool won) const { return won == true ? battleEndWinVideoFilenameFallback : battleEndLoseVideoFilenameFallback; }
|
||||||
bool hasBattleEndVideoFilenameFallback(bool won) const;
|
bool hasBattleEndVideoFilenameFallback(bool won) const;
|
||||||
|
|
||||||
|
string getBattleEndMusicFilename(bool won) const { return won == true ? battleEndWinMusicFilename : battleEndLoseMusicFilename; }
|
||||||
|
|
||||||
void saveGameSettingsToFile(std::string fileName, GameSettings *gameSettings,int advancedIndex=0);
|
void saveGameSettingsToFile(std::string fileName, GameSettings *gameSettings,int advancedIndex=0);
|
||||||
bool loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings);
|
bool loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings);
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ BattleEnd::BattleEnd(Program *program, const Stats *stats,ProgramState *originSt
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
initBackgroundVideo();
|
initBackgroundVideo();
|
||||||
|
initBackgroundMusic();
|
||||||
|
|
||||||
GraphicComponent::applyAllCustomProperties(containerName);
|
GraphicComponent::applyAllCustomProperties(containerName);
|
||||||
}
|
}
|
||||||
|
@ -175,6 +176,82 @@ std::pair<string,string> BattleEnd::getBattleEndVideo(bool won) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string BattleEnd::getBattleEndMusic(bool won) {
|
||||||
|
string result="";
|
||||||
|
string resultFallback="";
|
||||||
|
|
||||||
|
if(gameSettings != NULL) {
|
||||||
|
string currentTechName_factionPreview = gameSettings->getTech();
|
||||||
|
string currentFactionName_factionPreview = gameSettings->getFactionTypeName(stats.getThisFactionIndex());
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 tech [%s] faction [%s] won = %d\n",currentTechName_factionPreview.c_str(),currentFactionName_factionPreview.c_str(),won);
|
||||||
|
|
||||||
|
string factionDefinitionXML = Game::findFactionLogoFile(gameSettings, NULL,currentFactionName_factionPreview + ".xml");
|
||||||
|
if(factionDefinitionXML != "" && currentFactionName_factionPreview != GameConstants::RANDOMFACTION_SLOTNAME &&
|
||||||
|
currentFactionName_factionPreview != GameConstants::OBSERVER_SLOTNAME && fileExists(factionDefinitionXML) == true) {
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 tech [%s] faction [%s]\n",currentTechName_factionPreview.c_str(),currentFactionName_factionPreview.c_str());
|
||||||
|
|
||||||
|
XmlTree xmlTree;
|
||||||
|
std::map<string,string> mapExtraTagReplacementValues;
|
||||||
|
xmlTree.load(factionDefinitionXML, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
|
||||||
|
const XmlNode *factionNode= xmlTree.getRootNode();
|
||||||
|
if(won == true) {
|
||||||
|
if(factionNode->hasAttribute("faction-battle-end-win-music") == true) {
|
||||||
|
result = factionNode->getAttribute("faction-battle-end-win-music")->getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(factionNode->hasAttribute("faction-battle-end-lose-music") == true) {
|
||||||
|
result = factionNode->getAttribute("faction-battle-end-lose-music")->getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(won == true) {
|
||||||
|
resultFallback = Game::findFactionLogoFile(gameSettings, NULL,"battle_end_win_music.*");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resultFallback = Game::findFactionLogoFile(gameSettings, NULL,"battle_end_lose_music.*");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#3 result [%s] resultFallback [%s]\n",result.c_str(),resultFallback.c_str());
|
||||||
|
|
||||||
|
if(result == "") {
|
||||||
|
result = resultFallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//printf("currentFactionName_factionPreview [%s] random [%s] observer [%s] factionVideoUrl [%s]\n",currentFactionName_factionPreview.c_str(),GameConstants::RANDOMFACTION_SLOTNAME,GameConstants::OBSERVER_SLOTNAME,factionVideoUrl.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result == "") {
|
||||||
|
result = CoreData::getInstance().getBattleEndMusicFilename(won);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BattleEnd::initBackgroundMusic() {
|
||||||
|
string music = "";
|
||||||
|
|
||||||
|
if(stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||||
|
if(stats.getVictory(stats.getThisFactionIndex())){
|
||||||
|
//header += lang.get("Victory");
|
||||||
|
music = getBattleEndMusic(true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//header += lang.get("Defeat");
|
||||||
|
music = getBattleEndMusic(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(music != "" && fileExists(music) == true) {
|
||||||
|
battleEndMusic.open(music);
|
||||||
|
|
||||||
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
|
soundRenderer.playMusic(&battleEndMusic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BattleEnd::initBackgroundVideo() {
|
void BattleEnd::initBackgroundVideo() {
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false &&
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false &&
|
||||||
Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) {
|
Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ private:
|
||||||
|
|
||||||
Shared::Graphics::VideoPlayer *menuBackgroundVideo;
|
Shared::Graphics::VideoPlayer *menuBackgroundVideo;
|
||||||
GameSettings *gameSettings;
|
GameSettings *gameSettings;
|
||||||
|
StrSound battleEndMusic;
|
||||||
|
|
||||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||||
|
|
||||||
|
@ -69,6 +70,8 @@ private:
|
||||||
|
|
||||||
void initBackgroundVideo();
|
void initBackgroundVideo();
|
||||||
std::pair<string,string> getBattleEndVideo(bool won);
|
std::pair<string,string> getBattleEndVideo(bool won);
|
||||||
|
string getBattleEndMusic(bool won);
|
||||||
|
void initBackgroundMusic();
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
Loading…
Reference in New Issue
Block a user