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