From 9b1f8214eea0c86d41f903a5feba9aac78603df1 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 12 Nov 2021 19:13:03 +0800 Subject: *misc --- Runtime/Scripting/Events/Events.bind.cpp | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Runtime/Scripting/Events/Events.bind.cpp (limited to 'Runtime/Scripting/Events/Events.bind.cpp') diff --git a/Runtime/Scripting/Events/Events.bind.cpp b/Runtime/Scripting/Events/Events.bind.cpp new file mode 100644 index 0000000..40ea544 --- /dev/null +++ b/Runtime/Scripting/Events/Events.bind.cpp @@ -0,0 +1,65 @@ +#include "Runtime/Events/InputEvent.h" +#include "Runtime/Lua/LuaHelper.h" +#include "Runtime/Debug/Log.h" + +// Events.CopyEvent(e) +int CopyEvent(lua_State* L) +{ + LUA_BIND_STATE(L); + + InputEvent e; + e.RestoreFromTable(state, -1); + state.PushTable(e); + + return 1; +} + +static luaL_Reg funcs[] = { + {"CopyEvent", CopyEvent}, + {0, 0} +}; + +int luaopen_GameLab_Events(lua_State* L) +{ + log_info_tag("Scripting", "luaopen_GameLab_Events()"); + + LUA_BIND_STATE(L); + state.PushGlobalNamespace(); + state.PushNamespace("GameLab"); + state.PushNamespace("Events"); + + state.RegisterMethods(funcs); + + LUA_BIND_REGISTER_ENUM(state, "EEventType", + { "MouseDown", InputEvent_MouseDown }, + { "MouseUp", InputEvent_MouseUp }, + { "MouseMove", InputEvent_MouseMove }, + { "MouseDrag", InputEvent_MouseDrag }, + { "KeyDown", InputEvent_KeyDown }, + { "KeyUp", InputEvent_KeyUp }, + { "ScrollWheel", InputEvent_ScrollWheel }, + { "Repaint", InputEvent_Repaint }, + { "Layout", InputEvent_Layout }, + { "DragUpdated", InputEvent_DragUpdated }, + { "DragPerform", InputEvent_DragPerform }, + { "DragExited", InputEvent_DragExited }, + { "Ignore", InputEvent_Ignore }, + { "Used", InputEvent_Used }, + { "ValidateCommand", InputEvent_ValidateCommand }, + { "ExecuteCommand", InputEvent_ExecuteCommand }, + { "ContextClick", InputEvent_ContextClick }, + { "MouseEnterWindow", InputEvent_MouseEnterWindow }, + { "MouseLeaveWindow", InputEvent_MouseLeaveWindow }, + { "MagnifyGesture", InputEvent_MagnifyGesture }, + { "SwipeGesture", InputEvent_SwipeGesture }, + { "RotateGesture", InputEvent_RotateGesture } + ); + + LUA_BIND_REGISTER_ENUM(state, "EMouseButton", + { "LeftButton", Mouse_LeftButton }, + { "RightButton", Mouse_RightButton }, + { "MiddleButton", Mouse_MiddleButton } + ); + + return 1; +} \ No newline at end of file -- cgit v1.1-26-g67d0