2012-04-15 17:52:39 +02:00
|
|
|
#include "container.hpp"
|
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_Button.h>
|
|
|
|
#include <MyGUI_InputManager.h>
|
|
|
|
|
2012-05-11 11:52:07 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2014-01-07 19:49:16 +01:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2019-08-27 22:42:41 +04:00
|
|
|
#include "../mwbase/scriptmanager.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"
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
#include "../mwworld/class.hpp"
|
2017-09-11 14:49:55 +04:00
|
|
|
#include "../mwworld/inventorystore.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
|
2021-06-06 12:45:42 +02:00
|
|
|
#include "../mwmechanics/aipackage.hpp"
|
2014-04-27 05:40:07 +02:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
2021-06-06 12:45:42 +02:00
|
|
|
#include "../mwmechanics/summoning.hpp"
|
2014-01-07 03:01:33 +01:00
|
|
|
|
2019-08-27 22:42:41 +04:00
|
|
|
#include "../mwscript/interpretercontext.hpp"
|
|
|
|
|
2012-05-15 12:51:51 +02:00
|
|
|
#include "countdialog.hpp"
|
2012-05-18 17:27:55 +02:00
|
|
|
#include "inventorywindow.hpp"
|
2012-04-15 17:52:39 +02:00
|
|
|
|
2017-10-03 09:59:31 +04:00
|
|
|
#include "containeritemmodel.hpp"
|
2015-01-10 01:21:17 +01:00
|
|
|
#include "draganddrop.hpp"
|
2013-05-11 18:38:27 +02:00
|
|
|
#include "inventoryitemmodel.hpp"
|
|
|
|
#include "itemview.hpp"
|
|
|
|
#include "pickpocketitemmodel.hpp"
|
|
|
|
#include "sortfilteritemmodel.hpp"
|
2020-04-10 23:14:00 +03:00
|
|
|
#include "tooltips.hpp"
|
2013-05-11 18:38:27 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
namespace MWGui
|
2012-04-15 17:52:39 +02:00
|
|
|
{
|
2012-05-12 22:44:12 +02:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
ContainerWindow::ContainerWindow(DragAndDrop* dragAndDrop)
|
|
|
|
: WindowBase("openmw_container_window.layout")
|
|
|
|
, mDragAndDrop(dragAndDrop)
|
2018-10-09 10:21:12 +04:00
|
|
|
, mSortModel(nullptr)
|
|
|
|
, mModel(nullptr)
|
2015-04-30 19:24:27 -05:00
|
|
|
, mSelectedItem(-1)
|
2021-12-01 18:21:21 +01:00
|
|
|
, mTreatNextOpenAsLoot(false)
|
2012-05-15 20:33:34 +02:00
|
|
|
{
|
2013-05-11 18:38:27 +02:00
|
|
|
getWidget(mDisposeCorpseButton, "DisposeCorpseButton");
|
|
|
|
getWidget(mTakeButton, "TakeButton");
|
|
|
|
getWidget(mCloseButton, "CloseButton");
|
2012-05-15 21:44:57 +02:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
getWidget(mItemView, "ItemView");
|
|
|
|
mItemView->eventBackgroundClicked += MyGUI::newDelegate(this, &ContainerWindow::onBackgroundSelected);
|
|
|
|
mItemView->eventItemClicked += MyGUI::newDelegate(this, &ContainerWindow::onItemSelected);
|
2013-03-16 19:00:14 +01:00
|
|
|
|
2013-05-11 18:38:27 +02: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 19:00:14 +01:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
setCoord(200, 0, 600, 300);
|
|
|
|
}
|
2013-03-16 19:00:14 +01:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
void ContainerWindow::onItemSelected(int index)
|
|
|
|
{
|
2018-08-03 16:40:04 +04:00
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop)
|
2014-09-11 01:00:39 -04:00
|
|
|
{
|
2017-11-11 11:54:18 +04:00
|
|
|
dropItem();
|
2014-09-11 01:00:39 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-10 23:38:38 -04: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 18:48:41 -04:00
|
|
|
if (item.mFlags & ItemStack::Flag_Bound)
|
2014-09-10 23:38:38 -04:00
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sContentsMessage1}");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-11 18:38:27 +02: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 20:33:34 +02:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
mSelectedItem = mSortModel->mapToSource(index);
|
2012-04-15 17:52:39 +02:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
if (count > 1 && !shift)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2013-05-11 18:38:27 +02:00
|
|
|
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
2022-08-16 21:15:03 +02:00
|
|
|
std::string name{ object.getClass().getName(object) };
|
|
|
|
name += MWGui::ToolTips::getSoulString(object.getCellRef());
|
2020-04-10 23:14:00 +03:00
|
|
|
dialog->openCountDialog(name, "#{sTake}", count);
|
2013-05-11 18:38:27 +02:00
|
|
|
dialog->eventOkClicked.clear();
|
|
|
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem);
|
2012-05-06 11:04:07 +02:00
|
|
|
}
|
2018-08-03 16:40:04 +04:00
|
|
|
else
|
2018-10-09 10:21:12 +04:00
|
|
|
dragItem(nullptr, count);
|
2012-05-18 20:53:24 +02:00
|
|
|
}
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
void ContainerWindow::dragItem(MyGUI::Widget* sender, int count)
|
2012-05-18 20:53:24 +02:00
|
|
|
{
|
2018-08-03 16:40:04 +04:00
|
|
|
if (!mModel)
|
|
|
|
return;
|
|
|
|
|
2014-01-07 03:01:33 +01:00
|
|
|
if (!onTakeItem(mModel->getItem(mSelectedItem), count))
|
|
|
|
return;
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count);
|
2012-05-18 17:27:55 +02:00
|
|
|
}
|
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
void ContainerWindow::dropItem()
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2018-08-03 16:40:04 +04:00
|
|
|
if (!mModel)
|
|
|
|
return;
|
|
|
|
|
2017-10-04 22:37:08 +04:00
|
|
|
bool success = mModel->onDropItem(mDragAndDrop->mItem.mBase, mDragAndDrop->mDraggedCount);
|
2012-05-12 22:44:12 +02:00
|
|
|
|
2017-10-04 22:37:08 +04:00
|
|
|
if (success)
|
|
|
|
mDragAndDrop->drop(mModel, mItemView);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2012-05-12 22:44:12 +02:00
|
|
|
|
2013-05-11 18:38:27 +02:00
|
|
|
void ContainerWindow::onBackgroundSelected()
|
2012-04-30 13:01:18 +02:00
|
|
|
{
|
2018-08-03 16:40:04 +04:00
|
|
|
if (mDragAndDrop->mIsOnDragAndDrop)
|
2013-05-11 18:38:27 +02:00
|
|
|
dropItem();
|
2012-04-30 13:01:18 +02:00
|
|
|
}
|
2012-04-15 17:52:39 +02:00
|
|
|
|
2017-09-22 21:26:41 +02:00
|
|
|
void ContainerWindow::setPtr(const MWWorld::Ptr& container)
|
2012-05-11 16:58:07 +02:00
|
|
|
{
|
2021-12-01 18:21:21 +01:00
|
|
|
bool lootAnyway = mTreatNextOpenAsLoot;
|
|
|
|
mTreatNextOpenAsLoot = false;
|
2013-05-11 18:38:27 +02:00
|
|
|
mPtr = container;
|
2012-05-12 14:01:59 +02:00
|
|
|
|
2017-09-22 21:26:41 +02:00
|
|
|
bool loot = mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead();
|
|
|
|
|
2022-08-31 18:49:50 +02:00
|
|
|
std::unique_ptr<ItemModel> model;
|
2017-10-03 09:59:31 +04:00
|
|
|
if (mPtr.getClass().hasInventoryStore(mPtr))
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2021-12-01 18:21:21 +01:00
|
|
|
if (mPtr.getClass().isNpc() && !loot && !lootAnyway)
|
2017-10-03 09:59:31 +04:00
|
|
|
{
|
|
|
|
// we are stealing stuff
|
2022-08-31 18:49:50 +02:00
|
|
|
model = std::make_unique<PickpocketItemModel>(mPtr, std::make_unique<InventoryItemModel>(container),
|
2017-10-03 09:59:31 +04:00
|
|
|
!mPtr.getClass().getCreatureStats(mPtr).getKnockedDown());
|
|
|
|
}
|
|
|
|
else
|
2022-08-31 18:49:50 +02:00
|
|
|
model = std::make_unique<InventoryItemModel>(container);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-05-11 18:38:27 +02:00
|
|
|
else
|
2017-10-03 09:59:31 +04:00
|
|
|
{
|
2022-08-31 18:49:50 +02:00
|
|
|
model = std::make_unique<ContainerItemModel>(container);
|
2017-10-03 09:59:31 +04:00
|
|
|
}
|
2013-03-17 22:28:28 +01:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mDisposeCorpseButton->setVisible(loot);
|
2022-08-31 18:49:50 +02:00
|
|
|
mModel = model.get();
|
2022-08-31 19:03:45 +02:00
|
|
|
auto sortModel = std::make_unique<SortFilterItemModel>(std::move(model));
|
|
|
|
mSortModel = sortModel.get();
|
2013-05-11 18:38:27 +02:00
|
|
|
|
2022-08-31 19:03:45 +02:00
|
|
|
mItemView->setModel(std::move(sortModel));
|
2015-06-04 23:09:40 +03:00
|
|
|
mItemView->resetScrollBars();
|
2013-11-16 22:29:40 +01:00
|
|
|
|
2019-06-09 02:08:09 +03:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCloseButton);
|
2014-01-11 00:24:21 +01:00
|
|
|
|
2014-05-22 20:37:22 +02:00
|
|
|
setTitle(container.getClass().getName(container));
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
|
|
|
|
2014-07-07 23:37:59 +02:00
|
|
|
void ContainerWindow::resetReference()
|
|
|
|
{
|
|
|
|
ReferenceInterface::resetReference();
|
2018-10-09 10:21:12 +04:00
|
|
|
mItemView->setModel(nullptr);
|
|
|
|
mModel = nullptr;
|
|
|
|
mSortModel = nullptr;
|
2014-07-07 23:37:59 +02:00
|
|
|
}
|
|
|
|
|
2017-09-22 17:10:53 +02:00
|
|
|
void ContainerWindow::onClose()
|
2014-01-07 03:01:33 +01:00
|
|
|
{
|
2017-09-22 17:10:53 +02:00
|
|
|
WindowBase::onClose();
|
2014-01-07 03:01:33 +01:00
|
|
|
|
2020-10-22 01:57:23 +03:00
|
|
|
// Make sure the window was actually closed and not temporarily hidden.
|
|
|
|
if (MWBase::Environment::get().getWindowManager()->containsMode(GM_Container))
|
|
|
|
return;
|
|
|
|
|
2017-12-03 21:49:13 +04:00
|
|
|
if (mModel)
|
|
|
|
mModel->onClose();
|
2018-09-22 12:57:50 +04:00
|
|
|
|
2019-05-13 17:59:32 +04:00
|
|
|
if (!mPtr.isEmpty())
|
|
|
|
MWBase::Environment::get().getMechanicsManager()->onClose(mPtr);
|
2020-10-13 17:46:32 +02:00
|
|
|
resetReference();
|
2014-01-07 03:01:33 +01:00
|
|
|
}
|
|
|
|
|
2014-05-26 23:13:37 -04:00
|
|
|
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
2017-09-23 12:18:39 +02:00
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
2014-05-26 23:13:37 -04:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
2018-10-09 10:21:12 +04:00
|
|
|
if (mDragAndDrop != nullptr && mDragAndDrop->mIsOnDragAndDrop)
|
2017-09-11 14:49:55 +04:00
|
|
|
return;
|
|
|
|
|
2019-06-09 02:08:09 +03:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCloseButton);
|
2018-09-10 10:51:36 +04:00
|
|
|
|
2017-09-11 14:49:55 +04:00
|
|
|
// transfer everything into the player's inventory
|
|
|
|
ItemModel* playerModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getModel();
|
2020-10-22 01:57:23 +03:00
|
|
|
assert(mModel);
|
2017-09-11 14:49:55 +04:00
|
|
|
mModel->update();
|
|
|
|
|
|
|
|
// unequip all items to avoid unequipping/reequipping
|
|
|
|
if (mPtr.getClass().hasInventoryStore(mPtr))
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2017-09-11 14:49:55 +04:00
|
|
|
MWWorld::InventoryStore& invStore = mPtr.getClass().getInventoryStore(mPtr);
|
2013-05-11 18:38:27 +02:00
|
|
|
for (size_t i = 0; i < mModel->getItemCount(); ++i)
|
2012-05-16 14:30:02 +02:00
|
|
|
{
|
2014-01-07 03:01:33 +01:00
|
|
|
const ItemStack& item = mModel->getItem(i);
|
2017-09-11 14:49:55 +04:00
|
|
|
if (invStore.isEquipped(item.mBase) == false)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
invStore.unequipItem(item.mBase, mPtr);
|
|
|
|
}
|
|
|
|
}
|
2014-01-07 03:01:33 +01:00
|
|
|
|
2017-09-11 14:49:55 +04:00
|
|
|
mModel->update();
|
2014-01-07 03:01:33 +01:00
|
|
|
|
2017-09-11 14:49:55 +04: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;
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& sound = item.getClass().getUpSoundId(item);
|
2017-09-11 14:49:55 +04:00
|
|
|
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
|
|
|
|
2017-09-11 14:49:55 +04:00
|
|
|
const ItemStack& item = mModel->getItem(i);
|
|
|
|
|
|
|
|
if (!onTakeItem(item, item.mCount))
|
|
|
|
break;
|
|
|
|
|
|
|
|
mModel->moveItem(item, item.mCount, playerModel);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2017-09-11 14:49:55 +04:00
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
2012-05-11 16:58:07 +02:00
|
|
|
}
|
2012-05-27 01:14:33 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void ContainerWindow::onDisposeCorpseButtonClicked(MyGUI::Widget* sender)
|
2013-03-07 14:00:13 +01:00
|
|
|
{
|
2018-10-09 10:21:12 +04:00
|
|
|
if (mDragAndDrop == nullptr || !mDragAndDrop->mIsOnDragAndDrop)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2019-06-09 02:08:09 +03:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCloseButton);
|
2018-09-10 10:51:36 +04:00
|
|
|
|
2020-10-16 19:54:26 +00:00
|
|
|
// Copy mPtr because onTakeAllButtonClicked closes the window which resets the reference
|
|
|
|
MWWorld::Ptr ptr = mPtr;
|
2013-04-17 18:56:48 -04:00
|
|
|
onTakeAllButtonClicked(mTakeButton);
|
2013-03-07 14:00:13 +01:00
|
|
|
|
2020-10-16 19:54:26 +00:00
|
|
|
if (ptr.getClass().isPersistent(ptr))
|
2013-05-16 18:50:26 +02:00
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}");
|
|
|
|
else
|
2019-08-27 22:42:41 +04:00
|
|
|
{
|
2020-10-16 19:54:26 +00:00
|
|
|
MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
|
2019-08-27 22:42:41 +04:00
|
|
|
|
|
|
|
// If we dispose corpse before end of death animation, we should update death counter counter manually.
|
|
|
|
// Also we should run actor's script - it may react on actor's death.
|
|
|
|
if (creatureStats.isDead() && !creatureStats.isDeathAnimationFinished())
|
|
|
|
{
|
|
|
|
creatureStats.setDeathAnimationFinished(true);
|
2020-10-16 19:54:26 +00:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->notifyDied(ptr);
|
2019-08-27 22:42:41 +04:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& script = ptr.getClass().getScript(ptr);
|
2019-08-27 22:42:41 +04:00
|
|
|
if (!script.empty() && MWBase::Environment::get().getWorld()->getScriptsEnabled())
|
|
|
|
{
|
2020-10-16 19:54:26 +00:00
|
|
|
MWScript::InterpreterContext interpreterContext(&ptr.getRefData().getLocals(), ptr);
|
2022-08-12 20:56:50 +02:00
|
|
|
MWBase::Environment::get().getScriptManager()->run(script, interpreterContext);
|
2019-08-27 22:42:41 +04:00
|
|
|
}
|
2019-11-12 21:44:46 +03:00
|
|
|
|
|
|
|
// Clean up summoned creatures as well
|
2021-08-27 20:07:50 +02:00
|
|
|
auto& creatureMap = creatureStats.getSummonedCreatureMap();
|
2019-11-12 21:44:46 +03:00
|
|
|
for (const auto& creature : creatureMap)
|
2020-10-16 19:54:26 +00:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(ptr, creature.second);
|
2019-11-12 21:44:46 +03:00
|
|
|
creatureMap.clear();
|
2021-06-06 12:45:42 +02:00
|
|
|
|
|
|
|
// Check if we are a summon and inform our master we've bit the dust
|
|
|
|
for (const auto& package : creatureStats.getAiSequence())
|
|
|
|
{
|
|
|
|
if (package->followTargetThroughDoors() && !package->getTarget().isEmpty())
|
|
|
|
{
|
|
|
|
const auto& summoner = package->getTarget();
|
|
|
|
auto& summons = summoner.getClass().getCreatureStats(summoner).getSummonedCreatureMap();
|
|
|
|
auto it = std::find_if(summons.begin(), summons.end(),
|
|
|
|
[&](const auto& entry) { return entry.second == creatureStats.getActorId(); });
|
|
|
|
if (it != summons.end())
|
|
|
|
{
|
2021-08-28 11:06:47 +02:00
|
|
|
auto summon = *it;
|
2021-06-06 12:45:42 +02:00
|
|
|
summons.erase(it);
|
2021-08-28 11:06:47 +02:00
|
|
|
MWMechanics::purgeSummonEffect(summoner, summon);
|
2021-06-06 12:45:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-27 22:42:41 +04:00
|
|
|
}
|
|
|
|
|
2020-10-16 19:54:26 +00:00
|
|
|
MWBase::Environment::get().getWorld()->deleteObject(ptr);
|
2019-08-27 22:42:41 +04:00
|
|
|
}
|
2013-03-07 14:00:13 +01:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mPtr = MWWorld::Ptr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContainerWindow::onReferenceUnavailable()
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
2013-03-07 14:00:13 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 03:01:33 +01:00
|
|
|
bool ContainerWindow::onTakeItem(const ItemStack& item, int count)
|
|
|
|
{
|
2017-10-04 21:25:22 +04:00
|
|
|
return mModel->onTakeItem(item.mBase, count);
|
2014-01-07 03:01:33 +01:00
|
|
|
}
|
|
|
|
|
2021-07-15 22:31:26 +02:00
|
|
|
void ContainerWindow::onDeleteCustomData(const MWWorld::Ptr& ptr)
|
|
|
|
{
|
|
|
|
if (mModel && mModel->usesContainer(ptr))
|
|
|
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
|
|
|
|
}
|
2012-05-27 01:14:33 +02:00
|
|
|
}
|