diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 66ccfd50f..52714fd22 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -297,6 +297,8 @@ void ContainerBase::drawItems() MyGUI::IntSize size = MyGUI::IntSize(std::max(mItemView->getSize().width, x+42), mItemView->getSize().height); mItemView->setCanvasSize(size); mContainerWidget->setSize(size); + + notifyContentChanged(); } std::string ContainerBase::getCountString(const int count) diff --git a/apps/openmw/mwgui/container.hpp b/apps/openmw/mwgui/container.hpp index a19f9e91f..d93cdd187 100644 --- a/apps/openmw/mwgui/container.hpp +++ b/apps/openmw/mwgui/container.hpp @@ -80,6 +80,7 @@ namespace MWGui void Update(); void drawItems(); + virtual void notifyContentChanged() { } protected: MyGUI::ScrollView* mItemView; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 90adb80d5..d327653f0 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -281,6 +281,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender) // remove object from the container it was coming from object.getRefData().setCount(0); + mDragAndDrop->mDraggedFrom->notifyContentChanged(); mDragAndDrop->mIsOnDragAndDrop = false; MyGUI::Gui::getInstance().destroyWidget(mDragAndDrop->mDraggedWidget); diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 5e33d4600..8eb4b7bb1 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -95,9 +95,12 @@ namespace MWGui void InventoryWindow::openInventory() { - openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + openContainer(player); onWindowResize(static_cast(mMainWidget)); + + updateEncumbranceBar(); } void InventoryWindow::onWindowResize(MyGUI::Window* _sender) @@ -236,4 +239,20 @@ namespace MWGui } } } + + void InventoryWindow::updateEncumbranceBar() + { + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + + float capacity = MWWorld::Class::get(player).getCapacity(player); + float encumbrance = MWWorld::Class::get(player).getEncumbrance(player); + mEncumbranceBar->setProgressRange(capacity); + mEncumbranceBar->setProgressPosition(encumbrance); + mEncumbranceText->setCaption( boost::lexical_cast(int(encumbrance)) + "/" + boost::lexical_cast(int(capacity)) ); + } + + void InventoryWindow::notifyContentChanged() + { + updateEncumbranceBar(); + } } diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 18dc913fc..c1a36bd56 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -30,6 +30,8 @@ namespace MWGui void openInventory(); + virtual void notifyContentChanged(); + protected: MyGUI::Widget* mAvatar; MyGUI::TextBox* mArmorRating; @@ -50,6 +52,8 @@ namespace MWGui void onAvatarClicked(MyGUI::Widget* _sender); void onPinToggled(); + void updateEncumbranceBar(); + virtual bool isInventory() { return true; } virtual std::vector getEquippedItems(); virtual void _unequipItem(MWWorld::Ptr item);