LuaBox
Loading...
Searching...
No Matches
Gif.h
Go to the documentation of this file.
1#pragma once
2
3#include "lua_include.h"
4#include "global.h"
5#include "../gif.h"
6
16
17int GifCreate(lua_State* L)
18{
19 const char* path = luaL_checkstring(L, 1);
20 int x = luaL_checkinteger(L, 2);
21 int y = luaL_checkinteger(L, 3);
22
23 Gif** udata = (Gif**)lua_newuserdata(L, sizeof(Gif*));
24 *udata = new Gif(path, x, y);
25
26 luaL_getmetatable(L, "LuaGif");
27 lua_setmetatable(L, -2);
28
29 return 1;
30}
31
39
40int GifPlayAsync(lua_State* L)
41{
42 Gif* gif = *(Gif**)luaL_checkudata(L, 1, "LuaGif");
43 gif->PlayAsync();
44 return 0;
45}
46
54
55int GifStop(lua_State* L)
56{
57 Gif* gif = *(Gif**)luaL_checkudata(L, 1, "LuaGif");
58 gif->Stop();
59 return 0;
60}
61
62void RegisterGifLua(lua_State* L)
63{
64 if (luaL_newmetatable(L, "LuaGif"))
65 {
66 lua_pushvalue(L, -1);
67 lua_setfield(L, -2, "__index");
68
69 lua_pushcfunction(L, GifPlayAsync);
70 lua_setfield(L, -2, "PlayAsync");
71
72 lua_pushcfunction(L, GifStop);
73 lua_setfield(L, -2, "Stop");
74 }
75 lua_pop(L, 1);
76
77 lua_register(L, "GifCreate", GifCreate);
78}
int GifPlayAsync(lua_State *L)
Play the GIF asynchronously.
Definition Gif.h:40
int GifStop(lua_State *L)
Stop the GIF playback.
Definition Gif.h:55
int GifCreate(lua_State *L)
Create a new GIF object.
Definition Gif.h:17
void RegisterGifLua(lua_State *L)
Definition Gif.h:62