HoverRace  2.0
HudDecor.h
Go to the documentation of this file.
1 
2 // HudDecor.h
3 //
4 // Copyright (c) 2013-2015 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "../Util/OS.h"
25 
26 #include "Container.h"
27 
28 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
29 # ifdef MR_ENGINE
30 # define MR_DllDeclare __declspec( dllexport )
31 # else
32 # define MR_DllDeclare __declspec( dllimport )
33 # endif
34 #else
35 # define MR_DllDeclare
36 #endif
37 
38 namespace HoverRace {
39  namespace Display {
40  class Display;
41  }
42  namespace Player {
43  class Player;
44  }
45  namespace Model {
46  class Track;
47  }
48 }
49 
50 namespace HoverRace {
51 namespace Display {
52 
59 {
60  using SUPER = Container;
61 
62 public:
63  struct Props
64  {
65  enum
66  {
67  PLAYER = SUPER::Props::NEXT_,
71  };
72  };
73 
74 public:
75  HudDecor(Display &display);
76  virtual ~HudDecor() { }
77 
78 public:
79  using sizeChangedSignal_t = boost::signals2::signal<void(const Vec2&)>;
80  sizeChangedSignal_t &GetSizeChangedSignal() { return sizeChangedSignal; }
81 
82 protected:
83  void FireModelUpdate(int prop) override;
84 
96  virtual void OnHudRescaled(const Vec2 &hudScale) { HR_UNUSED(hudScale); }
97 
98 public:
99  virtual void Advance(Util::OS::timestamp_t) { };
100 
101 public:
102  Player::Player *GetPlayer() const { return player.get(); }
103  std::shared_ptr<Player::Player> SharePlayer() const { return player; }
104  void SetPlayer(std::shared_ptr<Player::Player> player);
105 
106  Model::Track *GetTrack() const { return track.get(); }
107  std::shared_ptr<Model::Track> ShareTrack() const { return track; }
108  void SetTrack(std::shared_ptr<Model::Track> track);
109 
110  const Vec2 &GetHudScale() const { return hudScale; }
111  void SetHudScale(const Vec2 &hudScale);
112 
113 private:
114  std::shared_ptr<Player::Player> player;
115  std::shared_ptr<Model::Track> track;
118 };
119 
120 } // namespace Display
121 } // namespace HoverRace
122 
123 #undef MR_DllDeclare
std::shared_ptr< Player::Player > SharePlayer() const
Definition: HudDecor.h:103
Base class for UI (2D) components.
Definition: UiViewModel.h:56
virtual ~HudDecor()
Definition: HudDecor.h:76
Model::Track * GetTrack() const
Definition: HudDecor.h:106
Definition: HudDecor.h:63
std::shared_ptr< Model::Track > ShareTrack() const
Definition: HudDecor.h:107
Definition: Vec.h:38
sizeChangedSignal_t & GetSizeChangedSignal()
Definition: HudDecor.h:80
std::shared_ptr< Player::Player > player
Definition: HudDecor.h:114
Base class for display managers.
Definition: Display.h:73
sizeChangedSignal_t sizeChangedSignal
Definition: HudDecor.h:117
A track level.
Definition: Track.h:57
std::shared_ptr< Model::Track > track
Definition: HudDecor.h:115
Base view model for elements of the heads-up display.
Definition: HudDecor.h:58
boost::signals2::signal< void(const Vec2 &)> sizeChangedSignal_t
Definition: HudDecor.h:79
First index for subclasses.
Definition: HudDecor.h:70
An invisible container for other UI widgets.
Definition: Container.h:49
virtual void Advance(Util::OS::timestamp_t)
Definition: HudDecor.h:99
Definition: Announcement.h:24
Base class for connected players.
Definition: Player.h:49
const Vec2 & GetHudScale() const
Definition: HudDecor.h:110
#define MR_DllDeclare
Definition: HudDecor.h:35
virtual void OnHudRescaled(const Vec2 &hudScale)
Called when the containing HUD changes the scaling factor (that is, when the viewport changes)...
Definition: HudDecor.h:96
Vec2 hudScale
Definition: HudDecor.h:116
MR_Int64 timestamp_t
Definition: OS.h:55
Player::Player * GetPlayer() const
Definition: HudDecor.h:102