mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 00:37:58 +03:00
104 lines
2.6 KiB
C++
104 lines
2.6 KiB
C++
![]() |
#include "framework.h"
|
||
|
#include "GameScriptSoundSourceInfo.h"
|
||
|
#include "GameScriptPosition.h"
|
||
|
/***
|
||
|
Camera info
|
||
|
|
||
|
@classmod SoundSourceInfo
|
||
|
@pragma nostrip
|
||
|
*/
|
||
|
|
||
|
extern bool const WarningsAsErrors;
|
||
|
|
||
|
static constexpr auto LUA_CLASS_NAME{ "SoundSourceInfo" };
|
||
|
|
||
|
static auto index_error = index_error_maker(GameScriptSoundSourceInfo, LUA_CLASS_NAME);
|
||
|
|
||
|
GameScriptSoundSourceInfo::GameScriptSoundSourceInfo(SOUND_SOURCE_INFO & ref, bool temp) : m_soundSource{ref}, m_temporary{ temp }
|
||
|
{};
|
||
|
|
||
|
GameScriptSoundSourceInfo::~GameScriptSoundSourceInfo() {
|
||
|
if (m_temporary)
|
||
|
{
|
||
|
s_callbackRemoveName(m_soundSource.luaName);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void GameScriptSoundSourceInfo::Register(sol::state* state)
|
||
|
{
|
||
|
state->new_usertype<GameScriptSoundSourceInfo>(LUA_CLASS_NAME,
|
||
|
sol::meta_function::index, index_error,
|
||
|
|
||
|
/// (@{Position}) position in level
|
||
|
// @mem pos
|
||
|
"pos", sol::property(&GameScriptSoundSourceInfo::GetPos, &GameScriptSoundSourceInfo::SetPos),
|
||
|
|
||
|
/// (string) unique string identifier.
|
||
|
// e.g. "machine_sound_1" or "discordant_humming"
|
||
|
// @mem name
|
||
|
"name", sol::property(&GameScriptSoundSourceInfo::GetName, &GameScriptSoundSourceInfo::SetName),
|
||
|
|
||
|
/// (int) sound ID
|
||
|
// @mem soundID
|
||
|
"soundID", sol::property(&GameScriptSoundSourceInfo::GetSoundID, &GameScriptSoundSourceInfo::SetSoundID),
|
||
|
|
||
|
/// (int) flags
|
||
|
// @mem flags
|
||
|
"flags", sol::property(&GameScriptSoundSourceInfo::GetFlags, &GameScriptSoundSourceInfo::SetFlags)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
GameScriptPosition GameScriptSoundSourceInfo::GetPos() const
|
||
|
{
|
||
|
return GameScriptPosition{ m_soundSource.x, m_soundSource.y, m_soundSource.z };
|
||
|
}
|
||
|
|
||
|
void GameScriptSoundSourceInfo::SetPos(GameScriptPosition const& pos)
|
||
|
{
|
||
|
m_soundSource.x = pos.x;
|
||
|
m_soundSource.y = pos.y;
|
||
|
m_soundSource.z = pos.z;
|
||
|
}
|
||
|
|
||
|
std::string GameScriptSoundSourceInfo::GetName() const
|
||
|
{
|
||
|
return m_soundSource.luaName;
|
||
|
}
|
||
|
|
||
|
void GameScriptSoundSourceInfo::SetName(std::string const & id)
|
||
|
{
|
||
|
if (id.empty() && WarningsAsErrors)
|
||
|
throw std::runtime_error("Name cannot be blank");
|
||
|
|
||
|
// remove the old name if we have one
|
||
|
s_callbackRemoveName(m_soundSource.luaName);
|
||
|
|
||
|
// un-register any other objects using this name.
|
||
|
// maybe we should throw an error if another object
|
||
|
// already uses the name...
|
||
|
s_callbackRemoveName(id);
|
||
|
m_soundSource.luaName = id;
|
||
|
// todo add error checking
|
||
|
s_callbackSetName(id, m_soundSource);
|
||
|
}
|
||
|
|
||
|
int GameScriptSoundSourceInfo::GetSoundID() const
|
||
|
{
|
||
|
return m_soundSource.soundId;
|
||
|
}
|
||
|
|
||
|
void GameScriptSoundSourceInfo::SetSoundID(int soundID)
|
||
|
{
|
||
|
m_soundSource.soundId = soundID;
|
||
|
}
|
||
|
|
||
|
int GameScriptSoundSourceInfo::GetFlags() const
|
||
|
{
|
||
|
return m_soundSource.flags;
|
||
|
}
|
||
|
|
||
|
void GameScriptSoundSourceInfo::SetFlags(int flags)
|
||
|
{
|
||
|
m_soundSource.flags = flags;
|
||
|
}
|