Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
hud.h
1 #pragma once
2 
3 #include <algorithm>
4 #include <list>
5 #include <map>
6 #include <set>
7 #include <vector>
8 
9 #include "geometry/sphere.h"
10 
11 #include "property/property.h"
12 
13 #include "utils/handle/handle.h"
14 
15 
16 enum class ClickType {
17  None,
18  Selection
19 };
20 
21 class Player;
22 class Hudget;
23 class WorldObject;
24 class HUDElements;
25 class HUDObjectDelegate;
26 class HudgetAnimation;
28 class AimHelperHudget;
29 class Viewer;
30 class WorldTreeScanner;
31 class CrossHair;
32 class TextFieldHudget;
33 
34 class HUD {
35 public:
36  HUD(Player* player);
37  ~HUD();
38 
39  Player* player();
40  const Sphere& sphere() const;
41 
42  CrossHair& crossHair();
43  AimHelperHudget& aimHelper();
44 
45  glm::vec3 centerOfView() const;
46  glm::vec3 position() const;
47  glm::quat orientation() const;
48 
49  void addHudget(Hudget* hudget);
50  void removeHudget(Hudget* hudget);
51 
52  void addObjectDelegate(HUDObjectDelegate* objectDelegate);
53  void removeObjectDelegate(HUDObjectDelegate* objectDelegate);
54 
55  HUDObjectDelegate* objectDelegate(WorldObject* worldObject);
56 
57  void setCrossHairOffset(const glm::vec2& mousePosition);
58 
59  void setTarget(WorldObject* target);
60  WorldObject* target();
61 
62  void onClick(ClickType clickType);
63 
64  void update(float deltaSec);
65  void draw();
66 
67  glm::vec3 applyTo(const glm::vec3 &vertex) const;
68 
69  float fovy() const;
70  float fovx() const;
71 
72  void showMissionInfo(const std::string& title, const std::string& caption);
73  void showMissionMessage(const std::string& message);
74  void showMessage(const std::string& message);
75 
76 
77 protected:
78  Player* m_player;
79  Viewer* m_viewer;
80  Sphere m_sphere;
81  Handle<WorldObject> m_target;
82  Property<bool> m_drawHud;
83 
84  float m_fovy;
85  float m_fovx;
86 
87  CrossHair* m_crossHair;
88  AimHelperHudget* m_aimHelper;
89 
90  std::unique_ptr<WorldTreeScanner> m_scanner;
91  std::unique_ptr<HUDElements> m_elements;
92 
93  std::map<WorldObject*, HUDObjectDelegate*> m_objectDelegates;
94 
95 
96  void updateScanner(float deltaSec);
97  void updateFov();
98 };
99 
Definition: hudget.h:15
Definition: worldobject.h:43
Definition: aimhelperhudget.h:21
Definition: hudgethideanimation.h:8
Definition: hudobjectdelegate.h:15
Definition: hudgetanimation.h:9
Definition: hud.h:34
Definition: crosshair.h:14
Definition: worldtreescanner.h:11
Definition: sphere.h:11
Definition: player.h:22
Definition: hudelements.h:18
Definition: viewer.h:12
Definition: textfieldhudget.h:12