mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-02 22:05:43 +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)
|
BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface & _owner, bool allowReplay)
|
||||||
: owner(_owner)
|
: owner(_owner), currentVideo(BattleResultVideo::NONE)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
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
|
if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
|
||||||
{
|
{
|
||||||
int text = 304;
|
int text = 304;
|
||||||
|
currentVideo = BattleResultVideo::WIN;
|
||||||
switch(br.result)
|
switch(br.result)
|
||||||
{
|
{
|
||||||
case EBattleResult::NORMAL:
|
case EBattleResult::NORMAL:
|
||||||
|
if(owner.cb->getBattle(br.battleID)->battleGetDefendedTown() && !weAreAttacker)
|
||||||
|
currentVideo = BattleResultVideo::WIN_SIEGE;
|
||||||
break;
|
break;
|
||||||
case EBattleResult::ESCAPE:
|
case EBattleResult::ESCAPE:
|
||||||
text = 303;
|
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));
|
logGlobal->error("Invalid battle result code %d. Assumed normal.", static_cast<int>(br.result));
|
||||||
break;
|
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];
|
std::string str = CGI->generaltexth->allTexts[text];
|
||||||
|
|
||||||
const CGHeroInstance * ourHero = owner.cb->getBattle(br.battleID)->battleGetMyHero();
|
const CGHeroInstance * ourHero = owner.cb->getBattle(br.battleID)->battleGetMyHero();
|
||||||
@ -598,28 +600,26 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
|
|||||||
else // we lose
|
else // we lose
|
||||||
{
|
{
|
||||||
int text = 311;
|
int text = 311;
|
||||||
AudioPath musicName = AudioPath::builtin("Music/LoseCombat");
|
currentVideo = BattleResultVideo::DEFEAT;
|
||||||
VideoPath videoName = VideoPath::builtin("LBSTART.BIK");
|
|
||||||
switch(br.result)
|
switch(br.result)
|
||||||
{
|
{
|
||||||
case EBattleResult::NORMAL:
|
case EBattleResult::NORMAL:
|
||||||
|
if(owner.cb->getBattle(br.battleID)->battleGetDefendedTown() && !weAreAttacker)
|
||||||
|
currentVideo = BattleResultVideo::DEFEAT_SIEGE;
|
||||||
break;
|
break;
|
||||||
case EBattleResult::ESCAPE:
|
case EBattleResult::ESCAPE:
|
||||||
musicName = AudioPath::builtin("Music/Retreat Battle");
|
currentVideo = BattleResultVideo::RETREAT;
|
||||||
videoName = VideoPath::builtin("RTSTART.BIK");
|
|
||||||
text = 310;
|
text = 310;
|
||||||
break;
|
break;
|
||||||
case EBattleResult::SURRENDER:
|
case EBattleResult::SURRENDER:
|
||||||
musicName = AudioPath::builtin("Music/Surrender Battle");
|
currentVideo = BattleResultVideo::SURRENDER;
|
||||||
videoName = VideoPath::builtin("SURRENDER.BIK");
|
|
||||||
text = 309;
|
text = 309;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->error("Invalid battle result code %d. Assumed normal.", static_cast<int>(br.result));
|
logGlobal->error("Invalid battle result code %d. Assumed normal.", static_cast<int>(br.result));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CCS->musich->playMusic(musicName, false, true);
|
playVideo();
|
||||||
CCS->videoh->open(videoName);
|
|
||||||
|
|
||||||
labels.push_back(std::make_shared<CLabel>(235, 235, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[text]));
|
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)
|
void BattleResultWindow::show(Canvas & to)
|
||||||
{
|
{
|
||||||
CIntObject::show(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)
|
void BattleResultWindow::buttonPressed(int button)
|
||||||
|
@ -163,6 +163,24 @@ private:
|
|||||||
std::vector<std::shared_ptr<CAnimImage>> icons;
|
std::vector<std::shared_ptr<CAnimImage>> icons;
|
||||||
std::shared_ptr<CTextBox> description;
|
std::shared_ptr<CTextBox> description;
|
||||||
CPlayerInterface & owner;
|
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
|
void buttonPressed(int button); //internal function for button callbacks
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user