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