1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-11 11:31:52 +02:00

video fix

This commit is contained in:
Laserlicht 2023-10-07 14:31:49 +02:00 committed by GitHub
parent 2e3e116bc4
commit 42bf5fdd58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 3 deletions

View File

@ -23,6 +23,7 @@ public:
virtual bool nextFrame()=0;
virtual void show(int x, int y, SDL_Surface *dst, bool update = true)=0;
virtual void redraw(int x, int y, SDL_Surface *dst, bool update = true)=0; //reblits buffer
virtual VideoPath videoName()=0;
virtual bool wait()=0;
virtual int curFrame() const =0;
virtual int frameCount() const =0;
@ -46,6 +47,7 @@ public:
void redraw( int x, int y, SDL_Surface *dst, bool update = true ) override {};
void show( int x, int y, SDL_Surface *dst, bool update = true ) override {};
bool nextFrame() override {return false;};
VideoPath videoName() override {return VideoPath();};
void close() override {};
bool wait() override {return false;};
bool open(const VideoPath & name, bool scale = false) override {return false;};
@ -106,6 +108,8 @@ public:
// 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;
VideoPath videoName() override {return fname;};
//TODO:
bool wait() override {return false;};
int curFrame() const override {return -1;};

View File

@ -566,9 +566,16 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
{
int text = 304;
AudioPath musicName = AudioPath::builtin("Music/Win Battle");
VideoPath videoName = VideoPath::builtin("WIN3.BIK");
switch(br.result)
{
case EBattleResult::NORMAL:
if(owner.cb->getBattle(br.battleID)->battleGetDefendedTown() && !weAreAttacker)
{
musicName = AudioPath::builtin("Music/Defend Castle");
videoName = VideoPath::builtin("DEFENDALL.BIK");
}
break;
case EBattleResult::ESCAPE:
text = 303;
@ -581,8 +588,8 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
break;
}
CCS->musich->playMusic(AudioPath::builtin("Music/Win Battle"), false, true);
CCS->videoh->open(VideoPath::builtin("WIN3.BIK"));
CCS->musich->playMusic(musicName, false, true);
CCS->videoh->open(videoName);
std::string str = CGI->generaltexth->allTexts[text];
const CGHeroInstance * ourHero = owner.cb->getBattle(br.battleID)->battleGetMyHero();
@ -603,6 +610,11 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
switch(br.result)
{
case EBattleResult::NORMAL:
if(owner.cb->getBattle(br.battleID)->battleGetDefendedTown() && !weAreAttacker)
{
musicName = AudioPath::builtin("Music/LoseCastle");
videoName = VideoPath::builtin("LOSECSTL.BIK");
}
break;
case EBattleResult::ESCAPE:
musicName = AudioPath::builtin("Music/Retreat Battle");
@ -634,7 +646,30 @@ void BattleResultWindow::activate()
void BattleResultWindow::show(Canvas & to)
{
CIntObject::show(to);
CCS->videoh->update(pos.x + 107, pos.y + 70, to.getInternalSurface(), true, false);
CCS->videoh->update(pos.x + 107, pos.y + 70, to.getInternalSurface(), true, false,
[&]()
{
if(CCS->videoh->videoName() == VideoPath::builtin("VIDEO/LBSTART"))
{
CCS->videoh->close();
CCS->videoh->open(VideoPath::builtin("VIDEO/LBLOOP"));
}
if(CCS->videoh->videoName() == VideoPath::builtin("VIDEO/RTSTART"))
{
CCS->videoh->close();
CCS->videoh->open(VideoPath::builtin("VIDEO/RTLOOP"));
}
if(CCS->videoh->videoName() == VideoPath::builtin("VIDEO/LOSECSTL"))
{
CCS->videoh->close();
CCS->videoh->open(VideoPath::builtin("VIDEO/LOSECSLP"));
}
if(CCS->videoh->videoName() == VideoPath::builtin("VIDEO/DEFENDALL"))
{
CCS->videoh->close();
CCS->videoh->open(VideoPath::builtin("VIDEO/DEFENDLOOP"));
}
});
}
void BattleResultWindow::buttonPressed(int button)