1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00
OpenMW/apps/openmw/mwgui/window_base.cpp

43 lines
1.2 KiB
C++
Raw Normal View History

2010-11-06 10:25:16 +00:00
#include "window_base.hpp"
#include <components/settings/settings.hpp>
#include "../mwbase/windowmanager.hpp"
2010-11-06 10:25:16 +00:00
using namespace MWGui;
WindowBase::WindowBase(const std::string& parLayout, MWBase::WindowManager& parWindowManager)
2010-11-06 10:25:16 +00:00
: Layout(parLayout)
, mWindowManager(parWindowManager)
2010-11-06 10:25:16 +00:00
{
}
void WindowBase::open()
{
}
void WindowBase::setVisible(bool visible)
{
bool wasVisible = mMainWidget->getVisible();
mMainWidget->setVisible(visible);
if (!wasVisible && visible)
open();
}
2010-11-06 10:25:16 +00:00
void WindowBase::center()
{
// Centre dialog
// MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize();
// Note by scrawl: The following works more reliably in the case when the window was _just_
// resized and MyGUI RenderManager doesn't know about the new size yet
MyGUI::IntSize gameWindowSize = MyGUI::IntSize(Settings::Manager::getInt("resolution x", "Video"),
Settings::Manager::getInt("resolution y", "Video"));
2010-11-06 10:25:16 +00:00
MyGUI::IntCoord coord = mMainWidget->getCoord();
coord.left = (gameWindowSize.width - coord.width)/2;
coord.top = (gameWindowSize.height - coord.height)/2;
mMainWidget->setCoord(coord);
}