mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
code review
This commit is contained in:
parent
fa19ed4e7c
commit
994da3fcf2
@ -190,8 +190,6 @@ int CSoundHandler::playSound(const AudioPath & sound, int repeats, bool cache)
|
||||
initCallback(channel);
|
||||
else
|
||||
initCallback(channel, [chunk](){ Mix_FreeChunk(chunk);});
|
||||
|
||||
channelPlaying[channel] = true;
|
||||
}
|
||||
else
|
||||
channel = -1;
|
||||
@ -211,11 +209,6 @@ void CSoundHandler::stopSound(int handler)
|
||||
Mix_HaltChannel(handler);
|
||||
}
|
||||
|
||||
bool CSoundHandler::isSoundPlaying(int handler)
|
||||
{
|
||||
return initialized && handler != -1 && channelPlaying[handler];
|
||||
}
|
||||
|
||||
// Sets the sound volume, from 0 (mute) to 100
|
||||
void CSoundHandler::setVolume(ui32 percent)
|
||||
{
|
||||
@ -259,8 +252,6 @@ void CSoundHandler::setCallback(int channel, std::function<void()> function)
|
||||
|
||||
void CSoundHandler::soundFinishedCallback(int channel)
|
||||
{
|
||||
channelPlaying[channel] = false;
|
||||
|
||||
boost::mutex::scoped_lock lockGuard(mutexCallbacks);
|
||||
|
||||
if (callbacks.count(channel) == 0)
|
||||
|
@ -60,7 +60,6 @@ private:
|
||||
|
||||
std::map<AudioPath, int> ambientChannels;
|
||||
std::map<int, int> channelVolumes;
|
||||
std::map<int, bool> channelPlaying;
|
||||
|
||||
void initCallback(int channel, const std::function<void()> & function);
|
||||
void initCallback(int channel);
|
||||
@ -79,7 +78,6 @@ public:
|
||||
int playSound(const AudioPath & sound, int repeats=0, bool cache=false);
|
||||
int playSoundFromSet(std::vector<soundBase::soundID> &sound_vec);
|
||||
void stopSound(int handler);
|
||||
bool isSoundPlaying(int handler);
|
||||
|
||||
void setCallback(int channel, std::function<void()> function);
|
||||
void soundFinishedCallback(int channel);
|
||||
|
@ -30,6 +30,11 @@ CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::f
|
||||
CCS->videoh->open(spe.prologVideo);
|
||||
CCS->musich->playMusic(spe.prologMusic, true, true);
|
||||
voiceSoundHandle = CCS->soundh->playSound(spe.prologVoice);
|
||||
auto onVoiceStop = [this]()
|
||||
{
|
||||
voiceStopped = true;
|
||||
};
|
||||
CCS->soundh->setCallback(voiceSoundHandle, onVoiceStop);
|
||||
|
||||
text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::METALLIC_GOLD, spe.prologText);
|
||||
text->scrollTextTo(-100);
|
||||
@ -50,7 +55,7 @@ void CPrologEpilogVideo::show(Canvas & to)
|
||||
else
|
||||
text->showAll(to); // blit text over video, if needed
|
||||
|
||||
if(text->textSize.y + 100 < positionCounter / 5 && !CCS->soundh->isSoundPlaying(voiceSoundHandle))
|
||||
if(text->textSize.y + 100 < positionCounter / 5 && voiceStopped)
|
||||
clickPressed(GH.getCursorPosition());
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@ class CPrologEpilogVideo : public CWindowObject
|
||||
|
||||
std::shared_ptr<CMultiLineLabel> text;
|
||||
|
||||
bool voiceStopped = false;
|
||||
|
||||
public:
|
||||
CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::function<void()> callback);
|
||||
|
||||
|
@ -404,8 +404,7 @@ CampaignScenario CampaignHandler::readScenarioFromMemory( CBinaryReader & reader
|
||||
ret.hasPrologEpilog = reader.readUInt8();
|
||||
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);
|
||||
bool isOriginalCampaign = boost::starts_with(header.getFilename(), "DATA/");
|
||||
|
||||
ui8 index = reader.readUInt8();
|
||||
ret.prologVideo = CampaignHandler::prologVideoName(index);
|
||||
|
Loading…
Reference in New Issue
Block a user