Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/gui/GUIManager.h @ 3254

Last change on this file since 3254 was 3196, checked in by rgrieder, 15 years ago

Merged pch branch back to trunk.

  • Property svn:eol-style set to native
File size: 4.9 KB
RevLine 
[1638]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
[3196]24 *      Benjamin Knecht
[1638]25 *   Co-authors:
[3196]26 *      ...
[1638]27 *
28 */
29
30/**
[3196]31@file
32@brief
33    Declaration of the GUIManager class.
[1638]34*/
35
36#ifndef _GUIManager_H__
37#define _GUIManager_H__
38
39#include "OrxonoxPrereqs.h"
[3196]40
41#include <map>
42#include <string>
[1638]43#include <CEGUIForwardRefs.h>
[3196]44
45#include "util/OgreForwardRefs.h"
[1638]46#include "core/input/InputInterfaces.h"
47
[2710]48// tolua_begin
49namespace orxonox
50{
[1638]51    /**
[2896]52    @class GUIManager
[1638]53    @brief
[2896]54        Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler.
55
56        The GUIManager is a singleton and can be called anywhere when access on the GUI is needed.
57        Creation of the GUIManager is therefore not possible and the cunstructor is private.
58
59        Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler.
60        Those input events are then injected into CEGUI in Lua.
[1638]61    */
[2710]62    class _OrxonoxExport GUIManager
63// tolua_end
64        : public KeyHandler, public MouseHandler
65// tolua_begin
[1638]66    {
[2710]67// tolua_end
[1638]68    public:
[2896]69        /**
70        @enum State
71            The current state of the GUIManager. There should maybe be more (or we can omit this totally).
72        */
[1638]73        enum State
74        {
[2896]75            Uninitialised,  //!< Initial state of the GUIManager
76            Ready,          //!< State after initialisation if ready
77            OnDisplay       //!< State if GUI is displayed
[1638]78        };
79
[1646]80        GUIManager();
81        ~GUIManager();
82
[1686]83        bool initialise(Ogre::RenderWindow* renderWindow);
[1638]84
[2896]85        void update(const Clock& time);
[1640]86
[2896]87        void showGUI(const std::string& name);
88        void executeCode(const std::string& str);
[1638]89
[3196]90        bool registerOverlay(const std::string& name, GUIOverlay* overlay); //!< Register a GUIOverlay with the GUIManager.
91        GUIOverlay* getOverlay(const std::string& name); // Get the GUIOverlay of the GUI with the given name.
[2962]92
[2896]93        void setCamera(Ogre::Camera* camera);
94
[1646]95        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
96        static GUIManager* getInstancePtr() { return singletonRef_s; }
97
[3008]98        void getLevelList(); //tolua_export
99
[1638]100    private:
[2896]101        GUIManager(const GUIManager& instance);                 //!< private constructor (this is a singleton class)
[1638]102
[2896]103        void loadLuaCode();
104
105        // keyHandler functions
[3196]106        void keyPressed (const KeyEvent& evt);
107        void keyReleased(const KeyEvent& evt);
[2896]108        void keyHeld    (const KeyEvent& evt) { }
[1638]109
[2896]110        // mouseHandler functions
[1887]111        void mouseButtonPressed (MouseButtonCode::ByEnum id);
112        void mouseButtonReleased(MouseButtonCode::ByEnum id);
[2896]113        void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
[3196]114        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
115        void mouseScrolled      (int abs, int rel);
[1638]116
[2896]117        void updateInput(float dt)  { }
118        void updateKey  (float dt)  { }
119        void updateMouse(float dt)  { }
[1638]120
[2896]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
[1638]128
[2896]129        State                       state_;             //!< reflects state of the GUIManager
[1638]130
[2962]131        std::map<std::string, GUIOverlay*> guiOverlays_;//!< A list of all GUIOverlay's.
132
[2896]133        static GUIManager*          singletonRef_s;     //!< Singleton reference to GUIManager
[2962]134
[1638]135    }; // tolua_export
136} // tolua_export
137
138#endif /* _GUIManager_H__ */
Note: See TracBrowser for help on using the repository browser.