added ag:🔉:{set,get}Volume() Lua interfaces
git-svn-id: svn://anubis/anaglym/trunk@295 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
9cdf2a4243
commit
957552e5b9
35
ag.cc
35
ag.cc
@ -327,6 +327,10 @@ namespace ag
|
|||||||
lua_setfield(L, -2, "loop");
|
lua_setfield(L, -2, "loop");
|
||||||
lua_pushcfunction(L, sound::loopForever);
|
lua_pushcfunction(L, sound::loopForever);
|
||||||
lua_setfield(L, -2, "loopForever");
|
lua_setfield(L, -2, "loopForever");
|
||||||
|
lua_pushcfunction(L, sound::getVolume);
|
||||||
|
lua_setfield(L, -2, "getVolume");
|
||||||
|
lua_pushcfunction(L, sound::setVolume);
|
||||||
|
lua_setfield(L, -2, "setVolume");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createLuaAMotor(lua_State * L, int id)
|
static void createLuaAMotor(lua_State * L, int id)
|
||||||
@ -1701,5 +1705,36 @@ namespace ag
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getVolume(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 1 && lua_istable(L, 1))
|
||||||
|
{
|
||||||
|
refptr<AV::Sound> snd = getSound(L, 1);
|
||||||
|
if (!snd.isNull())
|
||||||
|
{
|
||||||
|
float v = snd->getVolume();
|
||||||
|
lua_pushnumber(L, v);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int setVolume(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 2 && lua_istable(L, 1) && lua_isnumber(L, 2))
|
||||||
|
{
|
||||||
|
refptr<AV::Sound> snd = getSound(L, 1);
|
||||||
|
if (!snd.isNull())
|
||||||
|
{
|
||||||
|
float volume = lua_tonumber(L, 2);
|
||||||
|
snd->setVolume(volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user