Refactored audio sample playback
This commit is contained in:
@@ -201,7 +201,7 @@ public:
|
||||
void eventblocked(MTGCardInstance * opponent);
|
||||
|
||||
int isInPlay(GameObserver* game);
|
||||
JSample * getSample();
|
||||
const string& getSample();
|
||||
|
||||
JQuadPtr getIcon();
|
||||
|
||||
|
||||
@@ -73,7 +73,12 @@ public:
|
||||
}
|
||||
|
||||
virtual bool IsThreaded() = 0;
|
||||
|
||||
void PlaySample(const string& fileName) {
|
||||
JSample*sample = RetrieveSample(fileName);
|
||||
if(sample) {
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
}
|
||||
};
|
||||
virtual JQuadPtr RetrieveCard(MTGCard * card, int style = RETRIEVE_NORMAL,int submode = CACHE_NORMAL) = 0;
|
||||
virtual JSample * RetrieveSample(const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL) = 0;
|
||||
virtual JTexture * RetrieveTexture(const string& filename, int style = RETRIEVE_NORMAL, int submode = CACHE_NORMAL) = 0;
|
||||
|
||||
@@ -309,11 +309,9 @@ int Spell::resolve()
|
||||
//Play SFX
|
||||
if (options[Options::SFXVOLUME].number > 0)
|
||||
{
|
||||
JSample * sample = source->getSample();
|
||||
if (sample)
|
||||
{
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
}
|
||||
|
||||
if(observer->getResourceManager())
|
||||
observer->getResourceManager()->PlaySample(source->getSample());
|
||||
}
|
||||
AbilityFactory af(observer);
|
||||
af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), this);
|
||||
@@ -967,15 +965,26 @@ void ActionStack::Update(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
void ActionStack::cancelInterruptOffer(InterruptDecision cancelMode, bool log)
|
||||
void ActionStack::cancelInterruptOffer(InterruptDecision cancelMode, bool log, Player* cancelMe)
|
||||
{
|
||||
int playerId = (observer->isInterrupting == observer->players[1]) ? 1 : 0;
|
||||
int playerId;
|
||||
if(cancelMe != NULL) {
|
||||
if(observer->players[1] == cancelMe)
|
||||
playerId = 1;
|
||||
else
|
||||
playerId = 0;
|
||||
} else {
|
||||
playerId = (observer->isInterrupting == observer->players[1]) ? 1 : 0;
|
||||
}
|
||||
interruptDecision[playerId] = cancelMode;
|
||||
askIfWishesToInterrupt = NULL;
|
||||
observer->isInterrupting = NULL;
|
||||
timer = -1;
|
||||
if(log)
|
||||
observer->logAction(playerId, "no");
|
||||
if(log) {
|
||||
stringstream stream;
|
||||
stream << "no " << cancelMode;
|
||||
observer->logAction(playerId, stream.str());
|
||||
}
|
||||
}
|
||||
|
||||
void ActionStack::endOfInterruption(bool log)
|
||||
|
||||
@@ -4344,9 +4344,7 @@ void ATutorialMessage::Render()
|
||||
|
||||
if (options[Options::SFXVOLUME].number > 0)
|
||||
{
|
||||
JSample * sample = game->getResourceManager()->RetrieveSample("tutorial.wav");
|
||||
if (sample)
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
game->getResourceManager()->PlaySample("tutorial.wav");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -4381,9 +4379,7 @@ void ATutorialMessage::Render()
|
||||
|
||||
if (options[Options::SFXVOLUME].number > 0)
|
||||
{
|
||||
JSample * sample = game->getResourceManager()->RetrieveSample("chain.wav");
|
||||
if (sample)
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
game->getResourceManager()->PlaySample("chain.wav");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,11 +293,7 @@ void Credits::compute(GameObserver* g, GameApp * _app)
|
||||
|
||||
if (unlocked && options[Options::SFXVOLUME].number > 0)
|
||||
{
|
||||
JSample * sample = WResourceManager::Instance()->RetrieveSample("bonus.wav");
|
||||
if (sample)
|
||||
{
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
}
|
||||
WResourceManager::Instance()->PlaySample("bonus.wav");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4770,9 +4770,7 @@ int AManaProducer::reactToClick(MTGCardInstance * _card)
|
||||
|
||||
if (options[Options::SFXVOLUME].number > 0)
|
||||
{
|
||||
JSample * sample = WResourceManager::Instance()->RetrieveSample("mana.wav");
|
||||
if (sample)
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
WResourceManager::Instance()->PlaySample("mana.wav");
|
||||
}
|
||||
return ActivatedAbility::activateAbility();
|
||||
}
|
||||
|
||||
@@ -1023,12 +1023,10 @@ int MTGCardInstance::cantBeBlockedBy(MTGCardInstance * card)
|
||||
}
|
||||
|
||||
/* Choose a sound sample to associate to that card */
|
||||
JSample * MTGCardInstance::getSample()
|
||||
const string& MTGCardInstance::getSample()
|
||||
{
|
||||
JSample * js = 0;
|
||||
|
||||
if (sample.size())
|
||||
return WResourceManager::Instance()->RetrieveSample(sample);
|
||||
return sample;
|
||||
|
||||
for (int i = types.size() - 1; i > 0; i--)
|
||||
{
|
||||
@@ -1037,11 +1035,10 @@ JSample * MTGCardInstance::getSample()
|
||||
type = type + ".wav";
|
||||
if(getObserver() && getObserver()->getResourceManager())
|
||||
{
|
||||
js = WResourceManager::Instance()->RetrieveSample(type);
|
||||
if (js)
|
||||
if (getObserver()->getResourceManager()->RetrieveSample(type))
|
||||
{
|
||||
sample = string(type);
|
||||
return js;
|
||||
return sample;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1056,11 +1053,10 @@ JSample * MTGCardInstance::getSample()
|
||||
type = type + ".wav";
|
||||
if(getObserver() && getObserver()->getResourceManager())
|
||||
{
|
||||
js = WResourceManager::Instance()->RetrieveSample(type);
|
||||
if (js)
|
||||
if (getObserver()->getResourceManager()->RetrieveSample(type))
|
||||
{
|
||||
sample = string(type);
|
||||
return js;
|
||||
return sample;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1068,21 +1064,20 @@ JSample * MTGCardInstance::getSample()
|
||||
|
||||
string type = "";
|
||||
if(!types.size())
|
||||
return NULL;
|
||||
return sample;
|
||||
type = Subtypes::subtypesList->find(types[0]);
|
||||
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
||||
type.append(".wav");
|
||||
if(getObserver() && getObserver()->getResourceManager())
|
||||
{
|
||||
js = WResourceManager::Instance()->RetrieveSample(type);
|
||||
if (js)
|
||||
if (getObserver()->getResourceManager()->RetrieveSample(type))
|
||||
{
|
||||
sample = string(type);
|
||||
return js;
|
||||
return sample;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return sample;
|
||||
}
|
||||
|
||||
int MTGCardInstance::stepPower(CombatStep step)
|
||||
|
||||
@@ -327,9 +327,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
{
|
||||
if (card->isCreature() && g->getResourceManager())
|
||||
{
|
||||
JSample * sample = g->getResourceManager()->RetrieveSample("graveyard.wav");
|
||||
if (sample)
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
g->getResourceManager()->PlaySample("graveyard.wav");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,11 +175,7 @@ void StoryReward::Update(float dt)
|
||||
|
||||
if (!rewardSoundPlayed && options[Options::SFXVOLUME].number > 0)
|
||||
{
|
||||
JSample * sample = WResourceManager::Instance()->RetrieveSample("bonus.wav");
|
||||
if (sample)
|
||||
{
|
||||
JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
}
|
||||
WResourceManager::Instance()->PlaySample("bonus.wav");
|
||||
rewardSoundPlayed = 1;
|
||||
}
|
||||
rewardDone = 1;
|
||||
|
||||
Reference in New Issue
Block a user