1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 03:53:54 +00:00

check the container's "Organic" flag before trying to place items inside.

This commit is contained in:
scrawl 2012-05-17 14:13:35 +02:00
parent 0c1d06d9f7
commit 66abfd17ab
3 changed files with 21 additions and 3 deletions

View file

@ -143,7 +143,7 @@ void ContainerBase::onSelectedItemImpl(MyGUI::Widget* _sender, int count)
void ContainerBase::onContainerClicked(MyGUI::Widget* _sender) void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
{ {
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here if(mDragAndDrop->mIsOnDragAndDrop) //drop item here
{ {
MWWorld::Ptr object = *mDragAndDrop->mDraggedWidget->getUserData<MWWorld::Ptr>(); MWWorld::Ptr object = *mDragAndDrop->mDraggedWidget->getUserData<MWWorld::Ptr>();
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer); MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
@ -152,6 +152,20 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
{ {
assert(object.getContainerStore() && "Item is not in a container!"); assert(object.getContainerStore() && "Item is not in a container!");
// check the container's Organic flag (if this is a container). container with Organic flag doesn't allow putting items inside
if (mContainer.getTypeName() == typeid(ESM::Container).name())
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData>* ref = mContainer.get<ESM::Container>();
if (ref->base->flags & ESM::Container::Organic)
{
// user notification
MWBase::Environment::get().getWindowManager()->
messageBox(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sContentsMessage2")->str, std::vector<std::string>());
return;
}
}
int origCount = object.getRefData().getCount();
// check that we don't exceed the allowed weight (only for containers, not for inventory) // check that we don't exceed the allowed weight (only for containers, not for inventory)
if (!isInventory()) if (!isInventory())
@ -159,7 +173,6 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
float capacity = MWWorld::Class::get(mContainer).getCapacity(mContainer); float capacity = MWWorld::Class::get(mContainer).getCapacity(mContainer);
// try adding the item, and if weight is exceeded, just remove it again. // try adding the item, and if weight is exceeded, just remove it again.
int origCount = object.getRefData().getCount();
object.getRefData().setCount(mDragAndDrop->mDraggedCount); object.getRefData().setCount(mDragAndDrop->mDraggedCount);
MWWorld::ContainerStoreIterator it = containerStore.add(object); MWWorld::ContainerStoreIterator it = containerStore.add(object);
@ -181,7 +194,6 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
} }
else else
{ {
int origCount = object.getRefData().getCount();
object.getRefData().setCount (mDragAndDrop->mDraggedCount); object.getRefData().setCount (mDragAndDrop->mDraggedCount);
containerStore.add(object); containerStore.add(object);
object.getRefData().setCount (origCount - mDragAndDrop->mDraggedCount); object.getRefData().setCount (origCount - mDragAndDrop->mDraggedCount);

View file

@ -92,6 +92,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked); mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked);
mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver); mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
mMainWidget->eventMouseLostFocus += MyGUI::newDelegate(this, &HUD::onWorldMouseLostFocus);
} }
void HUD::setFpsLevel(int level) void HUD::setFpsLevel(int level)
@ -321,3 +322,7 @@ void HUD::onWorldMouseOver(MyGUI::Widget* _sender, int x, int y)
} }
} }
void HUD::onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new)
{
MyGUI::PointerManager::getInstance().setPointer("arrow");
}

View file

@ -53,5 +53,6 @@ namespace MWGui
void onWorldClicked(MyGUI::Widget* _sender); void onWorldClicked(MyGUI::Widget* _sender);
void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y); void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y);
void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new);
}; };
} }