From 5cbb08fee16cae95325f957bcd26f8f3f4116636 Mon Sep 17 00:00:00 2001 From: Douglas Diniz Date: Sun, 26 Aug 2012 11:47:45 -0300 Subject: [PATCH] Task 339 - Moving all sounds to actions --- apps/openmw/mwclass/door.cpp | 8 +------- apps/openmw/mwworld/action.cpp | 14 ++++++++------ apps/openmw/mwworld/action.hpp | 8 +++++--- apps/openmw/mwworld/actionteleport.cpp | 6 +++++- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index bf5dd4bba..f483aa3a8 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -6,8 +6,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" - #include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" @@ -108,13 +106,9 @@ namespace MWClass /// \todo remove this if clause once ActionTeleport can also support other actors if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) { - // the player is using the door - // The reason this is not 3D is that it would get interrupted when you teleport - //MWBase::Environment::get().getSoundManager()->playSound3D(ptr,openSound, 1.0, 1.0); - boost::shared_ptr action(new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest)); - action->setSound(openSound, true); + action->setSound(openSound); return action; } diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index 15bae4cd4..90e30a5bf 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -2,9 +2,13 @@ #include "action.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + #include "../mwbase/soundmanager.hpp" -MWWorld::Action::Action() {} +MWWorld::Action::Action() { + teleport = false; +} MWWorld::Action::~Action() {} @@ -12,15 +16,14 @@ void MWWorld::Action::execute (const Ptr& actor) { if (!mSoundId.empty()) { - if (onActor) + if (teleport == true) { - std::cout << "Douglas - Som Normal" << std::endl; + //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 { - std::cout << "Douglas - Som 3D" << std::endl; MWBase::Environment::get().getSoundManager()->playSound3D (actor, mSoundId, 1.0, 1.0, MWBase::SoundManager::Play_NoTrack); } @@ -29,8 +32,7 @@ void MWWorld::Action::execute (const Ptr& actor) executeImp (actor); } -void MWWorld::Action::setSound (const std::string& id, const bool onActorValue) +void MWWorld::Action::setSound (const std::string& id) { mSoundId = id; - onActor = onActorValue; } diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index f9ad975d3..01180a778 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -11,7 +11,6 @@ namespace MWWorld class Action { std::string mSoundId; - bool onActor; // not implemented Action (const Action& action); @@ -19,7 +18,10 @@ namespace MWWorld virtual void executeImp (const Ptr& actor) = 0; - public: + protected: + bool teleport; //True if the action will teleport the actor + + public: Action(); @@ -27,7 +29,7 @@ namespace MWWorld void execute (const Ptr& actor); - void setSound (const std::string& id, const bool onActor = false); + void setSound (const std::string& id); }; } diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 9c87d37ae..e65873223 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -9,10 +9,14 @@ namespace MWWorld ActionTeleport::ActionTeleport (const std::string& cellName, const ESM::Position& position) : mCellName (cellName), mPosition (position) - {} + { + teleport = true; + } void ActionTeleport::executeImp (const Ptr& actor) { + teleport = true; + if (mCellName.empty()) MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition); else