mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-31 22:05:10 +02:00
Merge pull request #3021 from Laserlicht/video
video loop fix and missing videos/sounds for battle result
This commit is contained in:
commit
e247c29269
@ -459,7 +459,7 @@ HeroInfoWindow::HeroInfoWindow(const InfoAboutHero & hero, Point * position)
|
||||
}
|
||||
|
||||
BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface & _owner, bool allowReplay)
|
||||
: owner(_owner)
|
||||
: owner(_owner), currentVideo(BattleResultVideo::NONE)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
||||
@ -566,9 +566,12 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
|
||||
if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
|
||||
{
|
||||
int text = 304;
|
||||
currentVideo = BattleResultVideo::WIN;
|
||||
switch(br.result)
|
||||
{
|
||||
case EBattleResult::NORMAL:
|
||||
if(owner.cb->getBattle(br.battleID)->battleGetDefendedTown() && !weAreAttacker)
|
||||
currentVideo = BattleResultVideo::WIN_SIEGE;
|
||||
break;
|
||||
case EBattleResult::ESCAPE:
|
||||
text = 303;
|
||||
@ -580,9 +583,8 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
|
||||
logGlobal->error("Invalid battle result code %d. Assumed normal.", static_cast<int>(br.result));
|
||||
break;
|
||||
}
|
||||
playVideo();
|
||||
|
||||
CCS->musich->playMusic(AudioPath::builtin("Music/Win Battle"), false, true);
|
||||
CCS->videoh->open(VideoPath::builtin("WIN3.BIK"));
|
||||
std::string str = CGI->generaltexth->allTexts[text];
|
||||
|
||||
const CGHeroInstance * ourHero = owner.cb->getBattle(br.battleID)->battleGetMyHero();
|
||||
@ -598,28 +600,26 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
|
||||
else // we lose
|
||||
{
|
||||
int text = 311;
|
||||
AudioPath musicName = AudioPath::builtin("Music/LoseCombat");
|
||||
VideoPath videoName = VideoPath::builtin("LBSTART.BIK");
|
||||
currentVideo = BattleResultVideo::DEFEAT;
|
||||
switch(br.result)
|
||||
{
|
||||
case EBattleResult::NORMAL:
|
||||
if(owner.cb->getBattle(br.battleID)->battleGetDefendedTown() && !weAreAttacker)
|
||||
currentVideo = BattleResultVideo::DEFEAT_SIEGE;
|
||||
break;
|
||||
case EBattleResult::ESCAPE:
|
||||
musicName = AudioPath::builtin("Music/Retreat Battle");
|
||||
videoName = VideoPath::builtin("RTSTART.BIK");
|
||||
currentVideo = BattleResultVideo::RETREAT;
|
||||
text = 310;
|
||||
break;
|
||||
case EBattleResult::SURRENDER:
|
||||
musicName = AudioPath::builtin("Music/Surrender Battle");
|
||||
videoName = VideoPath::builtin("SURRENDER.BIK");
|
||||
currentVideo = BattleResultVideo::SURRENDER;
|
||||
text = 309;
|
||||
break;
|
||||
default:
|
||||
logGlobal->error("Invalid battle result code %d. Assumed normal.", static_cast<int>(br.result));
|
||||
break;
|
||||
}
|
||||
CCS->musich->playMusic(musicName, false, true);
|
||||
CCS->videoh->open(videoName);
|
||||
playVideo();
|
||||
|
||||
labels.push_back(std::make_shared<CLabel>(235, 235, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[text]));
|
||||
}
|
||||
@ -634,7 +634,76 @@ 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,
|
||||
[&]()
|
||||
{
|
||||
playVideo(true);
|
||||
});
|
||||
}
|
||||
|
||||
void BattleResultWindow::playVideo(bool startLoop)
|
||||
{
|
||||
AudioPath musicName = AudioPath();
|
||||
VideoPath videoName = VideoPath();
|
||||
|
||||
if(!startLoop)
|
||||
{
|
||||
switch(currentVideo)
|
||||
{
|
||||
case BattleResultVideo::WIN:
|
||||
musicName = AudioPath::builtin("Music/Win Battle");
|
||||
videoName = VideoPath::builtin("WIN3.BIK");
|
||||
break;
|
||||
case BattleResultVideo::SURRENDER:
|
||||
musicName = AudioPath::builtin("Music/Surrender Battle");
|
||||
videoName = VideoPath::builtin("SURRENDER.BIK");
|
||||
break;
|
||||
case BattleResultVideo::RETREAT:
|
||||
musicName = AudioPath::builtin("Music/Retreat Battle");
|
||||
videoName = VideoPath::builtin("RTSTART.BIK");
|
||||
break;
|
||||
case BattleResultVideo::DEFEAT:
|
||||
musicName = AudioPath::builtin("Music/LoseCombat");
|
||||
videoName = VideoPath::builtin("LBSTART.BIK");
|
||||
break;
|
||||
case BattleResultVideo::DEFEAT_SIEGE:
|
||||
musicName = AudioPath::builtin("Music/LoseCastle");
|
||||
videoName = VideoPath::builtin("LOSECSTL.BIK");
|
||||
break;
|
||||
case BattleResultVideo::WIN_SIEGE:
|
||||
musicName = AudioPath::builtin("Music/Defend Castle");
|
||||
videoName = VideoPath::builtin("DEFENDALL.BIK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(currentVideo)
|
||||
{
|
||||
case BattleResultVideo::RETREAT:
|
||||
currentVideo = BattleResultVideo::RETREAT_LOOP;
|
||||
videoName = VideoPath::builtin("RTLOOP.BIK");
|
||||
break;
|
||||
case BattleResultVideo::DEFEAT:
|
||||
currentVideo = BattleResultVideo::DEFEAT_LOOP;
|
||||
videoName = VideoPath::builtin("LBLOOP.BIK");
|
||||
break;
|
||||
case BattleResultVideo::DEFEAT_SIEGE:
|
||||
currentVideo = BattleResultVideo::DEFEAT_SIEGE_LOOP;
|
||||
videoName = VideoPath::builtin("LOSECSLP.BIK");
|
||||
break;
|
||||
case BattleResultVideo::WIN_SIEGE:
|
||||
currentVideo = BattleResultVideo::WIN_SIEGE_LOOP;
|
||||
videoName = VideoPath::builtin("DEFENDLOOP.BIK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(musicName != AudioPath())
|
||||
CCS->musich->playMusic(musicName, false, true);
|
||||
|
||||
if(videoName != VideoPath())
|
||||
CCS->videoh->open(videoName);
|
||||
}
|
||||
|
||||
void BattleResultWindow::buttonPressed(int button)
|
||||
|
@ -164,6 +164,24 @@ private:
|
||||
std::shared_ptr<CTextBox> description;
|
||||
CPlayerInterface & owner;
|
||||
|
||||
enum BattleResultVideo
|
||||
{
|
||||
NONE,
|
||||
WIN,
|
||||
SURRENDER,
|
||||
RETREAT,
|
||||
RETREAT_LOOP,
|
||||
DEFEAT,
|
||||
DEFEAT_LOOP,
|
||||
DEFEAT_SIEGE,
|
||||
DEFEAT_SIEGE_LOOP,
|
||||
WIN_SIEGE,
|
||||
WIN_SIEGE_LOOP,
|
||||
};
|
||||
BattleResultVideo currentVideo;
|
||||
|
||||
void playVideo(bool startLoop = false);
|
||||
|
||||
void buttonPressed(int button); //internal function for button callbacks
|
||||
public:
|
||||
BattleResultWindow(const BattleResult & br, CPlayerInterface & _owner, bool allowReplay = false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user