Index: code/trunk/src/libraries/core/CorePrereqs.h
===================================================================
--- code/trunk/src/libraries/core/CorePrereqs.h	(revision 9672)
+++ code/trunk/src/libraries/core/CorePrereqs.h	(revision 9675)
@@ -38,5 +38,4 @@
 #include "OrxonoxConfig.h"
 #include <boost/version.hpp>
-#include <CEGUIVersion.h>
 
 //-----------------------------------------------------------------------
Index: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc	(revision 9672)
+++ code/trunk/src/libraries/core/GUIManager.cc	(revision 9675)
@@ -36,33 +36,55 @@
 #include <OgreRenderWindow.h>
 
-#include <CEGUIDefaultLogger.h>
-#include <CEGUIExceptions.h>
-#include <CEGUIFontManager.h>
-#include <CEGUIInputEvent.h>
-#include <CEGUIMouseCursor.h>
-#include <CEGUIResourceProvider.h>
-#include <CEGUISystem.h>
-#include <CEGUIWindow.h>
-#include <CEGUIWindowManager.h>
-#include <CEGUIXMLAttributes.h>
-#include <elements/CEGUIListbox.h>
-#include <elements/CEGUIListboxItem.h>
+#if CEGUI_VERSION >= 0x000800
+#   include <CEGUI/DefaultLogger.h>
+#   include <CEGUI/Exceptions.h>
+#   include <CEGUI/FontManager.h>
+#   include <CEGUI/InputEvent.h>
+#   include <CEGUI/MouseCursor.h>
+#   include <CEGUI/ResourceProvider.h>
+#   include <CEGUI/System.h>
+#   include <CEGUI/Window.h>
+#   include <CEGUI/WindowManager.h>
+#   include <CEGUI/XMLAttributes.h>
+#   include <CEGUI/widgets/Listbox.h>
+#   include <CEGUI/widgets/ListboxItem.h>
+#else
+#   include <CEGUIDefaultLogger.h>
+#   include <CEGUIExceptions.h>
+#   include <CEGUIFontManager.h>
+#   include <CEGUIInputEvent.h>
+#   include <CEGUIMouseCursor.h>
+#   include <CEGUIResourceProvider.h>
+#   include <CEGUISystem.h>
+#   include <CEGUIWindow.h>
+#   include <CEGUIWindowManager.h>
+#   include <CEGUIXMLAttributes.h>
+#   include <elements/CEGUIListbox.h>
+#   include <elements/CEGUIListboxItem.h>
+#endif
 
 #ifdef ORXONOX_OLD_CEGUI
-#  include <CEGUILua.h>
-#  include <ogreceguirenderer/OgreCEGUIRenderer.h>
+#   include <CEGUILua.h>
+#   include <ogreceguirenderer/OgreCEGUIRenderer.h>
 extern "C" {
-#  include <lauxlib.h>
+#   include <lauxlib.h>
 }
 #else
-#  include <ScriptingModules/LuaScriptModule/CEGUILua.h>
-#  include <RendererModules/Ogre/CEGUIOgreImageCodec.h>
-#  include <RendererModules/Ogre/CEGUIOgreRenderer.h>
-#  include <RendererModules/Ogre/CEGUIOgreResourceProvider.h>
-#  include <OgreCamera.h>
-#  include <OgreRenderQueueListener.h>
-#  include <OgreRenderSystem.h>
-#  include <OgreRoot.h>
-#  include <OgreSceneManager.h>
+#   if CEGUI_VERSION >= 0x000800
+#       include <CEGUI/ScriptModules/Lua/ScriptModule.h>
+#       include <CEGUI/RendererModules/Ogre/ImageCodec.h>
+#       include <CEGUI/RendererModules/Ogre/Renderer.h>
+#       include <CEGUI/RendererModules/Ogre/ResourceProvider.h>
+#   else
+#       include <ScriptingModules/LuaScriptModule/CEGUILua.h>
+#       include <RendererModules/Ogre/CEGUIOgreImageCodec.h>
+#       include <RendererModules/Ogre/CEGUIOgreRenderer.h>
+#       include <RendererModules/Ogre/CEGUIOgreResourceProvider.h>
+#   endif
+#   include <OgreCamera.h>
+#   include <OgreRenderQueueListener.h>
+#   include <OgreRenderSystem.h>
+#   include <OgreRoot.h>
+#   include <OgreSceneManager.h>
 #endif
 
@@ -208,5 +230,9 @@
             if (id == Ogre::RENDER_QUEUE_OVERLAY && invocation.empty())
             {
+#if CEGUI_VERSION >= 0x000800
+                CEGUI::System::getSingleton().renderAllGUIContexts();
+#else
                 CEGUI::System::getSingleton().renderGUI();
+#endif
 
                 // Important workaround! (at least required by CEGUI 0.7.5)
@@ -332,5 +358,9 @@
 
         // Align CEGUI mouse with OIS mouse
+#if CEGUI_VERSION >= 0x000800
+        guiSystem_->getDefaultGUIContext().injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
+#else
         guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
+#endif
 
         // Initialise the Lua framework and load the schemes
@@ -344,7 +374,13 @@
         this->menuRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MenuRootWindow");
         // And connect them
+#if CEGUI_VERSION >= 0x000800
+        CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(this->rootWindow_);
+        this->rootWindow_->addChild(this->hudRootWindow_);
+        this->rootWindow_->addChild(this->menuRootWindow_);
+#else
         CEGUI::System::getSingleton().setGUISheet(this->rootWindow_);
         this->rootWindow_->addChildWindow(this->hudRootWindow_);
         this->rootWindow_->addChildWindow(this->menuRootWindow_);
+#endif
 
         // No background to start with (sets the alpha value to 0)
@@ -413,5 +449,5 @@
     {
         assert(guiSystem_);
-        this->protectedCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));
     }
 
@@ -588,11 +624,20 @@
     void GUIManager::buttonPressed(const KeyEvent& evt)
     {
-        this->protectedCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
-        this->protectedCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText()));
+#if CEGUI_VERSION >= 0x000800
+        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyDown, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
+        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectChar, _1, evt.getText()));
+#else
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText()));
+#endif
     }
 
     void GUIManager::buttonReleased(const KeyEvent& evt)
     {
-        this->protectedCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
+#if CEGUI_VERSION >= 0x000800
+        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyUp, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
+#else
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
+#endif
     }
 
@@ -608,5 +653,9 @@
     void GUIManager::buttonPressed(MouseButtonCode::ByEnum id)
     {
-        this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id)));
+#if CEGUI_VERSION >= 0x000800
+        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonDown, _1, convertButton(id)));
+#else
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id)));
+#endif
     }
 
@@ -622,15 +671,27 @@
     void GUIManager::buttonReleased(MouseButtonCode::ByEnum id)
     {
-        this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id)));
+#if CEGUI_VERSION >= 0x000800
+        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonUp, _1, convertButton(id)));
+#else
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id)));
+#endif
     }
 
     void GUIManager::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
     {
-        this->protectedCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y));
+#if CEGUI_VERSION >= 0x000800
+        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMousePosition, _1, (float)abs.x, (float)abs.y));
+#else
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y));
+#endif
     }
 
     void GUIManager::mouseScrolled(int abs, int rel)
     {
-        this->protectedCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
+#if CEGUI_VERSION >= 0x000800
+        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
+#else
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
+#endif
     }
 
@@ -640,5 +701,9 @@
     void GUIManager::mouseLeft()
     {
-        this->protectedCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1));
+#if CEGUI_VERSION >= 0x000800
+        this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseLeaves, _1));
+#else
+        this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1));
+#endif
     }
 
@@ -692,10 +757,10 @@
         True if input was handled, false otherwise. A caught exception yields true.
     */
-    template <typename FunctionType>
-    bool GUIManager::protectedCall(FunctionType function)
+    template <typename FunctionType, typename ObjectType>
+    bool GUIManager::protectedCall(FunctionType function, ObjectType object)
     {
         try
         {
-            return function(this->guiSystem_);
+            return function(object);
         }
         catch (CEGUI::ScriptException& ex)
@@ -706,4 +771,18 @@
         }
     }
+
+    template <typename FunctionType>
+    bool GUIManager::protectedCeguiSystemCall(FunctionType function)
+    {
+        return this->protectedCall(function, this->guiSystem_);
+    }
+
+#if CEGUI_VERSION >= 0x000800
+    template <typename FunctionType>
+    bool GUIManager::protectedCeguiContextCall(FunctionType function)
+    {
+        return this->protectedCall(function, this->guiSystem_->getDefaultGUIContext());
+    }
+#endif
 
     /**
@@ -762,5 +841,9 @@
     void GUIManager::windowResized(unsigned int newWidth, unsigned int newHeight)
     {
+#if CEGUI_VERSION >= 0x000800
+        this->guiRenderer_->setDisplaySize(CEGUI::Sizef((float)newWidth, (float)newHeight));
+#else
         this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight));
+#endif
     }
 
@@ -812,5 +895,9 @@
             return;
 
+    #if CEGUI_VERSION >= 0x000800
+        CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", CEGUI::ASM_Both, CEGUI::Sizef(800.0f, 600.0f));
+    #else
         CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", true, 800.0f, 600.0f);
+    #endif
 #endif
     }
Index: code/trunk/src/libraries/core/GUIManager.h
===================================================================
--- code/trunk/src/libraries/core/GUIManager.h	(revision 9672)
+++ code/trunk/src/libraries/core/GUIManager.h	(revision 9675)
@@ -40,6 +40,13 @@
 #include <map>
 #include <string>
-#include <CEGUIForwardRefs.h>
-#include <CEGUIVersion.h>
+
+#if CEGUI_VERSION >= 0x000800
+#   include <CEGUI/ForwardRefs.h>
+#   include <CEGUI/Version.h>
+#else
+#   include <CEGUIForwardRefs.h>
+#   include <CEGUIVersion.h>
+#endif
+
 #include <boost/shared_ptr.hpp>
 
@@ -149,6 +156,14 @@
         void executeCode(const std::string& str);
 
+        template <typename FunctionType, typename ObjectType>
+        bool protectedCall(FunctionType function, ObjectType object);
+
         template <typename FunctionType>
-        bool protectedCall(FunctionType function);
+        bool protectedCeguiSystemCall(FunctionType function);
+
+#if CEGUI_VERSION >= 0x000800
+        template <typename FunctionType>
+        bool protectedCeguiContextCall(FunctionType function);
+#endif
 
         void changedCeguiOutputLevel();
Index: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc	(revision 9672)
+++ code/trunk/src/libraries/core/GraphicsManager.cc	(revision 9675)
@@ -402,7 +402,15 @@
         The name of this log (so you can have several listeners
         for different logs, and identify them)
+    @param skipThisMessage
+        If set to true by the messageLogged() implementation message will not be logged
     */
+#if OGRE_VERSION >= 0x010800
+    void GraphicsManager::messageLogged(const std::string& message,
+        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName, bool& skipThisMessage)
+        // TODO: do we have to ignore the message if skipThisMessage is set?
+#else
     void GraphicsManager::messageLogged(const std::string& message,
         Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
+#endif
     {
         OutputLevel orxonoxLevel;
Index: code/trunk/src/libraries/core/GraphicsManager.h
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.h	(revision 9672)
+++ code/trunk/src/libraries/core/GraphicsManager.h	(revision 9675)
@@ -108,6 +108,9 @@
 
         // event from Ogre::LogListener
-        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
-        bool maskDebug, const std::string& logName);
+#if OGRE_VERSION >= 0x010800
+        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName, bool& skipThisMessage);
+#else
+        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName);
+#endif
 
         // console commands
Index: code/trunk/src/libraries/core/Resource.cc
===================================================================
--- code/trunk/src/libraries/core/Resource.cc	(revision 9672)
+++ code/trunk/src/libraries/core/Resource.cc	(revision 9675)
@@ -101,5 +101,9 @@
                 ptr->group = group;
                 ptr->size = it->uncompressedSize;
+#if OGRE_VERSION >= 0x010800
+                if (dynamic_cast<const Ogre::FileSystemArchive*>(it->archive) != NULL)
+#else
                 if (dynamic_cast<Ogre::FileSystemArchive*>(it->archive) != NULL)
+#endif
                 {
                     boost::filesystem::path base(it->archive->getName());
Index: code/trunk/src/libraries/util/Exception.cc
===================================================================
--- code/trunk/src/libraries/util/Exception.cc	(revision 9672)
+++ code/trunk/src/libraries/util/Exception.cc	(revision 9675)
@@ -36,5 +36,11 @@
 
 #include <cstddef>
-#include <CEGUIExceptions.h>
+
+#if CEGUI_VERSION >= 0x000800
+#   include <CEGUI/Exceptions.h>
+#else
+#   include <CEGUIExceptions.h>
+#endif
+
 #include "Output.h"
 
