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:
parent
bffec0068b
commit
b1bd49ecd8
@ -803,6 +803,7 @@ void CAdventureMapInterface::onScreenResize()
|
||||
widget->setPlayer(currentPlayerID);
|
||||
widget->updateActiveState();
|
||||
widget->getMinimap()->update();
|
||||
widget->getInfoBar()->showSelection();
|
||||
|
||||
adjustActiveness();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user