Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged input branch into gui test branch (was about time)
svn save (it's still a mess and CMLs haven't been updated)
I'll have to create a special project to create the tolua_bind files for tolua itself anyway..

  • Property svn:eol-style set to native
File size: 3.8 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// forward declarations
45namespace CEGUI
46{
47    class OgreCEGUIRenderer;
48    class LuaScriptModule;
49}
50
51namespace orxonox // tolua_export
52{ // tolua_export
53    /**
54    @brief
55        Provides a simple interface to CEGUI with tolua methods and console commands
56    */
57    class _OrxonoxExport GUIManager : public KeyHandler, public MouseHandler
58    /*
59    class GUIManager { // tolua_export
60    */
61    {
62    public:
63        enum State
64        {
65            Uninitialised,
66            Ready,
67            OnDisplay
68        };
69
70        bool initialise();
71        void tick(float dt);
72        void showGUI(const std::string& name, bool showBackground); // tolua_export
73        void _hideGUI(); // tolua_export
74
75        static GUIManager& getInstance(); // tolua_export
76        static void showGUI_s(const std::string& name, bool showBackground)
77        {
78            getInstance().showGUI(name, showBackground);
79        }
80
81    private:
82        GUIManager();
83        GUIManager(const GUIManager& instance);
84        ~GUIManager();
85
86        void keyPressed (const KeyEvent& evt)
87        { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
88        void keyReleased(const KeyEvent& evt)
89        { guiSystem_->injectKeyUp(evt.key); }
90        void keyHeld    (const KeyEvent& evt)
91        { }
92
93        void mouseButtonPressed (MouseButton::Enum id);
94        void mouseButtonReleased(MouseButton::Enum id);
95        void mouseButtonHeld    (MouseButton::Enum id)
96        { }
97        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
98        { guiSystem_->injectMouseMove(rel.x, rel.y); }
99        void mouseScrolled      (int abs, int rel)
100        { guiSystem_->injectMouseWheelChange(rel);}
101
102        void tickInput(float dt) { }
103
104        void loadScenes();
105
106        Ogre::SceneManager*       emptySceneManager_;
107        Ogre::SceneManager*       backgroundSceneManager_;
108        Ogre::Camera*             emptyCamera_;
109        Ogre::Camera*             backgroundCamera_;
110        Ogre::Viewport*           viewport_;
111        Ogre::RenderWindow*       renderWindow_;
112        CEGUI::OgreCEGUIRenderer* guiRenderer_;
113        CEGUI::ResourceProvider*  resourceProvider_;
114        CEGUI::LuaScriptModule*   scriptModule_;
115        CEGUI::System*            guiSystem_;
116        CEGUI::Imageset*          backgroundImage_;
117
118        State state_;
119
120
121        static CEGUI::MouseButton convertButton(MouseButton::Enum button);
122    }; // tolua_export
123
124    inline void GUIManager::tick(float dt)
125    {
126        assert(guiSystem_);
127        guiSystem_->injectTimePulse(dt);
128    }
129} // tolua_export
130
131#endif /* _GUIManager_H__ */
Note: See TracBrowser for help on using the repository browser.