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