aboutsummaryrefslogtreecommitdiff
path: root/src/lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/event/luaopen_event.cpp12
-rw-r--r--src/lua/graphics/luaopen_graphics.cpp12
-rw-r--r--src/lua/time/luaopen_time.cpp8
3 files changed, 19 insertions, 13 deletions
diff --git a/src/lua/event/luaopen_event.cpp b/src/lua/event/luaopen_event.cpp
index a53863d..8802175 100644
--- a/src/lua/event/luaopen_event.cpp
+++ b/src/lua/event/luaopen_event.cpp
@@ -31,37 +31,37 @@ namespace lua
luax_setfield_string(L, "type", "quit");
break;
- case EventType::KEYDOWN:
+ case EventType::KEY_DOWN:
luax_setfield_string(L, "type", "keydown");
luax_setfield_string(L, "key", getKeyName(e.key.keysym.sym));
break;
- case EventType::KEYUP:
+ case EventType::KEY_UP:
luax_setfield_string(L, "type", "keyup");
luax_setfield_string(L, "key", getKeyName(e.key.keysym.sym));
break;
- case EventType::MOUSEMOTION:
+ case EventType::MOUSE_MOTION:
luax_setfield_string(L, "type", "mousemotion");
luax_setfield_number(L, "x", e.motion.x);
luax_setfield_number(L, "y", e.motion.y);
break;
- case EventType::MOUSEBUTTONDOWN:
+ case EventType::MOUSE_BUTTON_DOWN:
luax_setfield_string(L, "type", "mousebuttondown");
luax_setfield_string(L, "button", getButtonName(e.button.button));
luax_setfield_number(L, "x", e.button.x);
luax_setfield_number(L, "y", e.button.y);
break;
- case EventType::MOUSEBUTTONUP:
+ case EventType::MOUSE_BUTTON_UP:
luax_setfield_string(L, "type", "mousebuttonup");
luax_setfield_string(L, "button", getButtonName(e.button.button));
luax_setfield_number(L, "x", e.button.x);
luax_setfield_number(L, "y", e.button.y);
break;
- case EventType::MOUSEWHEEL:
+ case EventType::MOUSE_WHEEL:
luax_setfield_string(L, "type", "wheel");
if(e.wheel.x == -1)
luax_setfield_string(L, "x", "left");
diff --git a/src/lua/graphics/luaopen_graphics.cpp b/src/lua/graphics/luaopen_graphics.cpp
index 2d1ff57..a394cc3 100644
--- a/src/lua/graphics/luaopen_graphics.cpp
+++ b/src/lua/graphics/luaopen_graphics.cpp
@@ -27,12 +27,14 @@ namespace lua
*/
static int l_init(lua_State* L)
{
- WindowSystem* wnd = WindowSystem::get();
- WindowSystem::Setting setting;
+ Window* wnd = Window::get();
+ Window::Setting setting;
setting.width = luax_getfield_integer(L, 1, "width");
setting.height = luax_getfield_integer(L, 1, "height");
setting.title = luax_getfield_string(L, 1, "title");
setting.vsync = luax_getfield_bool(L, 1, "vsync");
+ setting.fullscreen = luax_getfield_bool(L, 1, "fullscreen");
+ setting.resizable= luax_getfield_bool(L, 1, "resizable");
if (!wnd->init(&setting))
{
luax_pushboolean(L, false);
@@ -44,7 +46,7 @@ namespace lua
static int l_destroy(lua_State* L)
{
- WindowSystem* wnd = WindowSystem::get();
+ Window* wnd = Window::get();
wnd->quit();
return 0;
}
@@ -54,7 +56,7 @@ namespace lua
*/
static int l_getSize(lua_State* L)
{
- WindowSystem* wnd = WindowSystem::get();
+ Window* wnd = Window::get();
luax_pushnumber(L, wnd->getW());
luax_pushnumber(L, wnd->getH());
return 2;
@@ -131,7 +133,7 @@ namespace lua
*/
static int l_present(lua_State* L)
{
- WindowSystem::get()->swapBuffers();
+ Window::get()->swapBuffers();
return 0;
}
diff --git a/src/lua/time/luaopen_time.cpp b/src/lua/time/luaopen_time.cpp
index 370d868..4ef5372 100644
--- a/src/lua/time/luaopen_time.cpp
+++ b/src/lua/time/luaopen_time.cpp
@@ -1,20 +1,24 @@
#include "lua/luax.h"
#include <SDL2/SDL.h>
+#include "libjin/jin.h"
+
namespace jin
{
namespace lua
{
+ using namespace jin::time;
+
static int l_sec(lua_State* L)
{
- luax_pushnumber(L, SDL_GetTicks()/1000.f);
+ luax_pushnumber(L, getSecond());
return 1;
}
static int l_sleep(lua_State* L)
{
double sec = luax_checknumber(L, 1);
- SDL_Delay(sec * 1000);
+ sleep(sec * 1000.0f);
return 0;
}