File: SoundInterface.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (109 lines) | stat: -rw-r--r-- 2,018 bytes parent folder | download | duplicates (3)
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
{
	ISoundShader::Ptr _shader;

public:
	ScriptSoundShader(const ISoundShader::Ptr& shader) :
		_shader(shader)
	{}

	operator ISoundShader::Ptr&() {
		return _shader;
	}

	std::string getName()
	{
		return _shader ? _shader->getDeclName() : "";
	}

	ScriptSoundRadii getRadii()
	{
		return _shader ? ScriptSoundRadii(_shader->getRadii()) : ScriptSoundRadii();
	}

	SoundFileList getSoundFileList()
	{
		return _shader ? _shader->getSoundFileList() : SoundFileList();
	}

	std::string getShaderFilePath()
	{
		return _shader ? _shader->getDeclFilePath() : std::string();
	}

	std::string getDefinition()
	{
		return _shader ? _shader->getBlockSyntax().contents : 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