[612] | 1 | /** |
---|
| 2 | @file Orxonox.h |
---|
| 3 | @brief Main Orxonox Class File |
---|
| 4 | @author Benjamin Knecht <beni_at_orxonox.net> |
---|
| 5 | */ |
---|
| 6 | |
---|
[673] | 7 | #ifndef _Orxonox_H__ |
---|
| 8 | #define _Orxonox_H__ |
---|
[612] | 9 | |
---|
[1039] | 10 | #include "OrxonoxPrereqs.h" |
---|
| 11 | |
---|
[715] | 12 | #include <string> |
---|
| 13 | |
---|
[612] | 14 | #include <OgrePrerequisites.h> |
---|
[777] | 15 | #include "audio/AudioPrereqs.h" |
---|
[729] | 16 | |
---|
[612] | 17 | #include "GraphicsEngine.h" |
---|
[1024] | 18 | #include "core/InputEventListener.h" |
---|
[612] | 19 | |
---|
| 20 | |
---|
| 21 | namespace orxonox { |
---|
| 22 | |
---|
| 23 | enum gameMode{ |
---|
| 24 | SERVER, |
---|
| 25 | CLIENT, |
---|
[1021] | 26 | STANDALONE |
---|
[612] | 27 | }; |
---|
| 28 | |
---|
[1032] | 29 | //! Orxonox singleton class |
---|
[1021] | 30 | class _OrxonoxExport Orxonox : public InputEventListener |
---|
[612] | 31 | { |
---|
| 32 | public: |
---|
[715] | 33 | void init(int argc, char **argv, std::string path); |
---|
[612] | 34 | void start(); |
---|
| 35 | // not sure if this should be private |
---|
[1021] | 36 | void abortImmediate(/* some error code */); |
---|
| 37 | void abortRequest(); |
---|
| 38 | inline audio::AudioManager* getAudioManagerPointer() { return auMan_; }; |
---|
| 39 | |
---|
[612] | 40 | static Orxonox* getSingleton(); |
---|
[1052] | 41 | static void destroySingleton(); |
---|
| 42 | |
---|
| 43 | static inline void slomo(float factor) { Orxonox::getSingleton()->timefactor_ = factor; } |
---|
| 44 | static inline void setTimeFactor(float factor = 1.0) { Orxonox::getSingleton()->timefactor_ = factor; } |
---|
| 45 | static inline float getTimeFactor() { return Orxonox::getSingleton()->timefactor_; } |
---|
| 46 | static inline void exit() { Orxonox::getSingleton()->abortRequest(); } |
---|
[612] | 47 | |
---|
[1021] | 48 | private: |
---|
| 49 | // don't mess with singletons |
---|
[612] | 50 | Orxonox(); |
---|
[1021] | 51 | Orxonox(Orxonox& instance); |
---|
| 52 | Orxonox& operator=(const Orxonox& instance); |
---|
| 53 | ~Orxonox(); |
---|
| 54 | |
---|
[612] | 55 | // init functions |
---|
[715] | 56 | void serverInit(std::string path); |
---|
| 57 | void clientInit(std::string path); |
---|
| 58 | void standaloneInit(std::string path); |
---|
[1021] | 59 | |
---|
[612] | 60 | // run functions |
---|
[1021] | 61 | void serverStart(); |
---|
| 62 | void clientStart(); |
---|
| 63 | void standaloneStart(); |
---|
| 64 | |
---|
| 65 | void createScene(); |
---|
[612] | 66 | void setupInputSystem(); |
---|
[1021] | 67 | void startRenderLoop(); |
---|
[1024] | 68 | float calculateEventTime(unsigned long, std::deque<unsigned long>&); |
---|
[612] | 69 | |
---|
[1024] | 70 | void eventOccured(InputEvent &evt); |
---|
| 71 | |
---|
[612] | 72 | private: |
---|
[717] | 73 | GraphicsEngine* ogre_; //!< our dearest graphics engine <3 |
---|
| 74 | std::string dataPath_; //!< path to data |
---|
| 75 | audio::AudioManager* auMan_; //!< audio manager |
---|
[1024] | 76 | InputManager* inputHandler_; //!< Handles input with key bindings |
---|
[1021] | 77 | Ogre::Timer* timer_; //!< Main loop timer |
---|
| 78 | // TODO: make this a config-value by creating a config class for orxonox |
---|
| 79 | float frameSmoothingTime_; |
---|
| 80 | HUD* orxonoxHUD_; |
---|
[1052] | 81 | bool bAbort_; //!< aborts the render loop if true |
---|
| 82 | float timefactor_; //!< A factor to change the gamespeed |
---|
[612] | 83 | |
---|
| 84 | // this is used to identify the mode (server/client/...) we're in |
---|
| 85 | gameMode mode_; |
---|
[715] | 86 | std::string serverIp_; |
---|
[1021] | 87 | |
---|
| 88 | static Orxonox *singletonRef_s; |
---|
[612] | 89 | }; |
---|
| 90 | } |
---|
[673] | 91 | #endif /* _Orxonox_H__ */ |
---|