Reverted previous commits, and handle disallowed inventory in MWWorld::Class. Wanted to avoid this, but the previous solution broke teleport door sounds. Also fixed book/scroll window take button showing when inventory was not allowed.

actorid
scrawl 12 years ago
parent 373de19aee
commit 00db13be32

@ -12,6 +12,7 @@
#include "../mwworld/actionalchemy.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -61,6 +62,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(
new MWWorld::ActionTake (ptr));

@ -15,6 +15,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -64,6 +65,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));

@ -13,6 +13,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwgui/tooltips.hpp"
@ -62,6 +63,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));

@ -9,6 +9,7 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/failedaction.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/cellstore.hpp"
@ -85,6 +86,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
const std::string lockedSound = "LockedChest";
const std::string trapActivationSound = "Disarm Trap Fail";

@ -13,6 +13,7 @@
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/actioneat.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwmechanics/npcstats.hpp"
@ -72,6 +73,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));

@ -88,6 +88,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();

@ -13,6 +13,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwgui/tooltips.hpp"
@ -62,6 +63,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));

@ -14,6 +14,7 @@
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/manualref.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwgui/tooltips.hpp"
@ -65,6 +66,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));

@ -13,6 +13,7 @@
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwgui/tooltips.hpp"
@ -62,6 +63,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(
new MWWorld::ActionTake (ptr));

@ -13,6 +13,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwgui/tooltips.hpp"
@ -61,6 +62,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));

@ -11,6 +11,7 @@
#include "../mwworld/actiontake.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwgui/tooltips.hpp"
@ -60,6 +61,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));

@ -13,6 +13,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/nullaction.hpp"
#include "../mwgui/tooltips.hpp"
@ -62,6 +63,9 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction ());
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));

@ -14,8 +14,10 @@
using namespace MWGui;
BookWindow::BookWindow (MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_book.layout", parWindowManager)
BookWindow::BookWindow (MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_book.layout", parWindowManager)
, mTakeButtonShow(true)
, mTakeButtonAllowed(true)
{
getWidget(mCloseButton, "CloseButton");
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked);
@ -85,7 +87,14 @@ void BookWindow::open (MWWorld::Ptr book)
void BookWindow::setTakeButtonShow(bool show)
{
mTakeButton->setVisible(show);
mTakeButtonShow = show;
mTakeButton->setVisible(mTakeButtonShow && mTakeButtonAllowed);
}
void BookWindow::setInventoryAllowed(bool allowed)
{
mTakeButtonAllowed = allowed;
mTakeButton->setVisible(mTakeButtonShow && mTakeButtonAllowed);
}
void BookWindow::onCloseButtonClicked (MyGUI::Widget* sender)

@ -17,6 +17,8 @@ namespace MWGui
void open(MWWorld::Ptr book);
void setTakeButtonShow(bool show);
void setInventoryAllowed(bool allowed);
protected:
void onNextPageButtonClicked (MyGUI::Widget* sender);
void onPrevPageButtonClicked (MyGUI::Widget* sender);
@ -40,6 +42,9 @@ namespace MWGui
std::vector<MyGUI::Widget*> mPages;
MWWorld::Ptr mBook;
bool mTakeButtonShow;
bool mTakeButtonAllowed;
};
}

@ -12,8 +12,10 @@
using namespace MWGui;
ScrollWindow::ScrollWindow (MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_scroll.layout", parWindowManager)
ScrollWindow::ScrollWindow (MWBase::WindowManager& parWindowManager)
: WindowBase("openmw_scroll.layout", parWindowManager)
, mTakeButtonShow(true)
, mTakeButtonAllowed(true)
{
getWidget(mTextView, "TextView");
@ -50,7 +52,14 @@ void ScrollWindow::open (MWWorld::Ptr scroll)
void ScrollWindow::setTakeButtonShow(bool show)
{
mTakeButton->setVisible(show);
mTakeButtonShow = show;
mTakeButton->setVisible(mTakeButtonShow && mTakeButtonAllowed);
}
void ScrollWindow::setInventoryAllowed(bool allowed)
{
mTakeButtonAllowed = allowed;
mTakeButton->setVisible(mTakeButtonShow && mTakeButtonAllowed);
}
void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender)

@ -15,6 +15,7 @@ namespace MWGui
void open (MWWorld::Ptr scroll);
void setTakeButtonShow(bool show);
void setInventoryAllowed(bool allowed);
protected:
void onCloseButtonClicked (MyGUI::Widget* _sender);
@ -26,6 +27,10 @@ namespace MWGui
MyGUI::ScrollView* mTextView;
MWWorld::Ptr mScroll;
bool mTakeButtonShow;
bool mTakeButtonAllowed;
};
}

@ -109,7 +109,6 @@ WindowManager::WindowManager(
, mHudEnabled(true)
, mTranslationDataStorage (translationDataStorage)
{
// Set up the GUI system
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath);
mGui = mGuiManager->getGui();
@ -196,6 +195,9 @@ WindowManager::WindowManager(
unsetSelectedSpell();
unsetSelectedWeapon();
if (newGame)
disallowAll ();
// Set up visibility
updateVisible();
}
@ -943,12 +945,23 @@ bool WindowManager::isAllowed (GuiWindow wnd) const
void WindowManager::allow (GuiWindow wnd)
{
mAllowed = (GuiWindow)(mAllowed | wnd);
if (wnd & GW_Inventory)
{
mBookWindow->setInventoryAllowed (true);
mScrollWindow->setInventoryAllowed (true);
}
updateVisible();
}
void WindowManager::disallowAll()
{
mAllowed = GW_None;
mBookWindow->setInventoryAllowed (false);
mScrollWindow->setInventoryAllowed (false);
updateVisible();
}

@ -18,7 +18,7 @@ MWWorld::Action::~Action() {}
void MWWorld::Action::execute (const Ptr& actor)
{
if (!mSoundId.empty() & executeImp (actor))
if (!mSoundId.empty())
{
if (mKeepSound && actor.getRefData().getHandle()=="player")
{
@ -35,6 +35,8 @@ void MWWorld::Action::execute (const Ptr& actor)
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
}
}
executeImp (actor);
}
void MWWorld::Action::setSound (const std::string& id)

@ -18,8 +18,7 @@ namespace MWWorld
Action (const Action& action);
Action& operator= (const Action& action);
/// @return true if the sound should be played, false if not (e.g. if the action is not allowed)
virtual bool executeImp (const Ptr& actor) = 0;
virtual void executeImp (const Ptr& actor) = 0;
protected:

@ -5,9 +5,8 @@
namespace MWWorld
{
bool ActionAlchemy::executeImp (const Ptr& actor)
void ActionAlchemy::executeImp (const Ptr& actor)
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy);
return true;
}
}

@ -7,7 +7,7 @@ namespace MWWorld
{
class ActionAlchemy : public Action
{
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
};
}

@ -9,10 +9,9 @@ namespace MWWorld
: Action (false, target), mId (id)
{}
bool ActionApply::executeImp (const Ptr& actor)
void ActionApply::executeImp (const Ptr& actor)
{
MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor);
return true;
}
@ -21,10 +20,9 @@ namespace MWWorld
: Action (false, target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
{}
bool ActionApplyWithSkill::executeImp (const Ptr& actor)
void ActionApplyWithSkill::executeImp (const Ptr& actor)
{
if (MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor) && mUsageType!=-1)
MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
return true;
}
}

@ -13,7 +13,7 @@ namespace MWWorld
{
std::string mId;
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
public:
@ -26,7 +26,7 @@ namespace MWWorld
int mSkillIndex;
int mUsageType;
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
public:

@ -16,7 +16,7 @@
namespace MWWorld
{
bool ActionEat::executeImp (const Ptr& actor)
void ActionEat::executeImp (const Ptr& actor)
{
// remove used item
getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1);
@ -42,8 +42,6 @@ namespace MWWorld
// increase skill
Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1);
}
return true;
}
ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {}

@ -8,7 +8,7 @@ namespace MWWorld
{
class ActionEat : public Action
{
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
public:

@ -16,7 +16,7 @@ namespace MWWorld
{
}
bool ActionEquip::executeImp (const Ptr& actor)
void ActionEquip::executeImp (const Ptr& actor)
{
MWWorld::InventoryStore& invStore = MWWorld::Class::get(actor).getInventoryStore(actor);
@ -113,7 +113,5 @@ namespace MWWorld
/* Set OnPCEquip Variable on item's script, if the player is equipping it, and it has a script with that variable declared */
if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "")
(*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 1);
return true;
}
}

@ -8,7 +8,7 @@ namespace MWWorld
{
class ActionEquip : public Action
{
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
public:
/// @param item to equip

@ -14,13 +14,12 @@ namespace MWWorld
{
}
bool ActionOpen::executeImp (const MWWorld::Ptr& actor)
void ActionOpen::executeImp (const MWWorld::Ptr& actor)
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return false;
return;
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget());
return true;
}
}

@ -10,7 +10,7 @@ namespace MWWorld
{
class ActionOpen : public Action
{
virtual bool executeImp (const MWWorld::Ptr& actor);
virtual void executeImp (const MWWorld::Ptr& actor);
public:
ActionOpen (const Ptr& container);

@ -19,7 +19,7 @@ namespace MWWorld
{
}
bool ActionRead::executeImp (const MWWorld::Ptr& actor)
void ActionRead::executeImp (const MWWorld::Ptr& actor)
{
LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>();
@ -53,6 +53,5 @@ namespace MWWorld
npcStats.flagAsUsed (ref->mBase->mId);
}
return true;
}
}

@ -8,7 +8,7 @@ namespace MWWorld
{
class ActionRead : public Action
{
virtual bool executeImp (const MWWorld::Ptr& actor);
virtual void executeImp (const MWWorld::Ptr& actor);
public:
/// @param book or scroll to read

@ -12,18 +12,13 @@ namespace MWWorld
{
ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {}
bool ActionTake::executeImp (const Ptr& actor)
void ActionTake::executeImp (const Ptr& actor)
{
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return false;
// insert into player's inventory
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
MWWorld::Class::get (player).getContainerStore (player).add (getTarget());
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
return true;
}
}

@ -8,7 +8,7 @@ namespace MWWorld
{
class ActionTake : public Action
{
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
public:

@ -3,15 +3,13 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/inputmanager.hpp"
namespace MWWorld
{
ActionTalk::ActionTalk (const Ptr& actor) : Action (false, actor) {}
bool ActionTalk::executeImp (const Ptr& actor)
void ActionTalk::executeImp (const Ptr& actor)
{
MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget());
return true;
}
}

@ -8,7 +8,7 @@ namespace MWWorld
{
class ActionTalk : public Action
{
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
public:

@ -12,12 +12,11 @@ namespace MWWorld
{
}
bool ActionTeleport::executeImp (const Ptr& actor)
void ActionTeleport::executeImp (const Ptr& actor)
{
if (mCellName.empty())
MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition);
else
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition);
return true;
}
}

@ -14,7 +14,7 @@ namespace MWWorld
std::string mCellName;
ESM::Position mPosition;
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
public:

@ -11,12 +11,11 @@ namespace MWWorld
{ }
bool FailedAction::executeImp (const Ptr& actor)
void FailedAction::executeImp (const Ptr& actor)
{
if ( actor.getRefData().getHandle()=="player" && !(message.empty()))
{
MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector<std::string>());
}
return true;
{
MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector<std::string>());
}
}
}

@ -10,11 +10,11 @@ namespace MWWorld
{
std::string message;
virtual bool executeImp (const Ptr& actor);
virtual void executeImp (const Ptr& actor);
public:
FailedAction (const std::string& message = std::string());
};
}
#endif
#endif

@ -8,7 +8,7 @@ namespace MWWorld
/// \brief Action: do nothing
class NullAction : public Action
{
virtual bool executeImp (const Ptr& actor) {return false;}
virtual void executeImp (const Ptr& actor) {}
};
}

Loading…
Cancel
Save