mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
campaignset
This commit is contained in:
parent
7b37c2353a
commit
34182069f5
@ -689,6 +689,8 @@ void CServerHandler::startCampaignScenario(std::shared_ptr<CampaignState> cs)
|
||||
GH.windows().pushWindow(CMM->menu);
|
||||
CMM->openCampaignLobby(ourCampaign);
|
||||
}
|
||||
else
|
||||
CMM->openCampaignScreen(ourCampaign->campaignSet);
|
||||
};
|
||||
if(epilogue.hasPrologEpilog)
|
||||
{
|
||||
|
@ -47,12 +47,12 @@
|
||||
|
||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||
|
||||
CCampaignScreen::CCampaignScreen(const JsonNode & config)
|
||||
: CWindowObject(BORDERED)
|
||||
CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
|
||||
: CWindowObject(BORDERED), campaignSet(name)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
|
||||
for(const JsonNode & node : config["images"].Vector())
|
||||
for(const JsonNode & node : config[name]["images"].Vector())
|
||||
images.push_back(CMainMenu::createPicture(node));
|
||||
|
||||
if(!images.empty())
|
||||
@ -63,14 +63,14 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config)
|
||||
pos = images[0]->pos; // fix height\width of this window
|
||||
}
|
||||
|
||||
if(!config["exitbutton"].isNull())
|
||||
if(!config[name]["exitbutton"].isNull())
|
||||
{
|
||||
buttonBack = createExitButton(config["exitbutton"]);
|
||||
buttonBack = createExitButton(config[name]["exitbutton"]);
|
||||
buttonBack->hoverable = true;
|
||||
}
|
||||
|
||||
for(const JsonNode & node : config["items"].Vector())
|
||||
campButtons.push_back(std::make_shared<CCampaignButton>(node));
|
||||
for(const JsonNode & node : config[name]["items"].Vector())
|
||||
campButtons.push_back(std::make_shared<CCampaignButton>(node, campaignSet));
|
||||
}
|
||||
|
||||
void CCampaignScreen::activate()
|
||||
@ -89,7 +89,8 @@ std::shared_ptr<CButton> CCampaignScreen::createExitButton(const JsonNode & butt
|
||||
return std::make_shared<CButton>(Point((int)button["x"].Float(), (int)button["y"].Float()), AnimationPath::fromJson(button["name"]), help, [=](){ close();}, EShortcut::GLOBAL_CANCEL);
|
||||
}
|
||||
|
||||
CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config)
|
||||
CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, std::string set)
|
||||
: set(set)
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
|
||||
@ -134,7 +135,7 @@ void CCampaignScreen::CCampaignButton::show(Canvas & to)
|
||||
void CCampaignScreen::CCampaignButton::clickReleased(const Point & cursorPosition)
|
||||
{
|
||||
CCS->videoh->close();
|
||||
CMainMenu::openCampaignLobby(campFile);
|
||||
CMainMenu::openCampaignLobby(campFile, set);
|
||||
}
|
||||
|
||||
void CCampaignScreen::CCampaignButton::hover(bool on)
|
||||
|
@ -40,14 +40,18 @@ private:
|
||||
VideoPath video; // the resource name of the video
|
||||
std::string hoverText;
|
||||
|
||||
std::string set;
|
||||
|
||||
void clickReleased(const Point & cursorPosition) override;
|
||||
void hover(bool on) override;
|
||||
|
||||
public:
|
||||
CCampaignButton(const JsonNode & config);
|
||||
CCampaignButton(const JsonNode & config, std::string set);
|
||||
void show(Canvas & to) override;
|
||||
};
|
||||
|
||||
std::string campaignSet;
|
||||
|
||||
std::vector<std::shared_ptr<CCampaignButton>> campButtons;
|
||||
std::vector<std::shared_ptr<CPicture>> images;
|
||||
std::shared_ptr<CButton> buttonBack;
|
||||
@ -55,9 +59,7 @@ private:
|
||||
std::shared_ptr<CButton> createExitButton(const JsonNode & button);
|
||||
|
||||
public:
|
||||
enum CampaignSet {ROE, AB, SOD, WOG};
|
||||
|
||||
CCampaignScreen(const JsonNode & config);
|
||||
CCampaignScreen(const JsonNode & config, std::string name);
|
||||
|
||||
void activate() override;
|
||||
};
|
||||
|
@ -349,14 +349,16 @@ void CMainMenu::openLobby(ESelectionScreen screenType, bool host, const std::vec
|
||||
GH.windows().createAndPushWindow<CSimpleJoinScreen>(host);
|
||||
}
|
||||
|
||||
void CMainMenu::openCampaignLobby(const std::string & campaignFileName)
|
||||
void CMainMenu::openCampaignLobby(const std::string & campaignFileName, std::string campaignSet)
|
||||
{
|
||||
auto ourCampaign = CampaignHandler::getCampaign(campaignFileName);
|
||||
openCampaignLobby(ourCampaign);
|
||||
openCampaignLobby(ourCampaign, campaignSet);
|
||||
}
|
||||
|
||||
void CMainMenu::openCampaignLobby(std::shared_ptr<CampaignState> campaign)
|
||||
void CMainMenu::openCampaignLobby(std::shared_ptr<CampaignState> campaign, std::string campaignSet)
|
||||
{
|
||||
campaign->campaignSet = campaignSet;
|
||||
|
||||
CSH->resetStateForLobby(StartInfo::CAMPAIGN);
|
||||
CSH->screenType = ESelectionScreen::campaignList;
|
||||
CSH->campaignStateToSend = campaign;
|
||||
@ -367,7 +369,7 @@ void CMainMenu::openCampaignScreen(std::string name)
|
||||
{
|
||||
if(vstd::contains(CMainMenuConfig::get().getCampaigns().Struct(), name))
|
||||
{
|
||||
GH.windows().createAndPushWindow<CCampaignScreen>(CMainMenuConfig::get().getCampaigns()[name]);
|
||||
GH.windows().createAndPushWindow<CCampaignScreen>(CMainMenuConfig::get().getCampaigns(), name);
|
||||
return;
|
||||
}
|
||||
logGlobal->error("Unknown campaign set: %s", name);
|
||||
|
@ -149,8 +149,8 @@ public:
|
||||
void onScreenResize() override;
|
||||
void update() override;
|
||||
static void openLobby(ESelectionScreen screenType, bool host, const std::vector<std::string> * names, ELoadMode loadMode);
|
||||
static void openCampaignLobby(const std::string & campaignFileName);
|
||||
static void openCampaignLobby(std::shared_ptr<CampaignState> campaign);
|
||||
static void openCampaignLobby(const std::string & campaignFileName, std::string campaignSet = "");
|
||||
static void openCampaignLobby(std::shared_ptr<CampaignState> campaign, std::string campaignSet = "");
|
||||
static void startTutorial();
|
||||
void openCampaignScreen(std::string name);
|
||||
|
||||
|
@ -293,6 +293,8 @@ public:
|
||||
static JsonNode crossoverSerialize(CGHeroInstance * hero);
|
||||
static CGHeroInstance * crossoverDeserialize(const JsonNode & node, CMap * map);
|
||||
|
||||
std::string campaignSet = "";
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<Campaign&>(*this);
|
||||
@ -302,6 +304,7 @@ public:
|
||||
h & mapsConquered;
|
||||
h & currentMap;
|
||||
h & chosenCampaignBonuses;
|
||||
h & campaignSet;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user