1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include <irrlicht.h>
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
// {{startx, starty},{endx,endy}}
lua_torecti(lua_State* L, int number, int* sx, int* sy, int* ex, int* ey){
lua_pushnumber(L,1);// ...,{},...,1
lua_gettable(L,number);// ...,{{sx,sy},{ex,ey}},...,{sx,sy}
lua_pushnumber(L,1);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},1
lua_gettable(L,-2);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},sx
*sx = lua_tonumber(L,-1);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},sx
lua_pop(1);// ...,{{sx,sy},{ex,ey}},...,{sx,sy}
lua_pushnumber(L,2);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},2
lua_gettable(L,-2);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},sy
*sy = lua_tonumber(L,-1);
lua_pop(2);// ...,{{sx,sy},{ex,ey}},...
lua_pushnumber(L,2);// ...,{{sx,sy},{ex,ey}},...,2
lua_gettable(L,number);// ...,{{sx,sy},{ex,ey}},...,{ex,ey}
lua_pushnumber(L,1);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},1
lua_gettable(L,-2);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},ex
*ex = lua_tonumber(L,-1);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},ex
lua_pop(L,1);// ...,{{sx,sy},{ex,ey}},...,{ex,ey}
lua_pushnumber(L,2);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},2
lua_gettable(L,-2);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},ey
*ey = lua_tonumber(L,-1);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},ey
lua_pop(L,2);// ...,{{sx,sy},{ex,ey}},...
}
int addIGUIButton(lua_State* L){
IGUIEnvironment env = lua_touserdata(L,1);
IGUIElement parent = lua_touserdata(L,2);
s32 id = lua_tonumber(L,3);
s32 sx,sy,ex,ey;
lua_torecti(L,4,&sx,&sy,&ex,&ey);
core::rect<s32> rect = core::rect<s32>(sx,sy,ex,ey);
IGUIElement* button = env->addButton(rect,parent,id,
}
void add_gui(lua_State* L){
}
blah
|