mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:15:31 +00:00
Add hooks for containers
This commit is contained in:
parent
536715cf46
commit
9ca206dda9
3 changed files with 49 additions and 1 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <MyGUI_InputManager.h>
|
#include <MyGUI_InputManager.h>
|
||||||
#include <MyGUI_Button.h>
|
#include <MyGUI_Button.h>
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/WorldController.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -132,6 +134,8 @@ namespace MWGui
|
||||||
|
|
||||||
void ContainerWindow::openContainer(const MWWorld::Ptr& container, bool loot)
|
void ContainerWindow::openContainer(const MWWorld::Ptr& container, bool loot)
|
||||||
{
|
{
|
||||||
|
mwmp::Main::get().getWorldController()->openContainer(container, loot);
|
||||||
|
|
||||||
mPickpocketDetected = false;
|
mPickpocketDetected = false;
|
||||||
mPtr = container;
|
mPtr = container;
|
||||||
|
|
||||||
|
@ -175,6 +179,7 @@ namespace MWGui
|
||||||
|
|
||||||
void ContainerWindow::close()
|
void ContainerWindow::close()
|
||||||
{
|
{
|
||||||
|
mwmp::Main::get().getWorldController()->closeContainer(mPtr);
|
||||||
WindowBase::close();
|
WindowBase::close();
|
||||||
|
|
||||||
if (dynamic_cast<PickpocketItemModel*>(mModel)
|
if (dynamic_cast<PickpocketItemModel*>(mModel)
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#include "../mwworld/worldimp.hpp"
|
#include "../mwworld/worldimp.hpp"
|
||||||
#include <components/esm/cellid.hpp>
|
#include <components/esm/cellid.hpp>
|
||||||
#include <components/openmw-mp/Log.hpp>
|
#include <components/openmw-mp/Log.hpp>
|
||||||
|
#include "../mwworld/containerstore.hpp"
|
||||||
|
#include "../mwworld/class.hpp"
|
||||||
|
#include <components/openmw-mp/Log.hpp>
|
||||||
|
|
||||||
#include "WorldController.hpp"
|
#include "WorldController.hpp"
|
||||||
#include "Main.hpp"
|
#include "Main.hpp"
|
||||||
|
@ -38,3 +40,39 @@ MWWorld::CellStore *mwmp::WorldController::getCell(const ESM::Cell& cell)
|
||||||
|
|
||||||
return cellStore;
|
return cellStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mwmp::WorldController::openContainer(const MWWorld::Ptr &container, bool loot)
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Container \"%s\" (%d) is openned. Loot: %s",
|
||||||
|
container.getCellRef().getRefId().c_str(),
|
||||||
|
container.getCellRef().getRefNum().mIndex,
|
||||||
|
loot ? "true" : "false");
|
||||||
|
|
||||||
|
MWWorld::ContainerStore &cont = container.getClass().getContainerStore(container);
|
||||||
|
for(MWWorld::ContainerStoreIterator iter = cont.begin(); iter != cont.end(); iter++)
|
||||||
|
{
|
||||||
|
int count = iter->getRefData().getCount();
|
||||||
|
const std::string &name = iter->getCellRef().getRefId();
|
||||||
|
|
||||||
|
LOG_APPEND(Log::LOG_VERBOSE, " - Item. Refid: \"%s\" Count: %d", name.c_str(), count);
|
||||||
|
|
||||||
|
/*if(::Misc::StringUtils::ciEqual(name, "gold_001"))
|
||||||
|
cont.remove("gold_001", count, container);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void mwmp::WorldController::closeContainer(const MWWorld::Ptr &container)
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Container \"%s\" (%d) is closed.",
|
||||||
|
container.getCellRef().getRefId().c_str(),
|
||||||
|
container.getCellRef().getRefNum().mIndex);
|
||||||
|
|
||||||
|
MWWorld::ContainerStore &cont = container.getClass().getContainerStore(container);
|
||||||
|
for(MWWorld::ContainerStoreIterator iter = cont.begin(); iter != cont.end(); iter++)
|
||||||
|
{
|
||||||
|
LOG_APPEND(Log::LOG_VERBOSE, " - Item. Refid: \"%s\" Count: %d",
|
||||||
|
iter->getCellRef().getRefId().c_str(), iter->getRefData().getCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef OPENMW_WORLDCONTROLLER_HPP
|
#ifndef OPENMW_WORLDCONTROLLER_HPP
|
||||||
#define OPENMW_WORLDCONTROLLER_HPP
|
#define OPENMW_WORLDCONTROLLER_HPP
|
||||||
|
|
||||||
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
class WorldController
|
class WorldController
|
||||||
|
@ -10,6 +12,9 @@ namespace mwmp
|
||||||
WorldController();
|
WorldController();
|
||||||
~WorldController();
|
~WorldController();
|
||||||
|
|
||||||
|
void openContainer(const MWWorld::Ptr& container, bool loot);
|
||||||
|
void closeContainer(const MWWorld::Ptr& container);
|
||||||
|
|
||||||
virtual MWWorld::CellStore *getCell(const ESM::Cell& cell);
|
virtual MWWorld::CellStore *getCell(const ESM::Cell& cell);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue