mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge pull request #3576 from Alexander-Wilms/conditional-screen-clearing
CVideoHandler: Call SDL_RenderClear() when playing intro, call SDL_Re…
This commit is contained in:
@@ -430,15 +430,15 @@ void playIntro()
|
|||||||
{
|
{
|
||||||
auto audioData = CCS->videoh->getAudio(VideoPath::builtin("3DOLOGO.SMK"));
|
auto audioData = CCS->videoh->getAudio(VideoPath::builtin("3DOLOGO.SMK"));
|
||||||
int sound = CCS->soundh->playSound(audioData);
|
int sound = CCS->soundh->playSound(audioData);
|
||||||
if(CCS->videoh->openAndPlayVideo(VideoPath::builtin("3DOLOGO.SMK"), 0, 1, true, true))
|
if(CCS->videoh->openAndPlayVideo(VideoPath::builtin("3DOLOGO.SMK"), 0, 1, EVideoType::INTRO))
|
||||||
{
|
{
|
||||||
audioData = CCS->videoh->getAudio(VideoPath::builtin("NWCLOGO.SMK"));
|
audioData = CCS->videoh->getAudio(VideoPath::builtin("NWCLOGO.SMK"));
|
||||||
sound = CCS->soundh->playSound(audioData);
|
sound = CCS->soundh->playSound(audioData);
|
||||||
if (CCS->videoh->openAndPlayVideo(VideoPath::builtin("NWCLOGO.SMK"), 0, 1, true, true))
|
if (CCS->videoh->openAndPlayVideo(VideoPath::builtin("NWCLOGO.SMK"), 0, 1, EVideoType::INTRO))
|
||||||
{
|
{
|
||||||
audioData = CCS->videoh->getAudio(VideoPath::builtin("H3INTRO.SMK"));
|
audioData = CCS->videoh->getAudio(VideoPath::builtin("H3INTRO.SMK"));
|
||||||
sound = CCS->soundh->playSound(audioData);
|
sound = CCS->soundh->playSound(audioData);
|
||||||
CCS->videoh->openAndPlayVideo(VideoPath::builtin("H3INTRO.SMK"), 0, 1, true, true);
|
CCS->videoh->openAndPlayVideo(VideoPath::builtin("H3INTRO.SMK"), 0, 1, EVideoType::INTRO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CCS->soundh->stopSound(sound);
|
CCS->soundh->stopSound(sound);
|
||||||
|
@@ -101,8 +101,8 @@ bool CVideoPlayer::open(const VideoPath & fname, bool scale)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// loop = to loop through the video
|
// loop = to loop through the video
|
||||||
// useOverlay = directly write to the screen.
|
// overlay = directly write to the screen.
|
||||||
bool CVideoPlayer::open(const VideoPath & videoToOpen, bool loop, bool useOverlay, bool scale)
|
bool CVideoPlayer::open(const VideoPath & videoToOpen, bool loop, bool overlay, bool scale)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ bool CVideoPlayer::open(const VideoPath & videoToOpen, bool loop, bool useOverla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a place to put our YUV image on that screen
|
// Allocate a place to put our YUV image on that screen
|
||||||
if (useOverlay)
|
if (overlay)
|
||||||
{
|
{
|
||||||
texture = SDL_CreateTexture( mainRenderer, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STATIC, pos.w, pos.h);
|
texture = SDL_CreateTexture( mainRenderer, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STATIC, pos.w, pos.h);
|
||||||
}
|
}
|
||||||
@@ -624,7 +624,7 @@ Point CVideoPlayer::size()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Plays a video. Only works for overlays.
|
// Plays a video. Only works for overlays.
|
||||||
bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey)
|
bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey, bool overlay)
|
||||||
{
|
{
|
||||||
// Note: either the windows player or the linux player is
|
// Note: either the windows player or the linux player is
|
||||||
// broken. Compensate here until the bug is found.
|
// broken. Compensate here until the bug is found.
|
||||||
@@ -647,7 +647,14 @@ bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey)
|
|||||||
|
|
||||||
SDL_Rect rect = CSDL_Ext::toSDL(pos);
|
SDL_Rect rect = CSDL_Ext::toSDL(pos);
|
||||||
|
|
||||||
|
if(overlay)
|
||||||
|
{
|
||||||
SDL_RenderFillRect(mainRenderer, &rect);
|
SDL_RenderFillRect(mainRenderer, &rect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_RenderClear(mainRenderer);
|
||||||
|
}
|
||||||
SDL_RenderCopy(mainRenderer, texture, nullptr, &rect);
|
SDL_RenderCopy(mainRenderer, texture, nullptr, &rect);
|
||||||
SDL_RenderPresent(mainRenderer);
|
SDL_RenderPresent(mainRenderer);
|
||||||
|
|
||||||
@@ -672,10 +679,27 @@ bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CVideoPlayer::openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey, bool scale)
|
bool CVideoPlayer::openAndPlayVideo(const VideoPath & name, int x, int y, EVideoType videoType)
|
||||||
{
|
{
|
||||||
|
bool scale;
|
||||||
|
bool stopOnKey;
|
||||||
|
bool overlay;
|
||||||
|
|
||||||
|
switch(videoType)
|
||||||
|
{
|
||||||
|
case EVideoType::INTRO:
|
||||||
|
stopOnKey = true;
|
||||||
|
scale = true;
|
||||||
|
overlay = false;
|
||||||
|
break;
|
||||||
|
case EVideoType::SPELLBOOK:
|
||||||
|
default:
|
||||||
|
stopOnKey = false;
|
||||||
|
scale = false;
|
||||||
|
overlay = true;
|
||||||
|
}
|
||||||
open(name, false, true, scale);
|
open(name, false, true, scale);
|
||||||
bool ret = playVideo(x, y, stopOnKey);
|
bool ret = playVideo(x, y, stopOnKey, overlay);
|
||||||
close();
|
close();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,12 @@
|
|||||||
struct SDL_Surface;
|
struct SDL_Surface;
|
||||||
struct SDL_Texture;
|
struct SDL_Texture;
|
||||||
|
|
||||||
|
enum class EVideoType : ui8
|
||||||
|
{
|
||||||
|
INTRO = 0, // use entire window: stopOnKey = true, scale = true, overlay = false
|
||||||
|
SPELLBOOK // overlay video: stopOnKey = false, scale = false, overlay = true
|
||||||
|
};
|
||||||
|
|
||||||
class IVideoPlayer : boost::noncopyable
|
class IVideoPlayer : boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -33,7 +39,7 @@ class IMainVideoPlayer : public IVideoPlayer
|
|||||||
public:
|
public:
|
||||||
virtual ~IMainVideoPlayer() = default;
|
virtual ~IMainVideoPlayer() = default;
|
||||||
virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> restart = nullptr){}
|
virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> restart = nullptr){}
|
||||||
virtual bool openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey = false, bool scale = false)
|
virtual bool openAndPlayVideo(const VideoPath & name, int x, int y, EVideoType videoType)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -90,7 +96,7 @@ class CVideoPlayer final : public IMainVideoPlayer
|
|||||||
double frameTime;
|
double frameTime;
|
||||||
bool doLoop; // loop through video
|
bool doLoop; // loop through video
|
||||||
|
|
||||||
bool playVideo(int x, int y, bool stopOnKey);
|
bool playVideo(int x, int y, bool stopOnKey, bool overlay);
|
||||||
bool open(const VideoPath & fname, bool loop, bool useOverlay = false, bool scale = false);
|
bool open(const VideoPath & fname, bool loop, bool useOverlay = false, bool scale = false);
|
||||||
public:
|
public:
|
||||||
CVideoPlayer();
|
CVideoPlayer();
|
||||||
@@ -106,7 +112,7 @@ public:
|
|||||||
void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> onVideoRestart = nullptr) override; //moves to next frame if appropriate, and blits it or blits only if redraw parameter is set true
|
void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> onVideoRestart = nullptr) override; //moves to next frame if appropriate, and blits it or blits only if redraw parameter is set true
|
||||||
|
|
||||||
// Opens video, calls playVideo, closes video; returns playVideo result (if whole video has been played)
|
// 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;
|
bool openAndPlayVideo(const VideoPath & name, int x, int y, EVideoType videoType) override;
|
||||||
|
|
||||||
std::pair<std::unique_ptr<ui8 []>, si64> getAudio(const VideoPath & videoToOpen) override;
|
std::pair<std::unique_ptr<ui8 []>, si64> getAudio(const VideoPath & videoToOpen) override;
|
||||||
|
|
||||||
|
@@ -519,13 +519,13 @@ void CSpellWindow::setCurrentPage(int value)
|
|||||||
void CSpellWindow::turnPageLeft()
|
void CSpellWindow::turnPageLeft()
|
||||||
{
|
{
|
||||||
if(settings["video"]["spellbookAnimation"].Bool() && !isBigSpellbook)
|
if(settings["video"]["spellbookAnimation"].Bool() && !isBigSpellbook)
|
||||||
CCS->videoh->openAndPlayVideo(VideoPath::builtin("PGTRNLFT.SMK"), pos.x+13, pos.y+15);
|
CCS->videoh->openAndPlayVideo(VideoPath::builtin("PGTRNLFT.SMK"), pos.x+13, pos.y+15, EVideoType::SPELLBOOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSpellWindow::turnPageRight()
|
void CSpellWindow::turnPageRight()
|
||||||
{
|
{
|
||||||
if(settings["video"]["spellbookAnimation"].Bool() && !isBigSpellbook)
|
if(settings["video"]["spellbookAnimation"].Bool() && !isBigSpellbook)
|
||||||
CCS->videoh->openAndPlayVideo(VideoPath::builtin("PGTRNRGH.SMK"), pos.x+13, pos.y+15);
|
CCS->videoh->openAndPlayVideo(VideoPath::builtin("PGTRNRGH.SMK"), pos.x+13, pos.y+15, EVideoType::SPELLBOOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSpellWindow::keyPressed(EShortcut key)
|
void CSpellWindow::keyPressed(EShortcut key)
|
||||||
|
Reference in New Issue
Block a user