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/libraries/core/input
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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()
Note: See TracChangeset for help on using the changeset viewer.