Laserlicht 2 سال پیش
والد
کامیت
42bf5fdd58
2فایلهای تغییر یافته به همراه42 افزوده شده و 3 حذف شده
  1. 4 0
      client/CVideoHandler.h
  2. 38 3
      client/battle/BattleInterfaceClasses.cpp

+ 4 - 0
client/CVideoHandler.h

@@ -23,6 +23,7 @@ public:
 	virtual bool nextFrame()=0;
 	virtual void show(int x, int y, SDL_Surface *dst, bool update = true)=0;
 	virtual void redraw(int x, int y, SDL_Surface *dst, bool update = true)=0; //reblits buffer
+	virtual VideoPath videoName()=0;
 	virtual bool wait()=0;
 	virtual int curFrame() const =0;
 	virtual int frameCount() const =0;
@@ -46,6 +47,7 @@ public:
 	void redraw( int x, int y, SDL_Surface *dst, bool update = true ) override {};
 	void show( int x, int y, SDL_Surface *dst, bool update = true ) override {};
 	bool nextFrame() override {return false;};
+	VideoPath videoName() override {return VideoPath();};
 	void close() override {};
 	bool wait() override {return false;};
 	bool open(const VideoPath & name, bool scale = false) override {return false;};
@@ -106,6 +108,8 @@ public:
 	// Opens video, calls playVideo, closes video; returns playVideo result (if whole video has been played)
 	bool openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey = false, bool scale = false) override;
 
+	VideoPath videoName() override {return fname;};
+
 	//TODO:
 	bool wait() override {return false;};
 	int curFrame() const override {return -1;};

+ 38 - 3
client/battle/BattleInterfaceClasses.cpp

@@ -566,9 +566,16 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
 	if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
 	{
 		int text = 304;
+		AudioPath musicName = AudioPath::builtin("Music/Win Battle");
+		VideoPath videoName = VideoPath::builtin("WIN3.BIK");
 		switch(br.result)
 		{
 		case EBattleResult::NORMAL:
+			if(owner.cb->getBattle(br.battleID)->battleGetDefendedTown() && !weAreAttacker)
+			{
+				musicName = AudioPath::builtin("Music/Defend Castle");
+				videoName = VideoPath::builtin("DEFENDALL.BIK");	
+			}
 			break;
 		case EBattleResult::ESCAPE:
 			text = 303;
@@ -581,8 +588,8 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
 			break;
 		}
 
-		CCS->musich->playMusic(AudioPath::builtin("Music/Win Battle"), false, true);
-		CCS->videoh->open(VideoPath::builtin("WIN3.BIK"));
+		CCS->musich->playMusic(musicName, false, true);
+		CCS->videoh->open(videoName);
 		std::string str = CGI->generaltexth->allTexts[text];
 
 		const CGHeroInstance * ourHero = owner.cb->getBattle(br.battleID)->battleGetMyHero();
@@ -603,6 +610,11 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
 		switch(br.result)
 		{
 		case EBattleResult::NORMAL:
+			if(owner.cb->getBattle(br.battleID)->battleGetDefendedTown() && !weAreAttacker)
+			{
+				musicName = AudioPath::builtin("Music/LoseCastle");
+				videoName = VideoPath::builtin("LOSECSTL.BIK");	
+			}
 			break;
 		case EBattleResult::ESCAPE:
 			musicName = AudioPath::builtin("Music/Retreat Battle");
@@ -634,7 +646,30 @@ void BattleResultWindow::activate()
 void BattleResultWindow::show(Canvas & to)
 {
 	CIntObject::show(to);
-	CCS->videoh->update(pos.x + 107, pos.y + 70, to.getInternalSurface(), true, false);
+	CCS->videoh->update(pos.x + 107, pos.y + 70, to.getInternalSurface(), true, false,
+	[&]()
+	{
+		if(CCS->videoh->videoName() == VideoPath::builtin("VIDEO/LBSTART"))
+		{
+			CCS->videoh->close();
+			CCS->videoh->open(VideoPath::builtin("VIDEO/LBLOOP"));
+		}
+		if(CCS->videoh->videoName() == VideoPath::builtin("VIDEO/RTSTART"))
+		{
+			CCS->videoh->close();
+			CCS->videoh->open(VideoPath::builtin("VIDEO/RTLOOP"));
+		}
+		if(CCS->videoh->videoName() == VideoPath::builtin("VIDEO/LOSECSTL"))
+		{
+			CCS->videoh->close();
+			CCS->videoh->open(VideoPath::builtin("VIDEO/LOSECSLP"));
+		}
+		if(CCS->videoh->videoName() == VideoPath::builtin("VIDEO/DEFENDALL"))
+		{
+			CCS->videoh->close();
+			CCS->videoh->open(VideoPath::builtin("VIDEO/DEFENDLOOP"));
+		}
+	});
 }
 
 void BattleResultWindow::buttonPressed(int button)