Merge remote branch 'werdanith/activationsounds2' into equipment

This commit is contained in:
Marc Zinnschlag 2012-03-15 14:06:48 +01:00
commit 3c3fb8d706
37 changed files with 436 additions and 24 deletions

View File

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -53,6 +56,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -71,4 +76,14 @@ namespace MWClass
registerClass (typeid (ESM::Apparatus).name(), instance); registerClass (typeid (ESM::Apparatus).name(), instance);
} }
std::string Apparatus::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Apparatus Up");
}
std::string Apparatus::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Apparatus Down");
}
} }

View File

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
}; };
} }

View File

@ -9,12 +9,15 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/environment.hpp" #include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp" #include "../mwworld/world.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -57,6 +60,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -161,4 +166,26 @@ namespace MWClass
registerClass (typeid (ESM::Armor).name(), instance); registerClass (typeid (ESM::Armor).name(), instance);
} }
std::string Armor::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
int es = getEuqipmentSkill(ptr, environment);
if (es == ESM::Skill::LightArmor)
return std::string("Item Armor Light Up");
else if (es == ESM::Skill::MediumArmor)
return std::string("Item Armor Medium Up");
else
return std::string("Item Armor Heavy Up");
}
std::string Armor::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
int es = getEuqipmentSkill(ptr, environment);
if (es == ESM::Skill::LightArmor)
return std::string("Item Armor Light Down");
else if (es == ESM::Skill::MediumArmor)
return std::string("Item Armor Medium Down");
else
return std::string("Item Armor Heavy Down");
}
} }

View File

@ -41,6 +41,12 @@ namespace MWClass
/// no such skill. /// no such skill.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -55,6 +58,8 @@ namespace MWClass
{ {
// TODO implement reading // TODO implement reading
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -73,4 +78,14 @@ namespace MWClass
registerClass (typeid (ESM::Book).name(), instance); registerClass (typeid (ESM::Book).name(), instance);
} }
std::string Book::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Book Up");
}
std::string Book::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Book Down");
}
} }

View File

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -7,10 +7,13 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -54,6 +57,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -124,4 +129,28 @@ namespace MWClass
registerClass (typeid (ESM::Clothing).name(), instance); registerClass (typeid (ESM::Clothing).name(), instance);
} }
std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
if (ref->base->data.type == 8)
{
return std::string("Item Ring Up");
}
return std::string("Item Clothes Up");
}
std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
if (ref->base->data.type == 8)
{
return std::string("Item Ring Down");
}
return std::string("Item Clothes Down");
}
} }

View File

@ -35,6 +35,12 @@ namespace MWClass
/// no such skill. /// no such skill.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -85,7 +85,7 @@ namespace MWClass
{ {
// TODO check for key // TODO check for key
std::cout << "Locked container" << std::endl; std::cout << "Locked container" << std::endl;
environment.mSoundManager->playSound(lockedSound, 1.0, 1.0); environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0, false);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
else else
@ -100,7 +100,7 @@ namespace MWClass
{ {
// Trap activation goes here // Trap activation goes here
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
environment.mSoundManager->playSound(trapActivationSound, 1.0, 1.0); environment.mSoundManager->playSound3D (ptr, trapActivationSound, 1.0, 1.0, false);
ptr.getCellRef().trap = ""; ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }

View File

@ -73,7 +73,7 @@ namespace MWClass
// TODO check for key // TODO check for key
// TODO report failure to player (message, sound?). Look up behaviour of original MW. // TODO report failure to player (message, sound?). Look up behaviour of original MW.
std::cout << "Locked!" << std::endl; std::cout << "Locked!" << std::endl;
environment.mSoundManager->playSound(lockedSound, 1.0, 1.0); environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0, false);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
@ -81,7 +81,7 @@ namespace MWClass
{ {
// Trap activation // Trap activation
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
environment.mSoundManager->playSound(trapActivationSound, 1.0, 1.0); environment.mSoundManager->playSound3D(ptr, trapActivationSound, 1.0, 1.0, false);
ptr.getCellRef().trap = ""; ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
@ -92,6 +92,7 @@ namespace MWClass
if (environment.mWorld->getPlayer().getPlayer()==actor) if (environment.mWorld->getPlayer().getPlayer()==actor)
{ {
// the player is using the door // the player is using the door
// The reason this is not 3D is that it would get interrupted when you teleport
environment.mSoundManager->playSound(openSound, 1.0, 1.0); environment.mSoundManager->playSound(openSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest)); new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest));
@ -109,7 +110,7 @@ namespace MWClass
// TODO return action for rotating the door // TODO return action for rotating the door
// This is a little pointless, but helps with testing // This is a little pointless, but helps with testing
environment.mSoundManager->playSound(openSound, 1.0, 1.0); environment.mSoundManager->playSound3D (ptr, openSound, 1.0, 1.0, false);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
} }

View File

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -51,6 +54,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -69,4 +74,14 @@ namespace MWClass
registerClass (typeid (ESM::Ingredient).name(), instance); registerClass (typeid (ESM::Ingredient).name(), instance);
} }
std::string Ingredient::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Ingredient Up");
}
std::string Ingredient::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Ingredient Down");
}
} }

View File

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -83,6 +83,8 @@ namespace MWClass
if (!(ref->base->data.flags & ESM::Light::Carry)) if (!(ref->base->data.flags & ESM::Light::Carry))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -114,4 +116,14 @@ namespace MWClass
registerClass (typeid (ESM::Light).name(), instance); registerClass (typeid (ESM::Light).name(), instance);
} }
std::string Light::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Misc Up");
}
std::string Light::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Misc Down");
}
} }

View File

@ -35,6 +35,12 @@ namespace MWClass
/// stay stacked when equipped? /// stay stacked when equipped?
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -7,10 +7,13 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -55,6 +58,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -82,4 +87,14 @@ namespace MWClass
registerClass (typeid (ESM::Tool).name(), instance); registerClass (typeid (ESM::Tool).name(), instance);
} }
std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Lockpick Up");
}
std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Lockpick Down");
}
} }

View File

@ -30,6 +30,12 @@ namespace MWClass
/// stay stacked when equipped? /// stay stacked when equipped?
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -53,6 +56,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -71,4 +76,28 @@ namespace MWClass
registerClass (typeid (ESM::Miscellaneous).name(), instance); registerClass (typeid (ESM::Miscellaneous).name(), instance);
} }
std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
if (ref->base->name =="Gold")
{
return std::string("Item Gold Up");
}
return std::string("Item Misc Up");
}
std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
if (ref->base->name =="Gold")
{
return std::string("Item Gold Down");
}
return std::string("Item Misc Down");
}
} }

View File

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -53,6 +56,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -71,4 +76,14 @@ namespace MWClass
registerClass (typeid (ESM::Potion).name(), instance); registerClass (typeid (ESM::Potion).name(), instance);
} }
std::string Potion::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Potion Up");
}
std::string Potion::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Potion Down");
}
} }

View File

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -7,10 +7,13 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -54,6 +57,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -81,4 +86,14 @@ namespace MWClass
registerClass (typeid (ESM::Probe).name(), instance); registerClass (typeid (ESM::Probe).name(), instance);
} }
std::string Probe::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Probe Up");
}
std::string Probe::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Probe Down");
}
} }

View File

@ -30,6 +30,12 @@ namespace MWClass
/// stay stacked when equipped? /// stay stacked when equipped?
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -53,6 +56,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -71,4 +76,14 @@ namespace MWClass
registerClass (typeid (ESM::Repair).name(), instance); registerClass (typeid (ESM::Repair).name(), instance);
} }
std::string Repair::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Repair Up");
}
std::string Repair::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Repair Down");
}
} }

View File

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -7,10 +7,13 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -54,6 +57,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -140,4 +145,96 @@ namespace MWClass
registerClass (typeid (ESM::Weapon).name(), instance); registerClass (typeid (ESM::Weapon).name(), instance);
} }
std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
int type = ref->base->data.type;
// Ammo
if (type == 12 || type == 13)
{
return std::string("Item Ammo Up");
}
// Bow
if (type == 9)
{
return std::string("Item Weapon Bow Up");
}
// Crossbow
if (type == 10)
{
return std::string("Item Weapon Crossbow Up");
}
// Longblades, One hand and Two
if (type == 1 || type == 2)
{
return std::string("Item Weapon Longblade Up");
}
// Shortblade and thrown weapons
// thrown weapons may not be entirely correct
if (type == 0 || type == 11)
{
return std::string("Item Weapon Shortblade Up");
}
// Spear
if (type == 6)
{
return std::string("Item Weapon Spear Up");
}
// Blunts and Axes
if (type == 3 || type == 4 || type == 5 || type == 7 || type == 8)
{
return std::string("Item Weapon Blunt Up");
}
return std::string("Item Misc Up");
}
std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
int type = ref->base->data.type;
// Ammo
if (type == 12 || type == 13)
{
return std::string("Item Ammo Down");
}
// Bow
if (type == 9)
{
return std::string("Item Weapon Bow Down");
}
// Crossbow
if (type == 10)
{
return std::string("Item Weapon Crossbow Down");
}
// Longblades, One hand and Two
if (type == 1 || type == 2)
{
return std::string("Item Weapon Longblade Down");
}
// Shortblade and thrown weapons
// thrown weapons may not be entirely correct
if (type == 0 || type == 11)
{
return std::string("Item Weapon Shortblade Down");
}
// Spear
if (type == 6)
{
return std::string("Item Weapon Spear Down");
}
// Blunts and Axes
if (type == 3 || type == 4 || type == 5 || type == 7 || type == 8)
{
return std::string("Item Weapon Blunt Down");
}
return std::string("Item Misc Down");
}
} }

View File

@ -41,6 +41,12 @@ namespace MWClass
/// no such skill. /// no such skill.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View File

@ -136,7 +136,7 @@ namespace MWSound
max = std::max(min, max); max = std::max(min, max);
} }
return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict); return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict, true);
} }
// Add a sound to the list and play it // Add a sound to the list and play it
@ -145,7 +145,7 @@ namespace MWSound
const std::string &id, const std::string &id,
float volume, float pitch, float volume, float pitch,
float min, float max, float min, float max,
bool loop) bool loop, bool untracked)
{ {
try try
{ {
@ -157,7 +157,10 @@ namespace MWSound
setPos(snd, ptr); setPos(snd, ptr);
snd->play(); snd->play();
sounds[ptr][id] = WSoundPtr(snd); if (!untracked)
{
sounds[ptr][id] = WSoundPtr(snd);
}
} }
catch(...) catch(...)
{ {
@ -373,7 +376,7 @@ namespace MWSound
void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename) void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename)
{ {
// The range values are not tested // The range values are not tested
std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict); std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict, true);
if(!filePath.empty()) if(!filePath.empty())
add(filePath, ptr, "_say_sound", 1, 1, 100, 20000, false); add(filePath, ptr, "_say_sound", 1, 1, 100, 20000, false);
else else
@ -397,6 +400,7 @@ namespace MWSound
snd->setVolume(volume); snd->setVolume(volume);
snd->setRange(min,max); snd->setRange(min,max);
snd->setPitch(pitch); snd->setPitch(pitch);
snd->setRelative(true);
snd->play(); snd->play();
if (loop) if (loop)
@ -412,13 +416,13 @@ namespace MWSound
} }
void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId, void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId,
float volume, float pitch, bool loop) float volume, float pitch, bool loop, bool untracked)
{ {
// Look up the sound in the ESM data // Look up the sound in the ESM data
float min, max; float min, max;
const std::string &file = lookup(soundId, volume, min, max); const std::string &file = lookup(soundId, volume, min, max);
if (file != "") if (file != "")
add(file, ptr, soundId, volume, pitch, min, max, loop); add(file, ptr, soundId, volume, pitch, min, max, loop, untracked);
} }
void SoundManager::stopSound3D (MWWorld::Ptr ptr, const std::string& soundId) void SoundManager::stopSound3D (MWWorld::Ptr ptr, const std::string& soundId)

View File

@ -87,7 +87,7 @@ namespace MWSound
void add(const std::string &file, void add(const std::string &file,
MWWorld::Ptr ptr, const std::string &id, MWWorld::Ptr ptr, const std::string &id,
float volume, float pitch, float min, float max, float volume, float pitch, float min, float max,
bool loop); bool loop, bool untracked=false);
void clearAll(PtrMap::iterator& it); void clearAll(PtrMap::iterator& it);
void remove(MWWorld::Ptr ptr, const std::string &id = ""); void remove(MWWorld::Ptr ptr, const std::string &id = "");
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const; bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const;
@ -136,7 +136,7 @@ namespace MWSound
///< Play a sound, independently of 3D-position ///< Play a sound, independently of 3D-position
void playSound3D (MWWorld::Ptr reference, const std::string& soundId, void playSound3D (MWWorld::Ptr reference, const std::string& soundId,
float volume, float pitch, bool loop); float volume, float pitch, bool loop, bool untracked=false);
///< Play a sound from an object ///< Play a sound from an object
void stopSound3D (MWWorld::Ptr reference, const std::string& soundId = ""); void stopSound3D (MWWorld::Ptr reference, const std::string& soundId = "");

View File

@ -156,4 +156,14 @@ namespace MWWorld
{ {
sClasses.insert (std::make_pair (key, instance)); sClasses.insert (std::make_pair (key, instance));
} }
std::string Class::getUpSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const
{
throw std::runtime_error ("class does not have an up sound");
}
std::string Class::getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const
{
throw std::runtime_error ("class does not have an down sound");
}
} }

View File

@ -162,6 +162,14 @@ namespace MWWorld
///< If there is no class for this pointer, an exception is thrown. ///< If there is no class for this pointer, an exception is thrown.
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance); static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
virtual std::string getUpSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the up sound ID of \a ptr or throw an exception, if class does not support ID retrieval
/// (default implementation: throw an exception)
virtual std::string getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the down sound ID of \a ptr or throw an exception, if class does not support ID retrieval
/// (default implementation: throw an exception)
}; };
} }

View File

@ -94,7 +94,7 @@ namespace Files
boost::filesystem::path result(""); boost::filesystem::path result("");
if (sectionName == "") if (sectionName == "")
{ {
return FileListLocator(mPriorityList, boost::filesystem::path(item), strict); return FileListLocator(mPriorityList, boost::filesystem::path(item), strict, false);
} }
else else
{ {
@ -103,7 +103,7 @@ namespace Files
std::cout << "Warning: There is no section named " << sectionName << "\n"; std::cout << "Warning: There is no section named " << sectionName << "\n";
return result; return result;
} }
result = FileListLocator(mMap[sectionName], boost::filesystem::path(item), strict); result = FileListLocator(mMap[sectionName], boost::filesystem::path(item), strict, false);
} }
return result; return result;
} }

View File

@ -42,13 +42,18 @@ bool isFile(const char *name)
} }
// Locates path in path container // Locates path in path container
boost::filesystem::path FileListLocator (const Files::PathContainer& list, const boost::filesystem::path& toFind, bool strict) boost::filesystem::path FileListLocator (const Files::PathContainer& list, const boost::filesystem::path& toFind,
bool strict, bool ignoreExtensions)
{ {
boost::filesystem::path result(""); boost::filesystem::path result("");
if (list.empty()) if (list.empty())
return result; return result;
std::string toFindStr = toFind.string(); std::string toFindStr;
if (ignoreExtensions)
toFindStr = boost::filesystem::basename(toFind);
else
toFindStr = toFind.string();
std::string fullPath; std::string fullPath;
@ -94,9 +99,9 @@ bool isFile(const char *name)
} }
// Overloaded form of the locator that takes a string and returns a string // Overloaded form of the locator that takes a string and returns a string
std::string FileListLocator (const Files::PathContainer& list,const std::string& toFind, bool strict) std::string FileListLocator (const Files::PathContainer& list,const std::string& toFind, bool strict, bool ignoreExtensions)
{ {
return FileListLocator(list, boost::filesystem::path(toFind), strict).string(); return FileListLocator(list, boost::filesystem::path(toFind), strict, ignoreExtensions).string();
} }
} }

View File

@ -27,10 +27,11 @@ bool isFile(const char *name);
/// that contains the searched path. /// that contains the searched path.
/// If it's not found it returns and empty path /// If it's not found it returns and empty path
/// Takes care of slashes, backslashes and it has a strict option. /// Takes care of slashes, backslashes and it has a strict option.
boost::filesystem::path FileListLocator (const Files::PathContainer& list, const boost::filesystem::path& toFind, bool strict); boost::filesystem::path FileListLocator (const Files::PathContainer& list, const boost::filesystem::path& toFind,
bool strict, bool ignoreExtensions);
/// Overloaded form of the locator that takes a string and returns a string /// Overloaded form of the locator that takes a string and returns a string
std::string FileListLocator (const Files::PathContainer& list,const std::string& toFind, bool strict); std::string FileListLocator (const Files::PathContainer& list,const std::string& toFind, bool strict, bool ignoreExtensions);
} }

View File

@ -52,9 +52,9 @@ namespace Sound {
Ogre::Vector3 nPos, nDir, nUp; Ogre::Vector3 nPos, nDir, nUp;
nPos = camera->getPosition(); nPos = camera->getRealPosition();
nDir = camera->getDirection(); nDir = camera->getRealDirection();
nUp = camera->getUp(); nUp = camera->getRealUp();
// Don't bother the sound system needlessly // Don't bother the sound system needlessly
if(nDir != dir || nPos != pos || nUp != up) if(nDir != dir || nPos != pos || nUp != up)

View File

@ -28,6 +28,7 @@ namespace Mangle
void setRange(float a, float b=0, float c=0) void setRange(float a, float b=0, float c=0)
{ client->setRange(a,b,c); } { client->setRange(a,b,c); }
void setStreaming(bool b) { client->setStreaming(b); } void setStreaming(bool b) { client->setStreaming(b); }
void setRelative(bool b) { client->setRelative(b); }
// The clone() function is not implemented here, as you will // The clone() function is not implemented here, as you will
// almost certainly want to override it yourself // almost certainly want to override it yourself

View File

@ -62,6 +62,9 @@ class Sound
/// Set loop mode /// Set loop mode
virtual void setRepeat(bool) = 0; virtual void setRepeat(bool) = 0;
/// If set to true the sound will not be affected by player movement
virtual void setRelative(bool) = 0;
/// Set streaming mode. /// Set streaming mode.
/** This may be used by implementations to optimize for very large /** This may be used by implementations to optimize for very large
files. If streaming mode is off (default), most implementations files. If streaming mode is off (default), most implementations

View File

@ -197,6 +197,7 @@ class Mangle::Sound::OpenAL_Sound : public Sound
void setPos(float x, float y, float z); void setPos(float x, float y, float z);
void setPitch(float); void setPitch(float);
void setRepeat(bool); void setRepeat(bool);
void setRelative(bool);
void notifyOwnerDeath() void notifyOwnerDeath()
{ ownerAlive = false; } { ownerAlive = false; }
@ -263,6 +264,7 @@ OpenAL_Factory::OpenAL_Factory(bool doSetup)
device = Device; device = Device;
context = Context; context = Context;
alDistanceModel(AL_LINEAR_DISTANCE);
} }
} }
@ -363,6 +365,12 @@ void OpenAL_Sound::setRepeat(bool rep)
alSourcei(inst, AL_LOOPING, rep?AL_TRUE:AL_FALSE); alSourcei(inst, AL_LOOPING, rep?AL_TRUE:AL_FALSE);
} }
void OpenAL_Sound::setRelative(bool rel)
{
alSourcei(inst, AL_SOURCE_RELATIVE, rel?AL_TRUE:AL_FALSE);
checkALError("setting relative");
}
SoundPtr OpenAL_Sound::clone() SoundPtr OpenAL_Sound::clone()
{ {
setupBuffer(); setupBuffer();