Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:36:08 AM (16 years ago)
Author:
dafrick
Message:

Merging of the current QuestSystem branch.

Location:
code/branches/questsystem5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/orxonox/gui/GUIManager.h

    r2710 r2907  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    4949{
    5050    /**
     51    @class GUIManager
    5152    @brief
    52         Provides a simple interface to CEGUI with tolua methods and console commands
     53        Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler.
     54
     55        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.
     57
     58        Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler.
     59        Those input events are then injected into CEGUI in Lua.
    5360    */
    5461    class _OrxonoxExport GUIManager
     
    5966// tolua_end
    6067    public:
     68        /**
     69        @enum State
     70            The current state of the GUIManager. There should maybe be more (or we can omit this totally).
     71        */
    6172        enum State
    6273        {
    63             Uninitialised,
    64             Ready,
    65             OnDisplay
     74            Uninitialised,  //!< Initial state of the GUIManager
     75            Ready,          //!< State after initialisation if ready
     76            OnDisplay       //!< State if GUI is displayed
    6677        };
    6778
     
    7081
    7182        bool initialise(Ogre::RenderWindow* renderWindow);
    72         void tick(float dt)
    73         {
    74             assert(guiSystem_);
    75             guiSystem_->injectTimePulse(dt);
    76         }
    77         void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export
    78         void hideGUI(); // tolua_export
    7983
    80         Ogre::Camera* getCamera() { return this->backgroundCamera_; }
     84        void update(const Clock& time);
    8185
    82         static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
    83         {
    84             getInstance().showGUI(name, sceneManager);
    85         }
     86        void showGUI(const std::string& name);
     87        void executeCode(const std::string& str);
     88
     89        void setCamera(Ogre::Camera* camera);
    8690
    8791        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
     
    8993
    9094    private:
    91         GUIManager(const GUIManager& instance);
     95        GUIManager(const GUIManager& instance);                 //!< private constructor (this is a singleton class)
    9296
     97        void loadLuaCode();
     98
     99        // keyHandler functions
    93100        void keyPressed (const KeyEvent& evt)
    94         { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
     101            { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
    95102        void keyReleased(const KeyEvent& evt)
    96         { guiSystem_->injectKeyUp(evt.key); }
    97         void keyHeld    (const KeyEvent& evt)
    98         { }
     103            { guiSystem_->injectKeyUp(evt.key); }
     104        void keyHeld    (const KeyEvent& evt) { }
    99105
     106        // mouseHandler functions
    100107        void mouseButtonPressed (MouseButtonCode::ByEnum id);
    101108        void mouseButtonReleased(MouseButtonCode::ByEnum id);
    102         void mouseButtonHeld    (MouseButtonCode::ByEnum id)
    103         { }
     109        void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
    104110        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
    105         { guiSystem_->injectMouseMove(rel.x, rel.y); }
     111            { guiSystem_->injectMouseMove(rel.x, rel.y); }
    106112        void mouseScrolled      (int abs, int rel)
    107         { guiSystem_->injectMouseWheelChange(rel);}
     113            { guiSystem_->injectMouseWheelChange(rel);}
    108114
    109         void tickInput(float dt) { }
    110         void tickKey(float dt) { }
    111         void tickMouse(float dt) { }
    112 
    113         void loadScenes();
    114 
    115         //Ogre::SceneManager*       emptySceneManager_;
    116         Ogre::SceneManager*       backgroundSceneManager_;
    117         //Ogre::Camera*             emptyCamera_;
    118         Ogre::Camera*             backgroundCamera_;
    119         //Ogre::Viewport*           viewport_;
    120         Ogre::RenderWindow*       renderWindow_;
    121         CEGUI::OgreCEGUIRenderer* guiRenderer_;
    122         CEGUI::ResourceProvider*  resourceProvider_;
    123         CEGUI::LuaScriptModule*   scriptModule_;
    124         CEGUI::DefaultLogger*     ceguiLogger_;
    125         CEGUI::System*            guiSystem_;
    126         CEGUI::Imageset*          backgroundImage_;
    127         lua_State*                luaState_;
    128 
    129         State state_;
     115        void updateInput(float dt)  { }
     116        void updateKey  (float dt)  { }
     117        void updateMouse(float dt)  { }
    130118
    131119        static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
    132120
    133         static GUIManager*        singletonRef_s;
     121        Ogre::RenderWindow*         renderWindow_;      //!< Ogre's render window to give CEGUI access to it
     122        CEGUI::OgreCEGUIRenderer*   guiRenderer_;       //!< CEGUI's interface to the Ogre Engine
     123        CEGUI::ResourceProvider*    resourceProvider_;  //!< CEGUI's resource provider
     124        CEGUI::LuaScriptModule*     scriptModule_;      //!< CEGUI's script module to use Lua
     125        CEGUI::DefaultLogger*       ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
     126        CEGUI::System*              guiSystem_;         //!< CEGUI's main system
     127        lua_State*                  luaState_;          //!< Lua state, access point to the Lua engine
     128
     129        State                       state_;             //!< reflects state of the GUIManager
     130
     131        static GUIManager*          singletonRef_s;     //!< Singleton reference to GUIManager
    134132    }; // tolua_export
    135133} // tolua_export
Note: See TracChangeset for help on using the changeset viewer.