Index: code/trunk/src/libraries/core/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/CMakeLists.txt	(revision 8706)
+++ code/trunk/src/libraries/core/CMakeLists.txt	(revision 8729)
@@ -19,7 +19,9 @@
 
 SET_SOURCE_FILES(CORE_SRC_FILES
+
+#BUILD_UNIT CoreStableBuildUnit.cc
+  ClassTreeMask.cc
   CommandLineParser.cc
   ConfigValueContainer.cc
-  Core.cc
   DynLib.cc
   DynLibManager.cc
@@ -28,43 +30,40 @@
   GameMode.cc
   GameState.cc
-  GraphicsManager.cc
-  GUIManager.cc
+  Identifier.cc
   Language.cc
+  Loader.cc
   LuaState.cc
+  MetaObjectList.cc
+  Namespace.cc
+  NamespaceNode.cc
   ObjectListBase.cc
   OrxonoxClass.cc
-  Resource.cc
-
-  # hierarchy
-  Identifier.cc
-  MetaObjectList.cc
-
-  # level
-  BaseObject.cc
-  ClassTreeMask.cc
-  Loader.cc
-  Namespace.cc
-  NamespaceNode.cc
   Template.cc
-  XMLPort.cc
-
-COMPILATION_BEGIN ListenerCompilation.cc
   ViewportEventListener.cc
   WindowEventListener.cc
   XMLNameListener.cc
-COMPILATION_END
+  XMLPort.cc
+#END_BUILD_UNIT
 
-COMPILATION_BEGIN FilesystemCompilation.cc
+  BaseObject.cc
+  Core.cc
+
+BUILD_UNIT OgreBuildUnit.cc
+  GraphicsManager.cc
+  GUIManager.cc
+  Resource.cc
+END_BUILD_UNIT
+
+BUILD_UNIT FilesystemBuildUnit.cc
   command/ArgumentCompletionFunctions.cc
   ConfigFileManager.cc
   PathConfig.cc
-COMPILATION_END
+END_BUILD_UNIT
 
-  # multithreading
-  ThreadPool.cc
-COMPILATION_BEGIN ThreadCompilation.cc
+BUILD_UNIT ThreadBuildUnit.cc
   command/TclThreadManager.cc
   Thread.cc
-COMPILATION_END
+  ThreadPool.cc
+END_BUILD_UNIT
 )
 
Index: code/trunk/src/libraries/core/CommandLineParser.cc
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.cc	(revision 8706)
+++ code/trunk/src/libraries/core/CommandLineParser.cc	(revision 8729)
@@ -41,6 +41,4 @@
 namespace orxonox
 {
-    SetCommandLineOnlyArgument(optionsFile, "start.ini").shortcut("o");
-
     /**
     @brief
@@ -50,8 +48,6 @@
         so that you can have simple command line switches.
     */
-    void CommandLineArgument::parse(const std::string& value, bool bParsingFile)
-    {
-        if (bParsingFile && this->bCommandLineOnly_)
-            ThrowException(Argument, "Command line argument '" + getName() + "' is not allowed in files.");
+    void CommandLineArgument::parse(const std::string& value)
+    {
         if (value_.getType() == MT_Type::Bool)
         {
@@ -116,19 +112,19 @@
     }
 
-    /**
-    @brief
-        Reads the command line parses the values of each argument.
-        It is then stored in the corresponding CommandLineArgument.
+    /** Parses the command line string for arguments and stores these.
     @note
         The reason that you have to provide the string to be parsed as
-        space separted list is because of argc and argv. If you only have
+        space separated list is because of argc and argv. If you only have
         a whole string, simply use getAllStrings() of SubString.
-    @param arguments
-        Vector of space separated strings.
-    @param bParsingFile
-        Parsing a file or the command line itself
-    */
-    void CommandLineParser::_parse(const std::vector<std::string>& arguments, bool bParsingFile)
-    {
+    @param cmdLine
+        Command line string WITHOUT the execution path.
+    */
+    void CommandLineParser::_parse(const std::string& cmdLine)
+    {
+        std::vector<std::string> arguments;
+        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
+        for (unsigned i = 0; i < tokens.size(); ++i)
+            arguments.push_back(tokens[i]);
+
         try
         {
@@ -177,5 +173,5 @@
                             if (!name.empty())
                             {
-                                checkFullArgument(name, value, bParsingFile);
+                                checkFullArgument(name, value);
                                 name.clear();
                                 assert(shortcut.empty());
@@ -183,5 +179,5 @@
                             else if (!shortcut.empty())
                             {
-                                checkShortcut(shortcut, value, bParsingFile);
+                                checkShortcut(shortcut, value);
                                 shortcut.clear();
                                 assert(name.empty());
@@ -222,10 +218,10 @@
             if (!name.empty())
             {
-                checkFullArgument(name, value, bParsingFile);
+                checkFullArgument(name, value);
                 assert(shortcut.empty());
             }
             else if (!shortcut.empty())
             {
-                checkShortcut(shortcut, value, bParsingFile);
+                checkShortcut(shortcut, value);
                 assert(name.empty());
             }
@@ -233,5 +229,5 @@
         catch (const ArgumentException& ex)
         {
-            COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl;
+            COUT(0) << "Could not parse command line: " << ex.what() << std::endl;
             COUT(0) << CommandLineParser::getUsageInformation() << std::endl;
             throw GeneralException("");
@@ -249,5 +245,5 @@
         Parsing a file or the command line itself
     */
-    void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile)
+    void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value)
     {
         std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
@@ -255,5 +251,5 @@
             ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
 
-        it->second->parse(value, bParsingFile);
+        it->second->parse(value);
     }
 
@@ -268,5 +264,5 @@
         Parsing a file or the command line itself
     */
-    void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile)
+    void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value)
     {
         std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
@@ -274,5 +270,5 @@
             ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
 
-        it->second->parse(value, bParsingFile);
+        it->second->parse(value);
     }
 
@@ -342,51 +338,3 @@
         }
     }
-
-    /**
-    @brief
-        Parses only the command line for CommandLineArguments.
-    */
-    void CommandLineParser::_parseCommandLine(const std::string& cmdLine)
-    {
-        std::vector<std::string> args;
-        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
-        for (unsigned i = 0; i < tokens.size(); ++i)
-            args.push_back(tokens[i]);
-        this->_parse(args, false);
-    }
-
-    /**
-    @brief
-        Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.
-    */
-    void CommandLineParser::_parseFile()
-    {
-        const std::string& filename = CommandLineParser::getValue("optionsFile").getString();
-
-        // look for additional arguments in given file or start.ini as default
-        // They will not overwrite the arguments given directly
-        std::ifstream file;
-        file.open((PathConfig::getConfigPathString() + filename).c_str());
-        std::vector<std::string> args;
-        if (file)
-        {
-            while (!file.eof())
-            {
-                std::string line;
-                std::getline(file, line);
-                line = removeTrailingWhitespaces(line);
-                //if (!(line[0] == '#' || line[0] == '%'))
-                //{
-                SubString tokens(line, " ", " ", false, '\\', true, '"', true, '\0', '\0', false, '#');
-                for (unsigned i = 0; i < tokens.size(); ++i)
-                    if (tokens[i][0] != '#')
-                        args.push_back(tokens[i]);
-                //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());
-                //}
-            }
-            file.close();
-        }
-
-        _parse(args, true);
-    }
 }
Index: code/trunk/src/libraries/core/CommandLineParser.h
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.h	(revision 8706)
+++ code/trunk/src/libraries/core/CommandLineParser.h	(revision 8729)
@@ -51,15 +51,8 @@
 #define SetCommandLineArgument(name, defaultValue) \
     orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLineParser::addArgument(#name, defaultValue, false)
-#define SetCommandLineOnlyArgument(name, defaultValue) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLineParser::addArgument(#name, defaultValue, true)
+    = orxonox::CommandLineParser::addArgument(#name, defaultValue)
 #define SetCommandLineSwitch(name) \
     orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLineParser::addArgument(#name, false, false)
-#define SetCommandLineOnlySwitch(name) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLineParser::addArgument(#name, false, true)
-
+    = orxonox::CommandLineParser::addArgument(#name, false)
 
 namespace orxonox
@@ -106,16 +99,15 @@
 
         //! Returns the actual value of the argument. Can be equal to default value.
-        MultiType getValue() const { return value_; }
+        const MultiType& getValue() const { return value_; }
         //! Returns the given default value as type T.
-        MultiType getDefaultValue() const { return defaultValue_; }
+        const MultiType& getDefaultValue() const { return defaultValue_; }
 
     private:
         //! Constructor initialises both value_ and defaultValue_ with defaultValue.
-        CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)
+        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
             : bHasDefaultValue_(true)
             , name_(name)
             , value_(defaultValue)
             , defaultValue_(defaultValue)
-            , bCommandLineOnly_(bCommandLineOnly)
         { }
 
@@ -125,5 +117,5 @@
 
         //! Parses the value string of a command line argument.
-        void parse(const std::string& value, bool bParsingFile);
+        void parse(const std::string& value);
 
         //! Tells whether the value has been changed by the command line.
@@ -137,5 +129,4 @@
         MultiType   value_;            //!< The actual value
         MultiType   defaultValue_;     //!< Default value. Should not be changed.
-        bool        bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
     };
 
@@ -155,6 +146,6 @@
 
         //! Parse redirection to internal member method.
-        static void parseCommandLine(const std::string& cmdLine) { _getInstance()._parseCommandLine(cmdLine); }
-        static void parseFile() { _getInstance()._parseFile(); }
+        static void parse(const std::string& cmdLine)
+        { _getInstance()._parse(cmdLine); }
 
         static std::string getUsageInformation();
@@ -165,8 +156,8 @@
         static void getValue(const std::string& name, T* value)
         { *value = (T)(getArgument(name)->getValue()); }
-        static MultiType getValue(const std::string& name)
+        static const MultiType& getValue(const std::string& name)
         { return getArgument(name)->getValue(); }
         template <class T>
-        static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly);
+        static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
 
         static bool existsArgument(const std::string& name)
@@ -189,9 +180,7 @@
         static CommandLineParser& _getInstance();
 
-        void _parseCommandLine(const std::string& cmdLine);
-        void _parseFile();
-        void _parse(const std::vector<std::string>& arguments, bool bParsingFile);
-        void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile);
-        void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile);
+        void _parse(const std::string& cmdLine);
+        void checkFullArgument(const std::string& name, const std::string& value);
+        void checkShortcut(const std::string& shortcut, const std::string& value);
 
         /**
@@ -222,9 +211,7 @@
     @param defaultValue
         Default value that is used when argument was not given.
-    @param bCommandLineOnly
-        Parsing a file or the command line itself
     */
     template <class T>
-    CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)
+    CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue)
     {
         OrxAssert(!_getInstance().existsArgument(name),
@@ -234,5 +221,5 @@
             << "Please use SetCommandLineSwitch and adjust your argument: " << name);
 
-        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly));
+        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
     }
 }
Index: code/trunk/src/libraries/core/ConfigValueIncludes.h
===================================================================
--- code/trunk/src/libraries/core/ConfigValueIncludes.h	(revision 8706)
+++ code/trunk/src/libraries/core/ConfigValueIncludes.h	(revision 8729)
@@ -255,3 +255,18 @@
     ModifyConfigValueGeneric(this, &varname, #varname, modifier, __VA_ARGS__)
 
+/** Modifies a runtime configurable value by using a modifier and some arguments.
+    If the container for the value doesn't yet exist, a warning is displayed.
+    Also, the @a variable argument will be modified and set to the current value.
+@param variable
+    Pointer to the variable where the value should be written to
+@param entryName
+    Name of the entry in the ini file (e.g. [MySection] myValue)
+@param modifier
+    On of these functions: set, tset, add, remove, reset, update
+@param ...
+    Arguments for the modifier function
+*/
+#define ModifyConfigValueExternal(variable, entryName, modifier, ...) \
+    ModifyConfigValueGeneric(this, &variable, entryName, modifier, __VA_ARGS__)
+
 #endif /* _ConfigValueIncludes_H__ */
Index: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc	(revision 8706)
+++ code/trunk/src/libraries/core/Core.cc	(revision 8729)
@@ -69,4 +69,5 @@
 #include "Language.h"
 #include "LuaState.h"
+#include "ObjectList.h"
 #include "command/ConsoleCommand.h"
 #include "command/IOConsole.h"
@@ -131,5 +132,5 @@
 
         // Parse command line arguments AFTER the modules have been loaded (static code!)
-        CommandLineParser::parseCommandLine(cmdLine);
+        CommandLineParser::parse(cmdLine);
 
         // Set configurable paths like log, config and media
@@ -143,7 +144,4 @@
         // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used
         OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());
-
-        // Parse additional options file now that we know its path
-        CommandLineParser::parseFile();
 
 #ifdef ORXONOX_PLATFORM_WINDOWS
@@ -168,4 +166,6 @@
         RegisterRootObject(Core);
         this->setConfigValues();
+        // Rewrite the log file with the correct log levels
+        OutputHandler::getInstance().rewriteLogFile();
 
 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
@@ -230,18 +230,23 @@
     }
 
+    namespace DefaultLevelLogFile
+    {
+        const OutputLevel::Value Dev  = OutputLevel::Debug;
+        const OutputLevel::Value User = OutputLevel::Info;
+    }
+
     //! Function to collect the SetConfigValue-macro calls.
     void Core::setConfigValues()
     {
-#ifdef ORXONOX_RELEASE
-        const unsigned int defaultLevelLogFile = 3;
-#else
-        const unsigned int defaultLevelLogFile = 4;
-#endif
-        SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
-            .description("The maximum level of debug output shown in the log file");
-        OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_);
+        // Choose the default level according to the path Orxonox was started (build directory or not)
+        OutputLevel::Value defaultLogLevel = (PathConfig::buildDirectoryRun() ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
+
+        SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile", defaultLogLevel)
+            .description("The maximum level of debug output written to the log file");
+        OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_);
 
         SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
-            .description("Developer mode. If not set, hides some things from the user to not confuse him.");
+            .description("Developer mode. If not set, hides some things from the user to not confuse him.")
+            .callback(this, &Core::devModeChanged);
         SetConfigValue(language_, Language::getInstance().defaultLanguage_)
             .description("The language of the in game text")
@@ -258,4 +263,37 @@
     }
 
+    /** Callback function for changes in the dev mode that affect debug levels.
+        The function behaves according to these rules:
+        - 'normal' mode is defined based on where the program was launched: if
+          the launch path was the build directory, development mode \c on is
+          normal, otherwise normal means development mode \c off.
+        - Debug levels should not be hard configured (\c config instead of
+          \c tconfig) in non 'normal' mode to avoid strange behaviour.
+        - Changing the development mode from 'normal' to the other state will
+          immediately change the debug levels to predefined values which can be
+          reconfigured with \c tconfig.
+    @note
+        The debug levels for the IOConsole and the InGameConsole can be found
+        in the Shell class. The same rules apply.
+    */
+    void Core::devModeChanged()
+    {
+        bool isNormal = (bDevMode_ == PathConfig::buildDirectoryRun());
+        if (isNormal)
+        {
+            ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update);
+        }
+        else
+        {
+            OutputLevel::Value level = (bDevMode_ ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
+            ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", tset, level);
+        }
+
+        // Inform listeners
+        ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
+        for (; it != ObjectList<DevModeListener>::end(); ++it)
+            it->devModeChanged(bDevMode_);
+    }
+
     //! Callback function if the language has changed.
     void Core::languageChanged()
@@ -440,3 +478,9 @@
         ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
     }
+
+
+    DevModeListener::DevModeListener()
+    {
+        RegisterRootObject(DevModeListener);
+    }
 }
Index: code/trunk/src/libraries/core/Core.h
===================================================================
--- code/trunk/src/libraries/core/Core.h	(revision 8706)
+++ code/trunk/src/libraries/core/Core.h	(revision 8729)
@@ -45,6 +45,4 @@
 
 #include <string>
-#include <loki/ScopeGuard.h>
-
 #include "util/DestructionHelper.h"
 #include "util/Singleton.h"
@@ -53,4 +51,13 @@
 namespace orxonox
 {
+    //! Informs about changes in the Development Mode.
+    class DevModeListener : virtual public OrxonoxClass
+    {
+    public:
+        DevModeListener();
+        virtual ~DevModeListener() {}
+        virtual void devModeChanged(bool value) = 0;
+    };
+
     /**
     @brief
@@ -101,4 +108,5 @@
             Core(const Core&); //!< Don't use (undefined symbol)
 
+            void devModeChanged();
             void languageChanged();
             void initRandomNumberGenerator();
@@ -128,5 +136,5 @@
 
             bool                      bGraphicsLoaded_;
-            int                       softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
+            int                       debugLevelLogFile_;          //!< The debug level for the log file (belongs to OutputHandler)
             std::string               language_;                   //!< The language
             bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
Index: code/trunk/src/libraries/core/CoreIncludes.h
===================================================================
--- code/trunk/src/libraries/core/CoreIncludes.h	(revision 8706)
+++ code/trunk/src/libraries/core/CoreIncludes.h	(revision 8729)
@@ -80,5 +80,4 @@
 #include "util/Debug.h"
 #include "Identifier.h"
-#include "SubclassIdentifier.h"
 #include "ClassFactory.h"
 #include "ObjectList.h"
Index: code/trunk/src/libraries/core/EventIncludes.h
===================================================================
--- code/trunk/src/libraries/core/EventIncludes.h	(revision 8706)
+++ code/trunk/src/libraries/core/EventIncludes.h	(revision 8729)
@@ -37,4 +37,6 @@
 
 #include "CorePrereqs.h"
+
+#include "Event.h"
 #include "XMLPort.h"
 #include "command/Executor.h"
Index: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc	(revision 8706)
+++ code/trunk/src/libraries/core/GUIManager.cc	(revision 8729)
@@ -490,5 +490,5 @@
     }
 
-    const std::string& GUIManager::createInputState(const std::string& name, TriBool::Value showCursor, TriBool::Value useKeyboard, bool bBlockJoyStick)
+    const std::string& GUIManager::createInputState(const std::string& name, tribool showCursor, tribool useKeyboard, bool bBlockJoyStick)
     {
         InputState* state = InputManager::getInstance().createInputState(name);
@@ -506,22 +506,22 @@
 #ifdef ORXONOX_PLATFORM_APPLE
         // There is no non exclusive mode on OS X yet
-        state->setMouseExclusive(TriBool::True);
-#else
-        if (showCursor == TriBool::Dontcare)
-            state->setMouseExclusive(TriBool::Dontcare);
-        else if (GraphicsManager::getInstance().isFullScreen() || showCursor == TriBool::False)
-            state->setMouseExclusive(TriBool::True);
+        state->setMouseExclusive(true);
+#else
+        if (showCursor == dontcare)
+            state->setMouseExclusive(dontcare);
+        else if (GraphicsManager::getInstance().isFullScreen() || showCursor == false)
+            state->setMouseExclusive(true);
         else
-            state->setMouseExclusive(TriBool::False);
-#endif
-
-        if (showCursor == TriBool::True)
+            state->setMouseExclusive(false);
+#endif
+
+        if (showCursor == true)
             state->setMouseHandler(this);
-        else if (showCursor == TriBool::False)
+        else if (showCursor == false)
             state->setMouseHandler(&InputHandler::EMPTY);
 
-        if (useKeyboard == TriBool::True)
+        if (useKeyboard == true)
             state->setKeyHandler(this);
-        else if (useKeyboard == TriBool::False)
+        else if (useKeyboard == false)
             state->setKeyHandler(&InputHandler::EMPTY);
 
@@ -717,4 +717,12 @@
     }
 
+    /** Helper method to get the developer's mode without having to export Core.h.
+    @see Core::inDevMode
+    */
+    /*static*/ bool GUIManager::inDevMode()
+    {
+         return Core::getInstance().inDevMode();
+    }
+
     /**
         @brief Callback of window event listener, called if the window is resized. Sets the display size of CEGUI.
Index: code/trunk/src/libraries/core/GUIManager.h
===================================================================
--- code/trunk/src/libraries/core/GUIManager.h	(revision 8706)
+++ code/trunk/src/libraries/core/GUIManager.h	(revision 8729)
@@ -39,5 +39,4 @@
 
 #include <map>
-#include <set>
 #include <string>
 #include <CEGUIForwardRefs.h>
@@ -47,15 +46,9 @@
 #include "util/DestructionHelper.h"
 #include "util/OgreForwardRefs.h"
-#include "util/TriBool.h"
+#include "util/tribool.h"
 #include "util/Singleton.h"
 #include "input/InputHandler.h"
-#include "Core.h"
 #include "OrxonoxClass.h"
 #include "WindowEventListener.h"
-
-// Tolua includes (have to be relative to the current directory)
-/*
-$cfile "../util/TriBool.h" // tolua_export
-*/
 
 #if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
@@ -66,4 +59,18 @@
 { // tolua_export
     class PlayerInfo; // Forward declaration
+
+    // Acquaint Tolua with tribool
+    /* tolua_begin
+    struct dontcare_keyword_t
+    {
+        dontcare_keyword_t();
+    };
+    class tribool
+    {
+        tribool(bool value);
+        tribool(dontcare_keyword_t);
+        bool operator==(tribool);
+    };
+    tolua_end */
 
     /**
@@ -104,12 +111,8 @@
         void setBackgroundImage(const std::string& image);
 
-        /**
-        @brief Helper method to get the developer's mode without having to export Core.h.
-        @see Core::inDevMode
-        */
-        static bool inDevMode(void) { return Core::getInstance().inDevMode(); } // tolua_export
+        static bool inDevMode(void); // tolua_export
 
         //! Creates a new InputState to be used with a GUI Sheet
-        const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export
+        const std::string& createInputState(const std::string& name, tribool showCursor = tribool(true), tribool useKeyboard = tribool(true), bool bBlockJoyStick = false); // tolua_export
         LuaState* getLuaState(void)
             { return this->luaState_; }
Index: code/trunk/src/libraries/core/Game.cc
===================================================================
--- code/trunk/src/libraries/core/Game.cc	(revision 8706)
+++ code/trunk/src/libraries/core/Game.cc	(revision 8729)
@@ -109,5 +109,5 @@
 
         // Do this after the Core creation!
-        ClassIdentifier<Game>::getIdentifier("Game")->initialiseObject(this, "Game", true);
+        RegisterRootObject(Game);
         this->setConfigValues();
 
Index: code/trunk/src/libraries/core/LuaState.cc
===================================================================
--- code/trunk/src/libraries/core/LuaState.cc	(revision 8706)
+++ code/trunk/src/libraries/core/LuaState.cc	(revision 8729)
@@ -40,16 +40,9 @@
 #include "util/Exception.h"
 #include "Resource.h"
-#include "ToluaBindCore.h"
 #include "command/IOConsole.h"
 
 namespace orxonox
 {
-    LuaState::ToluaInterfaceMap LuaState::toluaInterfaces_s;
-    std::vector<LuaState*> LuaState::instances_s;
-
     const std::string LuaState::ERROR_HANDLER_NAME = "errorHandler";
-
-    // Do this after declaring toluaInterfaces_s and instances_s to avoid larger problems
-    DeclareToluaInterface(Core);
 
     LuaState::LuaState()
@@ -277,7 +270,19 @@
     }
 
+    /*static*/ LuaState::ToluaInterfaceMap& LuaState::getToluaInterfaces()
+    {
+        static ToluaInterfaceMap p;
+        return p;
+    }
+
+    /*static*/ std::vector<LuaState*>& LuaState::getInstances()
+    {
+        static std::vector<LuaState*> p;
+        return p;
+    }
+
     /*static*/ bool LuaState::addToluaInterface(int (*function)(lua_State*), const std::string& name)
     {
-        for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)
+        for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
         {
             if (it->first == name || it->second == function)
@@ -287,8 +292,8 @@
             }
         }
-        toluaInterfaces_s[name] = function;
+        getToluaInterfaces()[name] = function;
 
         // Open interface in all LuaStates
-        for (std::vector<LuaState*>::const_iterator it = instances_s.begin(); it != instances_s.end(); ++it)
+        for (std::vector<LuaState*>::const_iterator it = getInstances().begin(); it != getInstances().end(); ++it)
             (*function)((*it)->luaState_);
 
@@ -299,6 +304,6 @@
     /*static*/ bool LuaState::removeToluaInterface(const std::string& name)
     {
-        ToluaInterfaceMap::iterator it = toluaInterfaces_s.find(name);
-        if (it == toluaInterfaces_s.end())
+        ToluaInterfaceMap::iterator it = getToluaInterfaces().find(name);
+        if (it == getToluaInterfaces().end())
         {
             COUT(2) << "Warning: Cannot remove Tolua interface '" << name << "': Not found" << std::endl;
@@ -307,5 +312,5 @@
 
         // Close interface in all LuaStates
-        for (std::vector<LuaState*>::const_iterator itState = instances_s.begin(); itState != instances_s.end(); ++itState)
+        for (std::vector<LuaState*>::const_iterator itState = getInstances().begin(); itState != getInstances().end(); ++itState)
         {
             lua_pushnil((*itState)->luaState_);
@@ -314,5 +319,5 @@
 
         // Remove entry
-        toluaInterfaces_s.erase(it);
+        getToluaInterfaces().erase(it);
 
         // Return dummy bool
@@ -322,5 +327,5 @@
     /*static*/ void LuaState::openToluaInterfaces(lua_State* state)
     {
-        for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)
+        for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
             (*it->second)(state);
     }
@@ -328,5 +333,5 @@
     /*static*/ void LuaState::closeToluaInterfaces(lua_State* state)
     {
-        for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)
+        for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
         {
             lua_pushnil(state);
Index: code/trunk/src/libraries/core/LuaState.h
===================================================================
--- code/trunk/src/libraries/core/LuaState.h	(revision 8706)
+++ code/trunk/src/libraries/core/LuaState.h	(revision 8729)
@@ -48,7 +48,4 @@
 #include <vector>
 #include <boost/shared_ptr.hpp>
-#include <loki/ScopeGuard.h>
-
-#include "ToluaInterface.h"
 
 namespace orxonox // tolua_export
@@ -121,7 +118,25 @@
 
         typedef std::map<std::string, int (*)(lua_State *L)> ToluaInterfaceMap;
-        static ToluaInterfaceMap toluaInterfaces_s;
-        static std::vector<LuaState*> instances_s;
+        static ToluaInterfaceMap& getToluaInterfaces();
+        static std::vector<LuaState*>& getInstances();
     }; // tolua_export
+
+
+    //! Helper class that registers/unregisters tolua bindings
+    class ToluaBindingsHelper
+    {
+    public:
+        ToluaBindingsHelper(int (*function)(lua_State*), const std::string& libraryName)
+            : libraryName_(libraryName)
+        {
+            LuaState::addToluaInterface(function, libraryName_);
+        }
+        ~ToluaBindingsHelper()
+        {
+            LuaState::removeToluaInterface(libraryName_);
+        }
+    private:
+        std::string libraryName_;
+    };
 } // tolua_export
 
Index: code/trunk/src/libraries/core/ObjectListBase.h
===================================================================
--- code/trunk/src/libraries/core/ObjectListBase.h	(revision 8706)
+++ code/trunk/src/libraries/core/ObjectListBase.h	(revision 8729)
@@ -41,7 +41,5 @@
 
 #include "CorePrereqs.h"
-
 #include <vector>
-#include "OrxonoxClass.h"
 
 namespace orxonox
Index: code/trunk/src/libraries/core/OrxonoxClass.h
===================================================================
--- code/trunk/src/libraries/core/OrxonoxClass.h	(revision 8706)
+++ code/trunk/src/libraries/core/OrxonoxClass.h	(revision 8729)
@@ -45,8 +45,8 @@
 
 #include "CorePrereqs.h"
-#include "Super.h"
 
 #include <set>
 #include <vector>
+#include "Super.h"
 
 /**
Index: code/trunk/src/libraries/core/PathConfig.cc
===================================================================
--- code/trunk/src/libraries/core/PathConfig.cc	(revision 8706)
+++ code/trunk/src/libraries/core/PathConfig.cc	(revision 8729)
@@ -74,5 +74,5 @@
 
     SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
-    SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
+    SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
 
     PathConfig::PathConfig()
Index: code/trunk/src/libraries/core/Super.h
===================================================================
--- code/trunk/src/libraries/core/Super.h	(revision 8706)
+++ code/trunk/src/libraries/core/Super.h	(revision 8729)
@@ -73,7 +73,5 @@
 
 #include "CorePrereqs.h"
-
 #include "util/Debug.h"
-#include "Event.h"
 
 ///////////////////////
Index: code/trunk/src/libraries/core/ToluaInterface.h
===================================================================
--- code/trunk/src/libraries/core/ToluaInterface.h	(revision 8706)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-@file
-@ingroup Lua
-@brief
-    This is required because tolua would parse this macro in LuaState.h and fail
-*/
-
-#ifndef _ToluaInterface_H__
-#define _ToluaInterface_H__
-
-#include "CorePrereqs.h"
-#include <boost/preprocessor/cat.hpp>
-
-// Macro for declaring a tolua interface of a library/module
-#define DeclareToluaInterface(libraryName) \
-    static bool BOOST_PP_CAT(bDummy##libraryName, __UNIQUE_NUMBER__) = orxonox::LuaState::addToluaInterface(&tolua_##libraryName##_open, #libraryName); \
-    static Loki::ScopeGuardImpl1<bool (*)(const std::string&), std::string> BOOST_PP_CAT(dummy##libraryName, __UNIQUE_NUMBER__)(&orxonox::LuaState::removeToluaInterface, #libraryName)
-
-#endif /* _ToluaInterface_H__ */
Index: code/trunk/src/libraries/core/ToluaInterfaceHook.lua
===================================================================
--- code/trunk/src/libraries/core/ToluaInterfaceHook.lua	(revision 8729)
+++ code/trunk/src/libraries/core/ToluaInterfaceHook.lua	(revision 8729)
@@ -0,0 +1,30 @@
+--
+--             ORXONOX - the hottest 3D action shooter ever to exist
+--                             > www.orxonox.net <
+--
+--        This program is free software; you can redistribute it and/or
+--         modify it under the terms of the GNU General Public License
+--        as published by the Free Software Foundation; either version 2
+--            of the License, or (at your option) any later version.
+--
+--       This program is distributed in the hope that it will be useful,
+--        but WITHOUT ANY WARRANTY; without even the implied warranty of
+--        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+--                 GNU General Public License for more details.
+--
+--   You should have received a copy of the GNU General Public License along
+--      with this program; if not, write to the Free Software Foundation,
+--     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+--
+--
+--  Author:
+--    Reto Grieder
+--
+
+-- Writes the static initialiser that registers the package open() function
+function post_include_hook(package_name)
+    output('\n')
+    output('#include "core/LuaState.h"\n')
+    output('int tolua_'..package_name..'_open(lua_State* tolua_S);\n')
+    output('static orxonox::ToluaBindingsHelper initialiser(&tolua_'..package_name..'_open, "'..package_name..'");')
+end
Index: code/trunk/src/libraries/core/ViewportEventListener.h
===================================================================
--- code/trunk/src/libraries/core/ViewportEventListener.h	(revision 8706)
+++ code/trunk/src/libraries/core/ViewportEventListener.h	(revision 8729)
@@ -30,7 +30,7 @@
 #define _ViewportEventListener_H__
 
+#include "CorePrereqs.h"
+
 #include "util/OgreForwardRefs.h"
-
-#include "CorePrereqs.h"
 #include "OrxonoxClass.h"
 
Index: code/trunk/src/libraries/core/command/Functor.h
===================================================================
--- code/trunk/src/libraries/core/command/Functor.h	(revision 8706)
+++ code/trunk/src/libraries/core/command/Functor.h	(revision 8729)
@@ -114,7 +114,7 @@
 #define _Functor_H__
 
+#include "core/CorePrereqs.h"
+
 #include <typeinfo>
-
-#include "core/CorePrereqs.h"
 
 #include "util/Debug.h"
Index: code/trunk/src/libraries/core/command/IOConsolePOSIX.cc
===================================================================
--- code/trunk/src/libraries/core/command/IOConsolePOSIX.cc	(revision 8706)
+++ code/trunk/src/libraries/core/command/IOConsolePOSIX.cc	(revision 8729)
@@ -236,24 +236,24 @@
     void IOConsole::printOutputLine(const std::string& text, Shell::LineType type)
     {
-/*
         // Colour line
         switch (type)
         {
-        case Shell::None:    this->cout_ << "\033[37m"; break;
         case Shell::Error:   this->cout_ << "\033[91m"; break;
-        case Shell::Warning: this->cout_ << "\033[31m"; break;
-        case Shell::Info:    this->cout_ << "\033[34m"; break;
-        case Shell::Debug:   this->cout_ << "\033[36m"; break;
-        case Shell::Verbose: this->cout_ << "\033[35m"; break;
-        case Shell::Ultra:   this->cout_ << "\033[37m"; break;
+        case Shell::Warning: this->cout_ << "\033[93m"; break;
+        case Shell::Info:    this->cout_ << "\033[90m"; break;
+        case Shell::Debug:   this->cout_ << "\033[90m"; break;
+        case Shell::Verbose: this->cout_ << "\033[90m"; break;
+        case Shell::Ultra:   this->cout_ << "\033[90m"; break;
+        case Shell::Command: this->cout_ << "\033[36m"; break;
+        case Shell::Hint:    this->cout_ << "\033[33m"; break;
+        case Shell::TDebug:  this->cout_ << "\033[95m"; break;
         default: break;
         }
-*/
 
         // Print output line
         this->cout_ << text;
 
-        // Reset colour to white
-//        this->cout_ << "\033[37m";
+        // Reset colour atributes
+        this->cout_ << "\033[0m";
     }
 
Index: code/trunk/src/libraries/core/command/IOConsoleWindows.cc
===================================================================
--- code/trunk/src/libraries/core/command/IOConsoleWindows.cc	(revision 8706)
+++ code/trunk/src/libraries/core/command/IOConsoleWindows.cc	(revision 8729)
@@ -208,4 +208,5 @@
         case Shell::Command: colour =                        FOREGROUND_GREEN                  | FOREGROUND_BLUE; break;
         case Shell::Hint:    colour =                        FOREGROUND_GREEN | FOREGROUND_RED                  ; break;
+        case Shell::TDebug:  colour = FOREGROUND_INTENSITY                    | FOREGROUND_RED | FOREGROUND_BLUE; break;
         default:             colour =                        FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break;
         }
Index: code/trunk/src/libraries/core/command/IOConsoleWindows.h
===================================================================
--- code/trunk/src/libraries/core/command/IOConsoleWindows.h	(revision 8706)
+++ code/trunk/src/libraries/core/command/IOConsoleWindows.h	(revision 8729)
@@ -39,5 +39,4 @@
 #include <sstream>
 #include <string>
-#include <vector>
 #include "util/Singleton.h"
 #include "Shell.h"
Index: code/trunk/src/libraries/core/command/Shell.cc
===================================================================
--- code/trunk/src/libraries/core/command/Shell.cc	(revision 8706)
+++ code/trunk/src/libraries/core/command/Shell.cc	(revision 8729)
@@ -34,4 +34,5 @@
 #include "Shell.h"
 
+#include "util/Math.h"
 #include "util/OutputHandler.h"
 #include "util/StringUtils.h"
@@ -40,4 +41,6 @@
 #include "core/ConfigFileManager.h"
 #include "core/ConfigValueIncludes.h"
+#include "core/PathConfig.h"
+#include "core/input/InputBuffer.h"
 #include "CommandExecutor.h"
 #include "ConsoleCommand.h"
@@ -84,8 +87,8 @@
 
         // Get the previous output and add it to the Shell
-        for (OutputHandler::OutputVectorIterator it = OutputHandler::getInstance().getOutputVectorBegin();
-            it != OutputHandler::getInstance().getOutputVectorEnd(); ++it)
-        {
-            if (it->first <= this->getSoftDebugLevel())
+        OutputHandler::OutputVector::const_iterator it = OutputHandler::getInstance().getOutput().begin();
+        for (;it != OutputHandler::getInstance().getOutput().end(); ++it)
+        {
+            if (it->first <= debugLevel_)
             {
                 this->outputBuffer_ << it->second;
@@ -96,4 +99,5 @@
         // Register the shell as output listener
         OutputHandler::getInstance().registerOutputListener(this);
+        OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
     }
 
@@ -105,4 +109,10 @@
         OutputHandler::getInstance().unregisterOutputListener(this);
         this->inputBuffer_->destroy();
+    }
+
+    namespace DefaultLogLevel
+    {
+        const OutputLevel::Value Dev  = OutputLevel::Info;
+        const OutputLevel::Value User = OutputLevel::Error;
     }
 
@@ -119,12 +129,9 @@
         SetConfigValue(cacheSize_s, 32);
 
-#ifdef ORXONOX_RELEASE
-        const unsigned int defaultLevel = 1;
-#else
-        const unsigned int defaultLevel = 3;
-#endif
-        SetConfigValueExternal(softDebugLevel_, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
-            .description("The maximal level of debug output shown in the Shell");
-        this->setSoftDebugLevel(this->softDebugLevel_);
+        // Choose the default level according to the path Orxonox was started (build directory or not)
+        OutputLevel::Value defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
+        SetConfigValueExternal(debugLevel_, "OutputHandler", "debugLevel" + consoleName_, defaultDebugLevel)
+            .description("The maximum level of debug output shown in the " + consoleName_);
+        OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
     }
 
@@ -150,4 +157,21 @@
             this->commandHistory_.erase(this->commandHistory_.begin() + index);
             ModifyConfigValue(commandHistory_, remove, index);
+        }
+    }
+
+    /** Called upon changes in the development mode (by Core)
+        Behaviour details see Core::devModeChanged.
+    */
+    void Shell::devModeChanged(bool value)
+    {
+        bool isNormal = (value == PathConfig::buildDirectoryRun());
+        if (isNormal)
+        {
+            ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, update);
+        }
+        else
+        {
+            OutputLevel::Value level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
+            ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, tset, level);
         }
     }
@@ -215,4 +239,16 @@
     }
 
+    /// Returns the current position of the cursor in the input buffer.
+    unsigned int Shell::getCursorPosition() const
+    {
+        return this->inputBuffer_->getCursorPosition();
+    }
+
+    /// Returns the current content of the input buffer (the text which was entered by the user)
+    const std::string& Shell::getInput() const
+    {
+        return this->inputBuffer_->get();
+    }
+
     /**
         @brief Sends output to the internal output buffer.
Index: code/trunk/src/libraries/core/command/Shell.h
===================================================================
--- code/trunk/src/libraries/core/command/Shell.h	(revision 8706)
+++ code/trunk/src/libraries/core/command/Shell.h	(revision 8729)
@@ -49,6 +49,6 @@
 
 #include "util/OutputHandler.h"
+#include "core/Core.h"
 #include "core/OrxonoxClass.h"
-#include "core/input/InputBuffer.h"
 
 namespace orxonox
@@ -85,5 +85,5 @@
         Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole.
     */
-    class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener
+    class _CoreExport Shell : public OutputListener, public DevModeListener
     {
         public:
@@ -91,4 +91,5 @@
             enum LineType
             {
+                TDebug  = OutputLevel::TDebug,
                 None    = OutputLevel::None,
                 Warning = OutputLevel::Warning,
@@ -118,11 +119,7 @@
 
             void setCursorPosition(unsigned int cursor);
-            /// Returns the current position of the cursor in the input buffer.
-            inline unsigned int getCursorPosition() const
-                { return this->inputBuffer_->getCursorPosition(); }
-
-            /// Returns the current content of the input buffer (the text which was entered by the user)
-            inline const std::string& getInput() const
-                { return this->inputBuffer_->get(); }
+            unsigned int getCursorPosition() const;
+
+            const std::string& getInput() const;
 
             typedef std::list<std::pair<std::string, LineType> > LineList;
@@ -146,4 +143,7 @@
         private:
             Shell(const Shell& other);
+
+            // DevModeListener
+            void devModeChanged(bool value);
 
             void addToHistory(const std::string& command);
@@ -197,5 +197,5 @@
             unsigned int              historyOffset_;       ///< The command history is a circular buffer, this variable defines the current write-offset
             std::vector<std::string>  commandHistory_;      ///< The history of commands that were entered by the user
-            int                       softDebugLevel_;      ///< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
+            int                       debugLevel_;          //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
             static unsigned int       cacheSize_s;          ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass
     };
Index: code/trunk/src/libraries/core/input/InputHandler.h
===================================================================
--- code/trunk/src/libraries/core/input/InputHandler.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/InputHandler.h	(revision 8729)
@@ -31,8 +31,17 @@
 
 #include "InputPrereqs.h"
-#include "util/Math.h"
 
 namespace orxonox
 {
+    /// A Vector class containing two integers @a x and @a y.
+    class IntVector2
+    {
+    public:
+        IntVector2() : x(0), y(0) { }
+        IntVector2(int _x, int _y) : x(_x), y(_y) { }
+        int x;
+        int y;
+    };
+
     namespace ButtonEvent
     {
Index: code/trunk/src/libraries/core/input/InputManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.cc	(revision 8706)
+++ code/trunk/src/libraries/core/input/InputManager.cc	(revision 8729)
@@ -94,5 +94,5 @@
         , oisInputManager_(0)
         , devices_(2)
-        , exclusiveMouse_(TriBool::False)
+        , exclusiveMouse_(false)
         , emptyState_(0)
         , calibratorCallbackHandler_(0)
@@ -108,5 +108,5 @@
 
         if (GraphicsManager::getInstance().isFullScreen())
-            exclusiveMouse_ = TriBool::True;
+            exclusiveMouse_ = true;
         this->loadDevices();
 
@@ -161,5 +161,5 @@
         paramList.insert(StringPair("w32_keyboard", "DISCL_FOREGROUND"));
         paramList.insert(StringPair("w32_mouse", "DISCL_FOREGROUND"));
-        if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen())
+        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
         {
             // Disable Windows key plus special keys (like play, stop, next, etc.)
@@ -174,5 +174,5 @@
         paramList.insert(StringPair("XAutoRepeatOn", "true"));
 
-        if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen())
+        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
         {
             if (CommandLineParser::getValue("keyboard_no_grab").getBool())
@@ -447,13 +447,14 @@
 
         // Check whether we have to change the mouse mode
-        TriBool::Value requestedMode = TriBool::Dontcare;
+        tribool requestedMode = dontcare;
         std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef();
         if (mouseStates.empty())
-            requestedMode = TriBool::False;
+            requestedMode = false;
         else
             requestedMode = mouseStates.front()->getMouseExclusive();
-        if (requestedMode != TriBool::Dontcare && exclusiveMouse_ != requestedMode)
-        {
-            exclusiveMouse_ = requestedMode;
+        if (requestedMode != dontcare && exclusiveMouse_ != requestedMode)
+        {
+            assert(requestedMode != dontcare);
+            exclusiveMouse_ = (requestedMode == true);
             if (!GraphicsManager::getInstance().isFullScreen())
                 this->reloadInternal();
@@ -644,5 +645,5 @@
     }
 
-    bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value)
+    bool InputManager::setMouseExclusive(const std::string& name, tribool value)
     {
         if (name == "empty")
Index: code/trunk/src/libraries/core/input/InputManager.h
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/InputManager.h	(revision 8729)
@@ -33,5 +33,4 @@
 
 #include <map>
-#include <set>
 #include <string>
 #include <vector>
@@ -39,5 +38,5 @@
 
 #include "util/Singleton.h"
-#include "util/TriBool.h"
+#include "util/tribool.h"
 #include "core/WindowEventListener.h"
 
@@ -169,5 +168,5 @@
             True if the call was successful, fals if the name was not found
         */
-        bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export
+        bool setMouseExclusive(const std::string& name, tribool value); // tolua_export
 
         //-------------------------------
@@ -215,5 +214,5 @@
         OIS::InputManager*                  oisInputManager_;      //!< OIS input manager
         std::vector<InputDevice*>           devices_;              //!< List of all input devices (keyboard, mouse, joy sticks)
-        TriBool::Value                      exclusiveMouse_;       //!< Currently applied mouse mode
+        bool                                exclusiveMouse_;       //!< Currently applied mouse mode
 
         // some internally handled states and handlers
Index: code/trunk/src/libraries/core/input/InputPrereqs.h
===================================================================
--- code/trunk/src/libraries/core/input/InputPrereqs.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/InputPrereqs.h	(revision 8729)
@@ -41,5 +41,4 @@
 #include <ois/OISKeyboard.h>
 #include <ois/OISMouse.h>
-#include <ois/OISJoyStick.h>
 #include "util/OrxEnum.h"
 
Index: code/trunk/src/libraries/core/input/InputState.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputState.cc	(revision 8706)
+++ code/trunk/src/libraries/core/input/InputState.cc	(revision 8729)
@@ -37,5 +37,5 @@
         , bAlwaysGetsInput_(bAlwaysGetsInput)
         , bTransparent_(bTransparent)
-        , exclusiveMouse_(TriBool::Dontcare)
+        , exclusiveMouse_(dontcare)
         , bExpired_(true)
         , handlers_(2)
Index: code/trunk/src/libraries/core/input/InputState.h
===================================================================
--- code/trunk/src/libraries/core/input/InputState.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/InputState.h	(revision 8729)
@@ -38,5 +38,5 @@
 #include <boost/bind.hpp>
 
-#include "util/TriBool.h"
+#include "util/tribool.h"
 #include "InputHandler.h"
 #include "InputManager.h"
@@ -112,6 +112,6 @@
         void setHandler        (InputHandler* handler);
 
-        void setMouseExclusive(TriBool::Value value) { exclusiveMouse_ = value; this->bExpired_ = true; }
-        TriBool::Value getMouseExclusive() const { return exclusiveMouse_; }
+        void setMouseExclusive(tribool value) { exclusiveMouse_ = value; this->bExpired_ = true; }
+        tribool getMouseExclusive() const { return exclusiveMouse_; }
 
         //! Returns the name of the state (which is unique!)
@@ -166,5 +166,5 @@
         const bool                  bAlwaysGetsInput_;      //!< See class declaration for explanation
         const bool                  bTransparent_;          //!< See class declaration for explanation
-        TriBool::Value              exclusiveMouse_;        //!< See class declaration for explanation
+        tribool                     exclusiveMouse_;        //!< See class declaration for explanation
         int                         priority_;              //!< Current priority (might change)
         bool                        bExpired_;              //!< See hasExpired()
Index: code/trunk/src/libraries/core/input/JoyStick.h
===================================================================
--- code/trunk/src/libraries/core/input/JoyStick.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/JoyStick.h	(revision 8729)
@@ -34,4 +34,5 @@
 #include <string>
 #include <vector>
+#include <ois/OISJoyStick.h>
 #include "InputDevice.h"
 
Index: code/trunk/src/libraries/core/input/JoyStickQuantityListener.h
===================================================================
--- code/trunk/src/libraries/core/input/JoyStickQuantityListener.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/JoyStickQuantityListener.h	(revision 8729)
@@ -36,4 +36,6 @@
 
 #include "InputPrereqs.h"
+
+#include <vector>
 #include "core/OrxonoxClass.h"
 
Index: code/trunk/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinderManager.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/KeyBinderManager.h	(revision 8729)
@@ -34,5 +34,4 @@
 #include <map>
 #include <string>
-#include <boost/shared_ptr.hpp>
 
 #include "util/Singleton.h"
Index: code/trunk/src/libraries/core/input/KeyDetector.h
===================================================================
--- code/trunk/src/libraries/core/input/KeyDetector.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/KeyDetector.h	(revision 8729)
@@ -32,5 +32,4 @@
 #include "InputPrereqs.h"
 
-#include <boost/shared_ptr.hpp>
 #include "util/Singleton.h"
 #include "KeyBinder.h"
Index: code/trunk/src/libraries/core/input/Keyboard.h
===================================================================
--- code/trunk/src/libraries/core/input/Keyboard.h	(revision 8706)
+++ code/trunk/src/libraries/core/input/Keyboard.h	(revision 8729)
@@ -31,6 +31,4 @@
 
 #include "InputPrereqs.h"
-
-#include "InputHandler.h"
 #include "InputDevice.h"
 
Index: code/trunk/src/libraries/core/input/Mouse.cc
===================================================================
--- code/trunk/src/libraries/core/input/Mouse.cc	(revision 8706)
+++ code/trunk/src/libraries/core/input/Mouse.cc	(revision 8729)
@@ -37,4 +37,5 @@
 // include this as last, X11 seems to define some macros...
 #include <ois/linux/LinuxMouse.h>
+#undef Success
 #endif
 
