uiMgr.h

Go to the documentation of this file.
00001 /*
00002  * uiMgr.h
00003  *
00004  *  Created on: Feb 18, 2012
00005  *      Author: sushil
00006  */
00007 
00008 #ifndef UIMGR_H_
00009 #define UIMGR_H_
00010 
00011 #include <list>
00012 #include <set>
00013 #include <map>
00014 
00015 
00016 #include <OgreCamera.h>
00017 #include <OgreFrameListener.h>
00018 #include <OgreWindowEventUtilities.h>
00019 #include <OgreSceneQuery.h>
00020 
00021 #include <OISEvents.h>
00022 #include <OISInputManager.h>
00023 #include <OISKeyboard.h>
00024 #include <OISMouse.h>
00025 
00026 #include <gfxNode.h>
00027 #include <gfxMgr.h>
00028 #include <cameraMgr.h>
00029 
00030 #include <selectionBox.h>
00031 
00032 #include <inputHandlers.h>
00033 #include <inputEvents.h>
00034 #include <controlGroupsHandler.h>
00035 #include <minimap.h>
00036 
00037 #include <group.h>
00038 
00039 #include <const.h>
00040 #include <enums.h>
00041 #include "HealthBar.h"
00042 #include "widgets.h"
00043 
00044 namespace OgreGFX {
00045 class GraphicsInteractionManager;
00046 class FEButton;
00047 
00056 class UIMgr : public GFXMgr, public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener, public OIS::MouseListener//, public OgreBites::SdkTrayListener
00057 {
00058 public:
00059     HealthBar bars; 
00061     Ogre::RenderWindow* renderWindow; 
00062     Ogre::SceneManager* sceneManager; 
00063             Ogre::Root *ogreRoot;
00064     Ogre::Camera* camera; 
00066     CameraMgr* cameraMgr; 
00068     OIS::InputManager* inputManager; 
00069     OIS::Mouse* mouse; 
00070     OIS::Keyboard* keyboard; 
00071     //OgreBites::SdkTrayManager* mTrayMgr; /* Used for managing default UI elements such as buttons, provided by the OGRE library */
00072 
00073     bool ctrlDown; 
00074     bool shiftDown; 
00075     bool altDown; 
00076     OIS::MouseState ms; 
00077             Ogre::Vector3 posUnderMouse;
00078             FEButton* buttonActive; 
00080     bool shutDown; 
00082                 Ogre::RaySceneQuery* raySceneQuery;
00083     float selectionDistanceSquaredThreshold; 
00084     std::list <OgreGFX::GFXNode*> currentSelections; 
00085                 boost::mutex selectionUpdateLock;
00086 
00087     SelectionBox* selectionBox; 
00088     Ogre::Vector2 startPos, stopPos; 
00089     Ogre::PlaneBoundedVolumeListSceneQuery* volQuery; 
00090     bool selectingNow; /* Switch for detecting if the user in the process of a mouse click and drag, for unit mass selection */
00091     bool volumeSelectingNow /* Switch for detecting if the user in the process of a mouse click and drag, for unit mass selection */;
00092 
00093     ControlGroupsHandler *controlGroupsHandler; 
00094     Minimap *minimap; 
00095                 //std::list<Ogre::MovableObject*> selected;
00096     Ogre::SceneNode* ghostUnderMouse;
00097     std::list<std::pair<std::deque<FastEcslent::Command*>, Ogre::SceneNode*> > waitingGhosts;
00098     
00099     void CreateGhostUnderMouse(std::string meshName);
00100     void DestroyGhostUnderMouse(Ogre::SceneNode* node);
00101 
00102     //HealthBar bar;
00103 
00109             void createInputSystem();
00110 
00117             void windowResized(Ogre::RenderWindow* win);
00123             void windowClosed(Ogre::RenderWindow* win);
00124 
00133             virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
00143             virtual bool frameStarted(const Ogre::FrameEvent& evt);
00153             virtual bool frameEnded(const Ogre::FrameEvent& evt);
00154 
00158             void DebugDrawTest();
00159 
00160             // OIS::KeyListener
00171     virtual bool keyPressed(const OIS::KeyEvent &arg);
00181     virtual bool keyReleased(const OIS::KeyEvent &arg);
00182             // OIS::MouseListener
00192     virtual bool mouseMoved(const OIS::MouseEvent &arg);
00204     virtual bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00214     virtual bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00215     
00216     virtual void ChangeGhostTextureRBGA(Ogre::SceneNode* ghost,Ogre::ColourValue color);
00217     virtual Ogre::ColourValue GetGhostTextureRBGA(Ogre::SceneNode* ghost);
00218     virtual void IncreaseGhostAlpha(Ogre::SceneNode* ghost,int percentIncrease);
00219 
00220 
00221             //Key and mouse handlers handling
00230     bool registerKeyHandler(const std::set<OIS::KeyCode> *modifiers, const OIS::KeyCode arg, OgreGFX::KeyHandler *handler);
00239             bool registerMouseHandler(const std::set<OIS::KeyCode> *modifiers, const OIS::MouseButtonID arg, OgreGFX::MouseHandler *handler);
00240 
00241 
00248             bool callKeyHandlers(const OIS::KeyEvent &arg);
00256             bool callMouseHandlers(const OIS::MouseEvent &arg, const OIS::MouseButtonID id);
00257 
00258     std::map <std::string, std::list<OgreGFX::KeyHandler *> > keyHandlers; 
00259             //std::map <std::string, OgreGFX::KeyHandler *> keyHandlers;
00260             //std::map <std::string, OgreGFX::MouseHandler *> mouseHandlers;
00261     std::map <std::string, std::list<OgreGFX::MouseHandler *> > mouseHandlers; 
00264             //UIMgr(Engine* eng, Ogre::RenderWindow* win, Ogre::SceneManager *sm, Ogre::Camera* cam);
00270     UIMgr(GraphicsInteractionManager *gim); //Engine* eng, Ogre::RenderWindow* win, Ogre::SceneManager *sm, Ogre::Camera* cam);
00271             ~UIMgr();
00275             void kill();
00276 
00283             void updateFEEngineWithSelections();
00290             void clearSelectionsAndUpdateFEEngine();
00291 
00295             void printCurrentSelections();
00296 
00304     void handleSingleSelection(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00313     void handleVolumeSelection(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00322             void doVolumeSelection(const Ogre::Vector2 &first, const Ogre::Vector2 &second);
00329             void selectEntity(int index);
00336             void decorateSelectedEntities();
00343             void drawSelectionCircles();
00350             void drawUnderMouseCircle();
00351 
00352             std::pair<int, Ogre::Vector3> entIndexUnderMouse();
00353             std::pair<int, Ogre::Vector3> entIndexUnderMouse(const OIS::MouseEvent &arg);
00354             std::pair<int, Ogre::Vector3> entIndexUnderMouse(const OIS::MouseState &arg);
00355 
00356             void handleCommand(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00357             void CommandMaintainAttack(int index);
00358             void CommandGatherOrPFMove(int index);
00359             void CommandMove(Ogre::Vector3 pos);
00360             void CommandPotentialFieldsMove(Ogre::Vector3 pos);
00361 
00362             FastEcslent::Group* groupFromSelections();
00363 
00364             int rayDistanceForVolume;
00365 
00366 
00367             virtual void initialize();
00368 //    virtual void buttonHit(OgreBites::Button* button);
00369 
00370         private:
00371             void checkSetModifiers(const OIS::KeyEvent &arg, bool value);
00372             void clearModifiersDown();
00373 
00374     std::pair<bool, Ogre::Vector3> getMouseWorldPos(const OIS::MouseState &arg);
00375 
00376             std::set<OIS::KeyCode> *makeModifiersSet();
00377             std::string modifierKeyHash(const OIS::KeyCode);
00378             std::string modifierKeyMouseHash(const OIS::MouseButtonID);
00379 
00380 
00381         };
00382 
00383 }
00384 
00385 #endif /* UIMGR_H_ */

Generated on Fri Dec 13 14:54:16 2013 for FastECSLent by  doxygen 1.5.4