diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index 31e891cba..83ce6b70e 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -711,7 +711,7 @@ void CServerHandler::startCampaignScenario(HighScoreParameter param, std::shared if(!ourCampaign->getOutroVideo().empty() && CCS->videoh->open(ourCampaign->getOutroVideo(), 1)) { CCS->musich->stopMusic(); - GH.windows().createAndPushWindow(ourCampaign->getOutroVideo(), ourCampaign->getVideoRim().empty() ? ImagePath::builtin("INTRORIM") : ourCampaign->getVideoRim(), false, 1, [campaignScoreCalculator, statistic](){ + GH.windows().createAndPushWindow(ourCampaign->getOutroVideo(), ourCampaign->getVideoRim().empty() ? ImagePath::builtin("INTRORIM") : ourCampaign->getVideoRim(), false, 1, [campaignScoreCalculator, statistic](bool skipped){ GH.windows().createAndPushWindow(true, *campaignScoreCalculator, statistic); }); } diff --git a/client/NetPacksLobbyClient.cpp b/client/NetPacksLobbyClient.cpp index 5c7822d97..88b84b420 100644 --- a/client/NetPacksLobbyClient.cpp +++ b/client/NetPacksLobbyClient.cpp @@ -210,7 +210,7 @@ void ApplyOnLobbyScreenNetPackVisitor::visitLobbyUpdateState(LobbyUpdateState & if(!handler.si->campState->conqueredScenarios().size() && !handler.si->campState->getIntroVideo().empty() && CCS->videoh->open(handler.si->campState->getIntroVideo(), 1)) { CCS->musich->stopMusic(); - GH.windows().createAndPushWindow(handler.si->campState->getIntroVideo(), handler.si->campState->getVideoRim().empty() ? ImagePath::builtin("INTRORIM") : handler.si->campState->getVideoRim(), false, 1, [bonusSel](){ + GH.windows().createAndPushWindow(handler.si->campState->getIntroVideo(), handler.si->campState->getVideoRim().empty() ? ImagePath::builtin("INTRORIM") : handler.si->campState->getVideoRim(), false, 1, [bonusSel](bool skipped){ if(!CSH->si->campState->getMusic().empty()) CCS->musich->playMusic(CSH->si->campState->getMusic(), true, false); GH.windows().pushWindow(bonusSel); diff --git a/client/lobby/CBonusSelection.cpp b/client/lobby/CBonusSelection.cpp index b6c5afc87..d293c1f3e 100644 --- a/client/lobby/CBonusSelection.cpp +++ b/client/lobby/CBonusSelection.cpp @@ -59,8 +59,8 @@ #include "../../lib/mapObjects/CGHeroInstance.h" -CampaignRimVideo::CampaignRimVideo(VideoPath video, ImagePath rim, bool showBackground, float scaleFactor, std::function closeCb) - : CWindowObject(BORDERED), closeCb(closeCb) +CampaignRimVideo::CampaignRimVideo(VideoPath video, ImagePath rim, bool showBackground, float scaleFactor, std::function closeCb) + : CWindowObject(BORDERED | NEEDS_ANIMATED_BACKGROUND), closeCb(closeCb) { OBJECT_CONSTRUCTION; @@ -68,12 +68,12 @@ CampaignRimVideo::CampaignRimVideo(VideoPath video, ImagePath rim, bool showBack if(!rim.empty()) { - videoPlayer = std::make_shared(Point(80, 186), video, true, [this](){ exit(); }); + videoPlayer = std::make_shared(Point(80, 186), video, true, [this](){ exit(false); }); pos = center(Rect(0, 0, 800, 600)); } else { - videoPlayer = std::make_shared(Point(0, 0), video, true, scaleFactor, [this](){ exit(); }); + videoPlayer = std::make_shared(Point(0, 0), video, true, scaleFactor, [this](){ exit(false); }); pos = center(Rect(0, 0, videoPlayer->pos.w, videoPlayer->pos.h)); } @@ -84,21 +84,21 @@ CampaignRimVideo::CampaignRimVideo(VideoPath video, ImagePath rim, bool showBack setBackground(rim); } -void CampaignRimVideo::exit() +void CampaignRimVideo::exit(bool skipped) { close(); if(closeCb) - closeCb(); + closeCb(skipped); } void CampaignRimVideo::clickPressed(const Point & cursorPosition) { - exit(); + exit(true); } void CampaignRimVideo::keyPressed(EShortcut key) { - exit(); + exit(true); } bool CampaignRimVideo::receiveEvent(const Point & position, int eventType) const diff --git a/client/lobby/CBonusSelection.h b/client/lobby/CBonusSelection.h index 13223f321..9b29eba94 100644 --- a/client/lobby/CBonusSelection.h +++ b/client/lobby/CBonusSelection.h @@ -39,11 +39,11 @@ class CampaignRimVideo : public CWindowObject std::shared_ptr videoPlayer; std::shared_ptr backgroundAroundWindow; - std::function closeCb; + std::function closeCb; - void exit(); + void exit(bool skipped); public: - CampaignRimVideo(VideoPath video, ImagePath rim, bool showBackground, float scaleFactor, std::function closeCb); + CampaignRimVideo(VideoPath video, ImagePath rim, bool showBackground, float scaleFactor, std::function closeCb); void clickPressed(const Point & cursorPosition) override; void keyPressed(EShortcut key) override; diff --git a/client/mainmenu/CMainMenu.cpp b/client/mainmenu/CMainMenu.cpp index 835157d59..17d2ac9d3 100644 --- a/client/mainmenu/CMainMenu.cpp +++ b/client/mainmenu/CMainMenu.cpp @@ -293,24 +293,7 @@ CMainMenu::CMainMenu(bool playVideoIntro) OBJECT_CONSTRUCTION; backgroundAroundMenu = std::make_shared(ImagePath::builtin("DIBOXBCK"), pos); - if(playVideoIntro) - { - auto playVideo = [](std::string video, bool rim, float scaleFactor, std::function cb){ - if(CCS->videoh->open(VideoPath::builtin(video), scaleFactor)) - GH.windows().createAndPushWindow(VideoPath::builtin(video), rim ? ImagePath::builtin("INTRORIM") : ImagePath::builtin(""), true, scaleFactor, [cb](){ cb(); }); - else - cb(); - }; - playVideo("3DOLOGO.SMK", false, 1, [playVideo](){ - playVideo("NWCLOGO.SMK", false, 2, [playVideo](){ - playVideo("H3INTRO.SMK", true, 1, [](){ - CCS->musich->playMusic(AudioPath::builtin("Music/MainMenu"), true, true); - }); - }); - }); - } - else - CCS->musich->playMusic(AudioPath::builtin("Music/MainMenu"), true, true); + playIntroVideos(playVideoIntro); } CMainMenu::~CMainMenu() @@ -319,6 +302,35 @@ CMainMenu::~CMainMenu() GH.curInt = nullptr; } +void CMainMenu::playIntroVideos(bool playVideoIntro) +{ + auto playMusic = [](){ CCS->musich->playMusic(AudioPath::builtin("Music/MainMenu"), true, true); }; + if(playVideoIntro) + { + auto playVideo = [](std::string video, bool rim, float scaleFactor, std::function cb){ + if(CCS->videoh->open(VideoPath::builtin(video), scaleFactor)) + GH.windows().createAndPushWindow(VideoPath::builtin(video), rim ? ImagePath::builtin("INTRORIM") : ImagePath::builtin(""), true, scaleFactor, [cb](bool skipped){ cb(skipped); }); + else + cb(true); + }; + playVideo("3DOLOGO.SMK", false, 1, [playVideo, playMusic](bool skipped){ + if(!skipped) + playVideo("NWCLOGO.SMK", false, 2, [playVideo, playMusic](bool skipped){ + if(!skipped) + playVideo("H3INTRO.SMK", true, 1, [playMusic](bool skipped){ + playMusic(); + }); + else + playMusic(); + }); + else + playMusic(); + }); + } + else + playMusic(); +} + void CMainMenu::activate() { // check if screen was resized while main menu was inactive - e.g. in gameplay mode diff --git a/client/mainmenu/CMainMenu.h b/client/mainmenu/CMainMenu.h index 1b4b263ec..599efad14 100644 --- a/client/mainmenu/CMainMenu.h +++ b/client/mainmenu/CMainMenu.h @@ -146,6 +146,8 @@ class CMainMenu : public CIntObject, public IUpdateable, public std::enable_shar CMainMenu(bool playVideoIntro); //Use CMainMenu::create + void playIntroVideos(bool playVideoIntro); + public: std::shared_ptr menu; diff --git a/client/windows/CWindowObject.cpp b/client/windows/CWindowObject.cpp index 282dec7a9..2b88f6064 100644 --- a/client/windows/CWindowObject.cpp +++ b/client/windows/CWindowObject.cpp @@ -59,7 +59,7 @@ CWindowObject::CWindowObject(int options_, const ImagePath & imageName): background(createBg(imageName, options_ & PLAYER_COLORED)) { if(!(options & NEEDS_ANIMATED_BACKGROUND)) //currently workaround for highscores (currently uses window as normal control, because otherwise videos are not played in background yet) - //assert(parent == nullptr); //Safe to remove, but windows should not have parent + assert(parent == nullptr); //Safe to remove, but windows should not have parent if(options & RCLICK_POPUP) CCS->curh->hide();