2012-04-15 15:52:39 +00:00
|
|
|
#include "container.hpp"
|
|
|
|
|
2015-01-10 01:50:43 +00:00
|
|
|
#include <MyGUI_InputManager.h>
|
|
|
|
#include <MyGUI_Button.h>
|
2017-02-04 19:33:50 +00:00
|
|
|
|
2017-04-24 16:46:12 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Include additional headers for multiplayer purposes
|
|
|
|
*/
|
2017-02-04 19:33:50 +00:00
|
|
|
#include <components/openmw-mp/Log.hpp>
|
2016-12-16 09:27:19 +00:00
|
|
|
#include "../mwmp/Main.hpp"
|
2017-02-04 19:33:50 +00:00
|
|
|
#include "../mwmp/Networking.hpp"
|
2017-02-06 15:40:32 +00:00
|
|
|
#include "../mwmp/WorldEvent.hpp"
|
2017-04-05 09:00:21 +00:00
|
|
|
#include "../mwmp/CellController.hpp"
|
2017-04-24 16:46:12 +00:00
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
2015-01-10 01:50:43 +00:00
|
|
|
|
2012-05-11 09:52:07 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
2012-08-12 16:11:09 +00:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2014-01-07 02:01:33 +00:00
|
|
|
#include "../mwbase/dialoguemanager.hpp"
|
2014-01-07 18:49:16 +00:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
#include "../mwworld/class.hpp"
|
2017-09-11 10:49:55 +00:00
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
|
2014-04-27 03:40:07 +00:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
2014-01-07 02:01:33 +00:00
|
|
|
|
2012-05-15 10:51:51 +00:00
|
|
|
#include "countdialog.hpp"
|
2012-05-18 15:27:55 +00:00
|
|
|
#include "inventorywindow.hpp"
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
#include "itemview.hpp"
|
2014-06-05 20:13:18 +00:00
|
|
|
#include "itemwidget.hpp"
|
2013-05-11 16:38:27 +00:00
|
|
|
#include "inventoryitemmodel.hpp"
|
2017-10-03 05:59:31 +00:00
|
|
|
#include "containeritemmodel.hpp"
|
2013-05-11 16:38:27 +00:00
|
|
|
#include "sortfilteritemmodel.hpp"
|
|
|
|
#include "pickpocketitemmodel.hpp"
|
2015-01-10 00:21:17 +00:00
|
|
|
#include "draganddrop.hpp"
|
2013-05-11 16:38:27 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
namespace MWGui
|
2012-04-15 15:52:39 +00:00
|
|
|
{
|
2012-05-12 20:44:12 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
ContainerWindow::ContainerWindow(DragAndDrop* dragAndDrop)
|
|
|
|
: WindowBase("openmw_container_window.layout")
|
|
|
|
, mDragAndDrop(dragAndDrop)
|
2015-05-01 00:24:27 +00:00
|
|
|
, mSortModel(NULL)
|
|
|
|
, mModel(NULL)
|
|
|
|
, mSelectedItem(-1)
|
2012-05-15 18:33:34 +00:00
|
|
|
{
|
2013-05-11 16:38:27 +00:00
|
|
|
getWidget(mDisposeCorpseButton, "DisposeCorpseButton");
|
|
|
|
getWidget(mTakeButton, "TakeButton");
|
|
|
|
getWidget(mCloseButton, "CloseButton");
|
2012-05-15 19:44:57 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
getWidget(mItemView, "ItemView");
|
|
|
|
mItemView->eventBackgroundClicked += MyGUI::newDelegate(this, &ContainerWindow::onBackgroundSelected);
|
|
|
|
mItemView->eventItemClicked += MyGUI::newDelegate(this, &ContainerWindow::onItemSelected);
|
2013-03-16 18:00:14 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
mDisposeCorpseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onDisposeCorpseButtonClicked);
|
|
|
|
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
|
|
|
|
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
|
2013-03-16 18:00:14 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
setCoord(200,0,600,300);
|
|
|
|
}
|
2013-03-16 18:00:14 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
void ContainerWindow::onItemSelected(int index)
|
|
|
|
{
|
2017-11-11 07:54:18 +00:00
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop && mModel)
|
2014-09-11 05:00:39 +00:00
|
|
|
{
|
2017-11-11 07:54:18 +00:00
|
|
|
dropItem();
|
2014-09-11 05:00:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-11 03:38:38 +00:00
|
|
|
const ItemStack& item = mSortModel->getItem(index);
|
|
|
|
|
|
|
|
// We can't take a conjured item from a container (some NPC we're pickpocketing, a box, etc)
|
2014-09-13 22:48:41 +00:00
|
|
|
if (item.mFlags & ItemStack::Flag_Bound)
|
2014-09-11 03:38:38 +00:00
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sContentsMessage1}");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
MWWorld::Ptr object = item.mBase;
|
|
|
|
int count = item.mCount;
|
|
|
|
bool shift = MyGUI::InputManager::getInstance().isShiftPressed();
|
|
|
|
if (MyGUI::InputManager::getInstance().isControlPressed())
|
|
|
|
count = 1;
|
2012-05-15 18:33:34 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
mSelectedItem = mSortModel->mapToSource(index);
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
if (count > 1 && !shift)
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2013-05-11 16:38:27 +00:00
|
|
|
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
2015-06-04 18:31:28 +00:00
|
|
|
dialog->openCountDialog(object.getClass().getName(object), "#{sTake}", count);
|
2013-05-11 16:38:27 +00:00
|
|
|
dialog->eventOkClicked.clear();
|
|
|
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem);
|
2012-05-06 09:04:07 +00:00
|
|
|
}
|
2013-04-17 22:56:48 +00:00
|
|
|
else
|
2013-05-11 16:38:27 +00:00
|
|
|
dragItem (NULL, count);
|
2012-05-18 18:53:24 +00:00
|
|
|
}
|
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
void ContainerWindow::dragItem(MyGUI::Widget* sender, int count)
|
2012-05-18 18:53:24 +00:00
|
|
|
{
|
2014-01-07 02:01:33 +00:00
|
|
|
if (!onTakeItem(mModel->getItem(mSelectedItem), count))
|
|
|
|
return;
|
|
|
|
|
2017-02-26 14:59:53 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Send an ID_CONTAINER packet every time an item starts being dragged
|
|
|
|
from a container
|
|
|
|
*/
|
2017-04-05 06:04:41 +00:00
|
|
|
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
|
|
|
worldEvent->reset();
|
2017-02-23 07:18:48 +00:00
|
|
|
worldEvent->cell = *mPtr.getCell()->getCell();
|
|
|
|
worldEvent->action = mwmp::BaseEvent::REMOVE;
|
2017-02-04 19:33:50 +00:00
|
|
|
|
|
|
|
mwmp::WorldObject worldObject;
|
|
|
|
worldObject.refId = mPtr.getCellRef().getRefId();
|
|
|
|
worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex;
|
2017-04-04 08:07:16 +00:00
|
|
|
worldObject.mpNum = mPtr.getCellRef().getMpNum();
|
2017-02-04 19:33:50 +00:00
|
|
|
|
2017-02-06 19:28:03 +00:00
|
|
|
MWWorld::Ptr itemPtr = mModel->getItem(mSelectedItem).mBase;
|
|
|
|
|
2017-02-04 19:33:50 +00:00
|
|
|
mwmp::ContainerItem containerItem;
|
2017-02-06 19:28:03 +00:00
|
|
|
containerItem.refId =itemPtr.getCellRef().getRefId();
|
|
|
|
containerItem.count = itemPtr.getRefData().getCount();
|
|
|
|
containerItem.charge = itemPtr.getCellRef().getCharge();
|
|
|
|
containerItem.actionCount = count;
|
2017-02-15 18:14:25 +00:00
|
|
|
|
2017-05-06 18:57:14 +00:00
|
|
|
worldObject.containerItems.push_back(containerItem);
|
2017-02-23 07:18:48 +00:00
|
|
|
worldEvent->addObject(worldObject);
|
2017-02-04 19:33:50 +00:00
|
|
|
|
2017-03-06 09:44:08 +00:00
|
|
|
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(worldEvent);
|
|
|
|
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send();
|
2017-02-04 19:33:50 +00:00
|
|
|
|
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i",
|
2017-03-04 06:55:35 +00:00
|
|
|
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(),
|
|
|
|
containerItem.refId.c_str(), containerItem.count);
|
2017-02-26 14:59:53 +00:00
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
2017-02-04 19:33:50 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count);
|
2012-05-18 15:27:55 +00:00
|
|
|
}
|
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
void ContainerWindow::dropItem()
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2017-10-04 18:37:08 +00:00
|
|
|
bool success = mModel->onDropItem(mDragAndDrop->mItem.mBase, mDragAndDrop->mDraggedCount);
|
2012-05-12 20:44:12 +00:00
|
|
|
|
2017-02-26 14:59:53 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Send an ID_CONTAINER packet every time an item is dropped in a container
|
|
|
|
*/
|
2017-11-12 04:35:15 +00:00
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
|
|
|
worldEvent->reset();
|
|
|
|
worldEvent->cell = *mPtr.getCell()->getCell();
|
|
|
|
worldEvent->action = mwmp::BaseEvent::ADD;
|
2017-02-05 17:33:11 +00:00
|
|
|
|
2017-11-12 04:35:15 +00:00
|
|
|
mwmp::WorldObject worldObject;
|
|
|
|
worldObject.refId = mPtr.getCellRef().getRefId();
|
|
|
|
worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex;
|
|
|
|
worldObject.mpNum = mPtr.getCellRef().getMpNum();
|
2017-02-05 17:33:11 +00:00
|
|
|
|
2017-11-12 04:35:15 +00:00
|
|
|
MWWorld::Ptr itemPtr = mDragAndDrop->mItem.mBase;
|
2017-02-06 20:45:23 +00:00
|
|
|
|
2017-11-12 04:35:15 +00:00
|
|
|
mwmp::ContainerItem containerItem;
|
|
|
|
containerItem.refId = itemPtr.getCellRef().getRefId();
|
|
|
|
|
|
|
|
// Make sure we get the drag and drop count, not the count of the original item
|
|
|
|
containerItem.count = mDragAndDrop->mDraggedCount;
|
2017-02-20 10:31:11 +00:00
|
|
|
|
2017-11-12 04:35:15 +00:00
|
|
|
containerItem.charge = itemPtr.getCellRef().getCharge();
|
2017-02-15 18:14:25 +00:00
|
|
|
|
2017-11-12 04:35:15 +00:00
|
|
|
worldObject.containerItems.push_back(containerItem);
|
|
|
|
worldEvent->addObject(worldObject);
|
2017-02-05 17:33:11 +00:00
|
|
|
|
2017-11-12 04:35:15 +00:00
|
|
|
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(worldEvent);
|
|
|
|
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send();
|
2017-02-05 17:33:11 +00:00
|
|
|
|
2017-11-12 04:35:15 +00:00
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i",
|
|
|
|
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(),
|
|
|
|
containerItem.refId.c_str(), containerItem.count);
|
|
|
|
}
|
2017-02-26 14:59:53 +00:00
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
2017-02-05 17:33:11 +00:00
|
|
|
|
2017-10-04 18:37:08 +00:00
|
|
|
if (success)
|
|
|
|
mDragAndDrop->drop(mModel, mItemView);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2012-05-12 20:44:12 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
void ContainerWindow::onBackgroundSelected()
|
2012-04-30 11:01:18 +00:00
|
|
|
{
|
2017-11-11 07:54:18 +00:00
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop && mModel)
|
2013-05-11 16:38:27 +00:00
|
|
|
dropItem();
|
2012-04-30 11:01:18 +00:00
|
|
|
}
|
2012-04-15 15:52:39 +00:00
|
|
|
|
2017-09-22 19:26:41 +00:00
|
|
|
void ContainerWindow::setPtr(const MWWorld::Ptr& container)
|
2012-05-11 14:58:07 +00:00
|
|
|
{
|
2017-10-06 01:10:04 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Mark this container as open for multiplayer logic purposes
|
|
|
|
*/
|
2017-10-07 20:33:36 +00:00
|
|
|
mwmp::Main::get().getCellController()->openContainer(container);
|
2017-10-06 01:10:04 +00:00
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
2016-12-16 09:27:19 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
mPtr = container;
|
2012-05-12 12:01:59 +00:00
|
|
|
|
2017-09-22 19:26:41 +00:00
|
|
|
bool loot = mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead();
|
|
|
|
|
2017-10-03 05:59:31 +00:00
|
|
|
if (mPtr.getClass().hasInventoryStore(mPtr))
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2017-10-03 05:59:31 +00:00
|
|
|
if (mPtr.getClass().isNpc() && !loot)
|
|
|
|
{
|
|
|
|
// we are stealing stuff
|
2017-10-04 17:25:22 +00:00
|
|
|
mModel = new PickpocketItemModel(mPtr, new InventoryItemModel(container),
|
2017-10-03 05:59:31 +00:00
|
|
|
!mPtr.getClass().getCreatureStats(mPtr).getKnockedDown());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mModel = new InventoryItemModel(container);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2013-05-11 16:38:27 +00:00
|
|
|
else
|
2017-10-03 05:59:31 +00:00
|
|
|
{
|
|
|
|
mModel = new ContainerItemModel(container);
|
|
|
|
}
|
2013-03-17 21:28:28 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mDisposeCorpseButton->setVisible(loot);
|
2012-05-12 12:01:59 +00:00
|
|
|
|
2013-05-11 16:38:27 +00:00
|
|
|
mSortModel = new SortFilterItemModel(mModel);
|
|
|
|
|
|
|
|
mItemView->setModel (mSortModel);
|
2015-06-04 20:09:40 +00:00
|
|
|
mItemView->resetScrollBars();
|
2013-11-16 21:29:40 +00:00
|
|
|
|
2014-01-29 16:26:18 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCloseButton);
|
2014-01-10 23:24:21 +00:00
|
|
|
|
2014-05-22 18:37:22 +00:00
|
|
|
setTitle(container.getClass().getName(container));
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 21:37:59 +00:00
|
|
|
void ContainerWindow::resetReference()
|
|
|
|
{
|
|
|
|
ReferenceInterface::resetReference();
|
|
|
|
mItemView->setModel(NULL);
|
2014-07-14 14:53:58 +00:00
|
|
|
mModel = NULL;
|
|
|
|
mSortModel = NULL;
|
2014-07-07 21:37:59 +00:00
|
|
|
}
|
|
|
|
|
2017-09-22 15:10:53 +00:00
|
|
|
void ContainerWindow::onClose()
|
2014-01-07 02:01:33 +00:00
|
|
|
{
|
2017-10-06 01:10:04 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Mark this container as closed for multiplayer logic purposes
|
|
|
|
*/
|
2017-04-05 09:00:21 +00:00
|
|
|
mwmp::Main::get().getCellController()->closeContainer(mPtr);
|
2017-10-06 01:10:04 +00:00
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
|
|
|
|
2017-09-22 15:10:53 +00:00
|
|
|
WindowBase::onClose();
|
2014-01-07 02:01:33 +00:00
|
|
|
|
2017-12-03 17:49:13 +00:00
|
|
|
if (mModel)
|
|
|
|
mModel->onClose();
|
2014-01-07 02:01:33 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 03:13:37 +00:00
|
|
|
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
2017-09-23 10:18:39 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
2014-05-27 03:13:37 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
2017-09-11 10:49:55 +00:00
|
|
|
if(mDragAndDrop != NULL && mDragAndDrop->mIsOnDragAndDrop)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// transfer everything into the player's inventory
|
|
|
|
ItemModel* playerModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getModel();
|
|
|
|
mModel->update();
|
|
|
|
|
|
|
|
// unequip all items to avoid unequipping/reequipping
|
|
|
|
if (mPtr.getClass().hasInventoryStore(mPtr))
|
2013-04-17 22:56:48 +00:00
|
|
|
{
|
2017-09-11 10:49:55 +00:00
|
|
|
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
|
2013-05-11 16:38:27 +00:00
|
|
|
for (size_t i=0; i<mModel->getItemCount(); ++i)
|
2012-05-16 12:30:02 +00:00
|
|
|
{
|
2014-01-07 02:01:33 +00:00
|
|
|
const ItemStack& item = mModel->getItem(i);
|
2017-09-11 10:49:55 +00:00
|
|
|
if (invStore.isEquipped(item.mBase) == false)
|
|
|
|
continue;
|
2014-01-07 02:01:33 +00:00
|
|
|
|
2017-09-11 10:49:55 +00:00
|
|
|
invStore.unequipItem(item.mBase, mPtr);
|
|
|
|
}
|
|
|
|
}
|
2014-01-07 02:01:33 +00:00
|
|
|
|
2017-09-11 10:49:55 +00:00
|
|
|
mModel->update();
|
2014-01-07 02:01:33 +00:00
|
|
|
|
2017-09-11 10:49:55 +00:00
|
|
|
for (size_t i=0; i<mModel->getItemCount(); ++i)
|
|
|
|
{
|
|
|
|
if (i==0)
|
|
|
|
{
|
|
|
|
// play the sound of the first object
|
|
|
|
MWWorld::Ptr item = mModel->getItem(i).mBase;
|
|
|
|
std::string sound = item.getClass().getUpSoundId(item);
|
|
|
|
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
|
|
|
|
2017-09-11 10:49:55 +00:00
|
|
|
const ItemStack& item = mModel->getItem(i);
|
2017-02-05 18:04:50 +00:00
|
|
|
|
2017-09-11 10:49:55 +00:00
|
|
|
if (!onTakeItem(item, item.mCount))
|
|
|
|
break;
|
2017-02-26 14:59:53 +00:00
|
|
|
|
2017-09-11 10:49:55 +00:00
|
|
|
mModel->moveItem(item, item.mCount, playerModel);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2017-09-11 10:49:55 +00:00
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
2017-09-22 16:12:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Send an ID_CONTAINER packet every time the Take All button is used on
|
|
|
|
a container
|
|
|
|
*/
|
|
|
|
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
|
|
|
worldEvent->reset();
|
|
|
|
worldEvent->cell = *mPtr.getCell()->getCell();
|
|
|
|
worldEvent->action = mwmp::BaseEvent::SET;
|
|
|
|
|
|
|
|
mwmp::WorldObject worldObject;
|
|
|
|
worldObject.refId = mPtr.getCellRef().getRefId();
|
|
|
|
worldObject.refNumIndex = mPtr.getCellRef().getRefNum().mIndex;
|
|
|
|
worldObject.mpNum = mPtr.getCellRef().getMpNum();
|
|
|
|
worldEvent->addObject(worldObject);
|
|
|
|
|
|
|
|
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->setEvent(worldEvent);
|
|
|
|
mwmp::Main::get().getNetworking()->getWorldPacket(ID_CONTAINER)->Send();
|
|
|
|
|
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s",
|
|
|
|
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str());
|
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
2012-05-11 14:58:07 +00:00
|
|
|
}
|
2012-05-26 23:14:33 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void ContainerWindow::onDisposeCorpseButtonClicked(MyGUI::Widget *sender)
|
2013-03-07 13:00:13 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
|
|
|
|
{
|
|
|
|
onTakeAllButtonClicked(mTakeButton);
|
2013-03-07 13:00:13 +00:00
|
|
|
|
2017-05-08 05:44:43 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Send an ID_OBJECT_DELETE packet every time a corpse is disposed of
|
|
|
|
*/
|
|
|
|
if (!mPtr.getClass().isPersistent(mPtr))
|
|
|
|
{
|
|
|
|
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
|
|
|
worldEvent->reset();
|
|
|
|
worldEvent->addObjectDelete(mPtr);
|
|
|
|
worldEvent->sendObjectDelete();
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
|
|
|
|
2014-05-22 18:37:22 +00:00
|
|
|
if (mPtr.getClass().isPersistent(mPtr))
|
2013-05-16 16:50:26 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}");
|
|
|
|
else
|
2013-04-17 22:56:48 +00:00
|
|
|
MWBase::Environment::get().getWorld()->deleteObject(mPtr);
|
2013-03-07 13:00:13 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
mPtr = MWWorld::Ptr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContainerWindow::onReferenceUnavailable()
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
2013-03-07 13:00:13 +00:00
|
|
|
}
|
|
|
|
|
2014-01-07 02:01:33 +00:00
|
|
|
bool ContainerWindow::onTakeItem(const ItemStack &item, int count)
|
|
|
|
{
|
2017-10-04 17:25:22 +00:00
|
|
|
return mModel->onTakeItem(item.mBase, count);
|
2014-01-07 02:01:33 +00:00
|
|
|
}
|
|
|
|
|
2012-05-26 23:14:33 +00:00
|
|
|
}
|