[Orxonox-commit 731] r3261 - in branches/core4/src/orxonox: . gui

rgrieder at orxonox.net rgrieder at orxonox.net
Tue Jun 30 17:32:18 CEST 2009


Author: rgrieder
Date: 2009-06-30 17:32:17 +0200 (Tue, 30 Jun 2009)
New Revision: 3261

Modified:
   branches/core4/src/orxonox/OrxonoxPrereqs.h
   branches/core4/src/orxonox/gui/GUIManager.cc
   branches/core4/src/orxonox/gui/GUIManager.h
Log:
#295: Capturing CEGUI output and rerouting it to COUT with reasonable level translations.

Modified: branches/core4/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/core4/src/orxonox/OrxonoxPrereqs.h	2009-06-30 14:53:06 UTC (rev 3260)
+++ branches/core4/src/orxonox/OrxonoxPrereqs.h	2009-06-30 15:32:17 UTC (rev 3261)
@@ -294,6 +294,7 @@
 namespace CEGUI
 {
     class DefaultLogger;
+    class Logger;
     class LuaScriptModule;
 
     class OgreCEGUIRenderer;

Modified: branches/core4/src/orxonox/gui/GUIManager.cc
===================================================================
--- branches/core4/src/orxonox/gui/GUIManager.cc	2009-06-30 14:53:06 UTC (rev 3260)
+++ branches/core4/src/orxonox/gui/GUIManager.cc	2009-06-30 15:32:17 UTC (rev 3261)
@@ -52,7 +52,9 @@
 #   include <CEGUILua.h>
 #endif
 
+#include "util/Debug.h"
 #include "util/Exception.h"
+#include "util/OrxAssert.h"
 #include "core/Core.h"
 #include "core/Clock.h"
 #include "ToluaBindCore.h"
@@ -61,6 +63,28 @@
 
 namespace orxonox
 {
+    class CEGUILogger : public CEGUI::DefaultLogger
+    {
+    public:
+	    void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)
+        {
+            int orxonoxLevel;
+            switch (level)
+            {
+                case CEGUI::Errors:      orxonoxLevel = 1; break;
+                case CEGUI::Warnings:    orxonoxLevel = 2; break;
+                case CEGUI::Standard:    orxonoxLevel = 4; break;
+                case CEGUI::Informative: orxonoxLevel = 5; break;
+                case CEGUI::Insane:      orxonoxLevel = 6; break;
+                default: OrxAssert(false, "CEGUI log level out of range, inpect immediately!");
+            }
+            OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
+                << "CEGUI: " << message << std::endl;
+
+            CEGUI::DefaultLogger::logEvent(message, level);
+        }
+    };
+
     static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
     GUIManager* GUIManager::singletonRef_s = 0;
 
@@ -139,7 +163,7 @@
                 this->luaState_ = this->scriptModule_->getLuaState();
 
                 // Create our own logger to specify the filepath
-                this->ceguiLogger_ = new DefaultLogger();
+                this->ceguiLogger_ = new CEGUILogger();
                 this->ceguiLogger_->setLogFilename(Core::getLogPathString() + "cegui.log");
                 // set the log level according to ours (translate by subtracting 1)
                 this->ceguiLogger_->setLoggingLevel(

Modified: branches/core4/src/orxonox/gui/GUIManager.h
===================================================================
--- branches/core4/src/orxonox/gui/GUIManager.h	2009-06-30 14:53:06 UTC (rev 3260)
+++ branches/core4/src/orxonox/gui/GUIManager.h	2009-06-30 15:32:17 UTC (rev 3261)
@@ -122,7 +122,7 @@
         CEGUI::OgreCEGUIRenderer*   guiRenderer_;       //!< CEGUI's interface to the Ogre Engine
         CEGUI::ResourceProvider*    resourceProvider_;  //!< CEGUI's resource provider
         CEGUI::LuaScriptModule*     scriptModule_;      //!< CEGUI's script module to use Lua
-        CEGUI::DefaultLogger*       ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
+        CEGUI::Logger*              ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
         CEGUI::System*              guiSystem_;         //!< CEGUI's main system
         lua_State*                  luaState_;          //!< Lua state, access point to the Lua engine
 




More information about the Orxonox-commit mailing list