Laserlicht пре 2 година
родитељ
комит
994da3fcf2

+ 0 - 9
client/CMusicHandler.cpp

@@ -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)

+ 0 - 2
client/CMusicHandler.h

@@ -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);

+ 6 - 1
client/mainmenu/CPrologEpilogVideo.cpp

@@ -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());
 }
 

+ 2 - 0
client/mainmenu/CPrologEpilogVideo.h

@@ -23,6 +23,8 @@ class CPrologEpilogVideo : public CWindowObject
 
 	std::shared_ptr<CMultiLineLabel> text;
 
+	bool voiceStopped = false;
+
 public:
 	CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::function<void()> callback);
 

+ 1 - 2
lib/campaign/CampaignHandler.cpp

@@ -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);