Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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