identify LiveCellRefs by ptr instead of render handle

actorid
Marc Zinnschlag 15 years ago
parent 3fae68b403
commit eeeb9b09f8

@ -80,5 +80,10 @@ namespace MWScript
{
return mSoundManager;
}
MWWorld::Ptr InterpreterContext::getReference()
{
return mReference;
}
}

@ -50,6 +50,9 @@ namespace MWScript
MWWorld::World& getWorld();
MWSound::SoundManager& getSoundManager();
MWWorld::Ptr getReference();
///< Reference, that the script is running from (can be empty)
};
}

@ -26,7 +26,8 @@ namespace MWSound
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
runtime.push (context.getSoundManager().sayDone ("", context));
runtime.push (context.getSoundManager().sayDone (context.getReference(),
context));
}
};
@ -43,7 +44,7 @@ namespace MWSound
runtime.pop();
runtime.push (context.getSoundManager().getSoundPlaying (
"", runtime.getStringLiteral (index), context));
context.getReference(), runtime.getStringLiteral (index), context));
}
};

@ -7,15 +7,15 @@
namespace MWSound
{
void SoundManager::say (const std::string& handle, const std::string& filename,
void SoundManager::say (MWWorld::Ptr reference, const std::string& filename,
const std::string& text, Interpreter::Context& context)
{
std::cout << "sound effect: " << handle << " is speaking" << std::endl;
std::cout << "sound effect: " << reference.getRefData().getHandle() << " is speaking" << std::endl;
context.messageBox (text);
}
bool SoundManager::sayDone (const std::string& handle, Interpreter::Context& context) const
bool SoundManager::sayDone (MWWorld::Ptr reference, Interpreter::Context& context) const
{
return false;
}
@ -34,32 +34,33 @@ namespace MWSound
<< std::endl;
}
void SoundManager::playSound3D (const std::string& handle, const std::string& soundId,
void SoundManager::playSound3D (MWWorld::Ptr reference, const std::string& soundId,
float volume, float pitch, Interpreter::Context& context)
{
std::cout
<< "sound effect: playing sound " << soundId
<< " from " << handle
<< " from " << reference.getRefData().getHandle()
<< " at volume " << volume << ", at pitch " << pitch
<< std::endl;
mSounds[handle] = soundId;
mSounds[reference.getRefData().getHandle()] = soundId;
}
void SoundManager::stopSound3D (const std::string& handle, const std::string& soundId,
void SoundManager::stopSound3D (MWWorld::Ptr reference, const std::string& soundId,
Interpreter::Context& context)
{
std::cout
<< "sound effect : stop playing sound " << soundId
<< " from " << handle << std::endl;
<< " from " << reference.getRefData().getHandle() << std::endl;
mSounds[handle] = "";
mSounds[reference.getRefData().getHandle()] = "";
}
bool SoundManager::getSoundPlaying (const std::string& handle, const std::string& soundId,
bool SoundManager::getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId,
Interpreter::Context& context) const
{
std::map<std::string, std::string>::const_iterator iter = mSounds.find (handle);
std::map<std::string, std::string>::const_iterator iter =
mSounds.find (reference.getRefData().getHandle());
if (iter==mSounds.end())
return false;

@ -4,6 +4,8 @@
#include <string>
#include <map>
#include "../mwworld/ptr.hpp"
namespace Interpreter
{
class Context;
@ -17,11 +19,6 @@ namespace MWSound
// not sure, if that is what Morrowind does. Beyond the dummy code in this class the script
// system does not make any assumption about the number of sound effects.
//
// - the handle argument below is the ogre handle. Since we can assume, that all objects
// that play a sound are in an active cell, they must have a handle. Sound script instructions
// that reference objects not in an active cell will be taken care of long before the flow
// of control reached this class.
//
// - all text-output (error messages and such) must be directed through the
// context.messageBox interface.
//
@ -35,16 +32,14 @@ namespace MWSound
public:
void say (const std::string& handle, const std::string& filename,
void say (MWWorld::Ptr reference, const std::string& filename,
const std::string& text, Interpreter::Context& context);
///< Make an actor say some text.
/// \param handle Handle as returned from render-subsystem
/// \param filename name of a sound file in "Sound/Vo/" in the data directory.
/// \param text Subtitle
bool sayDone (const std::string& handle, Interpreter::Context& context) const;
bool sayDone (MWWorld::Ptr reference, Interpreter::Context& context) const;
///< Is actor not speaking?
/// \param handle Handle as returned from render-subsystem
void streamMusic (const std::string& filename, Interpreter::Context& context);
///< Play a soundifle
@ -54,20 +49,17 @@ namespace MWSound
Interpreter::Context& context);
///< Play a sound, independently of 3D-position
void playSound3D (const std::string& handle, const std::string& soundId,
void playSound3D (MWWorld::Ptr reference, const std::string& soundId,
float volume, float pitch, Interpreter::Context& context);
///< Play a sound from an object
/// \param handle Handle as returned from render-subsystem
void stopSound3D (const std::string& handle, const std::string& soundId,
void stopSound3D (MWWorld::Ptr reference, const std::string& soundId,
Interpreter::Context& context);
///< Stop the given object from playing the given sound.
/// \param handle Handle as returned from render-subsystem
bool getSoundPlaying (const std::string& handle, const std::string& soundId,
bool getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId,
Interpreter::Context& context) const;
///< Is the given sound currently playing on the given object?
/// \param handle Handle as returned from render-subsystem
};
}

Loading…
Cancel
Save