Merge branch 'actiontarget'

actorid
Marc Zinnschlag 12 years ago
commit 0879abb948

@ -87,7 +87,6 @@ namespace MWClass
const std::string lockedSound = "LockedChest";
const std::string trapActivationSound = "Disarm Trap Fail";
if (ptr.getCellRef().lockLevel>0)
{
// TODO check for key
@ -98,12 +97,11 @@ namespace MWClass
}
else
{
std::cout << "Unlocked container" << std::endl;
if(ptr.getCellRef().trap.empty())
{
// Not trapped, Inventory GUI goes here
//return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr));
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
action->setSound ("chest open");
return action;
}
else
{

@ -6,7 +6,12 @@
#include "../mwbase/soundmanager.hpp"
MWWorld::Action::Action (bool teleport) : mTeleport (teleport)
const MWWorld::Ptr& MWWorld::Action::getTarget() const
{
return mTarget;
}
MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mTarget (target)
{}
MWWorld::Action::~Action() {}
@ -15,16 +20,19 @@ void MWWorld::Action::execute (const Ptr& actor)
{
if (!mSoundId.empty())
{
if (mTeleport == true)
if (mKeepSound && actor.getRefData().getHandle()=="player")
{
//this is a teleport action, so we need to call playSound
// sound moves with player when teleporting
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
MWBase::SoundManager::Play_NoTrack);
}
else
{
MWBase::Environment::get().getSoundManager()->playSound3D (actor, mSoundId, 1.0, 1.0,
MWBase::SoundManager::Play_NoTrack);
bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target
MWBase::Environment::get().getSoundManager()->playSound3D (local ? actor : mTarget,
mSoundId, 1.0, 1.0,
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
}
}

@ -3,15 +3,16 @@
#include <string>
#include "ptr.hpp"
namespace MWWorld
{
class Ptr;
/// \brief Abstract base for actions
class Action
{
std::string mSoundId;
bool mTeleport;
bool mKeepSound;
Ptr mTarget;
// not implemented
Action (const Action& action);
@ -19,10 +20,14 @@ namespace MWWorld
virtual void executeImp (const Ptr& actor) = 0;
public:
protected:
const Ptr& getTarget() const;
public:
Action (bool teleport = false);
///< \param teleport action will teleport the actor
Action (bool keepSound = false, const Ptr& target = Ptr());
///< \param keepSound Keep playing the sound even if the object the sound is played on is removed.
virtual ~Action();

@ -6,23 +6,23 @@
namespace MWWorld
{
ActionApply::ActionApply (const Ptr& target, const std::string& id)
: mTarget (target), mId (id)
: Action (false, target), mId (id)
{}
void ActionApply::executeImp (const Ptr& actor)
{
MWWorld::Class::get (mTarget).apply (mTarget, mId, actor);
MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor);
}
ActionApplyWithSkill::ActionApplyWithSkill (const Ptr& target, const std::string& id,
int skillIndex, int usageType)
: mTarget (target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
: Action (false, target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
{}
void ActionApplyWithSkill::executeImp (const Ptr& actor)
{
if (MWWorld::Class::get (mTarget).apply (mTarget, mId, actor) && mUsageType!=-1)
MWWorld::Class::get (mTarget).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
if (MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor) && mUsageType!=-1)
MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
}
}

@ -11,7 +11,6 @@ namespace MWWorld
{
class ActionApply : public Action
{
Ptr mTarget;
std::string mId;
virtual void executeImp (const Ptr& actor);
@ -23,7 +22,6 @@ namespace MWWorld
class ActionApplyWithSkill : public Action
{
Ptr mTarget;
std::string mId;
int mSkillIndex;
int mUsageType;

@ -9,7 +9,7 @@
namespace MWWorld
{
ActionEquip::ActionEquip (const MWWorld::Ptr& object) : mObject (object)
ActionEquip::ActionEquip (const MWWorld::Ptr& object) : Action (false, object)
{
}
@ -19,13 +19,13 @@ namespace MWWorld
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
// slots that this item can be equipped in
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(mObject).getEquipmentSlots(mObject);
std::pair<std::vector<int>, bool> slots = MWWorld::Class::get(getTarget()).getEquipmentSlots(getTarget());
// retrieve ContainerStoreIterator to the item
MWWorld::ContainerStoreIterator it = invStore.begin();
for (; it != invStore.end(); ++it)
{
if (*it == mObject)
if (*it == getTarget())
{
break;
}

@ -8,8 +8,6 @@ namespace MWWorld
{
class ActionEquip : public Action
{
Ptr mObject;
virtual void executeImp (const Ptr& actor);
public:

@ -10,8 +10,8 @@
namespace MWWorld
{
ActionOpen::ActionOpen (const MWWorld::Ptr& container) : mContainer (container) {
mContainer = container;
ActionOpen::ActionOpen (const MWWorld::Ptr& container) : Action (false, container)
{
}
void ActionOpen::executeImp (const MWWorld::Ptr& actor)
@ -20,6 +20,6 @@ namespace MWWorld
return;
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(mContainer);
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget());
}
}

@ -10,8 +10,6 @@ namespace MWWorld
{
class ActionOpen : public Action
{
Ptr mContainer;
virtual void executeImp (const MWWorld::Ptr& actor);
public:

@ -8,23 +8,23 @@
namespace MWWorld
{
ActionRead::ActionRead (const MWWorld::Ptr& object) : mObject (object)
ActionRead::ActionRead (const MWWorld::Ptr& object) : Action (false, object)
{
}
void ActionRead::executeImp (const MWWorld::Ptr& actor)
{
LiveCellRef<ESM::Book> *ref = mObject.get<ESM::Book>();
LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>();
if (ref->base->data.isScroll)
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Scroll);
MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(mObject);
MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(getTarget());
}
else
{
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Book);
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(mObject);
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(getTarget());
}
}
}

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

@ -10,7 +10,7 @@
namespace MWWorld
{
ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {}
ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {}
void ActionTake::executeImp (const Ptr& actor)
{
@ -20,10 +20,8 @@ namespace MWWorld
// insert into player's inventory
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
MWWorld::Class::get (player).getContainerStore (player).add (mObject);
MWWorld::Class::get (player).getContainerStore (player).add (getTarget());
// remove from world, if the item is currently in the world (it could also be in a container)
if (mObject.isInCell())
MWBase::Environment::get().getWorld()->deleteObject (mObject);
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
}
}

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

@ -6,10 +6,10 @@
namespace MWWorld
{
ActionTalk::ActionTalk (const Ptr& actor) : mActor (actor) {}
ActionTalk::ActionTalk (const Ptr& actor) : Action (false, actor) {}
void ActionTalk::executeImp (const Ptr& actor)
{
MWBase::Environment::get().getDialogueManager()->startDialogue (mActor);
MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget());
}
}

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

@ -75,6 +75,9 @@ namespace MWWorld
std::string RefData::getHandle()
{
if (!mBaseNode)
return "";
return mBaseNode->getName();
}

Loading…
Cancel
Save