Hi again.
I've made a VC7.1 (it's the only thing I have) solution for my LuaGUIScriptModule that should be really easy to get started with.
There is a static-lib project with Lua 5.0.2 and tolua++1.0.4, and a static-lib LuaScriptModule. I never tried a dll version.
in the LuaScriptModule/package dir is the package definition for tolua++. make.bat updates the source file. a precompiled tolua++.exe code generator is there too.
look at the .pkg files to see what there's bindings for. It's pretty complete.
the c++ code I use is like this:
init:
Code: Select all
mLuaScriptModule = new CEGUI::LuaScriptModule( LuaManager::getSingleton().getState() );
mSystem = new CEGUI::System( mRenderer, mLuaScriptModule, (CEGUI::utf8*)"../cegui.cfg" );
exit:
Code: Select all
if ( mSystem ) delete mSystem;
if ( mLuaScriptModule ) delete mLuaScriptModule;
here's my initscript to see how it works:
Code: Select all
-- get CEGUI singletons
local logger = CEGUI.Logger:getSingleton()
logger:logEvent( ">>> Init script says hello" )
local system = CEGUI.System:getSingleton()
local fontman = CEGUI.FontManager:getSingleton()
local schememan = CEGUI.SchemeManager:getSingleton()
local windowman = CEGUI.WindowManager:getSingleton()
-- load schemes
schememan:loadScheme( "TaharezLook.scheme" )
schememan:loadScheme( "WindowsLook.scheme" )
-- set default mouse cursor
system:setDefaultMouseCursor( "WindowsLook", "MouseArrow" )
-- load and set default font
local font = fontman:createFont( "Arial-10.font" )
system:setDefaultFont( font )
-- create default gui sheet - root
local sheet = windowman:createWindow( "DefaultGUISheet", "root" )
system:setGUISheet( sheet )
logger:logEvent( "<<< Init script says goodbye" )
events are handled pretty naturally, one parameter is passed. An EventArgs. You can the cast to the different types of EventArgs with a few utility functions. So an eventhandler would look something like this:
Code: Select all
function event_handler( e )
local we = CEGUI.toWindowEventArgs(e) -- new helper function
local handler = we.window
handler:setText( "scripted" );
--tolua.cast(e, "const CEGUI::WindowEventArgs").window:setText("scripted") --> this would do work too
end
In classes that have public member variables, I've removed the 'd_' prefix from their names.
If this is not enough - ask away...
Edit:
the tolua++ documentation says that it's possible to call constructors by their class name fx.
Code: Select all
window:setSize(CEGUI.Size(0.2,0.5))
but there is currently a bug when using namespaces, so you have to write:
Code: Select all
window:setSize(CEGUI.Size:new_local(0.2,0.5))