2
0
Эх сурвалжийг харах

Fix main menu resize on resolution change

Ivan Savenko 2 жил өмнө
parent
commit
b1bd49ecd8

+ 1 - 0
client/adventureMap/CAdventureMapInterface.cpp

@@ -803,6 +803,7 @@ void CAdventureMapInterface::onScreenResize()
 	widget->setPlayer(currentPlayerID);
 	widget->updateActiveState();
 	widget->getMinimap()->update();
+	widget->getInfoBar()->showSelection();
 
 	adjustActiveness();
 }

+ 20 - 0
client/mainmenu/CMainMenu.cpp

@@ -299,6 +299,26 @@ CMainMenu::~CMainMenu()
 		GH.curInt = nullptr;
 }
 
+void CMainMenu::activate()
+{
+	// check if screen was resized while main menu was inactive - e.g. in gameplay mode
+	if (pos.dimensions() != GH.screenDimensions())
+		onScreenResize();
+
+	CIntObject::activate();
+}
+
+void CMainMenu::onScreenResize()
+{
+	pos.w = GH.screenDimensions().x;
+	pos.h = GH.screenDimensions().y;
+
+	menu = nullptr;
+	menu = std::make_shared<CMenuScreen>(CMainMenuConfig::get().getConfig()["window"]);
+
+	backgroundAroundMenu->pos = pos;
+}
+
 void CMainMenu::update()
 {
 	if(CMM != this->shared_from_this()) //don't update if you are not a main interface

+ 2 - 0
client/mainmenu/CMainMenu.h

@@ -141,6 +141,8 @@ public:
 	std::shared_ptr<CMenuScreen> menu;
 
 	~CMainMenu();
+	void activate() override;
+	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);