Skip to content

Commit

Permalink
Some more conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 2, 2013
1 parent ea4dbb1 commit 9545988
Show file tree
Hide file tree
Showing 9 changed files with 474 additions and 524 deletions.
73 changes: 73 additions & 0 deletions Cheat Engine/LuaButton.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
unit LuaButton;

{$mode delphi}

interface

uses
Classes, SysUtils, lua, lualib, lauxlib, forms, controls, StdCtrls;

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(Tbutton, button_addMetaData);


end.


10 changes: 9 additions & 1 deletion Cheat Engine/LuaCaller.pas
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ procedure LuaCaller_setMethodProperty(L: PLua_state; c: TObject; prop: string; t
begin
lc:=TLuaCaller.create;
lc.luaroutine:=Lua_ToString(L, luafunctiononstack);
end
else
if lua_isnil(L, luafunctiononstack) then
begin
m.code:=nil;
m.data:=nil;
SetPropValue(c, prop, nil);
//setMethodProp(c, prop, m);
end;

if lc<>nil then
Expand Down Expand Up @@ -115,7 +123,7 @@ procedure LuaCaller_setMethodProperty(L: PLua_state; c: TObject; prop: string; t
else
raise exception.create('This type of method:'+typename+' is not yet supported');

setMethodProperty(c, prop, m);
setMethodProp(c, prop, m);
end;


Expand Down
48 changes: 48 additions & 0 deletions Cheat Engine/LuaGroupbox.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
unit LuaGroupbox;

{$mode delphi}

interface

uses
Classes, SysUtils, lua, lualib, lauxlib, stdctrls;

procedure initializeLuaGroupbox;
procedure groupbox_addMetaData(L: PLua_state; metatable: integer; userdata: integer );

implementation

uses luaclass, luahandler, pluginexports, LuaWinControl;

function createGroupBox(L: Plua_State): integer; cdecl;
var parameters: integer;
f,p: pointer;
begin
result:=0;
if lua_gettop(L)>=1 then
begin
f:=lua_toceuserdata(L, -1);
p:=ce_createGroupBox(f);

lua_pop(L, lua_gettop(L));

luaclass_newClass(L, p);
result:=1;
end;
end;

procedure groupbox_addMetaData(L: PLua_state; metatable: integer; userdata: integer );
begin
wincontrol_addMetaData(L, metatable, userdata);
end;

procedure initializeLuaGroupbox;
begin
lua_register(LuaVM, 'createGroupBox', createGroupBox);
end;

initialization
luaclass_register(TCustomGroupBox, groupbox_addMetaData);

end.

Loading

0 comments on commit 9545988

Please sign in to comment.