1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix main menu resize on resolution change

This commit is contained in:
Ivan Savenko 2023-05-08 00:59:48 +03:00
parent bffec0068b
commit b1bd49ecd8
3 changed files with 23 additions and 0 deletions

View File

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

View File

@ -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

View File

@ -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);