Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 30, 2011, 2:38:34 AM (14 years ago)
Author:
rgrieder
Message:

Replaced TriBool with a modified version of boost::tribool. The main reason was that 'True' and 'False' had to be replaced because of macro collisions.
So why not use the real true and false with a third state? That's what boost tribool did, so I changed that implementation to fit our needs and change its behavior.
It's also safer to use because it avoids unwanted implicit conversions.

Location:
code/branches/unity_build/src
Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/unity_build/src/libraries/core/GUIManager.cc

    r8669 r8678  
    419419    }
    420420
    421     const std::string& GUIManager::createInputState(const std::string& name, TriBool::Value showCursor, TriBool::Value useKeyboard, bool bBlockJoyStick)
     421    const std::string& GUIManager::createInputState(const std::string& name, tribool showCursor, tribool useKeyboard, bool bBlockJoyStick)
    422422    {
    423423        InputState* state = InputManager::getInstance().createInputState(name);
     
    435435#ifdef ORXONOX_PLATFORM_APPLE
    436436        // There is no non exclusive mode on OS X yet
    437         state->setMouseExclusive(TriBool::True);
    438 #else
    439         if (showCursor == TriBool::Dontcare)
    440             state->setMouseExclusive(TriBool::Dontcare);
    441         else if (GraphicsManager::getInstance().isFullScreen() || showCursor == TriBool::False)
    442             state->setMouseExclusive(TriBool::True);
     437        state->setMouseExclusive(true);
     438#else
     439        if (showCursor == dontcare)
     440            state->setMouseExclusive(dontcare);
     441        else if (GraphicsManager::getInstance().isFullScreen() || showCursor == false)
     442            state->setMouseExclusive(true);
    443443        else
    444             state->setMouseExclusive(TriBool::False);
    445 #endif
    446 
    447         if (showCursor == TriBool::True)
     444            state->setMouseExclusive(false);
     445#endif
     446
     447        if (showCursor == true)
    448448            state->setMouseHandler(this);
    449         else if (showCursor == TriBool::False)
     449        else if (showCursor == false)
    450450            state->setMouseHandler(&InputHandler::EMPTY);
    451451
    452         if (useKeyboard == TriBool::True)
     452        if (useKeyboard == true)
    453453            state->setKeyHandler(this);
    454         else if (useKeyboard == TriBool::False)
     454        else if (useKeyboard == false)
    455455            state->setKeyHandler(&InputHandler::EMPTY);
    456456
  • code/branches/unity_build/src/libraries/core/GUIManager.h

    r8669 r8678  
    4646#include "util/DestructionHelper.h"
    4747#include "util/OgreForwardRefs.h"
    48 #include "util/TriBool.h"
     48#include "util/tribool.h"
    4949#include "util/Singleton.h"
    5050#include "input/InputHandler.h"
    5151#include "OrxonoxClass.h"
    5252#include "WindowEventListener.h"
    53 
    54 // Tolua includes (have to be relative to the current directory)
    55 /*
    56 $cfile "../util/TriBool.h" // tolua_export
    57 */
    5853
    5954#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
     
    6459{ // tolua_export
    6560    class PlayerInfo; // Forward declaration
     61
     62    // Acquaint Tolua with tribool
     63    class tribool; // tolua_export
    6664
    6765    /**
     
    105103
    106104        //! Creates a new InputState to be used with a GUI Sheet
    107         const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export
     105        const std::string& createInputState(const std::string& name, tribool showCursor = true, tribool useKeyboard = true, bool bBlockJoyStick = false); // tolua_export
    108106        LuaState* getLuaState(void)
    109107            { return this->luaState_; }
  • code/branches/unity_build/src/libraries/core/input/InputManager.cc

    r8351 r8678  
    9494        , oisInputManager_(0)
    9595        , devices_(2)
    96         , exclusiveMouse_(TriBool::False)
     96        , exclusiveMouse_(false)
    9797        , emptyState_(0)
    9898        , calibratorCallbackHandler_(0)
     
    108108
    109109        if (GraphicsManager::getInstance().isFullScreen())
    110             exclusiveMouse_ = TriBool::True;
     110            exclusiveMouse_ = true;
    111111        this->loadDevices();
    112112
     
    161161        paramList.insert(StringPair("w32_keyboard", "DISCL_FOREGROUND"));
    162162        paramList.insert(StringPair("w32_mouse", "DISCL_FOREGROUND"));
    163         if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen())
     163        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
    164164        {
    165165            // Disable Windows key plus special keys (like play, stop, next, etc.)
     
    174174        paramList.insert(StringPair("XAutoRepeatOn", "true"));
    175175
    176         if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen())
     176        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
    177177        {
    178178            if (CommandLineParser::getValue("keyboard_no_grab").getBool())
     
    447447
    448448        // Check whether we have to change the mouse mode
    449         TriBool::Value requestedMode = TriBool::Dontcare;
     449        tribool requestedMode = dontcare;
    450450        std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef();
    451451        if (mouseStates.empty())
    452             requestedMode = TriBool::False;
     452            requestedMode = false;
    453453        else
    454454            requestedMode = mouseStates.front()->getMouseExclusive();
    455         if (requestedMode != TriBool::Dontcare && exclusiveMouse_ != requestedMode)
    456         {
    457             exclusiveMouse_ = requestedMode;
     455        if (requestedMode != dontcare && exclusiveMouse_ != requestedMode)
     456        {
     457            assert(requestedMode != dontcare);
     458            exclusiveMouse_ = (requestedMode == true);
    458459            if (!GraphicsManager::getInstance().isFullScreen())
    459460                this->reloadInternal();
     
    644645    }
    645646
    646     bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value)
     647    bool InputManager::setMouseExclusive(const std::string& name, tribool value)
    647648    {
    648649        if (name == "empty")
  • code/branches/unity_build/src/libraries/core/input/InputManager.h

    r8672 r8678  
    3838
    3939#include "util/Singleton.h"
    40 #include "util/TriBool.h"
     40#include "util/tribool.h"
    4141#include "core/WindowEventListener.h"
    4242
     
    168168            True if the call was successful, fals if the name was not found
    169169        */
    170         bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export
     170        bool setMouseExclusive(const std::string& name, tribool value); // tolua_export
    171171
    172172        //-------------------------------
     
    214214        OIS::InputManager*                  oisInputManager_;      //!< OIS input manager
    215215        std::vector<InputDevice*>           devices_;              //!< List of all input devices (keyboard, mouse, joy sticks)
    216         TriBool::Value                      exclusiveMouse_;       //!< Currently applied mouse mode
     216        bool                                exclusiveMouse_;       //!< Currently applied mouse mode
    217217
    218218        // some internally handled states and handlers
  • code/branches/unity_build/src/libraries/core/input/InputState.cc

    r7284 r8678  
    3737        , bAlwaysGetsInput_(bAlwaysGetsInput)
    3838        , bTransparent_(bTransparent)
    39         , exclusiveMouse_(TriBool::Dontcare)
     39        , exclusiveMouse_(dontcare)
    4040        , bExpired_(true)
    4141        , handlers_(2)
  • code/branches/unity_build/src/libraries/core/input/InputState.h

    r8351 r8678  
    3838#include <boost/bind.hpp>
    3939
    40 #include "util/TriBool.h"
     40#include "util/tribool.h"
    4141#include "InputHandler.h"
    4242#include "InputManager.h"
     
    112112        void setHandler        (InputHandler* handler);
    113113
    114         void setMouseExclusive(TriBool::Value value) { exclusiveMouse_ = value; this->bExpired_ = true; }
    115         TriBool::Value getMouseExclusive() const { return exclusiveMouse_; }
     114        void setMouseExclusive(tribool value) { exclusiveMouse_ = value; this->bExpired_ = true; }
     115        tribool getMouseExclusive() const { return exclusiveMouse_; }
    116116
    117117        //! Returns the name of the state (which is unique!)
     
    166166        const bool                  bAlwaysGetsInput_;      //!< See class declaration for explanation
    167167        const bool                  bTransparent_;          //!< See class declaration for explanation
    168         TriBool::Value              exclusiveMouse_;        //!< See class declaration for explanation
     168        tribool                     exclusiveMouse_;        //!< See class declaration for explanation
    169169        int                         priority_;              //!< Current priority (might change)
    170170        bool                        bExpired_;              //!< See hasExpired()
  • code/branches/unity_build/src/orxonox/gamestates/GSLevel.cc

    r8079 r8678  
    7777        {
    7878            gameInputState_ = InputManager::getInstance().createInputState("game");
    79             gameInputState_->setMouseExclusive(TriBool::True);
     79            gameInputState_->setMouseExclusive(true);
    8080            gameInputState_->setHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
    8181            KeyBinderManager::getInstance().setToDefault();
    8282
    8383            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly");
    84             guiMouseOnlyInputState_->setMouseExclusive(TriBool::True);
     84            guiMouseOnlyInputState_->setMouseExclusive(true);
    8585            guiMouseOnlyInputState_->setMouseHandler(&GUIManager::getInstance());
    8686
Note: See TracChangeset for help on using the changeset viewer.