diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 4ca6e9581..e2a2e7f14 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -50,7 +50,7 @@ add_openmw_dir (mwsound add_openmw_dir (mwworld refdata worldimp physicssystem scene globals class action nullaction actionteleport - containerstore actiontalk actiontake manualref player cellfunctors + containerstore actiontalk actiontake manualref player cellfunctors failedaction cells localscripts customdata weather inventorystore ptr actionopen actionread actionequip timestamp actionalchemy cellstore actionapply actioneat esmstore store recordcmp diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index a9cd9d06f..76c1c40f1 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -8,7 +8,7 @@ #include "../mwbase/windowmanager.hpp" #include "../mwworld/ptr.hpp" -#include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/cellstore.hpp" @@ -129,7 +129,7 @@ namespace MWClass { // Trap activation goes here std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; - boost::shared_ptr action(new MWWorld::NullAction); + boost::shared_ptr action(new MWWorld::FailedAction); action->setSound(trapActivationSound); ptr.getCellRef().mTrap = ""; return action; @@ -137,7 +137,7 @@ namespace MWClass } else { - boost::shared_ptr action(new MWWorld::NullAction); + boost::shared_ptr action(new MWWorld::FailedAction); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 53fc72649..843d1af4c 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -10,6 +10,7 @@ #include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/actionteleport.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -110,8 +111,7 @@ namespace MWClass // Trap activation std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; - boost::shared_ptr action(new MWWorld::NullAction); - + boost::shared_ptr action(new MWWorld::FailedAction); action->setSound(trapActivationSound); ptr.getCellRef().mTrap = ""; @@ -133,7 +133,7 @@ namespace MWClass else { // another NPC or a creature is using the door - return boost::shared_ptr (new MWWorld::NullAction); + return boost::shared_ptr (new MWWorld::FailedAction); } } else @@ -152,7 +152,7 @@ namespace MWClass else { // locked, and we can't open. - boost::shared_ptr action(new MWWorld::NullAction); + boost::shared_ptr action(new MWWorld::FailedAction); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 0020d0864..b94b0d395 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -12,6 +12,7 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -55,7 +56,7 @@ namespace MWClass if(!model.empty()) physics.addObject(ptr); - + if (!ref->mBase->mSound.empty()) MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); } @@ -91,7 +92,7 @@ namespace MWClass ptr.get(); if (!(ref->mBase->mData.mFlags & ESM::Light::Carry)) - return boost::shared_ptr (new MWWorld::NullAction); + return boost::shared_ptr (new MWWorld::FailedAction); boost::shared_ptr action(new MWWorld::ActionTake (ptr)); diff --git a/apps/openmw/mwworld/failedaction.cpp b/apps/openmw/mwworld/failedaction.cpp new file mode 100644 index 000000000..8c64db69f --- /dev/null +++ b/apps/openmw/mwworld/failedaction.cpp @@ -0,0 +1,21 @@ +#include "failedaction.hpp" +#include "../mwbase/world.hpp" + +#include "../mwbase/environment.hpp" +#include "../mwbase/windowmanager.hpp" + + +namespace MWWorld +{ + FailedAction::FailedAction (const std::string& msg) : Action (false), message(msg) + { } + + + void FailedAction::executeImp (const Ptr& actor) + { + if ( actor.getRefData().getHandle()=="player" and !(message.empty())) + { + MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector()); + } + } +} diff --git a/apps/openmw/mwworld/failedaction.hpp b/apps/openmw/mwworld/failedaction.hpp new file mode 100644 index 000000000..e736bfb63 --- /dev/null +++ b/apps/openmw/mwworld/failedaction.hpp @@ -0,0 +1,20 @@ +#ifndef GAME_MWWORLD_FAILEDACTION_H +#define GAME_MWWORLD_FAILEDACTION_H + +#include "action.hpp" +#include "ptr.hpp" + +namespace MWWorld +{ + class FailedAction : public Action + { + std::string message; + + virtual void executeImp (const Ptr& actor); + + public: + FailedAction (const std::string& message = std::string()); + }; +} + +#endif \ No newline at end of file