mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 02:15:32 +00:00
fix item duplication bug when picking up object with the mouse and immediately dropping again
This commit is contained in:
parent
1ecc6f97ed
commit
ea8e3ca1c8
1 changed files with 10 additions and 4 deletions
|
@ -311,17 +311,23 @@ namespace MWGui
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(sound, 1, 1);
|
MWBase::Environment::get().getSoundManager()->playSound(sound, 1, 1);
|
||||||
|
|
||||||
int count = object.getRefData().getCount();
|
int count = object.getRefData().getCount();
|
||||||
MWWorld::ActionTake action(object);
|
|
||||||
action.execute();
|
// add to player inventory
|
||||||
|
// can't use ActionTake here because we need an MWWorld::Ptr to the newly inserted object
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
|
MWWorld::Ptr newObject = *MWWorld::Class::get (player).getContainerStore (player).add (object);
|
||||||
|
// remove from world
|
||||||
|
MWBase::Environment::get().getWorld()->deleteObject (object);
|
||||||
|
|
||||||
mDragAndDrop->mIsOnDragAndDrop = true;
|
mDragAndDrop->mIsOnDragAndDrop = true;
|
||||||
mDragAndDrop->mDraggedCount = count;
|
mDragAndDrop->mDraggedCount = count;
|
||||||
|
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(object).getInventoryIcon(object);
|
path += MWWorld::Class::get(newObject).getInventoryIcon(newObject);
|
||||||
MyGUI::ImageBox* baseWidget = mContainerWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
MyGUI::ImageBox* baseWidget = mContainerWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
||||||
baseWidget->detachFromWidget();
|
baseWidget->detachFromWidget();
|
||||||
baseWidget->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
baseWidget->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
||||||
baseWidget->setUserData(object);
|
baseWidget->setUserData(newObject);
|
||||||
mDragAndDrop->mDraggedWidget = baseWidget;
|
mDragAndDrop->mDraggedWidget = baseWidget;
|
||||||
ImageBox* image = baseWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
ImageBox* image = baseWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
|
|
Loading…
Reference in a new issue