forked from cheat-engine/cheat-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LuaButton.pas
executable file
·73 lines (56 loc) · 1.85 KB
/
LuaButton.pas
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
unit LuaButton;
{$mode delphi}
interface
uses
Classes, SysUtils, lua, lualib, lauxlib, forms, controls, StdCtrls, betterControls;
procedure InitializeLuaButton;
procedure button_addMetaData(L: PLua_state; metatable: integer; userdata: integer );
implementation
uses LuaHandler, LuaClass, LuaWinControl;
function createButton(L: Plua_State): integer; cdecl;
var c: TWincontrol;
b: Tbutton;
begin
result:=0;
if lua_gettop(L)=1 then
begin
c:=lua_toceuserdata(L, 1);
b:=TButton.create(c);
b.Parent:=c;
luaclass_newClass(L, b);
result:=1;
end;
end;
function button_getModalResult(L: PLua_State): integer; cdecl;
var
button: Tcustombutton;
begin
button:=luaclass_getClassObject(L);
lua_pushinteger(L, integer(button.ModalResult));
result:=1;
end;
function button_setModalResult(L: PLua_State): integer; cdecl;
var
button: Tcustombutton;
begin
result:=0;
button:=luaclass_getClassObject(L);
if lua_gettop(L)>=1 then
button.ModalResult:=TModalResult(lua_tointeger(L,-1));
end;
procedure button_addMetaData(L: PLua_state; metatable: integer; userdata: integer);
begin
wincontrol_addMetaData(L, metatable, userdata);
luaclass_addClassFunctionToTable(L, metatable, userdata, 'getModalResult', button_getModalResult);
luaclass_addClassFunctionToTable(L, metatable, userdata, 'setModalResult', button_setModalResult);
luaclass_addPropertyToTable(L, metatable, userdata, 'ModalResult', button_getModalResult, button_setModalResult);
end;
procedure InitializeLuaButton;
begin
lua_register(LuaVM, 'createButton', createButton);
lua_register(LuaVM, 'button_getModalResult', button_getModalResult);
lua_register(LuaVM, 'button_setModalResult', button_setModalResult);
end;
initialization
luaclass_register(stdctrls.Tbutton, button_addMetaData);
end.