Changing sounds to Action.

Adding onActor to Action to choose between playSound and playSound3D.
actorid
Douglas Diniz 13 years ago
parent 97c45455fd
commit 82e7c04c0a

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -63,10 +62,12 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(
new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const

@ -7,7 +7,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -66,10 +65,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const
@ -271,9 +271,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const
{
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
return action;
}
MWWorld::Ptr

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -62,12 +61,13 @@ namespace MWClass
}
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
std::string Clothing::getScript (const MWWorld::Ptr& ptr) const
@ -222,9 +222,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const
{
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
return action;
}
MWWorld::Ptr

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -93,8 +92,9 @@ namespace MWClass
{
// TODO check for key
std::cout << "Locked container" << std::endl;
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
action->setSound(lockedSound);
return action;
}
else
{
@ -109,9 +109,10 @@ namespace MWClass
{
// Trap activation goes here
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, trapActivationSound, 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
action->setSound(trapActivationSound);
ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
return action;
}
}
}

@ -5,8 +5,9 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/ptr.hpp"
@ -80,17 +81,25 @@ namespace MWClass
// TODO check for key
// TODO report failure to player (message, sound?). Look up behaviour of original MW.
std::cout << "Locked!" << std::endl;
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
action->setSound(lockedSound);
return action;
}
if(!ptr.getCellRef().trap.empty())
{
// Trap activation
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, trapActivationSound, 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
action->setSound(trapActivationSound);
ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
return action;
}
if (ref->ref.teleport)
@ -101,9 +110,13 @@ namespace MWClass
{
// 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()->playSound(openSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest));
//MWBase::Environment::get().getSoundManager()->playSound3D(ptr,openSound, 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest));
action->setSound(openSound, true);
return action;
}
else
{
@ -117,8 +130,11 @@ namespace MWClass
// TODO return action for rotating the door
// This is a little pointless, but helps with testing
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, openSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
action->setSound(openSound);
return action;
}
}

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -62,10 +61,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const

@ -94,10 +94,11 @@ namespace MWClass
if (!(ref->base->data.flags & ESM::Light::Carry))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
std::string Light::getScript (const MWWorld::Ptr& ptr) const
@ -191,9 +192,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr) const
{
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
return action;
}
MWWorld::Ptr

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -64,10 +63,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const
@ -160,9 +160,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr) const
{
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
return action;
}
MWWorld::Ptr

@ -7,7 +7,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -67,10 +66,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -64,10 +63,12 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(
new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound (getUpSoundId(ptr));
return action;
}
std::string Potion::getScript (const MWWorld::Ptr& ptr) const

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -63,10 +62,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
std::string Probe::getScript (const MWWorld::Ptr& ptr) const
@ -159,9 +159,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr) const
{
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
return action;
}
MWWorld::Ptr

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -62,10 +61,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
std::string Repair::getScript (const MWWorld::Ptr& ptr) const

@ -5,7 +5,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp"
@ -64,10 +63,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor) const
{
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr));
action->setSound(getUpSoundId(ptr));
return action;
}
bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const
@ -360,9 +360,11 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
{
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
action->setSound(getUpSoundId(ptr));
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
return action;
}
MWWorld::Ptr

@ -11,13 +11,26 @@ MWWorld::Action::~Action() {}
void MWWorld::Action::execute (const Ptr& actor)
{
if (!mSoundId.empty())
MWBase::Environment::get().getSoundManager()->playSound3D (actor, mSoundId, 1.0, 1.0,
MWBase::SoundManager::Play_NoTrack);
{
if (onActor)
{
std::cout << "Douglas - Som Normal" << std::endl;
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);
}
}
executeImp (actor);
}
void MWWorld::Action::setSound (const std::string& id)
void MWWorld::Action::setSound (const std::string& id, const bool onActorValue)
{
mSoundId = id;
onActor = onActorValue;
}

@ -11,6 +11,7 @@ namespace MWWorld
class Action
{
std::string mSoundId;
bool onActor;
// not implemented
Action (const Action& action);
@ -26,7 +27,7 @@ namespace MWWorld
void execute (const Ptr& actor);
void setSound (const std::string& id);
void setSound (const std::string& id, const bool onActor = false);
};
}

Loading…
Cancel
Save