Adjust screen-sized widgets automatically using Stretch align

deque
scrawl 11 years ago
parent 715d357f24
commit 6cb9382bf0

@ -59,7 +59,7 @@ namespace MWGui
}; };
HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) HUD::HUD(int fpsLevel, DragAndDrop* dragAndDrop)
: Layout("openmw_hud.layout") : Layout("openmw_hud.layout")
, mHealth(NULL) , mHealth(NULL)
, mMagicka(NULL) , mMagicka(NULL)
@ -97,7 +97,7 @@ namespace MWGui
, mWeaponSpellTimer(0.f) , mWeaponSpellTimer(0.f)
, mDrowningFlashTheta(0.f) , mDrowningFlashTheta(0.f)
{ {
setCoord(0,0, width, height); mMainWidget->setSize(MyGUI::RenderManager::getInstance().getViewSize());
// Energy bars // Energy bars
getWidget(mHealthFrame, "HealthFrame"); getWidget(mHealthFrame, "HealthFrame");
@ -405,11 +405,6 @@ namespace MWGui
mDrowningFlashTheta += dt * Ogre::Math::TWO_PI; mDrowningFlashTheta += dt * Ogre::Math::TWO_PI;
} }
void HUD::onResChange(int width, int height)
{
setCoord(0, 0, width, height);
}
void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent) void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent)
{ {
const ESM::Spell* spell = const ESM::Spell* spell =

@ -15,7 +15,7 @@ namespace MWGui
class HUD : public OEngine::GUI::Layout, public LocalMapBase class HUD : public OEngine::GUI::Layout, public LocalMapBase
{ {
public: public:
HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop); HUD(int fpsLevel, DragAndDrop* dragAndDrop);
virtual ~HUD(); virtual ~HUD();
void setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value); void setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value);
void setFPS(float fps); void setFPS(float fps);
@ -47,7 +47,6 @@ namespace MWGui
void setCrosshairVisible(bool visible); void setCrosshairVisible(bool visible);
void onFrame(float dt); void onFrame(float dt);
void onResChange(int width, int height);
void setCellName(const std::string& cellName); void setCellName(const std::string& cellName);

@ -30,6 +30,8 @@ namespace MWGui
, mProgress(0) , mProgress(0)
, mVSyncWasEnabled(false) , mVSyncWasEnabled(false)
{ {
mMainWidget->setSize(MyGUI::RenderManager::getInstance().getViewSize());
getWidget(mLoadingText, "LoadingText"); getWidget(mLoadingText, "LoadingText");
getWidget(mProgressBar, "ProgressBar"); getWidget(mProgressBar, "ProgressBar");
@ -56,13 +58,6 @@ namespace MWGui
mBackgroundImage->setVisible(visible); mBackgroundImage->setVisible(visible);
} }
void LoadingScreen::onResChange(int w, int h)
{
setCoord(0,0,w,h);
mBackgroundImage->setCoord(MyGUI::IntCoord(0,0,w,h));
}
void LoadingScreen::loadingOn() void LoadingScreen::loadingOn()
{ {
// Early-out if already on // Early-out if already on

@ -35,8 +35,6 @@ namespace MWGui
void setLoadingProgress (const std::string& stage, int depth, int current, int total); void setLoadingProgress (const std::string& stage, int depth, int current, int total);
void loadingDone(); void loadingDone();
void onResChange(int w, int h);
void updateWindow(Ogre::RenderWindow* rw) { mWindow = rw; } void updateWindow(Ogre::RenderWindow* rw) { mWindow = rw; }
private: private:

@ -180,12 +180,7 @@ namespace MWGui
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);
// Get size info from the Gui object
int w = MyGUI::RenderManager::getInstance().getViewSize().width;
int h = MyGUI::RenderManager::getInstance().getViewSize().height;
mLoadingScreen = new LoadingScreen(mRendering->getScene (), mRendering->getWindow ()); mLoadingScreen = new LoadingScreen(mRendering->getScene (), mRendering->getWindow ());
mLoadingScreen->onResChange (w,h);
//set up the hardware cursor manager //set up the hardware cursor manager
mCursorManager = new SFO::SDLCursorManager(); mCursorManager = new SFO::SDLCursorManager();
@ -195,7 +190,6 @@ namespace MWGui
MyGUI::InputManager::getInstance().eventChangeKeyFocus += MyGUI::newDelegate(this, &WindowManager::onKeyFocusChanged); MyGUI::InputManager::getInstance().eventChangeKeyFocus += MyGUI::newDelegate(this, &WindowManager::onKeyFocusChanged);
onCursorChange(MyGUI::PointerManager::getInstance().getDefaultPointer()); onCursorChange(MyGUI::PointerManager::getInstance().getDefaultPointer());
//SDL_ShowCursor(false);
mCursorManager->setEnabled(true); mCursorManager->setEnabled(true);
@ -242,7 +236,7 @@ namespace MWGui
trackWindow(mDialogueWindow, "dialogue"); trackWindow(mDialogueWindow, "dialogue");
mContainerWindow = new ContainerWindow(mDragAndDrop); mContainerWindow = new ContainerWindow(mDragAndDrop);
trackWindow(mContainerWindow, "container"); trackWindow(mContainerWindow, "container");
mHud = new HUD(w,h, mShowFPSLevel, mDragAndDrop); mHud = new HUD(mShowFPSLevel, mDragAndDrop);
mToolTips = new ToolTips(); mToolTips = new ToolTips();
mScrollWindow = new ScrollWindow(); mScrollWindow = new ScrollWindow();
mBookWindow = new BookWindow(); mBookWindow = new BookWindow();
@ -266,7 +260,7 @@ namespace MWGui
trackWindow(mCompanionWindow, "companion"); trackWindow(mCompanionWindow, "companion");
mScreenFader = new ScreenFader(); mScreenFader = new ScreenFader();
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Overlay"); mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Stretch,"Overlay");
mHud->setVisible(mHudEnabled); mHud->setVisible(mHudEnabled);
@ -1020,7 +1014,6 @@ namespace MWGui
{ {
sizeVideo(x, y); sizeVideo(x, y);
mGuiManager->windowResized(); mGuiManager->windowResized();
mLoadingScreen->onResChange (x,y);
if (!mHud) if (!mHud)
return; // UI not initialized yet return; // UI not initialized yet
@ -1034,7 +1027,6 @@ namespace MWGui
it->first->setSize(size); it->first->setSize(size);
} }
mHud->onResChange(x, y);
mConsole->onResChange(x, y); mConsole->onResChange(x, y);
mMenu->onResChange(x, y); mMenu->onResChange(x, y);
mSettingsWindow->center(); mSettingsWindow->center();
@ -1043,7 +1035,6 @@ namespace MWGui
mBookWindow->center(); mBookWindow->center();
mQuickKeysMenu->center(); mQuickKeysMenu->center();
mSpellBuyingWindow->center(); mSpellBuyingWindow->center();
mInputBlocker->setSize(MyGUI::IntSize(x,y));
} }
void WindowManager::pushGuiMode(GuiMode mode) void WindowManager::pushGuiMode(GuiMode mode)

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout"> <MyGUI type="Layout">
<Widget type="Widget" layer="HUD" position="0 0 300 200" name="_Main"> <Widget type="Widget" layer="HUD" position="0 0 300 200" name="_Main" align="Stretch">
<!-- Energy bars --> <!-- Energy bars -->
<Widget type="ProgressBar" skin="MW_EnergyBar_Yellow" position="13 131 65 12" align="Left Bottom" name="EnemyHealth"> <Widget type="ProgressBar" skin="MW_EnergyBar_Yellow" position="13 131 65 12" align="Left Bottom" name="EnemyHealth">
<Property key="Visible" value="false"/> <Property key="Visible" value="false"/>

@ -2,7 +2,7 @@
<MyGUI type="Layout"> <MyGUI type="Layout">
<!-- The entire screen --> <!-- The entire screen -->
<Widget type="Widget" layer="LoadingScreen" position="0 0 300 300" name="_Main"> <Widget type="Widget" layer="LoadingScreen" position="0 0 300 300" name="_Main" align="Stretch">
<Widget type="Widget" skin="HUD_Box" position="0 245 300 48" align="Bottom HCenter"> <Widget type="Widget" skin="HUD_Box" position="0 245 300 48" align="Bottom HCenter">

Loading…
Cancel
Save