Ver Fonte

get back to campaignmenu

Laserlicht há 2 anos atrás
pai
commit
52b86eb9c1

+ 4 - 0
client/CServerHandler.cpp

@@ -690,7 +690,11 @@ void CServerHandler::startCampaignScenario(std::shared_ptr<CampaignState> cs)
 				CMM->openCampaignLobby(ourCampaign);
 			}
 			else
+			{
+				GH.windows().pushWindow(CMM);
+				GH.windows().pushWindow(CMM->menu);
 				CMM->openCampaignScreen(ourCampaign->campaignSet);
+			}
 		};
 		if(epilogue.hasPrologEpilog)
 		{

+ 3 - 3
client/mainmenu/CCampaignScreen.cpp

@@ -89,8 +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, std::string set)
-	: set(set)
+CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, std::string campaignSet)
+	: campaignSet(campaignSet)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
 
@@ -135,7 +135,7 @@ void CCampaignScreen::CCampaignButton::show(Canvas & to)
 void CCampaignScreen::CCampaignButton::clickReleased(const Point & cursorPosition)
 {
 	CCS->videoh->close();
-	CMainMenu::openCampaignLobby(campFile, set);
+	CMainMenu::openCampaignLobby(campFile, campaignSet);
 }
 
 void CCampaignScreen::CCampaignButton::hover(bool on)

+ 3 - 3
client/mainmenu/CCampaignScreen.h

@@ -40,13 +40,13 @@ private:
 		VideoPath video; // the resource name of the video
 		std::string hoverText;
 
-		std::string set;
+		std::string campaignSet;
 
 		void clickReleased(const Point & cursorPosition) override;
 		void hover(bool on) override;
 
 	public:
-		CCampaignButton(const JsonNode & config, std::string set);
+		CCampaignButton(const JsonNode & config, std::string campaignSet);
 		void show(Canvas & to) override;
 	};
 
@@ -59,7 +59,7 @@ private:
 	std::shared_ptr<CButton> createExitButton(const JsonNode & button);
 
 public:
-	CCampaignScreen(const JsonNode & config, std::string name);
+	CCampaignScreen(const JsonNode & config, std::string campaignSet);
 
 	void activate() override;
 };

+ 3 - 4
client/mainmenu/CMainMenu.cpp

@@ -352,13 +352,12 @@ void CMainMenu::openLobby(ESelectionScreen screenType, bool host, const std::vec
 void CMainMenu::openCampaignLobby(const std::string & campaignFileName, std::string campaignSet)
 {
 	auto ourCampaign = CampaignHandler::getCampaign(campaignFileName);
-	openCampaignLobby(ourCampaign, campaignSet);
+	ourCampaign->campaignSet = campaignSet;
+	openCampaignLobby(ourCampaign);
 }
 
-void CMainMenu::openCampaignLobby(std::shared_ptr<CampaignState> campaign, std::string campaignSet)
+void CMainMenu::openCampaignLobby(std::shared_ptr<CampaignState> campaign)
 {
-	campaign->campaignSet = campaignSet;
-
 	CSH->resetStateForLobby(StartInfo::CAMPAIGN);
 	CSH->screenType = ESelectionScreen::campaignList;
 	CSH->campaignStateToSend = campaign;

+ 1 - 1
client/mainmenu/CMainMenu.h

@@ -150,7 +150,7 @@ public:
 	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, std::string campaignSet = "");
-	static void openCampaignLobby(std::shared_ptr<CampaignState> campaign, std::string campaignSet = "");
+	static void openCampaignLobby(std::shared_ptr<CampaignState> campaign);
 	static void startTutorial();
 	void openCampaignScreen(std::string name);