mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
code review
This commit is contained in:
parent
e963550431
commit
a43475042f
@ -662,10 +662,13 @@ void CServerHandler::endGameplay()
|
||||
{
|
||||
GH.curInt = CMM.get();
|
||||
CMM->enable();
|
||||
CMM->playMusic();
|
||||
}
|
||||
else
|
||||
{
|
||||
GH.curInt = CMainMenu::create(false).get();
|
||||
auto mainMenu = CMainMenu::create();
|
||||
GH.curInt = mainMenu.get();
|
||||
mainMenu->playMusic();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "CHighScoreScreen.h"
|
||||
#include "CStatisticScreen.h"
|
||||
#include "CMainMenu.h"
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../gui/WindowHandler.h"
|
||||
#include "../gui/Shortcut.h"
|
||||
@ -170,6 +171,7 @@ void CHighScoreScreen::buttonResetClick()
|
||||
void CHighScoreScreen::buttonExitClick()
|
||||
{
|
||||
close();
|
||||
CMM->playMusic();
|
||||
}
|
||||
|
||||
CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc, const StatisticDataSet & statistic)
|
||||
|
@ -284,7 +284,7 @@ const JsonNode & CMainMenuConfig::getCampaigns() const
|
||||
return campaignSets;
|
||||
}
|
||||
|
||||
CMainMenu::CMainMenu(bool playVideoIntro)
|
||||
CMainMenu::CMainMenu()
|
||||
{
|
||||
pos.w = GH.screenDimensions().x;
|
||||
pos.h = GH.screenDimensions().y;
|
||||
@ -292,8 +292,6 @@ CMainMenu::CMainMenu(bool playVideoIntro)
|
||||
menu = std::make_shared<CMenuScreen>(CMainMenuConfig::get().getConfig()["window"]);
|
||||
OBJECT_CONSTRUCTION;
|
||||
backgroundAroundMenu = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), pos);
|
||||
|
||||
playIntroVideos(playVideoIntro);
|
||||
}
|
||||
|
||||
CMainMenu::~CMainMenu()
|
||||
@ -302,33 +300,33 @@ CMainMenu::~CMainMenu()
|
||||
GH.curInt = nullptr;
|
||||
}
|
||||
|
||||
void CMainMenu::playIntroVideos(bool playVideoIntro)
|
||||
void CMainMenu::playIntroVideos()
|
||||
{
|
||||
auto playMusic = [](){ CCS->musich->playMusic(AudioPath::builtin("Music/MainMenu"), true, true); };
|
||||
if(playVideoIntro)
|
||||
{
|
||||
auto playVideo = [](std::string video, bool rim, float scaleFactor, std::function<void(bool)> cb){
|
||||
if(CCS->videoh->open(VideoPath::builtin(video), scaleFactor))
|
||||
GH.windows().createAndPushWindow<VideoWindow>(VideoPath::builtin(video), rim ? ImagePath::builtin("INTRORIM") : ImagePath::builtin(""), true, scaleFactor, [cb](bool skipped){ cb(skipped); });
|
||||
else
|
||||
cb(true);
|
||||
};
|
||||
playVideo("3DOLOGO.SMK", false, 1.25, [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
|
||||
auto playVideo = [](std::string video, bool rim, float scaleFactor, std::function<void(bool)> cb){
|
||||
if(CCS->videoh->open(VideoPath::builtin(video), scaleFactor))
|
||||
GH.windows().createAndPushWindow<VideoWindow>(VideoPath::builtin(video), rim ? ImagePath::builtin("INTRORIM") : ImagePath::builtin(""), true, scaleFactor, [cb](bool skipped){ cb(skipped); });
|
||||
else
|
||||
cb(true);
|
||||
};
|
||||
|
||||
playVideo("3DOLOGO.SMK", false, 1.25, [playVideo, this](bool skipped){
|
||||
if(!skipped)
|
||||
playVideo("NWCLOGO.SMK", false, 2, [playVideo, this](bool skipped){
|
||||
if(!skipped)
|
||||
playVideo("H3INTRO.SMK", true, 1, [this](bool skipped){
|
||||
playMusic();
|
||||
});
|
||||
else
|
||||
playMusic();
|
||||
});
|
||||
}
|
||||
else
|
||||
playMusic();
|
||||
});
|
||||
else
|
||||
playMusic();
|
||||
});
|
||||
else
|
||||
playMusic();
|
||||
});
|
||||
}
|
||||
|
||||
void CMainMenu::playMusic()
|
||||
{
|
||||
CCS->musich->playMusic(AudioPath::builtin("Music/MainMenu"), true, true);
|
||||
}
|
||||
|
||||
void CMainMenu::activate()
|
||||
@ -449,10 +447,10 @@ void CMainMenu::openHighScoreScreen()
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<CMainMenu> CMainMenu::create(bool playVideoIntro)
|
||||
std::shared_ptr<CMainMenu> CMainMenu::create()
|
||||
{
|
||||
if(!CMM)
|
||||
CMM = std::shared_ptr<CMainMenu>(new CMainMenu(playVideoIntro));
|
||||
CMM = std::shared_ptr<CMainMenu>(new CMainMenu());
|
||||
|
||||
return CMM;
|
||||
}
|
||||
|
@ -144,9 +144,7 @@ class CMainMenu : public CIntObject, public IUpdateable, public std::enable_shar
|
||||
|
||||
std::vector<VideoPath> videoPlayList;
|
||||
|
||||
CMainMenu(bool playVideoIntro); //Use CMainMenu::create
|
||||
|
||||
void playIntroVideos(bool playVideoIntro);
|
||||
CMainMenu(); //Use CMainMenu::create
|
||||
|
||||
public:
|
||||
std::shared_ptr<CMenuScreen> menu;
|
||||
@ -162,10 +160,12 @@ public:
|
||||
static void openHighScoreScreen();
|
||||
void openCampaignScreen(std::string name);
|
||||
|
||||
static std::shared_ptr<CMainMenu> create(bool playVideoIntro);
|
||||
static std::shared_ptr<CMainMenu> create();
|
||||
|
||||
static std::shared_ptr<CPicture> createPicture(const JsonNode & config);
|
||||
|
||||
void playIntroVideos();
|
||||
void playMusic();
|
||||
};
|
||||
|
||||
/// Simple window to enter the server's address.
|
||||
|
@ -372,9 +372,14 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
bool playIntroVideo = !settings["session"]["headless"].Bool() && !vm.count("battle") && !vm.count("nointro") && settings["video"]["showIntro"].Bool();
|
||||
auto mmenu = CMainMenu::create(playIntroVideo);
|
||||
auto mmenu = CMainMenu::create();
|
||||
GH.curInt = mmenu.get();
|
||||
|
||||
bool playIntroVideo = !settings["session"]["headless"].Bool() && !vm.count("battle") && !vm.count("nointro") && settings["video"]["showIntro"].Bool();
|
||||
if(playIntroVideo)
|
||||
mmenu->playIntroVideos();
|
||||
else
|
||||
mmenu->playMusic();
|
||||
}
|
||||
|
||||
std::vector<std::string> names;
|
||||
|
Loading…
Reference in New Issue
Block a user