forked from teamnwah/openmw-tes3coop
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);
|
||||
|
||||
using Interpreter::Context::messageBox;
|
||||
virtual void messageBox (const std::string& message,
|
||||
const std::vector<std::string>& buttons);
|
||||
|
||||
|
|
|
@ -25,15 +25,15 @@ namespace MWScript
|
|||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
|
||||
std::string file = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().say (context.getReference(), file, text,
|
||||
context);
|
||||
|
||||
context.getSoundManager().say (context.getReference(), file, text);
|
||||
context.messageBox (text);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -46,8 +46,7 @@ namespace MWScript
|
|||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
runtime.push (context.getSoundManager().sayDone (context.getReference(),
|
||||
context));
|
||||
runtime.push (context.getSoundManager().sayDone (context.getReference()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -63,7 +62,7 @@ namespace MWScript
|
|||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
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);
|
||||
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;
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().playSound (sound, volume, pitch, context);
|
||||
context.getSoundManager().playSound (sound, volume, pitch);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -122,7 +121,7 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
runtime.pop();
|
||||
|
||||
context.getSoundManager().stopSound3D (context.getReference(), sound, context);
|
||||
context.getSoundManager().stopSound3D (context.getReference(), sound);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -183,7 +182,7 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
||||
context.getReference(), runtime.getStringLiteral (index), context));
|
||||
context.getReference(), runtime.getStringLiteral (index)));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -206,7 +205,7 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
context.getSoundManager().say (context.getWorld().getPtr (id, true),
|
||||
file, text, context);
|
||||
file, text);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -223,7 +222,7 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
runtime.push (context.getSoundManager().sayDone (
|
||||
context.getWorld().getPtr (id, true), context));
|
||||
context.getWorld().getPtr (id, true)));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -247,7 +246,7 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
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();
|
||||
|
||||
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();
|
||||
|
||||
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 (
|
||||
context.getWorld().getPtr (id, true),
|
||||
runtime.getStringLiteral (index), context));
|
||||
runtime.getStringLiteral (index)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
#include "soundmanager.hpp"
|
||||
|
||||
#include <components/interpreter/context.hpp>
|
||||
|
||||
#include <openengine/sound/sndmanager.hpp>
|
||||
|
||||
/* 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,
|
||||
const std::string& text, Interpreter::Context& context)
|
||||
const std::string& text)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void SoundManager::playSound (const std::string& soundId, float volume, float pitch,
|
||||
Interpreter::Context& context)
|
||||
void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
|
||||
{
|
||||
std::cout
|
||||
<< "sound effect: playing sound " << soundId
|
||||
|
@ -90,7 +86,7 @@ namespace MWSound
|
|||
}
|
||||
|
||||
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
|
||||
<< "sound effect: playing sound " << soundId
|
||||
|
@ -101,8 +97,7 @@ namespace MWSound
|
|||
mData->mSounds[reference.getRefData().getHandle()] = soundId;
|
||||
}
|
||||
|
||||
void SoundManager::stopSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
||||
Interpreter::Context& context)
|
||||
void SoundManager::stopSound3D (MWWorld::Ptr reference, const std::string& soundId)
|
||||
{
|
||||
std::cout
|
||||
<< "sound effect : stop playing sound " << soundId
|
||||
|
@ -111,8 +106,7 @@ namespace MWSound
|
|||
mData->mSounds[reference.getRefData().getHandle()] = "";
|
||||
}
|
||||
|
||||
bool SoundManager::getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId,
|
||||
Interpreter::Context& context) const
|
||||
bool SoundManager::getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId) const
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator iter =
|
||||
mData->mSounds.find (reference.getRefData().getHandle());
|
||||
|
|
|
@ -6,11 +6,6 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace Interpreter
|
||||
{
|
||||
class Context;
|
||||
}
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Root;
|
||||
|
@ -35,32 +30,29 @@ namespace MWSound
|
|||
~SoundManager();
|
||||
|
||||
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.
|
||||
/// \param filename name of a sound file in "Sound/Vo/" in the data directory.
|
||||
/// \param text Subtitle
|
||||
|
||||
bool sayDone (MWWorld::Ptr reference, Interpreter::Context& context) const;
|
||||
bool sayDone (MWWorld::Ptr reference) const;
|
||||
///< Is actor not speaking?
|
||||
|
||||
void streamMusic (const std::string& filename, Interpreter::Context& context);
|
||||
void streamMusic (const std::string& filename);
|
||||
///< Play a soundifle
|
||||
/// \param filename name of a sound file in "Music/" in the data directory.
|
||||
|
||||
void playSound (const std::string& soundId, float volume, float pitch,
|
||||
Interpreter::Context& context);
|
||||
void playSound (const std::string& soundId, float volume, float pitch);
|
||||
///< Play a sound, independently of 3D-position
|
||||
|
||||
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
|
||||
|
||||
void stopSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
||||
Interpreter::Context& context);
|
||||
void stopSound3D (MWWorld::Ptr reference, const std::string& soundId);
|
||||
///< Stop the given object from playing the given sound.
|
||||
|
||||
bool getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId,
|
||||
Interpreter::Context& context) const;
|
||||
bool getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId) const;
|
||||
///< Is the given sound currently playing on the given object?
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue