Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem2/src/orxonox/gui/GUIManager.h @ 2595

Last change on this file since 2595 was 2509, checked in by rgrieder, 16 years ago

Merged revisions 1875-2278 of the buildsystem branch to buildsystem2.

  • Property svn:eol-style set to native
File size: 4.1 KB
Line 
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
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @brief Declaration of the GUIManager class.
32*/
33
34#ifndef _GUIManager_H__
35#define _GUIManager_H__
36
37#include "OrxonoxPrereqs.h"
38#include <OgrePrerequisites.h>
39#include <CEGUIForwardRefs.h>
40#include <CEGUIInputEvent.h>
41#include <CEGUISystem.h>
42#include "core/input/InputInterfaces.h"
43
44// tolua_begin
45namespace orxonox
46{
47    /**
48    @brief
49        Provides a simple interface to CEGUI with tolua methods and console commands
50    */
51    class _OrxonoxExport GUIManager
52// tolua_end
53        : public KeyHandler, public MouseHandler
54// tolua_begin
55    {
56// tolua_end
57    public:
58        enum State
59        {
60            Uninitialised,
61            Ready,
62            OnDisplay
63        };
64
65        GUIManager();
66        ~GUIManager();
67
68        bool initialise(Ogre::RenderWindow* renderWindow);
69        void tick(float dt)
70        {
71            assert(guiSystem_);
72            guiSystem_->injectTimePulse(dt);
73        }
74        void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export
75        void hideGUI(); // tolua_export
76
77        Ogre::Camera* getCamera() { return this->backgroundCamera_; }
78
79        static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
80        {
81            getInstance().showGUI(name, sceneManager);
82        }
83
84        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
85        static GUIManager* getInstancePtr() { return singletonRef_s; }
86
87    private:
88        GUIManager(const GUIManager& instance);
89
90        void keyPressed (const KeyEvent& evt)
91        { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
92        void keyReleased(const KeyEvent& evt)
93        { guiSystem_->injectKeyUp(evt.key); }
94        void keyHeld    (const KeyEvent& evt)
95        { }
96
97        void mouseButtonPressed (MouseButtonCode::ByEnum id);
98        void mouseButtonReleased(MouseButtonCode::ByEnum id);
99        void mouseButtonHeld    (MouseButtonCode::ByEnum id)
100        { }
101        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
102        { guiSystem_->injectMouseMove(rel.x, rel.y); }
103        void mouseScrolled      (int abs, int rel)
104        { guiSystem_->injectMouseWheelChange(rel);}
105
106        void tickInput(float dt) { }
107        void tickKey(float dt) { }
108        void tickMouse(float dt) { }
109
110        void loadScenes();
111
112        //Ogre::SceneManager*       emptySceneManager_;
113        Ogre::SceneManager*       backgroundSceneManager_;
114        //Ogre::Camera*             emptyCamera_;
115        Ogre::Camera*             backgroundCamera_;
116        //Ogre::Viewport*           viewport_;
117        Ogre::RenderWindow*       renderWindow_;
118        CEGUI::OgreCEGUIRenderer* guiRenderer_;
119        CEGUI::ResourceProvider*  resourceProvider_;
120        CEGUI::LuaScriptModule*   scriptModule_;
121        CEGUI::System*            guiSystem_;
122        CEGUI::Imageset*          backgroundImage_;
123        lua_State*                luaState_;
124
125        State state_;
126
127        static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
128
129        static GUIManager*        singletonRef_s;
130    }; // tolua_export
131} // tolua_export
132
133#endif /* _GUIManager_H__ */
Note: See TracBrowser for help on using the repository browser.