| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "isound.h" |
| 4 |
#include "iscript.h" |
| 5 |
#include "iscriptinterface.h" |
| 6 |
|
| 7 |
namespace script |
| 8 |
{ |
| 9 |
|
| 10 |
class ScriptSoundRadii |
| 11 |
{ |
| 12 |
SoundRadii _radii; |
| 13 |
public: |
| 14 |
ScriptSoundRadii() : |
| 15 |
_radii(0,0,false) |
| 16 |
{} |
| 17 |
|
| 18 |
ScriptSoundRadii(const SoundRadii& radii) : |
| 19 |
_radii(radii) |
| 20 |
{} |
| 21 |
|
| 22 |
operator SoundRadii&() { |
| 23 |
return _radii; |
| 24 |
} |
| 25 |
|
| 26 |
void setMin(float min, int inMetres) |
| 27 |
{ |
| 28 |
_radii.setMin(min, static_cast<bool>(inMetres)); |
| 29 |
} |
| 30 |
|
| 31 |
void setMax(float max, int inMetres) |
| 32 |
{ |
| 33 |
_radii.setMax(max, static_cast<bool>(inMetres)); |
| 34 |
} |
| 35 |
|
| 36 |
float getMin(int inMetres) const |
| 37 |
{ |
| 38 |
return _radii.getMin(static_cast<bool>(inMetres)); |
| 39 |
} |
| 40 |
|
| 41 |
float getMax(int inMetres) const |
| 42 |
{ |
| 43 |
return _radii.getMax(static_cast<bool>(inMetres)); |
| 44 |
} |
| 45 |
}; |
| 46 |
|
| 47 |
/** |
| 48 |
* This class represents a single sound shader for a script. |
| 49 |
*/ |
| 50 |
class ScriptSoundShader |
| 51 |
{ |
| 52 |
ISoundShader::Ptr _shader; |
| 53 |
|
| 54 |
public: |
| 55 |
ScriptSoundShader(const ISoundShader::Ptr& shader) : |
| 56 |
_shader(shader) |
| 57 |
{} |
| 58 |
|
| 59 |
operator ISoundShader::Ptr&() { |
| 60 |
return _shader; |
| 61 |
} |
| 62 |
|
| 63 |
std::string getName() |
| 64 |
{ |
| 65 |
return _shader ? _shader->getDeclName() : ""; |
| 66 |
} |
| 67 |
|
| 68 |
ScriptSoundRadii getRadii() |
| 69 |
{ |
| 70 |
return _shader ? ScriptSoundRadii(_shader->getRadii()) : ScriptSoundRadii(); |
| 71 |
} |
| 72 |
|
| 73 |
SoundFileList getSoundFileList() |
| 74 |
{ |
| 75 |
return _shader ? _shader->getSoundFileList() : SoundFileList(); |
| 76 |
} |
| 77 |
|
| 78 |
std::string getShaderFilePath() |
| 79 |
{ |
| 80 |
return _shader ? _shader->getDeclFilePath() : std::string(); |
| 81 |
} |
| 82 |
|
| 83 |
std::string getDefinition() |
| 84 |
{ |
| 85 |
return _shader ? _shader->getBlockSyntax().contents : std::string(); |
| 86 |
} |
| 87 |
|
| 88 |
bool isNull() const { |
| 89 |
return _shader == NULL; |
| 90 |
} |
| 91 |
}; |
| 92 |
|
| 93 |
/** |
| 94 |
* greebo: This class provides the script interface for the GlobalSoundManager module. |
| 95 |
*/ |
| 96 |
class SoundManagerInterface : |
| 97 |
public IScriptInterface |
| 98 |
{ |
| 99 |
public: |
| 100 |
// Wrapper methods for exposing the SoundManager interface |
| 101 |
ScriptSoundShader getSoundShader(const std::string& shaderName); |
| 102 |
bool playSound(const std::string& fileName); |
| 103 |
void stopSound(); |
| 104 |
|
| 105 |
// IScriptInterface implementation |
| 106 |
void registerInterface(py::module& scope, py::dict& globals) override; |
| 107 |
}; |
| 108 |
|
| 109 |
} // namespace script |