2
0
Эх сурвалжийг харах

Merge pull request #3416 from Laserlicht/video_campaign_fix

video position for campaigns
Ivan Savenko 1 жил өмнө
parent
commit
121ef77440

+ 8 - 0
client/CVideoHandler.cpp

@@ -615,6 +615,14 @@ std::pair<std::unique_ptr<ui8 []>, si64> CVideoPlayer::getAudio(const VideoPath
 	return dat;
 }
 
+Point CVideoPlayer::size()
+{
+	if(frame)
+		return Point(frame->width, frame->height);
+	else
+		return Point(0, 0);
+}
+
 // Plays a video. Only works for overlays.
 bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey)
 {

+ 3 - 0
client/CVideoHandler.h

@@ -38,6 +38,7 @@ public:
 		return false;
 	}
 	virtual std::pair<std::unique_ptr<ui8 []>, si64> getAudio(const VideoPath & videoToOpen) { return std::make_pair(nullptr, 0); };
+	virtual Point size() { return Point(0, 0); };
 };
 
 class CEmptyVideoPlayer final : public IMainVideoPlayer
@@ -109,6 +110,8 @@ public:
 
 	std::pair<std::unique_ptr<ui8 []>, si64> getAudio(const VideoPath & videoToOpen) override;
 
+	Point size() override;
+
 	//TODO:
 	bool wait() override {return false;};
 	int curFrame() const override {return -1;};

+ 2 - 4
client/mainmenu/CPrologEpilogVideo.cpp

@@ -45,10 +45,8 @@ CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::f
 void CPrologEpilogVideo::show(Canvas & to)
 {
 	to.drawColor(pos, Colors::BLACK);
-	//BUG: some videos are 800x600 in size while some are 800x400
-	//VCMI should center them in the middle of the screen. Possible but needs modification
-	//of video player API which I'd like to avoid until we'll get rid of Windows-specific player
-	CCS->videoh->update(pos.x, pos.y, to.getInternalSurface(), true, false);
+	//some videos are 800x600 in size while some are 800x400
+	CCS->videoh->update(pos.x, pos.y + (CCS->videoh->size().y == 400 ? 100 : 0), to.getInternalSurface(), true, false);
 
 	//move text every 5 calls/frames; seems to be good enough
 	++positionCounter;