00001
00002
00003
00004
00005
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
00043 namespace OgreGFX {
00044
00045 class GraphicsInteractionManager;
00046
00055 class UIMgr : public GFXMgr, public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener, public OIS::MouseListener
00056 {
00057 public:
00058 HealthBar bars;
00060 Ogre::RenderWindow* renderWindow;
00061 Ogre::SceneManager* sceneManager;
00062 Ogre::Root *ogreRoot;
00063 Ogre::Camera* camera;
00065 CameraMgr* cameraMgr;
00067 OIS::InputManager* inputManager;
00068 OIS::Mouse* mouse;
00069 OIS::Keyboard* keyboard;
00070
00071
00072 bool ctrlDown;
00073 bool shiftDown;
00074 bool altDown;
00075 OIS::MouseState ms;
00076 Ogre::Vector3 posUnderMouse;
00077
00078 bool shutDown;
00080 Ogre::RaySceneQuery* raySceneQuery;
00081 float selectionDistanceSquaredThreshold;
00082 std::list <OgreGFX::GFXNode*> currentSelections;
00083 boost::mutex selectionUpdateLock;
00084
00085 SelectionBox* selectionBox;
00086 Ogre::Vector2 startPos, stopPos;
00087 Ogre::PlaneBoundedVolumeListSceneQuery* volQuery;
00088 bool selectingNow;
00089 bool volumeSelectingNow ;
00090
00091 ControlGroupsHandler *controlGroupsHandler;
00092 Minimap *minimap;
00093
00094
00095
00096
00102 void createInputSystem();
00103
00110 void windowResized(Ogre::RenderWindow* win);
00116 void windowClosed(Ogre::RenderWindow* win);
00117
00126 virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
00136 virtual bool frameStarted(const Ogre::FrameEvent& evt);
00146 virtual bool frameEnded(const Ogre::FrameEvent& evt);
00147
00151 void DebugDrawTest();
00152
00153
00164 virtual bool keyPressed(const OIS::KeyEvent &arg);
00174 virtual bool keyReleased(const OIS::KeyEvent &arg);
00175
00185 virtual bool mouseMoved(const OIS::MouseEvent &arg);
00197 virtual bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00207 virtual bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00208
00209
00210
00219 bool registerKeyHandler(const std::set<OIS::KeyCode> *modifiers, const OIS::KeyCode arg, OgreGFX::KeyHandler *handler);
00228 bool registerMouseHandler(const std::set<OIS::KeyCode> *modifiers, const OIS::MouseButtonID arg, OgreGFX::MouseHandler *handler);
00229
00230
00237 bool callKeyHandlers(const OIS::KeyEvent &arg);
00245 bool callMouseHandlers(const OIS::MouseEvent &arg, const OIS::MouseButtonID id);
00246
00247 std::map <std::string, std::list<OgreGFX::KeyHandler *> > keyHandlers;
00248
00249
00250 std::map <std::string, std::list<OgreGFX::MouseHandler *> > mouseHandlers;
00253
00259 UIMgr(GraphicsInteractionManager *gim);
00260 ~UIMgr();
00264 void kill();
00265
00272 void updateFEEngineWithSelections();
00279 void clearSelectionsAndUpdateFEEngine();
00280
00284 void printCurrentSelections();
00285
00293 void handleSingleSelection(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00302 void handleVolumeSelection(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00311 void doVolumeSelection(const Ogre::Vector2 &first, const Ogre::Vector2 &second);
00318 void selectEntity(int index);
00325 void decorateSelectedEntities();
00332 void drawSelectionCircles();
00339 void drawUnderMouseCircle();
00340
00341 std::pair<int, Ogre::Vector3> entIndexUnderMouse();
00342 std::pair<int, Ogre::Vector3> entIndexUnderMouse(const OIS::MouseEvent &arg);
00343 std::pair<int, Ogre::Vector3> entIndexUnderMouse(const OIS::MouseState &arg);
00344
00345 void handleCommand(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00346 void CommandMaintainAttack(int index);
00347 void CommandGatherOrPFMove(int index);
00348 void CommandMove(Ogre::Vector3 pos);
00349 void CommandPotentialFieldsMove(Ogre::Vector3 pos);
00350
00351 FastEcslent::Group* groupFromSelections();
00352
00353 int rayDistanceForVolume;
00354
00355
00356 virtual void initialize();
00357
00358
00359 private:
00360 void checkSetModifiers(const OIS::KeyEvent &arg, bool value);
00361 void clearModifiersDown();
00362
00363 std::pair<bool, Ogre::Vector3> getMouseWorldPos(const OIS::MouseState &arg);
00364
00365 std::set<OIS::KeyCode> *makeModifiersSet();
00366 std::string modifierKeyHash(const OIS::KeyCode);
00367 std::string modifierKeyMouseHash(const OIS::MouseButtonID);
00368
00369
00370 };
00371
00372 }
00373
00374 #endif