mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Added Source:getType
This commit is contained in:
@@ -34,6 +34,11 @@ Source::~Source()
|
||||
{
|
||||
}
|
||||
|
||||
Source::Type Source::getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
bool Source::getConstant(const char *in, Type &out)
|
||||
{
|
||||
return types.find(in, out);
|
||||
|
||||
@@ -96,6 +96,8 @@ public:
|
||||
virtual void setMaxDistance(float distance) = 0;
|
||||
virtual float getMaxDistance() const = 0;
|
||||
|
||||
virtual Type getType() const;
|
||||
|
||||
static bool getConstant(const char *in, Type &out);
|
||||
static bool getConstant(Type in, const char *&out);
|
||||
static bool getConstant(const char *in, Unit &out);
|
||||
|
||||
@@ -289,6 +289,19 @@ int w_Source_getRolloff(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_getType(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
Source::Type stype = t->getType();
|
||||
const char *typestr;
|
||||
|
||||
if (!Source::getConstant(stype, typestr))
|
||||
return luaL_error(L, "Unknown Source type.");
|
||||
|
||||
lua_pushstring(L, typestr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] =
|
||||
{
|
||||
{ "play", w_Source_play },
|
||||
@@ -324,6 +337,8 @@ static const luaL_Reg functions[] =
|
||||
{ "setRolloff", w_Source_setRolloff},
|
||||
{ "getRolloff", w_Source_getRolloff},
|
||||
|
||||
{ "getType", w_Source_getType },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ int w_Source_setDistance(lua_State *L);
|
||||
int w_Source_getDistance(lua_State *L);
|
||||
int w_Source_setRolloff(lua_State *L);
|
||||
int w_Source_getRolloff(lua_State *L);
|
||||
int w_Source_getType(lua_State *L);
|
||||
extern "C" int luaopen_source(lua_State *L);
|
||||
|
||||
} // audio
|
||||
|
||||
Reference in New Issue
Block a user