ScriptingModule

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

User avatar
zola
Quite a regular
Quite a regular
Posts: 48
Joined: Wed Jan 12, 2005 12:06

ScriptingModule

Postby zola » Sun Jul 25, 2004 17:25

Hi CE
I have seen in demo8 that You use Lua for scripting. This language seems to provide the possibility to bind scripting functions directly to guievents (that is, one can have function pointers or something similar).

I'm using AngelScript in my projects, but AngelScript doesn't yet provide function pointers.

Will it be possible to register for guievents without having to bind the scriptfunction?

Something like this would be nice to have

Code: Select all

 guiwindow.subscribeEvent(const String& eventname, const String& scriptfunctionname)


In the ScriptModule we could introduce a member with this signature

Code: Select all

virtual int executeScriptFunction(const String& function_name, const CEGUI::EventArgs& e)   = 0;


What do You think about it?

Regards
Tom

User avatar
zola
Quite a regular
Quite a regular
Posts: 48
Joined: Wed Jan 12, 2005 12:06

ScriptingModule

Postby zola » Sun Jul 25, 2004 17:56

I' m completely new to the boost::Signal stuff.
Am I right if I just would do the following

Code: Select all


// in C/C++
struct EventHandlerProxy
{
  String scriptFun;
  operator()(const CEGUI::EventArgs& e){
   // do my scripting function calls using scriptFun as function name
  }

}

// in ScriptCode
EventHandlerProxy* myProxy=new EventHandlerProxy();
myProxy.scriptFun="handleQuit";
windows->subscribeEvent(theEvent, myProxy);


User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

ScriptingModule

Postby CrazyEddie » Sun Jul 25, 2004 18:03

Your other post came in while I was typing this, so forgive the overlap :)

This is a reasonable request, just some notes on my preliminary thoughts about this...

I'll definately add a method to ScriptModule, I'll probably call it 'executeScriptEventHandler' or something though to make its purpose clear.

Yes, your proxy approach would work okay. Infact the CEGUILua module handles most of the magic of translating what is provided by luabind into what is expected by the core of CEGUI using a system such as that, though nothing needs to be done manually by the client of the system, it's all done magically for you ;). I will probably keep this type of translation in the concrete ScriptModule classes rather than extending Event/EventSet, since I don't want to tie these to higher level classes.

(Overlap) It's no major thing to acheive this - just a mini functor class to store some script specific data (in this case the name of the scripted function) and the application operator to do something useful with it (so call the new executeScriptEventHandler method in ScriptModule).

I would have liked to have had the CEGUILua module released by now, but I have had major issues getting the version of luabind I'm using to work with the older VC++ compilers, so untill the luabind guys fix these problems, the Lua scripting module is in limbo.

I actually briefly looked at AngelScript on Friday and thought it was pretty cool :)

User avatar
zola
Quite a regular
Quite a regular
Posts: 48
Joined: Wed Jan 12, 2005 12:06

ScriptingModule

Postby zola » Sun Jul 25, 2004 19:21

AngelScript is very cool 8) and easy to use too.

Which classes do You suggest making available through scripting?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

ScriptingModule

Postby CrazyEddie » Mon Jul 26, 2004 04:49

It all depends on what you want to be able to do.

I had stated that the Lua support would enable you to do anything in Lua that you can do using the C++ interface, and as such The CEGUILua module exposes the entire system :lol:

For a more minimal approach, the low-level classes (Size, Vector2/Point, Vector3, Rect, ColouRect etc) would be essential, and then WindowManager, Event/EventSet, plus whichever widget types you want to use would probably get you a reasonable amount of access. If you wanted to do custom rendering stuff via script, then add Image/Imageset/ImagesetManager and Font/FontManager. As I said, it depends ;)


Return to “CEGUI Library Development Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests