mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
wait while audio playing; no audio on custom campaigns
This commit is contained in:
parent
fc1ce85a72
commit
00f07f93d1
@ -190,6 +190,8 @@ int CSoundHandler::playSound(const AudioPath & sound, int repeats, bool cache)
|
|||||||
initCallback(channel);
|
initCallback(channel);
|
||||||
else
|
else
|
||||||
initCallback(channel, [chunk](){ Mix_FreeChunk(chunk);});
|
initCallback(channel, [chunk](){ Mix_FreeChunk(chunk);});
|
||||||
|
|
||||||
|
channelPlaying[channel] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
channel = -1;
|
channel = -1;
|
||||||
@ -209,6 +211,11 @@ void CSoundHandler::stopSound(int handler)
|
|||||||
Mix_HaltChannel(handler);
|
Mix_HaltChannel(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSoundHandler::isSoundPlaying(int handler)
|
||||||
|
{
|
||||||
|
return initialized && handler != -1 && channelPlaying[handler];
|
||||||
|
}
|
||||||
|
|
||||||
// Sets the sound volume, from 0 (mute) to 100
|
// Sets the sound volume, from 0 (mute) to 100
|
||||||
void CSoundHandler::setVolume(ui32 percent)
|
void CSoundHandler::setVolume(ui32 percent)
|
||||||
{
|
{
|
||||||
@ -252,6 +259,8 @@ void CSoundHandler::setCallback(int channel, std::function<void()> function)
|
|||||||
|
|
||||||
void CSoundHandler::soundFinishedCallback(int channel)
|
void CSoundHandler::soundFinishedCallback(int channel)
|
||||||
{
|
{
|
||||||
|
channelPlaying[channel] = false;
|
||||||
|
|
||||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||||
|
|
||||||
if (callbacks.count(channel) == 0)
|
if (callbacks.count(channel) == 0)
|
||||||
|
@ -60,6 +60,7 @@ private:
|
|||||||
|
|
||||||
std::map<AudioPath, int> ambientChannels;
|
std::map<AudioPath, int> ambientChannels;
|
||||||
std::map<int, int> channelVolumes;
|
std::map<int, int> channelVolumes;
|
||||||
|
std::map<int, bool> channelPlaying;
|
||||||
|
|
||||||
void initCallback(int channel, const std::function<void()> & function);
|
void initCallback(int channel, const std::function<void()> & function);
|
||||||
void initCallback(int channel);
|
void initCallback(int channel);
|
||||||
@ -78,6 +79,7 @@ public:
|
|||||||
int playSound(const AudioPath & sound, int repeats=0, bool cache=false);
|
int playSound(const AudioPath & sound, int repeats=0, bool cache=false);
|
||||||
int playSoundFromSet(std::vector<soundBase::soundID> &sound_vec);
|
int playSoundFromSet(std::vector<soundBase::soundID> &sound_vec);
|
||||||
void stopSound(int handler);
|
void stopSound(int handler);
|
||||||
|
bool isSoundPlaying(int handler);
|
||||||
|
|
||||||
void setCallback(int channel, std::function<void()> function);
|
void setCallback(int channel, std::function<void()> function);
|
||||||
void soundFinishedCallback(int channel);
|
void soundFinishedCallback(int channel);
|
||||||
|
@ -50,7 +50,7 @@ void CPrologEpilogVideo::show(Canvas & to)
|
|||||||
else
|
else
|
||||||
text->showAll(to); // blit text over video, if needed
|
text->showAll(to); // blit text over video, if needed
|
||||||
|
|
||||||
if(text->textSize.y + 100 < positionCounter / 5)
|
if(text->textSize.y + 100 < positionCounter / 5 && !CCS->soundh->isSoundPlaying(voiceSoundHandle))
|
||||||
clickPressed(GH.getCursorPosition());
|
clickPressed(GH.getCursorPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,10 +404,13 @@ CampaignScenario CampaignHandler::readScenarioFromMemory( CBinaryReader & reader
|
|||||||
ret.hasPrologEpilog = reader.readUInt8();
|
ret.hasPrologEpilog = reader.readUInt8();
|
||||||
if(ret.hasPrologEpilog)
|
if(ret.hasPrologEpilog)
|
||||||
{
|
{
|
||||||
|
std::string originalCampaigns[] = { "DATA/GOOD1", "DATA/EVIL1", "DATA/GOOD2", "DATA/NEUTRAL1", "DATA/EVIL2", "DATA/GOOD3", "DATA/SECRET1", "DATA/AB", "DATA/BLOOD", "DATA/SLAYER", "DATA/FESTIVAL", "DATA/FIRE", "DATA/FOOL", "DATA/GEM", "DATA/GELU", "DATA/CRAG", "DATA/SANDRO", "DATA/YOG", "DATA/FINAL", "DATA/SECRET" };
|
||||||
|
bool isOriginalCampaign = std::find(std::begin(originalCampaigns), std::end(originalCampaigns), header.getFilename()) != std::end(originalCampaigns);
|
||||||
|
|
||||||
ui8 index = reader.readUInt8();
|
ui8 index = reader.readUInt8();
|
||||||
ret.prologVideo = CampaignHandler::prologVideoName(index);
|
ret.prologVideo = CampaignHandler::prologVideoName(index);
|
||||||
ret.prologMusic = CampaignHandler::prologMusicName(reader.readUInt8());
|
ret.prologMusic = CampaignHandler::prologMusicName(reader.readUInt8());
|
||||||
ret.prologVoice = CampaignHandler::prologVoiceName(index);
|
ret.prologVoice = isOriginalCampaign ? CampaignHandler::prologVoiceName(index) : AudioPath();
|
||||||
ret.prologText = readLocalizedString(reader, header.filename, header.modName, header.encoding, identifier);
|
ret.prologText = readLocalizedString(reader, header.filename, header.modName, header.encoding, identifier);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user