Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2808 was 2808, checked in by bknecht, 15 years ago

You can now toggle visibility ingame. Strangely the SceneManager changes after the initial enter()-function of GSStandalone. That's why - for the moment - the SceneManager is set every tick to be able to keep track of the current SceneManager.

Also there are some strange functions defined not having a real purpose aside from debug (the implementation is not clean at all, but rather full of shortcuts and functional). At least it compiles and runs ;-)

  • Property svn:eol-style set to native
File size: 4.6 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/Clock.h"
43#include "core/input/InputInterfaces.h"
44
45// Forward declaration
46namespace CEGUI { class DefaultLogger; }
47
48// tolua_begin
49namespace orxonox
50{
51    /**
52    @brief
53        Provides a simple interface to CEGUI with tolua methods and console commands
54    */
55    class _OrxonoxExport GUIManager
56// tolua_end
57        : public KeyHandler, public MouseHandler
58// tolua_begin
59    {
60// tolua_end
61    public:
62        enum State
63        {
64            Uninitialised,
65            Ready,
66            OnDisplay
67        };
68
69        GUIManager();
70        ~GUIManager();
71
72        bool initialise(Ogre::RenderWindow* renderWindow);
73        void loadScene(const std::string& name);
74        void update(const Clock& time)
75        {
76            assert(guiSystem_);
77            guiSystem_->injectTimePulse(time.getDeltaTime());
78        }
79        void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export
80        void hideGUI(); // tolua_export
81        void testOutput(const std::string& str); // tolua_export
82
83        static void toggleGUI();
84
85        Ogre::Camera* getCamera() { return this->backgroundCamera_; }
86
87        static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
88        {
89            getInstance().showGUI(name, sceneManager);
90        }
91
92        // please remove
93        void testFct();
94
95        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
96        static GUIManager* getInstancePtr() { return singletonRef_s; }
97
98    private:
99        GUIManager(const GUIManager& instance);
100
101        void keyPressed (const KeyEvent& evt)
102        { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
103        void keyReleased(const KeyEvent& evt)
104        { guiSystem_->injectKeyUp(evt.key); }
105        void keyHeld    (const KeyEvent& evt)
106        { }
107
108        void mouseButtonPressed (MouseButtonCode::ByEnum id);
109        void mouseButtonReleased(MouseButtonCode::ByEnum id);
110        void mouseButtonHeld    (MouseButtonCode::ByEnum id)
111        { }
112        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
113        { guiSystem_->injectMouseMove(rel.x, rel.y); }
114        void mouseScrolled      (int abs, int rel)
115        { guiSystem_->injectMouseWheelChange(rel);}
116
117        void updateInput(float dt) { }
118        void updateKey(float dt) { }
119        void updateMouse(float dt) { }
120
121        void loadScenes();
122
123        //Ogre::SceneManager*       emptySceneManager_;
124        Ogre::SceneManager*       backgroundSceneManager_;
125        //Ogre::Camera*             emptyCamera_;
126        Ogre::Camera*             backgroundCamera_;
127        //Ogre::Viewport*           viewport_;
128        Ogre::RenderWindow*       renderWindow_;
129        CEGUI::OgreCEGUIRenderer* guiRenderer_;
130        CEGUI::ResourceProvider*  resourceProvider_;
131        CEGUI::LuaScriptModule*   scriptModule_;
132        CEGUI::DefaultLogger*     ceguiLogger_;
133        CEGUI::System*            guiSystem_;
134        CEGUI::Imageset*          backgroundImage_;
135        lua_State*                luaState_;
136        Ogre::SceneManager*         currentSceneManager_;
137
138        State state_;
139
140        static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
141
142        static GUIManager*        singletonRef_s;
143    }; // tolua_export
144} // tolua_export
145
146#endif /* _GUIManager_H__ */
Note: See TracBrowser for help on using the repository browser.