From 63ee20de6ce908802764e0d7712d10173762e977 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Mon, 1 Jan 2024 15:25:42 +0100 Subject: [PATCH] video campaign fix --- client/CVideoHandler.cpp | 8 ++++++++ client/CVideoHandler.h | 3 +++ client/mainmenu/CPrologEpilogVideo.cpp | 6 ++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp index f76d1912b..370bfb4c6 100644 --- a/client/CVideoHandler.cpp +++ b/client/CVideoHandler.cpp @@ -615,6 +615,14 @@ std::pair, 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) { diff --git a/client/CVideoHandler.h b/client/CVideoHandler.h index 211b9db3f..38499bede 100644 --- a/client/CVideoHandler.h +++ b/client/CVideoHandler.h @@ -38,6 +38,7 @@ public: return false; } virtual std::pair, 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, si64> getAudio(const VideoPath & videoToOpen) override; + Point size() override; + //TODO: bool wait() override {return false;}; int curFrame() const override {return -1;}; diff --git a/client/mainmenu/CPrologEpilogVideo.cpp b/client/mainmenu/CPrologEpilogVideo.cpp index 6446d6d1b..d81bd07e7 100644 --- a/client/mainmenu/CPrologEpilogVideo.cpp +++ b/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;