From 477f1b42ab48495c320f02a32caa4aa99b994f0c Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 15 May 2012 23:28:04 +0200 Subject: [PATCH] fixed another item dropping bug --- apps/openmw/mwgui/container.cpp | 11 +++++++++++ apps/openmw/mwgui/container.hpp | 2 +- apps/openmw/mwgui/hud.cpp | 5 ++++- apps/openmw/mwgui/inventorywindow.cpp | 6 ++++++ apps/openmw/mwgui/inventorywindow.hpp | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 6d80c16edd..5ae943ea49 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -118,6 +118,17 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender) containerStore.add(object); object.getRefData().setCount (origCount - mDragAndDrop->mDraggedCount); } + else + { + // check that we don't exceed the allowed weight (only for containers, not for inventory) + if (isInventory()) + { + float curWeight = MWWorld::Class::get(mContainer).getEncumbrance(mContainer); + float capacity = MWWorld::Class::get(mContainer).getCapacity(mContainer); + + + } + } mDragAndDrop->mIsOnDragAndDrop = false; MyGUI::Gui::getInstance().destroyWidget(mDragAndDrop->mDraggedWidget); diff --git a/apps/openmw/mwgui/container.hpp b/apps/openmw/mwgui/container.hpp index d93cdd187d..174f18f9a5 100644 --- a/apps/openmw/mwgui/container.hpp +++ b/apps/openmw/mwgui/container.hpp @@ -77,7 +77,7 @@ namespace MWGui void openContainer(MWWorld::Ptr container); void setFilter(Filter filter); ///< set category filter - void Update(); + virtual void Update(); void drawItems(); virtual void notifyContentChanged() { } diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 96c971c4e8..c15801da4d 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -269,6 +269,9 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender) float mouseX = cursorPosition.left / float(viewSize.width); float mouseY = cursorPosition.top / float(viewSize.height); + int origCount = object.getRefData().getCount(); + object.getRefData().setCount(mDragAndDrop->mDraggedCount); + if (world->canPlaceObject(mouseX, mouseY)) world->placeObject(object, mouseX, mouseY); else @@ -280,7 +283,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender) MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); // remove object from the container it was coming from - object.getRefData().setCount(object.getRefData().getCount() - mDragAndDrop->mDraggedCount); + object.getRefData().setCount(origCount - mDragAndDrop->mDraggedCount); mDragAndDrop->mDraggedFrom->notifyContentChanged(); mDragAndDrop->mIsOnDragAndDrop = false; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index dbf335e5f0..a1e73d0edd 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -242,7 +242,13 @@ namespace MWGui } void InventoryWindow::notifyContentChanged() + { + } + + void InventoryWindow::Update() { updateEncumbranceBar(); + + ContainerBase::Update(); } } diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index c1a36bd561..ae0d809867 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -30,6 +30,7 @@ namespace MWGui void openInventory(); + virtual void Update(); virtual void notifyContentChanged(); protected: