| 1 | /* |
|---|
| 2 | ----------------------------------------------------------------------------- |
|---|
| 3 | This source file is part of OGRE |
|---|
| 4 | (Object-oriented Graphics Rendering Engine) |
|---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
|---|
| 6 | |
|---|
| 7 | Copyright (c) 2000-2006 The OGRE Team |
|---|
| 8 | Also see acknowledgements in Readme.html |
|---|
| 9 | |
|---|
| 10 | You may use this sample code for anything you like, it is not covered by the |
|---|
| 11 | LGPL like the rest of the engine. |
|---|
| 12 | ----------------------------------------------------------------------------- |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | #ifndef _UIHandler_H_ |
|---|
| 16 | #define _UIHandler_H_ |
|---|
| 17 | |
|---|
| 18 | #include "CEGUI/CEGUI.h" |
|---|
| 19 | |
|---|
| 20 | #include "OgreFrameListener.h" |
|---|
| 21 | #include <OIS/OIS.h> |
|---|
| 22 | |
|---|
| 23 | class ColladaDemo; |
|---|
| 24 | |
|---|
| 25 | class UIHandler : public Ogre::FrameListener, public OIS::KeyListener, OIS::MouseListener |
|---|
| 26 | { |
|---|
| 27 | #define MINSPEED .150f |
|---|
| 28 | #define MOVESPEED 30 |
|---|
| 29 | #define MAXSPEED 1.800f |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | protected: |
|---|
| 33 | ColladaDemo* mMain; |
|---|
| 34 | |
|---|
| 35 | Ogre::Vector3 mTranslateVector; |
|---|
| 36 | bool mStatsOn; |
|---|
| 37 | unsigned int mNumScreenShots; |
|---|
| 38 | float mMoveScale; |
|---|
| 39 | float mRotScale; |
|---|
| 40 | float mSpeed; |
|---|
| 41 | float mAvgFrameTime; |
|---|
| 42 | int mSceneDetailIndex; |
|---|
| 43 | Ogre::Real mMoveSpeed; |
|---|
| 44 | Ogre::Real mRotateSpeed; |
|---|
| 45 | float mSkipCount; |
|---|
| 46 | float mUpdateFreq; |
|---|
| 47 | CEGUI::Point mLastMousePosition; |
|---|
| 48 | bool mLastMousePositionSet; |
|---|
| 49 | |
|---|
| 50 | OIS::Mouse *mMouse; |
|---|
| 51 | OIS::Keyboard *mKeyboard; |
|---|
| 52 | OIS::InputManager* mInputManager; |
|---|
| 53 | |
|---|
| 54 | float mRotX, mRotY; |
|---|
| 55 | Ogre::TextureFilterOptions mFiltering; |
|---|
| 56 | int mAniso; |
|---|
| 57 | bool mQuit; |
|---|
| 58 | bool mLMBDown; |
|---|
| 59 | bool mRMBDown; |
|---|
| 60 | bool mProcessMovement; |
|---|
| 61 | bool mUpdateMovement; |
|---|
| 62 | bool mMoveFwd; |
|---|
| 63 | bool mMoveBck; |
|---|
| 64 | bool mMoveLeft; |
|---|
| 65 | bool mMoveRight; |
|---|
| 66 | |
|---|
| 67 | CEGUI::Renderer* mGuiRenderer; |
|---|
| 68 | CEGUI::Window* mGuiAvg; |
|---|
| 69 | CEGUI::Window* mGuiCurr; |
|---|
| 70 | CEGUI::Window* mGuiBest; |
|---|
| 71 | CEGUI::Window* mGuiWorst; |
|---|
| 72 | CEGUI::Window* mGuiTris; |
|---|
| 73 | CEGUI::Window* mGuiDbg; |
|---|
| 74 | CEGUI::Window* mRoot; |
|---|
| 75 | |
|---|
| 76 | CEGUI::MouseButton convertOgreButtonToCegui(OIS::MouseButtonID b); |
|---|
| 77 | void CheckMovementKeys( CEGUI::Key::Scan keycode, bool state ); |
|---|
| 78 | void updateStats(); |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | public: |
|---|
| 82 | UIHandler(ColladaDemo* main); |
|---|
| 83 | virtual ~UIHandler(); |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | virtual bool mouseMoved (const OIS::MouseEvent &e); |
|---|
| 87 | virtual bool mouseDragged (const OIS::MouseEvent &e); |
|---|
| 88 | virtual bool keyPressed (const OIS::KeyEvent &e); |
|---|
| 89 | virtual bool keyReleased (const OIS::KeyEvent &e); |
|---|
| 90 | virtual bool mousePressed (const OIS::MouseEvent &e,OIS::MouseButtonID); |
|---|
| 91 | virtual bool mouseReleased (const OIS::MouseEvent &e,OIS::MouseButtonID); |
|---|
| 92 | |
|---|
| 93 | // do-nothing events |
|---|
| 94 | virtual bool keyClicked (const OIS::KeyEvent &e) {return false;} |
|---|
| 95 | virtual bool mouseClicked (const OIS::MouseEvent &e) {return false;} |
|---|
| 96 | virtual bool mouseEntered (const OIS::MouseEvent &e) {return false;} |
|---|
| 97 | virtual bool mouseExited (const OIS::MouseEvent &e) {return false;} |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | bool frameStarted(const Ogre::FrameEvent& evt); |
|---|
| 101 | bool handleMouseMove(const CEGUI::EventArgs& e); |
|---|
| 102 | bool handleMouseButtonUp(const CEGUI::EventArgs& e); |
|---|
| 103 | bool handleMouseButtonDown(const CEGUI::EventArgs& e); |
|---|
| 104 | bool handleMouseWheelEvent(const CEGUI::EventArgs& e); |
|---|
| 105 | bool handleKeyDownEvent(const CEGUI::EventArgs& e); |
|---|
| 106 | bool handleKeyUpEvent(const CEGUI::EventArgs& e); |
|---|
| 107 | }; |
|---|
| 108 | |
|---|
| 109 | #endif // _UIHandler_H_ |
|---|