1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Merge pull request #3416 from Laserlicht/video_campaign_fix

video position for campaigns
This commit is contained in:
Ivan Savenko 2024-01-03 12:32:40 +02:00 committed by GitHub
commit 121ef77440
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

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

View File

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

View File

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