- cleanup ingame music patch. Let's not use this patch until we fix issue 144 maybe?
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-11-29 06:11:02 +00:00
parent ec553ddfb8
commit 5af8d83c03
2 changed files with 44 additions and 41 deletions
+1 -11
View File
@@ -34,17 +34,7 @@ class GameStateDuel: public GameState, public JGuiListener
int OpponentsDeckid; int OpponentsDeckid;
string musictrack; string musictrack;
bool MusicExist(string FileName){ bool MusicExist(string FileName);
string filepath = RESPATH;
filepath = filepath + "/" + resources.musicFile(FileName);
std::ifstream file(filepath.c_str());
if (file) {
file.close();
return true;
}
else
return false;
}
void loadPlayer(int playerId, int decknb = 0, int isAI = 0); void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
void loadPlayerMomir(int playerId, int isAI); void loadPlayerMomir(int playerId, int isAI);
void loadPlayerRandom(int playerId, int isAI, int mode); void loadPlayerRandom(int playerId, int isAI, int mode);
+43 -30
View File
@@ -68,11 +68,7 @@ void GameStateDuel::Start()
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
renderer->EnableVSync(true); renderer->EnableVSync(true);
OpponentsDeckid=0; OpponentsDeckid=0;
//stop menu music
if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music);
}
#ifdef TESTSUITE #ifdef TESTSUITE
SAFE_DELETE(testSuite); SAFE_DELETE(testSuite);
@@ -251,7 +247,18 @@ void GameStateDuel::End()
} }
//TODO Move This to utils or ResourceManager. Don't we have more generic functions that can do that?
bool GameStateDuel::MusicExist(string FileName){
string filepath = RESPATH;
filepath = filepath + "/" + resources.musicFile(FileName);
std::ifstream file(filepath.c_str());
if (file) {
file.close();
return true;
}
else
return false;
}
void GameStateDuel::Update(float dt) void GameStateDuel::Update(float dt)
{ {
@@ -338,30 +345,6 @@ void GameStateDuel::Update(float dt)
} }
break; break;
case DUEL_STATE_PLAY: case DUEL_STATE_PLAY:
//start of in game music code
musictrack = "";
//check opponent id and choose the music track based on it
if(OpponentsDeckid) {
char temp[4096];
sprintf(temp,"ai_baka_music%i.mp3",OpponentsDeckid);
musictrack.assign(temp);
}
else if(mParent->gameType == GAME_TYPE_CLASSIC)
musictrack = "ai_baka_music.mp3";
else if(mParent->gameType == GAME_TYPE_MOMIR)
musictrack = "ai_baka_music_momir.mp3";
else if(mParent->gameType == GAME_TYPE_RANDOM1 || mParent->gameType == GAME_TYPE_RANDOM2)
musictrack = "ai_baka_music_random.mp3";
if(!MusicExist(musictrack))
musictrack = "ai_baka_music.mp3";
//play the music
if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0 && MusicExist(musictrack)){
GameApp::music = resources.ssLoadMusic(musictrack.c_str());
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
}
//end of music code
if (!game){ if (!game){
GameObserver::Init(mPlayers, 2); GameObserver::Init(mPlayers, 2);
game = GameObserver::GetInstance(); game = GameObserver::GetInstance();
@@ -372,6 +355,36 @@ void GameStateDuel::Update(float dt)
game->players[i]->life+=4; game->players[i]->life+=4;
} }
} }
//stop menu music
if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music);
}
//start of in game music code
if (GameApp::HasMusic && options[Options::MUSICVOLUME].number > 0){
musictrack = "";
//check opponent id and choose the music track based on it
if(OpponentsDeckid) {
char temp[4096];
sprintf(temp,"ai_baka_music%i.mp3",OpponentsDeckid);
musictrack.assign(temp);
}
else if(mParent->gameType == GAME_TYPE_CLASSIC)
musictrack = "ai_baka_music.mp3";
else if(mParent->gameType == GAME_TYPE_MOMIR)
musictrack = "ai_baka_music_momir.mp3";
else if(mParent->gameType == GAME_TYPE_RANDOM1 || mParent->gameType == GAME_TYPE_RANDOM2)
musictrack = "ai_baka_music_random.mp3";
if(!MusicExist(musictrack))
musictrack = "ai_baka_music.mp3";
if (MusicExist(musictrack)){
GameApp::music = resources.ssLoadMusic(musictrack.c_str());
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
}
}
//end of music code
} }
// mParent->effect->UpdateSmall(dt); // mParent->effect->UpdateSmall(dt);
game->Update(dt); game->Update(dt);