starting the System with my own ScriptModule

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
granx
Quite a regular
Quite a regular
Posts: 80
Joined: Fri Apr 29, 2005 21:58

starting the System with my own ScriptModule

Postby granx » Tue Jun 28, 2005 00:11

Hello,
I have written a ScriptModule which provides no functionality. It is just enough to compile. I am specifying it when initializing the System singleton along with the renderer. I don't know what effect this has on the System, but it is causing a crash during initialization now. The crash occurs during initialization of the System, however an exception is throw from CEGUIDefaultResourceProvider.cpp. Here is that code:

Code: Select all

void DefaultResourceProvider::loadRawDataContainer(...)
{
  ...
  std::ifstream dataFile(filename.c_str(), std::ios::binary|std::ios::ate);
  if( dataFile.fail())
    {
      throw InvalidRequestException((utf8*) "DefaultResourceProvider::load - " + filename + " does not exist");
    }


I was expecting my new usage of the ScriptModule to not be so intrusive. Is this a poor assumption? If I don't specify the ScriptModule, and the only constructor argument is the renderer, it runs fine. Here is how I initialize the System:

Code: Select all

   new CEGUI::System(new CEGUI::OpenGLRenderer(0), _script);


and here is my ?harmless? ScriptModule:

Code: Select all

   ///\todo improve this.
   class ScriptModule : public CEGUI::ScriptModule
   {
   public:
      ScriptModule(Application* a): _app(a)
      {
      }

      virtual ~ScriptModule()
      {
      }

      virtual void  executeScriptFile(const CEGUI::String& filename, const CEGUI::String& resourceGroup = "")
      {
      }

      virtual int   executeScriptGlobal(const CEGUI::String& function_name)
      {
         return 0;
      }

      virtual bool  executeScriptedEventHandler(const CEGUI::String& handler_name, const CEGUI::EventArgs& e)
      {
         return false;
      }

      virtual void  executeString(const CEGUI::String& str)
      {
      }

   private:
      ScriptModule();      // not implemented by design
      Application* _app;
   };


By the way, once I can get the System intialized without crashing, which of the virtual function(s) should I implement to handle (xml defined) Event tags, given a known 'registry' of application callbacks?

Thanks, -granx

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

Re: starting the System with my own ScriptModule

Postby CrazyEddie » Tue Jun 28, 2005 08:40

Hi,

What's the exception that's getting thrown?

The method that gets called via the internal <Event> mapping system is:

Code: Select all

executeScriptedEventHandler(const CEGUI::String& handler_name, const CEGUI::EventArgs& e)


So, this is the one where you want to put your dispatcher code.

User avatar
granx
Quite a regular
Quite a regular
Posts: 80
Joined: Fri Apr 29, 2005 21:58

Re: starting the System with my own ScriptModule

Postby granx » Tue Jun 28, 2005 16:45

What's the exception that's getting thrown?

The exception is: CEGUI::InvalidRequestException @ 0x0012ccec
:D
... is the one where you want to put your dispatcher code.

Thanks!

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

Re: starting the System with my own ScriptModule

Postby CrazyEddie » Tue Jun 28, 2005 18:51

granx wrote:
What's the exception that's getting thrown?

The exception is: CEGUI::InvalidRequestException @ 0x0012ccec
:D

I realised that I missed that after posting; I was too busy laughing at myself to change it :lol:

The problem is it's trying to load a config file named "cegui.config", this is an XML file which specifies some options. I thought this was optional, though now I see that it's not when using a ScriptModule (yes, I know I wrote the damned thing, but I forgot about this).

Try putting the following in cegui.config and saving it (and also 'CEGUIConfig.xsd' from XMLRefSchema if you're using Xerces) somewhere the resource provider will find it...

Code: Select all

<?xml version="1.0" ?>
<CEGUIConfig
    LogFile="CEGUI.log"
/>


Sorry about forgetting that. Really this should have been made optional, I don't recall if there was a reason it's not :oops:

User avatar
granx
Quite a regular
Quite a regular
Posts: 80
Joined: Fri Apr 29, 2005 21:58

Re: starting the System with my own ScriptModule

Postby granx » Tue Jun 28, 2005 20:40

CE,
Thanks again. That fixed it. Consider this thread closed.
p.s. don't forget to include that option in the next release please :)
-granx

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

Re: starting the System with my own ScriptModule

Postby CrazyEddie » Wed Jun 29, 2005 08:39

I'll need to consider the optional config thing a while. The problem is that I implemented it via a default parameter, so other peoples code may be relying upon this; i.e. they have the same code as you do, except they require the config to be automatically bought in. Having said that, this is non-obvious behaviour, so I may well change it (it will not get done for 0.3.0 as that's almost certainly getting packaged up today).

User avatar
granx
Quite a regular
Quite a regular
Posts: 80
Joined: Fri Apr 29, 2005 21:58

Re: starting the System with my own ScriptModule

Postby granx » Fri Jul 08, 2005 00:12

Why must the ScriptModule be specified during construction of the System? Sorry, I was just curious. From my new experience with the ScriptModule, it seems that its sole purpose is to handle an Event, and thus, until a valid ScriptModule is provided, the System should be behaving as it does when the ScriptModule* member is left invalid. Which implies that you could specify a ScriptModule at any point during the life of an application. Therefore, I beleive a System::setScriptingModule(ScriptModule* s) function should be added to the API. What do you think?

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

Re: starting the System with my own ScriptModule

Postby CrazyEddie » Fri Jul 08, 2005 08:29

It's possible to run start-up and shutdown scripts, specified in the cegui.config file. Because of this, it's required to pass the ScriptModule in at the earliest possible moment to enable the start-up script to be run. This arrangement enables an entire app to be implemented via script, except the initial creation of the Renderer, ScriptModule, and CEGUI::System objects (which is how the old Demo 8 was done).

User avatar
Acrion
Just popping in
Just popping in
Posts: 18
Joined: Tue Jun 28, 2005 18:45
Location: Maine, USA
Contact:

Re: starting the System with my own ScriptModule

Postby Acrion » Fri Jul 08, 2005 17:33

I think I got around that by using a different overloaded constructor and passing NULL as the configuration file when I created System with a scripting module.
[font=Verdana][size=xx-small]"It's not hard to stand out when the general level of competence is so low" -EMH[/size][/font]
namik@flashmail.com


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 15 guests