Jeck - As prior, but for sounds and music as well. Use CommonRes->ssLoadMusic / CommonRes->ssLoadSample.
This commit is contained in:
@@ -193,7 +193,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
|
||||
SAFE_DELETE(GameApp::music);
|
||||
}
|
||||
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/track1.mp3");
|
||||
GameApp::music = GameApp::CommonRes->ssLoadMusic("track1.mp3");
|
||||
if (GameApp::music){
|
||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,11 @@ public:
|
||||
JSample* GetSample(const string &sampleName);
|
||||
JSample* GetSample(int id);
|
||||
|
||||
//Wrapped from JRenderer, if we need it.
|
||||
//Wrapped from other bits, if we want them.
|
||||
JTexture* LoadTexture(const char* filename, int mode = 0, int textureFormat = TEXTURE_FORMAT);
|
||||
//Wrapped from JSoundSystem
|
||||
JMusic * ssLoadMusic(const char *fileName);
|
||||
JSample * ssLoadSample(const char *fileName);
|
||||
|
||||
//Our new redirect system.
|
||||
string graphicsFile(const string filename, const string specific = "");
|
||||
|
||||
@@ -103,7 +103,7 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
||||
options.save();
|
||||
}
|
||||
if (unlocked){
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav");
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("bonus.wav");
|
||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,12 +66,17 @@ void GameApp::Create()
|
||||
options.theGame = this;
|
||||
|
||||
//Test for Music files presence
|
||||
std::ifstream file(RESPATH"/sound/Track0.mp3");
|
||||
string filepath = RESPATH;
|
||||
filepath = filepath + "/" + CommonRes->musicFile("Track0.mp3");
|
||||
std::ifstream file(filepath.c_str());
|
||||
if (file)
|
||||
file.close();
|
||||
else
|
||||
HasMusic = 0;
|
||||
std::ifstream file2(RESPATH"/sound/Track1.mp3");
|
||||
|
||||
filepath = RESPATH;
|
||||
filepath = filepath + "/" + CommonRes->musicFile("Track1.mp3");
|
||||
std::ifstream file2(filepath.c_str());
|
||||
if (file2)
|
||||
file2.close();
|
||||
else
|
||||
|
||||
@@ -150,7 +150,7 @@ void GameStateMenu::Start(){
|
||||
subMenuController = NULL;
|
||||
|
||||
if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){
|
||||
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/Track0.mp3");
|
||||
GameApp::music = GameApp::CommonRes->ssLoadMusic("Track0.mp3");
|
||||
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -2334,7 +2334,7 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output,
|
||||
if (tap) source->tap();
|
||||
|
||||
if (options[Options::SFXVOLUME].number > 0){
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("mana.wav");
|
||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
}
|
||||
return resolve();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -150,7 +150,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
if (options[Options::SFXVOLUME].number > 0){
|
||||
if (to == g->players[0]->game->graveyard || to == g->players[1]->game->graveyard){
|
||||
if (card->isCreature()){
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/graveyard.wav");
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("graveyard.wav");
|
||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,10 +158,10 @@ JSample * SampleCache::getSample(string filename){
|
||||
map<string,SampleCached *>::iterator it = cache.find(filename);
|
||||
if (it == cache.end()){
|
||||
if (cache.size() >10) cleanOldest(); //Poor man's limit
|
||||
JSample * sample = JSoundSystem::GetInstance()->LoadSample(filename.c_str());
|
||||
if (!sample && fileExists(filename.c_str())){ //Out of Ram ??
|
||||
JSample * sample = GameApp::CommonRes->ssLoadSample(filename.c_str());
|
||||
if (!sample && fileExists(GameApp::CommonRes->sfxFile(filename).c_str())){ //Out of Ram ??
|
||||
cleanCache();
|
||||
sample = JSoundSystem::GetInstance()->LoadSample(filename.c_str());
|
||||
sample = GameApp::CommonRes->ssLoadSample(filename.c_str());
|
||||
}
|
||||
|
||||
cache[filename] = NEW SampleCached(lastTime, sample);
|
||||
|
||||
@@ -206,4 +206,11 @@ JSample* WResourceManager::GetSample(int id){
|
||||
|
||||
JTexture* WResourceManager::LoadTexture(const char* filename, int mode, int textureFormat){
|
||||
return JRenderer::GetInstance()->LoadTexture(graphicsFile(filename).c_str(),mode,textureFormat);
|
||||
}
|
||||
|
||||
JMusic * WResourceManager::ssLoadMusic(const char *fileName){
|
||||
return JSoundSystem::GetInstance()->LoadMusic(musicFile(fileName).c_str());
|
||||
}
|
||||
JSample * WResourceManager::ssLoadSample(const char *fileName){
|
||||
return JSoundSystem::GetInstance()->LoadSample(sfxFile(fileName).c_str());
|
||||
}
|
||||
Reference in New Issue
Block a user