Emergency 20 Dokumentation  4.2.0
GameInputHandler.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
14 #include "em5/audio/AudioProxy.h"
15 
17 
18 #include <glm/glm.hpp>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace qsf
25 {
26  class Entity;
27  class Component;
28  class KeyboardEvent;
29  class MouseButtonEvent;
30  class MouseMoveEvent;
31  class EntitySelectionRectangle;
32  namespace game
33  {
34  class CommandManager;
35  }
36 }
37 
38 
39 //[-------------------------------------------------------]
40 //[ Namespace ]
41 //[-------------------------------------------------------]
42 namespace em5
43 {
44 
45 
46  //[-------------------------------------------------------]
47  //[ Classes ]
48  //[-------------------------------------------------------]
54  {
55 
56 
57  //[-------------------------------------------------------]
58  //[ Public methods ]
59  //[-------------------------------------------------------]
60  public:
65  explicit GameInputHandler(uint32 id);
66 
71  virtual ~GameInputHandler();
72 
77  bool isCurrentCommandButtonPressedByIndex(size_t index) const;
78 
83  void resetCurrentCommandButtonPressed();
84 
89  bool getRightMouseButtonWasDragged() const;
90 
91 
92  //[-------------------------------------------------------]
93  //[ Protected virtual qsf::InputHandler methods ]
94  //[-------------------------------------------------------]
95  protected:
96  virtual void updateInputHandler(const qsf::Time& timePassed) override;
97 
98 
99  //[-------------------------------------------------------]
100  //[ Protected virtual qsf::InputListener methods ]
101  //[-------------------------------------------------------]
102  protected:
103  virtual void eventReceived(const qsf::InputEvent& inputEvent, Response& response) override;
104 
105 
106  //[-------------------------------------------------------]
107  //[ Private methods ]
108  //[-------------------------------------------------------]
109  private:
110  qsf::Entity* getEntityForSelection(const qsf::Component& component) const;
111 
112  void processKeyboardEvent(const qsf::KeyboardEvent& keyboardEvent);
113  void processMouseButtonEvent(const qsf::MouseButtonEvent& mouseButtonEvent);
114 
115  void onLeftDown(const qsf::MouseButtonEvent& mouseButtonEvent);
116  void onLeftUp(const qsf::MouseButtonEvent& mouseButtonEvent);
117  void onLeftClick(const qsf::MouseButtonEvent& mouseButtonEvent);
118 
119  void onRightDown(const qsf::MouseButtonEvent& mouseButtonEvent);
120  void onRightUp(const qsf::MouseButtonEvent& mouseButtonEvent);
121  void onRightClick(const qsf::MouseButtonEvent& mouseButtonEvent);
122 
123  void onEscape();
124  // Pressed the number [1-9] on non numpad to select or save unit group
125  void onNumber(uint32 pressedGroup, bool anyControlPressed);
126  // Opens the chat window in multip player game if it is hidden
127  void onReturn();
128 
129  void selectNextUnit(bool forward, bool jumpToUnit);
130  void selectNextUnitSameType(bool forward);
131  uint64 getNextUnitInList(const std::vector<uint64>& unitIds, uint64 selectedId, bool forward) const;
132 
140  void updateDebugCommandBox();
141 
142  SelectionManager::IdSet getAllSameUnits(qsf::Entity& entity) const;
143  SelectionManager::IdSet getAllSameVisibleUnits(qsf::Entity& entity) const;
144 
145  void goToNextFreeplayEvent();
146 
147 
148  //[-------------------------------------------------------]
149  //[ Private data ]
150  //[-------------------------------------------------------]
151  private:
152  qsf::EntitySelectionRectangle* mSelectionRectangle;
153  bool mLeftMouseButtonDown;
154  bool mRightMouseButtonDown;
155  glm::vec2 mRightMouseButtonDragStart;
156  bool mRightMouseButtonWasDragged;
157 
158  // Double click
159  glm::vec2 mDoubleClickStart;
160  bool mDoubleClickIsActive;
161  qsf::Time mDoubleClickDuration;
162 
163  // Key press
164  uint32 mCurrentCommandButtonPressed; // Watches if a commando shortcut key is pressed and detects the key release event; 0 = no key is pressed
165 
166  AudioProxy mAudioProxy;
167 
168  bool mCurrentInputBlockedState;
169 
170  // For cycling through active events
171  int mCurrentEventIndex;
172 
173 
174  };
175 
176 
177 //[-------------------------------------------------------]
178 //[ Namespace ]
179 //[-------------------------------------------------------]
180 } // em5
Definition: ActionPriority.h:13
Pixel space selection rectangle for selecting entities.
Definition: EntitySelectionRectangle.h:41
Abstract component class.
Definition: Component.h:105
Entity class.
Definition: Entity.h:46
Input handler base class.
Definition: InputHandler.h:40
unsigned int uint32
Definition: PlatformTypes.h:181
Input event base class.
Definition: InputEvent.h:40
#define EM5_API_EXPORT
Definition: Export.h:28
uint64_t uint64
Definition: PlatformTypes.h:184
boost::container::flat_set< uint64 > IdSet
Definition: SelectionManagerTemplate.h:52
Definition: PickupPersonByParamedicAction.h:21
Mouse button event class.
Definition: MouseButtonEvent.h:46
Extended audio proxy for easier multiplay usage.
Definition: AudioProxy.h:47
Keyboard event class.
Definition: KeyboardEvent.h:44
Definition: InputListener.h:51
EMERGENCY 5 main game input handler class.
Definition: GameInputHandler.h:53
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32