From 7ed763262faa3dac19249c09fdff86050f399929 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 31 Jul 2013 21:40:29 +0200 Subject: [PATCH] GUI mode dependent position --- apps/openmw/mwgui/inventorywindow.cpp | 43 +++++++++++++++++++++++++- apps/openmw/mwgui/inventorywindow.hpp | 10 ++++++ apps/openmw/mwgui/windowmanagerimp.cpp | 4 +++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 9fa87c4b8..9e3488f28 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -36,6 +36,11 @@ namespace MWGui , mPreview(MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ()) , mPreviewDirty(true) , mDragAndDrop(dragAndDrop) + , mPositionInventory(0, 342, 498, 258) + , mPositionContainer(0, 342, 498, 258) + , mPositionCompanion(0, 342, 498, 258) + , mPositionBarter(0, 342, 498, 258) + , mGuiMode(GM_Inventory) { static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize); @@ -67,7 +72,7 @@ namespace MWGui mFilterAll->setStateSelected(true); - setCoord(0, 342, 498, 258); + setCoord(mPositionInventory.left, mPositionInventory.top, mPositionInventory.width, mPositionInventory.height); onWindowResize(static_cast(mMainWidget)); mPreview.setup(); @@ -83,6 +88,27 @@ namespace MWGui mPreview.setup(); } + void InventoryWindow::setGuiMode(GuiMode mode) + { + mGuiMode = mode; + switch(mode) { + case GM_Container: + mMainWidget->setCoord(mPositionContainer); + break; + case GM_Companion: + mMainWidget->setCoord(mPositionCompanion); + break; + case GM_Barter: + mMainWidget->setCoord(mPositionBarter); + break; + case GM_Inventory: + default: + mMainWidget->setCoord(mPositionInventory); + break; + } + onWindowResize(static_cast(mMainWidget)); + } + TradeItemModel* InventoryWindow::getTradeModel() { return mTradeModel; @@ -210,6 +236,21 @@ namespace MWGui _sender->getSize().width - 12 - (_sender->getSize().height-44) * aspect - 15, _sender->getSize().height-44 ); + switch(mGuiMode) { + case GM_Container: + mPositionContainer = _sender->getCoord(); + break; + case GM_Companion: + mPositionCompanion = _sender->getCoord(); + break; + case GM_Barter: + mPositionBarter = _sender->getCoord(); + break; + case GM_Inventory: + default: + mPositionInventory = _sender->getCoord(); + } + if (mMainWidget->getSize().width != mLastXSize || mMainWidget->getSize().height != mLastYSize) { mLastXSize = mMainWidget->getSize().width; diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 13c118913..35140437d 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -5,6 +5,7 @@ #include "windowpinnablebase.hpp" #include "widgets.hpp" +#include "mode.hpp" namespace MWGui { @@ -47,6 +48,8 @@ namespace MWGui void updatePlayer(); + void setGuiMode(GuiMode mode); + private: DragAndDrop* mDragAndDrop; @@ -73,6 +76,13 @@ namespace MWGui MyGUI::Button* mFilterMagic; MyGUI::Button* mFilterMisc; + MyGUI::IntCoord mPositionInventory; + MyGUI::IntCoord mPositionContainer; + MyGUI::IntCoord mPositionCompanion; + MyGUI::IntCoord mPositionBarter; + + GuiMode mGuiMode; + int mLastXSize; int mLastYSize; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 03fd7c796..f254d9c25 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -441,16 +441,19 @@ namespace MWGui mMap ->setVisible(eff & GW_Map); mStatsWindow ->setVisible(eff & GW_Stats); mInventoryWindow->setVisible(eff & GW_Inventory); + mInventoryWindow->setGuiMode(mode); mSpellWindow ->setVisible(eff & GW_Magic); break; } case GM_Container: mContainerWindow->setVisible(true); mInventoryWindow->setVisible(true); + mInventoryWindow->setGuiMode(mode); break; case GM_Companion: mCompanionWindow->setVisible(true); mInventoryWindow->setVisible(true); + mInventoryWindow->setGuiMode(mode); break; case GM_Dialogue: mDialogueWindow->setVisible(true); @@ -458,6 +461,7 @@ namespace MWGui case GM_Barter: mInventoryWindow->setVisible(true); mInventoryWindow->setTrading(true); + mInventoryWindow->setGuiMode(mode); mTradeWindow->setVisible(true); break; case GM_SpellBuying: