mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Decoupled SoundManager from Interpreter::Context
This commit is contained in:
parent
34572f0b19
commit
8067d62800
4 changed files with 33 additions and 47 deletions
|
@ -51,6 +51,7 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void setLocalFloat (int index, float value);
|
virtual void setLocalFloat (int index, float value);
|
||||||
|
|
||||||
|
using Interpreter::Context::messageBox;
|
||||||
virtual void messageBox (const std::string& message,
|
virtual void messageBox (const std::string& message,
|
||||||
const std::vector<std::string>& buttons);
|
const std::vector<std::string>& buttons);
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,15 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string file = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string file = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().say (context.getReference(), file, text,
|
context.getSoundManager().say (context.getReference(), file, text);
|
||||||
context);
|
context.messageBox (text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,8 +46,7 @@ namespace MWScript
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().sayDone (context.getReference(),
|
runtime.push (context.getSoundManager().sayDone (context.getReference()));
|
||||||
context));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ namespace MWScript
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().streamMusic (sound, context);
|
context.getSoundManager().streamMusic (sound);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,7 +78,7 @@ namespace MWScript
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound (sound, 1.0, 1.0, context);
|
context.getSoundManager().playSound (sound, 1.0, 1.0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,7 +100,7 @@ namespace MWScript
|
||||||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound (sound, volume, pitch, context);
|
context.getSoundManager().playSound (sound, volume, pitch);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,7 +121,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (context.getReference(), sound,
|
context.getSoundManager().playSound3D (context.getReference(), sound,
|
||||||
1.0, 1.0, mLoop, context);
|
1.0, 1.0, mLoop);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (context.getReference(), sound, volume,
|
context.getSoundManager().playSound3D (context.getReference(), sound, volume,
|
||||||
pitch, mLoop, context);
|
pitch, mLoop);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -166,7 +165,7 @@ namespace MWScript
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().stopSound3D (context.getReference(), sound, context);
|
context.getSoundManager().stopSound3D (context.getReference(), sound);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -183,7 +182,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
runtime.push (context.getSoundManager().getSoundPlaying (
|
||||||
context.getReference(), runtime.getStringLiteral (index), context));
|
context.getReference(), runtime.getStringLiteral (index)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -206,7 +205,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().say (context.getWorld().getPtr (id, true),
|
context.getSoundManager().say (context.getWorld().getPtr (id, true),
|
||||||
file, text, context);
|
file, text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -223,7 +222,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().sayDone (
|
runtime.push (context.getSoundManager().sayDone (
|
||||||
context.getWorld().getPtr (id, true), context));
|
context.getWorld().getPtr (id, true)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -247,7 +246,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (
|
context.getSoundManager().playSound3D (
|
||||||
context.getWorld().getPtr (id, true), sound, 1.0, 1.0, mLoop, context);
|
context.getWorld().getPtr (id, true), sound, 1.0, 1.0, mLoop);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -277,7 +276,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (
|
context.getSoundManager().playSound3D (
|
||||||
context.getWorld().getPtr (id, true), sound, volume, pitch, mLoop, context);
|
context.getWorld().getPtr (id, true), sound, volume, pitch, mLoop);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -298,7 +297,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().stopSound3D (
|
context.getSoundManager().stopSound3D (
|
||||||
context.getWorld().getPtr (id, true), sound, context);
|
context.getWorld().getPtr (id, true), sound);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -319,7 +318,7 @@ namespace MWScript
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
runtime.push (context.getSoundManager().getSoundPlaying (
|
||||||
context.getWorld().getPtr (id, true),
|
context.getWorld().getPtr (id, true),
|
||||||
runtime.getStringLiteral (index), context));
|
runtime.getStringLiteral (index)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
|
|
||||||
#include "soundmanager.hpp"
|
#include "soundmanager.hpp"
|
||||||
|
|
||||||
#include <components/interpreter/context.hpp>
|
|
||||||
|
|
||||||
#include <openengine/sound/sndmanager.hpp>
|
#include <openengine/sound/sndmanager.hpp>
|
||||||
|
|
||||||
/* Set up the sound manager to use Audiere for input (reading sound
|
/* Set up the sound manager to use Audiere for input (reading sound
|
||||||
|
@ -63,25 +61,23 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::say (MWWorld::Ptr reference, const std::string& filename,
|
void SoundManager::say (MWWorld::Ptr reference, const std::string& filename,
|
||||||
const std::string& text, Interpreter::Context& context)
|
const std::string& text)
|
||||||
{
|
{
|
||||||
std::cout << "sound effect: " << reference.getRefData().getHandle() << " is speaking" << std::endl;
|
std::cout << "sound effect: " << reference.getRefData().getHandle() << " is speaking" << std::endl;
|
||||||
|
|
||||||
context.messageBox (text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoundManager::sayDone (MWWorld::Ptr reference, Interpreter::Context& context) const
|
bool SoundManager::sayDone (MWWorld::Ptr reference) const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::streamMusic (const std::string& filename, Interpreter::Context& context)
|
void SoundManager::streamMusic (const std::string& filename)
|
||||||
{
|
{
|
||||||
std::cout << "sound effect: playing music" << filename << std::endl;
|
std::cout << "sound effect: playing music" << filename << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::playSound (const std::string& soundId, float volume, float pitch,
|
void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
|
||||||
Interpreter::Context& context)
|
|
||||||
{
|
{
|
||||||
std::cout
|
std::cout
|
||||||
<< "sound effect: playing sound " << soundId
|
<< "sound effect: playing sound " << soundId
|
||||||
|
@ -90,7 +86,7 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::playSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
void SoundManager::playSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
||||||
float volume, float pitch, bool loop, Interpreter::Context& context)
|
float volume, float pitch, bool loop)
|
||||||
{
|
{
|
||||||
std::cout
|
std::cout
|
||||||
<< "sound effect: playing sound " << soundId
|
<< "sound effect: playing sound " << soundId
|
||||||
|
@ -101,8 +97,7 @@ namespace MWSound
|
||||||
mData->mSounds[reference.getRefData().getHandle()] = soundId;
|
mData->mSounds[reference.getRefData().getHandle()] = soundId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::stopSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
void SoundManager::stopSound3D (MWWorld::Ptr reference, const std::string& soundId)
|
||||||
Interpreter::Context& context)
|
|
||||||
{
|
{
|
||||||
std::cout
|
std::cout
|
||||||
<< "sound effect : stop playing sound " << soundId
|
<< "sound effect : stop playing sound " << soundId
|
||||||
|
@ -111,8 +106,7 @@ namespace MWSound
|
||||||
mData->mSounds[reference.getRefData().getHandle()] = "";
|
mData->mSounds[reference.getRefData().getHandle()] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoundManager::getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId,
|
bool SoundManager::getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId) const
|
||||||
Interpreter::Context& context) const
|
|
||||||
{
|
{
|
||||||
std::map<std::string, std::string>::const_iterator iter =
|
std::map<std::string, std::string>::const_iterator iter =
|
||||||
mData->mSounds.find (reference.getRefData().getHandle());
|
mData->mSounds.find (reference.getRefData().getHandle());
|
||||||
|
|
|
@ -6,11 +6,6 @@
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
namespace Interpreter
|
|
||||||
{
|
|
||||||
class Context;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
class Root;
|
class Root;
|
||||||
|
@ -35,32 +30,29 @@ namespace MWSound
|
||||||
~SoundManager();
|
~SoundManager();
|
||||||
|
|
||||||
void say (MWWorld::Ptr reference, const std::string& filename,
|
void say (MWWorld::Ptr reference, const std::string& filename,
|
||||||
const std::string& text, Interpreter::Context& context);
|
const std::string& text);
|
||||||
///< Make an actor say some text.
|
///< Make an actor say some text.
|
||||||
/// \param filename name of a sound file in "Sound/Vo/" in the data directory.
|
/// \param filename name of a sound file in "Sound/Vo/" in the data directory.
|
||||||
/// \param text Subtitle
|
/// \param text Subtitle
|
||||||
|
|
||||||
bool sayDone (MWWorld::Ptr reference, Interpreter::Context& context) const;
|
bool sayDone (MWWorld::Ptr reference) const;
|
||||||
///< Is actor not speaking?
|
///< Is actor not speaking?
|
||||||
|
|
||||||
void streamMusic (const std::string& filename, Interpreter::Context& context);
|
void streamMusic (const std::string& filename);
|
||||||
///< Play a soundifle
|
///< Play a soundifle
|
||||||
/// \param filename name of a sound file in "Music/" in the data directory.
|
/// \param filename name of a sound file in "Music/" in the data directory.
|
||||||
|
|
||||||
void playSound (const std::string& soundId, float volume, float pitch,
|
void playSound (const std::string& soundId, float volume, float pitch);
|
||||||
Interpreter::Context& context);
|
|
||||||
///< 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, Interpreter::Context& context);
|
float volume, float pitch, bool loop);
|
||||||
///< 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);
|
||||||
Interpreter::Context& context);
|
|
||||||
///< Stop the given object from playing the given sound.
|
///< Stop the given object from playing the given sound.
|
||||||
|
|
||||||
bool getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId,
|
bool getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId) const;
|
||||||
Interpreter::Context& context) const;
|
|
||||||
///< Is the given sound currently playing on the given object?
|
///< Is the given sound currently playing on the given object?
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue