|
|
@ -22,12 +22,10 @@
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
#include "../mwbase/dialoguemanager.hpp"
|
|
|
|
#include "../mwbase/dialoguemanager.hpp"
|
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
#include "../mwworld/inventorystore.hpp"
|
|
|
|
#include "../mwworld/inventorystore.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include "../mwmechanics/pickpocket.hpp"
|
|
|
|
|
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include "countdialog.hpp"
|
|
|
|
#include "countdialog.hpp"
|
|
|
@ -47,7 +45,6 @@ namespace MWGui
|
|
|
|
ContainerWindow::ContainerWindow(DragAndDrop* dragAndDrop)
|
|
|
|
ContainerWindow::ContainerWindow(DragAndDrop* dragAndDrop)
|
|
|
|
: WindowBase("openmw_container_window.layout")
|
|
|
|
: WindowBase("openmw_container_window.layout")
|
|
|
|
, mDragAndDrop(dragAndDrop)
|
|
|
|
, mDragAndDrop(dragAndDrop)
|
|
|
|
, mPickpocketDetected(false)
|
|
|
|
|
|
|
|
, mSortModel(NULL)
|
|
|
|
, mSortModel(NULL)
|
|
|
|
, mModel(NULL)
|
|
|
|
, mModel(NULL)
|
|
|
|
, mSelectedItem(-1)
|
|
|
|
, mSelectedItem(-1)
|
|
|
@ -69,9 +66,8 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
|
|
void ContainerWindow::onItemSelected(int index)
|
|
|
|
void ContainerWindow::onItemSelected(int index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop)
|
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop && mModel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mModel && mModel->allowedToInsertItems())
|
|
|
|
|
|
|
|
dropItem();
|
|
|
|
dropItem();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -151,32 +147,15 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
|
|
void ContainerWindow::dropItem()
|
|
|
|
void ContainerWindow::dropItem()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mPtr.getTypeName() == typeid(ESM::Container).name())
|
|
|
|
bool success = mModel->onDropItem(mDragAndDrop->mItem.mBase, mDragAndDrop->mDraggedCount);
|
|
|
|
{
|
|
|
|
|
|
|
|
// check container organic flag
|
|
|
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Container>* ref = mPtr.get<ESM::Container>();
|
|
|
|
|
|
|
|
if (ref->mBase->mFlags & ESM::Container::Organic)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->
|
|
|
|
|
|
|
|
messageBox("#{sContentsMessage2}");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check that we don't exceed container capacity
|
|
|
|
|
|
|
|
MWWorld::Ptr item = mDragAndDrop->mItem.mBase;
|
|
|
|
|
|
|
|
float weight = item.getClass().getWeight(item) * mDragAndDrop->mDraggedCount;
|
|
|
|
|
|
|
|
if (mPtr.getClass().getCapacity(mPtr) < mPtr.getClass().getEncumbrance(mPtr) + weight)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sContentsMessage3}");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
|
|
|
|
Send an ID_CONTAINER packet every time an item is dropped in a container
|
|
|
|
Send an ID_CONTAINER packet every time an item is dropped in a container
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
|
|
|
|
{
|
|
|
|
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
|
|
|
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
|
|
|
worldEvent->reset();
|
|
|
|
worldEvent->reset();
|
|
|
|
worldEvent->cell = *mPtr.getCell()->getCell();
|
|
|
|
worldEvent->cell = *mPtr.getCell()->getCell();
|
|
|
@ -206,16 +185,18 @@ namespace MWGui
|
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i",
|
|
|
|
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(),
|
|
|
|
worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(),
|
|
|
|
containerItem.refId.c_str(), containerItem.count);
|
|
|
|
containerItem.refId.c_str(), containerItem.count);
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
mDragAndDrop->drop(mModel, mItemView);
|
|
|
|
mDragAndDrop->drop(mModel, mItemView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ContainerWindow::onBackgroundSelected()
|
|
|
|
void ContainerWindow::onBackgroundSelected()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop && mModel && mModel->allowedToInsertItems())
|
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop && mModel)
|
|
|
|
dropItem();
|
|
|
|
dropItem();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -231,7 +212,6 @@ namespace MWGui
|
|
|
|
End of tes3mp addition
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
mPickpocketDetected = false;
|
|
|
|
|
|
|
|
mPtr = container;
|
|
|
|
mPtr = container;
|
|
|
|
|
|
|
|
|
|
|
|
bool loot = mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead();
|
|
|
|
bool loot = mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead();
|
|
|
@ -241,8 +221,7 @@ namespace MWGui
|
|
|
|
if (mPtr.getClass().isNpc() && !loot)
|
|
|
|
if (mPtr.getClass().isNpc() && !loot)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// we are stealing stuff
|
|
|
|
// we are stealing stuff
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
mModel = new PickpocketItemModel(mPtr, new InventoryItemModel(container),
|
|
|
|
mModel = new PickpocketItemModel(player, new InventoryItemModel(container),
|
|
|
|
|
|
|
|
!mPtr.getClass().getCreatureStats(mPtr).getKnockedDown());
|
|
|
|
!mPtr.getClass().getCreatureStats(mPtr).getKnockedDown());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -287,24 +266,7 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
|
|
WindowBase::onClose();
|
|
|
|
WindowBase::onClose();
|
|
|
|
|
|
|
|
|
|
|
|
if (dynamic_cast<PickpocketItemModel*>(mModel)
|
|
|
|
mModel->onClose();
|
|
|
|
// Make sure we were actually closed, rather than just temporarily hidden (e.g. console or main menu opened)
|
|
|
|
|
|
|
|
&& !MWBase::Environment::get().getWindowManager()->containsMode(GM_Container)
|
|
|
|
|
|
|
|
// If it was already detected while taking an item, no need to check now
|
|
|
|
|
|
|
|
&& !mPickpocketDetected
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
|
|
|
|
MWMechanics::Pickpocket pickpocket(player, mPtr);
|
|
|
|
|
|
|
|
if (pickpocket.finish())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWBase::Environment::get().getMechanicsManager()->commitCrime(
|
|
|
|
|
|
|
|
player, mPtr, MWBase::MechanicsManager::OT_Pickpocket, 0, true);
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Container);
|
|
|
|
|
|
|
|
mPickpocketDetected = true;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
|
|
@ -422,32 +384,7 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
|
|
bool ContainerWindow::onTakeItem(const ItemStack &item, int count)
|
|
|
|
bool ContainerWindow::onTakeItem(const ItemStack &item, int count)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
return mModel->onTakeItem(item.mBase, count);
|
|
|
|
// TODO: move to ItemModels
|
|
|
|
|
|
|
|
if (dynamic_cast<PickpocketItemModel*>(mModel)
|
|
|
|
|
|
|
|
&& !mPtr.getClass().getCreatureStats(mPtr).getKnockedDown())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWMechanics::Pickpocket pickpocket(player, mPtr);
|
|
|
|
|
|
|
|
if (pickpocket.pick(item.mBase, count))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MWBase::Environment::get().getMechanicsManager()->commitCrime(
|
|
|
|
|
|
|
|
player, mPtr, MWBase::MechanicsManager::OT_Pickpocket, 0, true);
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Container);
|
|
|
|
|
|
|
|
mPickpocketDetected = true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
player.getClass().skillUsageSucceeded(player, ESM::Skill::Sneak, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Looting a dead corpse is considered OK
|
|
|
|
|
|
|
|
if (mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead())
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, item.mBase, mPtr, count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|