Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 22, 2010, 2:47:10 PM (15 years ago)
Author:
rgrieder
Message:

Merged remaining revisions from gamestate to gamestates2.

Location:
code/branches/gamestates2
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestates2

  • code/branches/gamestates2/src/libraries/core/Core.cc

    r6417 r6595  
    225225
    226226        // Load the CEGUI interface
    227         guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(),
    228             inputManager_->getMousePosition(), graphicsManager_->isFullScreen()));
     227        guiManager_.reset(new GUIManager(inputManager_->getMousePosition()));
    229228
    230229        bGraphicsLoaded_ = true;
  • code/branches/gamestates2/src/libraries/core/Core.h

    r6417 r6595  
    3838#include "util/ScopeGuard.h"
    3939#include "util/Singleton.h"
    40 #include "core/OrxonoxClass.h"
     40#include "OrxonoxClass.h"
    4141
    4242namespace orxonox
  • code/branches/gamestates2/src/libraries/core/GUIManager.cc

    r6502 r6595  
    5757#include "ConsoleCommand.h"
    5858#include "Core.h"
     59#include "GraphicsManager.h"
    5960#include "LuaState.h"
    6061#include "PathConfig.h"
    6162#include "Resource.h"
     63#include "input/InputManager.h"
     64#include "input/InputState.h"
     65#include "input/KeyBinderManager.h"
    6266
    6367namespace orxonox
     
    108112    @return true if success, otherwise false
    109113    */
    110     GUIManager::GUIManager(Ogre::RenderWindow* renderWindow, const std::pair<int, int>& mousePosition, bool bFullScreen)
    111         : renderWindow_(renderWindow)
    112         , resourceProvider_(0)
     114    GUIManager::GUIManager(const std::pair<int, int>& mousePosition)
     115        : resourceProvider_(NULL)
    113116        , camera_(NULL)
    114         , bShowIngameGUI_(false)
    115117    {
    116118        using namespace CEGUI;
     
    119121
    120122        // Note: No SceneManager specified yet
    121         guiRenderer_.reset(new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_OVERLAY, false, 3000));
     123        guiRenderer_.reset(new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000));
    122124        resourceProvider_ = guiRenderer_->createResourceProvider();
    123125        resourceProvider_->setDefaultResourceGroup("GUI");
     
    141143        guiSystem_.reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get()));
    142144
     145        // Align CEGUI mouse with OIS mouse
     146        guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
     147
     148        // Hide the mouse cursor unless playing in full screen mode
     149        if (!GraphicsManager::getInstance().isFullScreen())
     150            CEGUI::MouseCursor::getSingleton().hide();
     151
    143152        // Initialise the basic Lua code
    144153        this->luaState_->doFile("InitialiseGUI.lua");
    145 
    146         // Align CEGUI mouse with OIS mouse
    147         guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
    148 
    149         // Hide the mouse cursor unless playing in full screen mode
    150         if (!bFullScreen)
    151             CEGUI::MouseCursor::getSingleton().hide();
    152154    }
    153155
     
    208210    }
    209211
     212    /** Loads a GUI sheet by Lua script
     213    @param name
     214        The name of the GUI (like the script name, but without the extension)
     215    */
     216    void GUIManager::loadGUI(const std::string& name)
     217    {
     218        this->executeCode("loadGUI(\"" + name + "\")");
     219    }
     220
    210221    /**
    211222    @brief
     
    240251    {
    241252        GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")");
     253    }
     254
     255    const std::string& GUIManager::createInputState(const std::string& name, TriBool::Value showMouse, TriBool::Value useKeyboard, bool bBlockJoyStick)
     256    {
     257        InputState* state = InputManager::getInstance().createInputState(name);
     258
     259        if (GraphicsManager::getInstance().isFullScreen() && showMouse == TriBool::True ||
     260           !GraphicsManager::getInstance().isFullScreen() && showMouse == TriBool::False)
     261            state->setMouseExclusive(TriBool::True);
     262        else
     263            state->setMouseExclusive(TriBool::Dontcare);
     264
     265        if (showMouse == TriBool::True)
     266            state->setMouseHandler(this);
     267        else if (showMouse == TriBool::False)
     268            state->setMouseHandler(&InputHandler::EMPTY);
     269
     270        if (useKeyboard == TriBool::True)
     271            state->setKeyHandler(this);
     272        else if (useKeyboard == TriBool::False)
     273            state->setKeyHandler(&InputHandler::EMPTY);
     274
     275        if (bBlockJoyStick)
     276            state->setJoyStickHandler(&InputHandler::EMPTY);
     277
     278        return state->getName();
    242279    }
    243280
  • code/branches/gamestates2/src/libraries/core/GUIManager.h

    r6417 r6595  
    4141
    4242#include "util/OgreForwardRefs.h"
     43#include "util/TriBool.h"
    4344#include "util/Singleton.h"
    4445#include "input/InputHandler.h"
     46
     47// Tolua includes (have to be relative to the current directory)
     48/*
     49$cfile "../util/TriBool.h" // tolua_export
     50*/
    4551
    4652namespace orxonox // tolua_export
     
    5460
    5561        The GUIManager is a singleton and can be called anywhere when access on the GUI is needed.
    56         Creation of the GUIManager is therefore not possible and the cunstructor is private.
    5762
    5863        Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler.
     
    6469        friend class Singleton<GUIManager>;
    6570    public:
    66         GUIManager(Ogre::RenderWindow* renderWindow, const std::pair<int, int>& mousePosition, bool bFullScreen);
     71        GUIManager(const std::pair<int, int>& mousePosition);
    6772        ~GUIManager();
    6873
    6974        void preUpdate(const Clock& time);
    7075
     76        void loadGUI(const std::string& name);
    7177        static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true);
    7278        void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true);
     
    7581        void setBackground(const std::string& name);
    7682
     83        const std::string& createInputState(const std::string& name, TriBool::Value showMouse = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export
     84
    7785        void setCamera(Ogre::Camera* camera);
    7886        Ogre::Camera* getCamera() { return this->camera_; }
    79 
    80         static GUIManager* getInstancePtr() { return singletonPtr_s; }
    8187
    8288        inline void setPlayer(const std::string& guiname, PlayerInfo* player)
     
    8793        // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
    8894        static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
     95
     96        static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export
    8997
    9098    private:
     
    102110        void mouseMoved    (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
    103111        void mouseScrolled (int abs, int rel);
    104 
    105112        scoped_ptr<CEGUI::OgreCEGUIRenderer> guiRenderer_;      //!< CEGUI's interface to the Ogre Engine
    106113        scoped_ptr<LuaState>                 luaState_;         //!< LuaState, access point to the Lua engine
     
    108115        scoped_ptr<CEGUI::System>            guiSystem_;        //!< CEGUI's main system
    109116        shared_ptr<ResourceInfo>             rootFileInfo_;     //!< Resource information about the root script
    110         Ogre::RenderWindow*                  renderWindow_;     //!< Ogre's render window to give CEGUI access to it
    111117        CEGUI::ResourceProvider*             resourceProvider_; //!< CEGUI's resource provider
    112118        CEGUI::Logger*                       ceguiLogger_;      //!< CEGUI's logger to be able to log CEGUI errors in our log
    113         std::map<std::string, PlayerInfo*>   players_;          //!< Stores the player (owner) for each gui
     119        std::map<std::string, PlayerInfo*>   players_;          //!< Stores the player (owner) for each GUI
    114120        Ogre::Camera*                        camera_;           //!< Camera used to render the scene with the GUI
    115121
    116122        static GUIManager*                   singletonPtr_s;    //!< Singleton reference to GUIManager
    117         bool                                 bShowIngameGUI_;
    118123
    119124    }; // tolua_export
  • code/branches/gamestates2/src/libraries/core/Game.h

    r6417 r6595  
    5050#include "util/ScopeGuard.h"
    5151#include "util/Singleton.h"
    52 #include "core/OrxonoxClass.h"
     52#include "OrxonoxClass.h"
    5353
    5454/**
  • code/branches/gamestates2/src/libraries/core/IOConsole.cc

    r6422 r6595  
    3535#include "util/Clock.h"
    3636#include "util/Math.h"
    37 #include "core/Game.h"
    38 #include "core/input/InputBuffer.h"
     37#include "Game.h"
     38#include "input/InputBuffer.h"
    3939
    4040// ##########################
  • code/branches/gamestates2/src/libraries/core/IOConsole.h

    r6417 r6595  
    3737#include <vector>
    3838#include "util/Singleton.h"
    39 #include "core/Shell.h"
     39#include "Shell.h"
    4040
    4141#ifdef ORXONOX_PLATFORM_UNIX
  • code/branches/gamestates2/src/libraries/core/LuaState.h

    r6417 r6595  
    4040
    4141#include "util/ScopeGuard.h"
    42 #include "core/Functor.h"
     42#include "Functor.h"
    4343#include "ToluaInterface.h"
    4444
  • code/branches/gamestates2/src/libraries/core/Template.cc

    r6417 r6595  
    3333
    3434#include "util/Debug.h"
    35 #include "core/CoreIncludes.h"
    36 #include "core/XMLPort.h"
     35#include "CoreIncludes.h"
     36#include "XMLPort.h"
    3737
    3838namespace orxonox
  • code/branches/gamestates2/src/libraries/core/input/InputManager.cc

    r6422 r6595  
    8787        , oisInputManager_(0)
    8888        , devices_(2)
    89         , mouseMode_(MouseMode::Nonexclusive)
     89        , exclusiveMouse_(TriBool::False)
    9090        , emptyState_(0)
    9191        , calibratorCallbackHandler_(0)
     
    9898
    9999        if (GraphicsManager::getInstance().isFullScreen())
    100             mouseMode_ = MouseMode::Exclusive;
     100            exclusiveMouse_ = TriBool::True;
    101101        this->loadDevices();
    102102
     
    155155        paramList.insert(std::make_pair("w32_keyboard", "DISCL_FOREGROUND"));
    156156        paramList.insert(std::make_pair("w32_mouse", "DISCL_FOREGROUND"));
    157         if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())
     157        if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen())
    158158        {
    159159            // Disable Windows key plus special keys (like play, stop, next, etc.)
     
    168168        paramList.insert(std::make_pair("XAutoRepeatOn", "true"));
    169169
    170         if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())
     170        if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen())
    171171        {
    172172            if (CommandLineParser::getValue("keyboard_no_grab").getBool())
     
    504504
    505505        // Check whether we have to change the mouse mode
    506         MouseMode::Value requestedMode = MouseMode::Dontcare;
     506        TriBool::Value requestedMode = TriBool::Dontcare;
    507507        std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef();
    508508        if (mouseStates.empty())
    509             requestedMode = MouseMode::Nonexclusive;
     509            requestedMode = TriBool::False;
    510510        else
    511             requestedMode = mouseStates.front()->getMouseMode();
    512         if (requestedMode != MouseMode::Dontcare && mouseMode_ != requestedMode)
    513         {
    514             mouseMode_ = requestedMode;
     511            requestedMode = mouseStates.front()->getMouseExclusive();
     512        if (requestedMode != TriBool::Dontcare && exclusiveMouse_ != requestedMode)
     513        {
     514            exclusiveMouse_ = requestedMode;
    515515            if (!GraphicsManager::getInstance().isFullScreen())
    516516                this->reloadInternal();
  • code/branches/gamestates2/src/libraries/core/input/InputManager.h

    r6417 r6595  
    3838
    3939#include "util/Singleton.h"
     40#include "util/TriBool.h"
    4041#include "core/WindowEventListener.h"
    4142#include "InputState.h"
     
    159160            - The removal process is being postponed if InputManager::preUpdate() is currently running.
    160161        */
    161         bool destroyState(const std::string& name);
     162        bool destroyState(const std::string& name); // tolua_export
    162163
    163164        //-------------------------------
     
    196197        OIS::InputManager*                  oisInputManager_;      //!< OIS input manager
    197198        std::vector<InputDevice*>           devices_;              //!< List of all input devices (keyboard, mouse, joy sticks)
    198         MouseMode::Value                    mouseMode_;            //!< Currently applied mouse mode
     199        TriBool::Value                      exclusiveMouse_;       //!< Currently applied mouse mode
    199200
    200201        // some internally handled states and handlers
  • code/branches/gamestates2/src/libraries/core/input/InputState.cc

    r6417 r6595  
    3737        , bAlwaysGetsInput_(bAlwaysGetsInput)
    3838        , bTransparent_(bTransparent)
    39         , mouseMode_(MouseMode::Dontcare)
     39        , exclusiveMouse_(TriBool::Dontcare)
    4040        , bExpired_(true)
    4141        , handlers_(2)
  • code/branches/gamestates2/src/libraries/core/input/InputState.h

    r5929 r6595  
    3737
    3838#include "util/OrxEnum.h"
     39#include "util/TriBool.h"
    3940#include "InputHandler.h"
    4041#include "JoyStickQuantityListener.h"
     
    5657    };
    5758
    58     namespace MouseMode
    59     {
    60         enum Value
    61         {
    62             Exclusive,
    63             Nonexclusive,
    64             Dontcare
    65         };
    66     }
    6759
    6860    /**
     
    7365        that stack and only the top one gets the input events. This is done for
    7466        every device (keyboard, mouse, all joy sticks) separately to allow
    75         for intance keyboard input capturing for the console while you can still
     67        for instance keyboard input capturing for the console while you can still
    7668        steer a ship with the mouse.
    7769        There are two exceptions to this behaviour though:
     
    8375          the state will always receive input as long as it is activated.
    8476        - Note: If you mark an InputState with both parameters on, then it will
    85           not influence ony other InputState at all.
     77          not influence only other InputState at all.
    8678
    8779    @par Priorities
     
    9587    @par Exclusive/Non-Exclusive mouse Mode
    9688        You can select a specific mouse mode that tells whether the application
    97         should have exclusive accessto it or not.
     89        should have exclusive access to it or not.
    9890        When in non-exclusive mode, you can move the mouse out of the window
    9991        like with any other normal window (only for windowed mode!).
     
    130122        void setHandler        (InputHandler* handler);
    131123
    132         void setMouseMode(MouseMode::Value value) { mouseMode_ = value; this->bExpired_ = true; }
    133         MouseMode::Value getMouseMode() const { return mouseMode_; }
     124        void setMouseExclusive(TriBool::Value value) { exclusiveMouse_ = value; this->bExpired_ = true; }
     125        TriBool::Value getMouseExclusive() const { return exclusiveMouse_; }
    134126
    135127        //! Returns the name of the state (which is unique!)
     
    184176        const bool                  bAlwaysGetsInput_;      //!< See class declaration for explanation
    185177        const bool                  bTransparent_;          //!< See class declaration for explanation
    186         MouseMode::Value            mouseMode_;             //!< See class declaration for explanation
     178        TriBool::Value              exclusiveMouse_;        //!< See class declaration for explanation
    187179        int                         priority_;              //!< Current priority (might change)
    188180        bool                        bExpired_;              //!< See hasExpired()
Note: See TracChangeset for help on using the changeset viewer.