input_command_handler.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #pragma once
  2. #include <QPointF>
  3. #include <QString>
  4. namespace Engine::Core {
  5. class World;
  6. class Entity;
  7. using EntityID = unsigned int;
  8. } // namespace Engine::Core
  9. namespace Render::GL {
  10. class Camera;
  11. }
  12. namespace Game::Systems {
  13. class SelectionSystem;
  14. class SelectionController;
  15. class PickingService;
  16. } // namespace Game::Systems
  17. namespace App::Controllers {
  18. class CommandController;
  19. }
  20. class CursorManager;
  21. class HoverTracker;
  22. struct ViewportState {
  23. int width = 0;
  24. int height = 0;
  25. };
  26. class InputCommandHandler {
  27. public:
  28. InputCommandHandler(Engine::Core::World *world,
  29. Game::Systems::SelectionController *selection_controller,
  30. App::Controllers::CommandController *command_controller,
  31. CursorManager *cursor_manager,
  32. HoverTracker *hover_tracker,
  33. Game::Systems::PickingService *picking_service,
  34. Render::GL::Camera *camera);
  35. void on_map_clicked(qreal sx, qreal sy, int local_owner_id,
  36. const ViewportState &viewport);
  37. void on_right_click(qreal sx, qreal sy, int local_owner_id,
  38. const ViewportState &viewport);
  39. void on_right_double_click(qreal sx, qreal sy, int local_owner_id,
  40. const ViewportState &viewport);
  41. void on_attack_click(qreal sx, qreal sy, const ViewportState &viewport);
  42. void on_stop_command();
  43. void on_hold_command();
  44. void on_guard_command();
  45. void on_formation_command();
  46. void on_run_command();
  47. void on_guard_click(qreal sx, qreal sy, const ViewportState &viewport);
  48. [[nodiscard]] bool any_selected_in_hold_mode() const;
  49. [[nodiscard]] bool any_selected_in_guard_mode() const;
  50. [[nodiscard]] bool any_selected_in_formation_mode() const;
  51. [[nodiscard]] bool any_selected_in_run_mode() const;
  52. [[nodiscard]] bool is_placing_formation() const;
  53. void on_formation_mouse_move(qreal sx, qreal sy,
  54. const ViewportState &viewport);
  55. void on_formation_scroll(float delta);
  56. void on_formation_confirm();
  57. void on_formation_cancel();
  58. void on_patrol_click(qreal sx, qreal sy, const ViewportState &viewport);
  59. void on_click_select(qreal sx, qreal sy, bool additive, int local_owner_id,
  60. const ViewportState &viewport);
  61. void on_area_selected(qreal x1, qreal y1, qreal x2, qreal y2, bool additive,
  62. int local_owner_id, const ViewportState &viewport);
  63. void select_all_troops(int local_owner_id);
  64. void select_unit_by_id(int unit_id, int local_owner_id);
  65. void set_hover_at_screen(qreal sx, qreal sy, const ViewportState &viewport);
  66. static void reset_movement(Engine::Core::Entity *entity);
  67. void set_spectator_mode(bool is_spectator) {
  68. m_is_spectator_mode = is_spectator;
  69. }
  70. private:
  71. Engine::Core::World *m_world;
  72. Game::Systems::SelectionController *m_selection_controller;
  73. App::Controllers::CommandController *m_command_controller;
  74. CursorManager *m_cursor_manager;
  75. HoverTracker *m_hover_tracker;
  76. Game::Systems::PickingService *m_picking_service;
  77. Render::GL::Camera *m_camera;
  78. bool m_is_spectator_mode = false;
  79. };