From 1cecab6e3da1f347f2508baea465bd4e94d8395c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:08:59 +0200 Subject: [PATCH 01/11] fixed RefData::getHandle --- apps/openmw/mwworld/refdata.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwworld/refdata.cpp b/apps/openmw/mwworld/refdata.cpp index 14ddd3ec5..41794c2ad 100644 --- a/apps/openmw/mwworld/refdata.cpp +++ b/apps/openmw/mwworld/refdata.cpp @@ -75,6 +75,9 @@ namespace MWWorld std::string RefData::getHandle() { + if (!mBaseNode) + return ""; + return mBaseNode->getName(); } From 733654d730dcab2d26ab5d7b2f789adc16ed7c40 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:14:33 +0200 Subject: [PATCH 02/11] Issue #370: implemented target handling in action base class --- apps/openmw/mwworld/action.cpp | 15 ++++++++++----- apps/openmw/mwworld/action.hpp | 13 +++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index 748f6aff7..efce2b129 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -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 teleport, const Ptr& target) : mTeleport (teleport), mTarget (target) {} MWWorld::Action::~Action() {} @@ -15,16 +20,16 @@ void MWWorld::Action::execute (const Ptr& actor) { if (!mSoundId.empty()) { - if (mTeleport == true) + if (mTeleport && actor.getRefData().getHandle()=="player") { - //this is a teleport action, so we need to call playSound 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); + MWBase::Environment::get().getSoundManager()->playSound3D (mTarget.isEmpty() ? actor : mTarget, + mSoundId, 1.0, 1.0, + mTeleport ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal); } } diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index 511a7002d..c47565113 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -3,15 +3,16 @@ #include +#include "ptr.hpp" + namespace MWWorld { - class Ptr; - /// \brief Abstract base for actions class Action { std::string mSoundId; bool mTeleport; + Ptr mTarget; // not implemented Action (const Action& action); @@ -19,9 +20,13 @@ namespace MWWorld virtual void executeImp (const Ptr& actor) = 0; - public: + protected: + + const Ptr& getTarget() const; + + public: - Action (bool teleport = false); + Action (bool teleport = false, const Ptr& target = Ptr()); ///< \param teleport action will teleport the actor virtual ~Action(); From cc55056adf73f865b4480ba0617839e5a5a5ea12 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:18:59 +0200 Subject: [PATCH 03/11] Issue #370: replaced custom target handling in apply action with base class implementation --- apps/openmw/mwworld/actionapply.cpp | 10 +++++----- apps/openmw/mwworld/actionapply.hpp | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwworld/actionapply.cpp b/apps/openmw/mwworld/actionapply.cpp index 595ee6cb3..f78b8f798 100644 --- a/apps/openmw/mwworld/actionapply.cpp +++ b/apps/openmw/mwworld/actionapply.cpp @@ -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); } } diff --git a/apps/openmw/mwworld/actionapply.hpp b/apps/openmw/mwworld/actionapply.hpp index 523bf9373..3353ae0ee 100644 --- a/apps/openmw/mwworld/actionapply.hpp +++ b/apps/openmw/mwworld/actionapply.hpp @@ -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; From 3f181f9a9d71368bcaa847ca00df194979f5e674 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:21:56 +0200 Subject: [PATCH 04/11] Issue #370: Support for targets in containers --- apps/openmw/mwworld/action.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index efce2b129..98682e705 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -22,12 +22,15 @@ void MWWorld::Action::execute (const Ptr& actor) { if (mTeleport && actor.getRefData().getHandle()=="player") { + // 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 (mTarget.isEmpty() ? actor : mTarget, + bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target + + MWBase::Environment::get().getSoundManager()->playSound3D (local ? actor : mTarget, mSoundId, 1.0, 1.0, mTeleport ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal); } From b51c42146f6fa99020c348172b11559060df425f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:24:55 +0200 Subject: [PATCH 05/11] Issue #370: replaced custom target handling in read action with base class implementation --- apps/openmw/mwworld/actionread.cpp | 8 ++++---- apps/openmw/mwworld/actionread.hpp | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index 5c6ab93c1..7fb2b23e7 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -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 *ref = mObject.get(); + LiveCellRef *ref = getTarget().get(); 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()); } } } diff --git a/apps/openmw/mwworld/actionread.hpp b/apps/openmw/mwworld/actionread.hpp index 9bb74fb88..00a4756dd 100644 --- a/apps/openmw/mwworld/actionread.hpp +++ b/apps/openmw/mwworld/actionread.hpp @@ -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: From 8c2b4f996c044bc5b92a14f91b847c5759a29bb1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:27:10 +0200 Subject: [PATCH 06/11] Issue #370: replaced custom target handling in equip action with base class implementation --- apps/openmw/mwworld/actionequip.cpp | 6 +++--- apps/openmw/mwworld/actionequip.hpp | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/actionequip.cpp b/apps/openmw/mwworld/actionequip.cpp index 20e0afb68..d8c019644 100644 --- a/apps/openmw/mwworld/actionequip.cpp +++ b/apps/openmw/mwworld/actionequip.cpp @@ -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, bool> slots = MWWorld::Class::get(mObject).getEquipmentSlots(mObject); + std::pair, 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; } diff --git a/apps/openmw/mwworld/actionequip.hpp b/apps/openmw/mwworld/actionequip.hpp index 5685a294a..3b56c7402 100644 --- a/apps/openmw/mwworld/actionequip.hpp +++ b/apps/openmw/mwworld/actionequip.hpp @@ -8,8 +8,6 @@ namespace MWWorld { class ActionEquip : public Action { - Ptr mObject; - virtual void executeImp (const Ptr& actor); public: From ea1c3fe1e46de41d49c85e002da17c0f86768644 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:29:51 +0200 Subject: [PATCH 07/11] Issue #370: replaced custom target handling in open action with base class implementation --- apps/openmw/mwworld/actionopen.cpp | 6 +++--- apps/openmw/mwworld/actionopen.hpp | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/actionopen.cpp b/apps/openmw/mwworld/actionopen.cpp index 15a9f510d..040a3856e 100644 --- a/apps/openmw/mwworld/actionopen.cpp +++ b/apps/openmw/mwworld/actionopen.cpp @@ -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()); } } diff --git a/apps/openmw/mwworld/actionopen.hpp b/apps/openmw/mwworld/actionopen.hpp index 5666ff293..c49ebefa5 100644 --- a/apps/openmw/mwworld/actionopen.hpp +++ b/apps/openmw/mwworld/actionopen.hpp @@ -10,8 +10,6 @@ namespace MWWorld { class ActionOpen : public Action { - Ptr mContainer; - virtual void executeImp (const MWWorld::Ptr& actor); public: From 8ed8dd649a9ca68ef0f23c71dc77a2c086100c6f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:34:44 +0200 Subject: [PATCH 08/11] Issue #370: replaced custom target handling in take action with base class implementation --- apps/openmw/mwworld/actiontake.cpp | 8 +++----- apps/openmw/mwworld/actiontake.hpp | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index 90f3c000e..ef24f1536 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -10,7 +10,7 @@ namespace MWWorld { - ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {} + ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (false, 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()); } } diff --git a/apps/openmw/mwworld/actiontake.hpp b/apps/openmw/mwworld/actiontake.hpp index 52a114acf..b0a9b8247 100644 --- a/apps/openmw/mwworld/actiontake.hpp +++ b/apps/openmw/mwworld/actiontake.hpp @@ -8,8 +8,6 @@ namespace MWWorld { class ActionTake : public Action { - MWWorld::Ptr mObject; - virtual void executeImp (const Ptr& actor); public: From fb8aae243dab4487e56845e45fd59f869b327f46 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:38:21 +0200 Subject: [PATCH 09/11] Issue #370: replaced custom target handling in talk action with base class implementation --- apps/openmw/mwworld/actiontalk.cpp | 4 ++-- apps/openmw/mwworld/actiontalk.hpp | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwworld/actiontalk.cpp b/apps/openmw/mwworld/actiontalk.cpp index d94cb67f4..905497f85 100644 --- a/apps/openmw/mwworld/actiontalk.cpp +++ b/apps/openmw/mwworld/actiontalk.cpp @@ -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()); } } diff --git a/apps/openmw/mwworld/actiontalk.hpp b/apps/openmw/mwworld/actiontalk.hpp index 53adf9e53..b88b168d8 100644 --- a/apps/openmw/mwworld/actiontalk.hpp +++ b/apps/openmw/mwworld/actiontalk.hpp @@ -8,8 +8,6 @@ namespace MWWorld { class ActionTalk : public Action { - Ptr mActor; - virtual void executeImp (const Ptr& actor); public: From 6813bafbfcf7ed6ae5354fec34e5caf5e0a376cb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 15:42:41 +0200 Subject: [PATCH 10/11] added missing sound effect for chest opening; minor cleanup --- apps/openmw/mwclass/container.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 608fc6122..4f11e1c0e 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -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 (new MWWorld::NullAction); - return boost::shared_ptr (new MWWorld::ActionOpen(ptr)); + boost::shared_ptr action (new MWWorld::ActionOpen(ptr)); + action->setSound ("chest open"); + return action; } else { From da041f902f7a9e87e8c54df00056a60002f03004 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Sep 2012 20:56:28 +0200 Subject: [PATCH 11/11] Issue #370: fixed item taking sound --- apps/openmw/mwworld/action.cpp | 6 +++--- apps/openmw/mwworld/action.hpp | 6 +++--- apps/openmw/mwworld/actiontake.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index 98682e705..a5199fb3e 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -11,7 +11,7 @@ const MWWorld::Ptr& MWWorld::Action::getTarget() const return mTarget; } -MWWorld::Action::Action (bool teleport, const Ptr& target) : mTeleport (teleport), mTarget (target) +MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mTarget (target) {} MWWorld::Action::~Action() {} @@ -20,7 +20,7 @@ void MWWorld::Action::execute (const Ptr& actor) { if (!mSoundId.empty()) { - if (mTeleport && actor.getRefData().getHandle()=="player") + if (mKeepSound && actor.getRefData().getHandle()=="player") { // sound moves with player when teleporting MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0, @@ -32,7 +32,7 @@ void MWWorld::Action::execute (const Ptr& actor) MWBase::Environment::get().getSoundManager()->playSound3D (local ? actor : mTarget, mSoundId, 1.0, 1.0, - mTeleport ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal); + mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal); } } diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index c47565113..d8e5d93bb 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -11,7 +11,7 @@ namespace MWWorld class Action { std::string mSoundId; - bool mTeleport; + bool mKeepSound; Ptr mTarget; // not implemented @@ -26,8 +26,8 @@ namespace MWWorld public: - Action (bool teleport = false, const Ptr& target = Ptr()); - ///< \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(); diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index ef24f1536..fd28dd52e 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -10,7 +10,7 @@ namespace MWWorld { - ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (false, object) {} + ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {} void ActionTake::executeImp (const Ptr& actor) {