OS independent Error/MessageBox type function?

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
ErUs
Posts: 165
Joined: Thu Oct 07, 2004 6:13 pm

OS independent Error/MessageBox type function?

Post by ErUs »

i find every large project i create i end up having to make a fatalError() type function usualy using win32's MessageBox() to display he error info.

maybe there should be an irrlicht function to display a messagebox on any OS (if it is possible) ?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Code: Select all

  Environment->addMessageBox(L"Fatal Error", messageText);
Something like that? I realize that this won't work until after the IrrlichtDevice has been initialized, but I would expect that to happen very early in your process startup. Of course it would require your app to render the GUI environment, and for it to remain stable after the error occured...

Code: Select all

class MyEventReceiver : public IEventReceiver
{
public:
   MyEventReceiver(IGUIEnvironment* environ)
      : Environ(0)
   {
      setEnvironment(environ);
   }

   virtual ~MyEventReceiver()
   {
      setEnvironment(0);
   }

   void setEnvironment(IGUIEnvironment* environ)
   {
      if (Environ)
         Environ->drop();

      Environ = environ;

      if (Environ)
         Environ->grab();
   }

   virtual bool OnEvent(SEvent event)
   {
      switch(event.EventType)
      {
         case EET_LOG_TEXT_EVENT:
            if (event.LogEvent.Level == ELL_ERROR && Environ)
            {
               core::stringw widen(event.LogEvent.Text);
               Environ->addMessageBox(L"Fatal Error", widen.c_str());

               return true;
            }
            break;
         //case ;
      }

      return false;
   }

private:
   IGUIEnvironment* Environ;
};
Post Reply