mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
scaling
This commit is contained in:
@@ -17,7 +17,12 @@
|
||||
#include "../render/Canvas.h"
|
||||
|
||||
VideoWidgetBase::VideoWidgetBase(const Point & position, const VideoPath & video, bool playAudio)
|
||||
: playAudio(playAudio)
|
||||
: VideoWidgetBase(position, video, playAudio, 1.0)
|
||||
{
|
||||
}
|
||||
|
||||
VideoWidgetBase::VideoWidgetBase(const Point & position, const VideoPath & video, bool playAudio, float scaleFactor)
|
||||
: playAudio(playAudio), scaleFactor(scaleFactor)
|
||||
{
|
||||
addUsedEvents(TIME);
|
||||
pos += position;
|
||||
@@ -28,7 +33,7 @@ VideoWidgetBase::~VideoWidgetBase() = default;
|
||||
|
||||
void VideoWidgetBase::playVideo(const VideoPath & fileToPlay)
|
||||
{
|
||||
videoInstance = CCS->videoh->open(fileToPlay, Point(0, 0));
|
||||
videoInstance = CCS->videoh->open(fileToPlay, scaleFactor);
|
||||
if (videoInstance)
|
||||
{
|
||||
pos.w = videoInstance->size().x;
|
||||
@@ -119,11 +124,6 @@ void VideoWidgetBase::tick(uint32_t msPassed)
|
||||
}
|
||||
}
|
||||
|
||||
Point VideoWidgetBase::size()
|
||||
{
|
||||
return videoInstance->size();
|
||||
}
|
||||
|
||||
VideoWidget::VideoWidget(const Point & position, const VideoPath & prologue, const VideoPath & looped, bool playAudio)
|
||||
: VideoWidgetBase(position, prologue, playAudio)
|
||||
, loopedVideo(looped)
|
||||
@@ -147,6 +147,12 @@ VideoWidgetOnce::VideoWidgetOnce(const Point & position, const VideoPath & video
|
||||
{
|
||||
}
|
||||
|
||||
VideoWidgetOnce::VideoWidgetOnce(const Point & position, const VideoPath & video, bool playAudio, float scaleFactor, const std::function<void()> & callback)
|
||||
: VideoWidgetBase(position, video, playAudio, scaleFactor)
|
||||
, callback(callback)
|
||||
{
|
||||
}
|
||||
|
||||
void VideoWidgetOnce::onPlaybackFinished()
|
||||
{
|
||||
callback();
|
||||
|
||||
@@ -22,6 +22,7 @@ class VideoWidgetBase : public CIntObject
|
||||
std::pair<std::unique_ptr<ui8[]>, si64> audioData = {nullptr, 0};
|
||||
int audioHandle = -1;
|
||||
bool playAudio = false;
|
||||
float scaleFactor = 1.0;
|
||||
|
||||
void loadAudio(const VideoPath & file);
|
||||
void startAudio();
|
||||
@@ -29,6 +30,7 @@ class VideoWidgetBase : public CIntObject
|
||||
|
||||
protected:
|
||||
VideoWidgetBase(const Point & position, const VideoPath & video, bool playAudio);
|
||||
VideoWidgetBase(const Point & position, const VideoPath & video, bool playAudio, float scaleFactor);
|
||||
|
||||
virtual void onPlaybackFinished() = 0;
|
||||
void playVideo(const VideoPath & video);
|
||||
@@ -42,8 +44,6 @@ public:
|
||||
void showAll(Canvas & to) override;
|
||||
void tick(uint32_t msPassed) override;
|
||||
|
||||
Point size();
|
||||
|
||||
void setPlaybackFinishedCallback(std::function<void()>);
|
||||
};
|
||||
|
||||
@@ -64,4 +64,5 @@ class VideoWidgetOnce final: public VideoWidgetBase
|
||||
void onPlaybackFinished() final;
|
||||
public:
|
||||
VideoWidgetOnce(const Point & position, const VideoPath & video, bool playAudio, const std::function<void()> & callback);
|
||||
VideoWidgetOnce(const Point & position, const VideoPath & video, bool playAudio, float scaleFactor, const std::function<void()> & callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user