updated lua bindings + input manager
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
const char wiImageEffects_BindLua::className[] = "ImageEffects";
|
||||
|
||||
Luna<wiImageEffects_BindLua>::FunctionType wiImageEffects_BindLua::methods[] = {
|
||||
lunamethod(wiImageEffects_BindLua, GetPos),
|
||||
lunamethod(wiImageEffects_BindLua, GetSize),
|
||||
lunamethod(wiImageEffects_BindLua, SetPos),
|
||||
lunamethod(wiImageEffects_BindLua, SetSize),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<wiImageEffects_BindLua>::PropertyType wiImageEffects_BindLua::properties[] = {
|
||||
@@ -14,6 +18,50 @@ wiImageEffects_BindLua::wiImageEffects_BindLua(const wiImageEffects& effects) :e
|
||||
{
|
||||
}
|
||||
|
||||
int wiImageEffects_BindLua::GetPos(lua_State* L)
|
||||
{
|
||||
wiLua::SSetFloat3(L, effects.pos);
|
||||
return 3;
|
||||
}
|
||||
int wiImageEffects_BindLua::GetSize(lua_State* L)
|
||||
{
|
||||
wiLua::SSetFloat2(L, effects.siz);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int wiImageEffects_BindLua::SetPos(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
{
|
||||
effects.pos.x = wiLua::SGetFloat(L, 2);
|
||||
if (argc > 2)
|
||||
effects.pos.y = wiLua::SGetFloat(L, 3);
|
||||
if (argc > 3)
|
||||
effects.pos.z = wiLua::SGetFloat(L, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetPos(float x,y,z) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int wiImageEffects_BindLua::SetSize(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
{
|
||||
effects.siz.x = wiLua::SGetFloat(L, 2);
|
||||
if (argc > 2)
|
||||
effects.siz.y = wiLua::SGetFloat(L, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetSize(float x,y) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
wiImageEffects_BindLua::wiImageEffects_BindLua(lua_State *L)
|
||||
{
|
||||
float x = 0, y = 0, w = 100, h = 100;
|
||||
|
||||
@@ -16,6 +16,12 @@ public:
|
||||
wiImageEffects_BindLua(lua_State *L);
|
||||
~wiImageEffects_BindLua();
|
||||
|
||||
int GetPos(lua_State* L);
|
||||
int GetSize(lua_State* L);
|
||||
|
||||
int SetPos(lua_State* L);
|
||||
int SetSize(lua_State* L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
|
||||
@@ -42,34 +42,13 @@ void wiInputManager::Update(){
|
||||
|
||||
bool todelete = false;
|
||||
|
||||
switch (type)
|
||||
if (down(button, type, playerIndex))
|
||||
{
|
||||
case wiInputManager::DIRECTINPUT_JOYPAD:
|
||||
if(dinput!=nullptr && dinput->isButtonDown(playerIndex,button)){
|
||||
iter->second++;
|
||||
}
|
||||
else{
|
||||
todelete=true;
|
||||
}
|
||||
break;
|
||||
case wiInputManager::XINPUT_JOYPAD:
|
||||
if(xinput!=nullptr && xinput->isButtonDown(playerIndex,button)){
|
||||
iter->second++;
|
||||
}
|
||||
else{
|
||||
todelete=true;
|
||||
}
|
||||
break;
|
||||
case wiInputManager::KEYBOARD:
|
||||
if(dinput!=nullptr && dinput->IsKeyDown(button)){
|
||||
iter->second++;
|
||||
}
|
||||
else{
|
||||
todelete=true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
iter->second++;
|
||||
}
|
||||
else
|
||||
{
|
||||
todelete = true;
|
||||
}
|
||||
|
||||
if(todelete){
|
||||
@@ -101,18 +80,15 @@ bool wiInputManager::down(DWORD button, InputType inputType, short playerindex)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool wiInputManager::press(DWORD button){
|
||||
return press(button,0,InputType::KEYBOARD);
|
||||
}
|
||||
bool wiInputManager::press(DWORD button, short playerIndex, InputType inputType){
|
||||
bool wiInputManager::press(DWORD button, InputType inputType, short playerindex){
|
||||
|
||||
if (!down(button, inputType, playerIndex))
|
||||
if (!down(button, inputType, playerindex))
|
||||
return false;
|
||||
|
||||
Input input = Input();
|
||||
input.button=button;
|
||||
input.type=inputType;
|
||||
input.playerIndex=playerIndex;
|
||||
input.playerIndex = playerindex;
|
||||
InputCollection::iterator iter = inputs.find(input);
|
||||
if(iter==inputs.end()){
|
||||
inputs.insert(InputCollection::value_type(input,0));
|
||||
@@ -120,10 +96,7 @@ bool wiInputManager::press(DWORD button, short playerIndex, InputType inputType)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool wiInputManager::hold(DWORD button, DWORD frames, bool continuous){
|
||||
return hold(button, frames, 0, continuous, InputType::KEYBOARD);
|
||||
}
|
||||
bool wiInputManager::hold(DWORD button, DWORD frames, short playerIndex, bool continuous, InputType inputType){
|
||||
bool wiInputManager::hold(DWORD button, DWORD frames, bool continuous, InputType inputType, short playerIndex){
|
||||
|
||||
if (!down(button, inputType, playerIndex))
|
||||
return false;
|
||||
|
||||
@@ -44,9 +44,7 @@ public:
|
||||
static InputCollection inputs;
|
||||
|
||||
static bool down(DWORD button, InputType inputType = InputType::KEYBOARD, short playerindex = 0);
|
||||
static bool press(DWORD button);
|
||||
static bool press(DWORD button, short playerIndex, InputType inputType = InputType::XINPUT_JOYPAD);
|
||||
static bool hold(DWORD button, DWORD frames = 30, bool continuous = false);
|
||||
static bool hold(DWORD button, DWORD frames = 30, short playerIndex = 0, bool continuous = false, InputType inputType = InputType::XINPUT_JOYPAD);
|
||||
static bool press(DWORD button, InputType inputType = InputType::KEYBOARD, short playerindex = 0);
|
||||
static bool hold(DWORD button, DWORD frames = 30, bool continuous = false, InputType inputType = InputType::KEYBOARD, short playerIndex = 0);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user