forked from teamnwah/openmw-tes3coop
item added to the player and OnActivate is triggered when the inventory is closed
This commit is contained in:
parent
1ee5dcff77
commit
4e6f53d6f1
3 changed files with 26 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "inventorywindow.hpp"
|
#include "inventorywindow.hpp"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <MyGUI_Window.h>
|
#include <MyGUI_Window.h>
|
||||||
#include <MyGUI_ImageBox.h>
|
#include <MyGUI_ImageBox.h>
|
||||||
|
@ -149,6 +150,15 @@ namespace MWGui
|
||||||
mItemView->setModel(NULL);
|
mItemView->setModel(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InventoryWindow::activateItems()
|
||||||
|
{
|
||||||
|
for (std::vector<MWWorld::Ptr>::iterator it = mItemsToActivate.begin(); it != mItemsToActivate.end(); it++)
|
||||||
|
{
|
||||||
|
it->getRefData().activate();
|
||||||
|
}
|
||||||
|
mItemsToActivate.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void InventoryWindow::setGuiMode(GuiMode mode)
|
void InventoryWindow::setGuiMode(GuiMode mode)
|
||||||
{
|
{
|
||||||
std::string setting = "inventory";
|
std::string setting = "inventory";
|
||||||
|
@ -653,6 +663,16 @@ namespace MWGui
|
||||||
if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up
|
if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
std::string scriptName = object.getClass().getScript(object); // Objects that have OnActivte in their script cannot be picked up through inventory
|
||||||
|
if (!scriptName.empty() && MWBase::Environment::get().getScriptManager()->hasOnActivate(scriptName))
|
||||||
|
{
|
||||||
|
if (std::find(mItemsToActivate.begin(), mItemsToActivate.end(), object) == mItemsToActivate.end())
|
||||||
|
{
|
||||||
|
mItemsToActivate.push_back(object);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int count = object.getRefData().getCount();
|
int count = object.getRefData().getCount();
|
||||||
|
|
||||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
|
|
|
@ -58,6 +58,8 @@ namespace MWGui
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
void activateItems();
|
||||||
|
|
||||||
void useItem(const MWWorld::Ptr& ptr);
|
void useItem(const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
void setGuiMode(GuiMode mode);
|
void setGuiMode(GuiMode mode);
|
||||||
|
@ -70,6 +72,8 @@ namespace MWGui
|
||||||
|
|
||||||
int mSelectedItem;
|
int mSelectedItem;
|
||||||
|
|
||||||
|
std::vector<MWWorld::Ptr> mItemsToActivate;
|
||||||
|
|
||||||
MWWorld::Ptr mPtr;
|
MWWorld::Ptr mPtr;
|
||||||
|
|
||||||
MWGui::ItemView* mItemView;
|
MWGui::ItemView* mItemView;
|
||||||
|
|
|
@ -1171,6 +1171,8 @@ namespace MWGui
|
||||||
mGuiModeStates[mode].update(false);
|
mGuiModeStates[mode].update(false);
|
||||||
if (!noSound)
|
if (!noSound)
|
||||||
playSound(mGuiModeStates[mode].mCloseSound);
|
playSound(mGuiModeStates[mode].mCloseSound);
|
||||||
|
if (mode == GM_Inventory)
|
||||||
|
mInventoryWindow->activateItems(); // Activate cursed items when inventory is closed
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mGuiModes.empty())
|
if (!mGuiModes.empty())
|
||||||
|
|
Loading…
Reference in a new issue