WindowSystem.h
Upload User: wegemann
Upload Date: 2020-01-03
Package Size: 3891k
Code Size: 3k
Category:

Game Engine

Development Platform:

Visual C++

  1. #ifndef _WINDOW_SYSTEM_H
  2. #define _WINDOW_SYSTEM_H
  3. #include "Window/WndSysBase.h"
  4. #include <queue>
  5. #include "OIS/ois.h"
  6. #include "Ogre/OgreRenderWindow.h"
  7. #include "Ogre/OgreVector2.h"
  8. #define SYS_MOUSE_LEFT 0x01
  9. #define SYS_MOUSE_RIGHT 0x02
  10. #define SYS_MOUSE_MIDDLE 0x03
  11. #define SYS_MOUSE_BUTTON3 0x04
  12. #define SYS_MOUSE_BUTTON4 0x05
  13. #define SYS_MOUSE_BUTTON5 0x06
  14. #define SYS_MOUSE_BUTTON6 0x07
  15. #define SYS_MOUSE_BUTTON7 0x08
  16. class FadeSystem;
  17. class WindowSystem : public SingletonT<WindowSystem>
  18. {
  19. public:
  20. WindowSystem();
  21. ~WindowSystem();
  22. public:
  23. typedef std::vector<WndBase*> SingleShowControls;
  24. bool init(Ogre::RenderWindow* win,Ogre::SceneManager* pSceneMgr);
  25. void destroy();
  26. WndBase* getRootWindow();
  27. void renderStarted();
  28. void renderEnded();
  29. void process();
  30. void operation(float deltaTime);
  31. HRESULT winProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,bool& handled);
  32. void onWindowLost(WndBase* win);
  33. void activeWindow(WndBase* win);
  34. void unactuatedWindow(WndBase* win);
  35. bool getMouseOnWindow();
  36. void setLeftDown(bool down);
  37. bool getLeftDown();
  38. WndBase* getTopWindow();
  39. void clearTopWindow();
  40. Window*  getParentWindow(WndBase* win);
  41. // OIS的输入处理
  42. bool onKeyDown(Ogre::uint key);
  43. bool onChar(Ogre::uint32 code);
  44. bool onKeyUp(Ogre::uint key);
  45. bool onKeyClick(Ogre::uint key);
  46. bool onMouseButtonDown(int button);
  47. bool onMouseButtonDoubleClick(int button);
  48. bool onMouseButtonUp(int button);
  49. bool onMouseMove(float delta_x, float delta_y);
  50. // windows消息
  51. bool onMouseWheel(int delta);
  52. void addSingleShowControl(WndBase* base);
  53. void removeSingleShowControl(WndBase* base);
  54. private:
  55. bool handleMouseLeftDown(); // 鼠标按下
  56. bool handleMouseLeftUp(); // 鼠标抬起
  57. bool handleMouseRightDown();
  58. bool handleMouseRightUp();
  59. bool handleMouseWheel(int delta);
  60. bool handleMouseMove(); // 鼠标移动
  61. bool onDoubleClick(); // 双击
  62. bool handleKeyDown(WPARAM wParam);
  63. bool handleKeyUp(WPARAM wParam);
  64. bool handleKeyClick(WPARAM wParam);
  65. bool handleChar(unsigned int code);
  66. private:
  67. WndBase* getTargetWindow(Point pos, bool check_handle = true);
  68. bool getExactnessCursorIndex(int &id);
  69. private:
  70. WndBase* m_focusWindow;
  71. //Window* m_focusWindowForKeyHandle;
  72. WndBase* m_focusWindowForKeyHandle;
  73. WndBase* m_mouseLeftDownWindow;
  74. WndBase* m_mouseRightDownWindow;
  75. WndBase* m_mouseOnWindow;
  76. WndBase* m_topWindow;
  77. WndBase* m_rootWindow;
  78. bool m_bLeftDown; // 鼠标左键在控件上按下
  79. bool m_bReturnDown;
  80. Ogre::RenderWindow* m_pWindow;
  81. bool m_bCursorSHow;
  82. SingleShowControls mSingleShowControls; // 没有父窗体的独立控件
  83. FadeSystem* mFadeSystem; // 淡入淡出系统
  84. };
  85. #endif // _WINDOW_SYSTEM_H