2010-08-07 20:25:17 +02:00
|
|
|
#include "actiontake.hpp"
|
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2014-01-07 19:49:16 +01:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2012-08-12 18:11:09 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
#include "../mwbase/world.hpp"
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2018-09-10 15:18:07 +04:00
|
|
|
#include "../mwgui/inventorywindow.hpp"
|
|
|
|
|
2010-08-07 20:25:17 +02:00
|
|
|
#include "class.hpp"
|
2012-02-23 12:38:25 +01:00
|
|
|
#include "containerstore.hpp"
|
2010-08-07 20:25:17 +02:00
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
2012-09-04 20:56:28 +02:00
|
|
|
ActionTake::ActionTake(const MWWorld::Ptr& object)
|
|
|
|
: Action(true, object)
|
|
|
|
{
|
|
|
|
}
|
2010-08-07 20:25:17 +02:00
|
|
|
|
2013-02-17 15:56:22 +01:00
|
|
|
void ActionTake::executeImp(const Ptr& actor)
|
2010-08-07 20:25:17 +02:00
|
|
|
{
|
2018-09-10 15:18:07 +04:00
|
|
|
// When in GUI mode, we should use drag and drop
|
|
|
|
if (actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
|
|
|
{
|
|
|
|
MWGui::GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
|
|
|
|
if (mode == MWGui::GM_Inventory || mode == MWGui::GM_Container)
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->pickUpObject(getTarget());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-07 19:49:16 +01:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->itemTaken(
|
2015-02-03 23:43:56 +01:00
|
|
|
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
|
2017-01-18 21:57:50 +01:00
|
|
|
MWWorld::Ptr newitem
|
2023-01-16 23:51:04 +01:00
|
|
|
= *actor.getClass().getContainerStore(actor).add(getTarget(), getTarget().getRefData().getCount());
|
2012-09-04 15:34:44 +02:00
|
|
|
MWBase::Environment::get().getWorld()->deleteObject(getTarget());
|
2017-01-18 21:57:50 +01:00
|
|
|
setTarget(newitem);
|
2010-08-07 20:25:17 +02:00
|
|
|
}
|
|
|
|
}
|