24 #include "../Util/OS.h" 25 #include "../Exception.h" 31 #if defined(_WIN32) && defined(HR_ENGINE_SHARED) 33 # define MR_DllDeclare __declspec( dllexport ) 35 # define MR_DllDeclare __declspec( dllimport ) 38 # define MR_DllDeclare 45 namespace MainCharacter {
71 PLAYER = SUPER::Props::NEXT_,
98 static const size_t NUM = NNW + 1;
108 if (t < 0 || t > NNW) {
109 std::ostringstream oss;
110 oss <<
"Invalid HUD alignment: " << t;
113 return static_cast<type>(t);
117 return t ==
NW || t ==
NE || t ==
SE || t ==
SW;
158 HudChild(std::shared_ptr<HudDecor> decor);
159 HudChild(
const HudChild&) =
delete;
160 HudChild(HudChild &&other);
162 HudChild &operator=(
const HudChild&) =
delete;
163 HudChild &operator=(HudChild &&other);
176 hud(hud), alignment(alignment)
193 template<
class T,
class... Args>
194 typename std::enable_if<
195 std::is_base_of<HudDecor, T>::value,
200 return hud.NewHudChild<T>(alignment, std::forward<Args>(args)...);
209 Hud(
Display &display, std::shared_ptr<Player::Player> player,
210 std::shared_ptr<Model::Track> track,
230 return { *
this, alignment };
242 template<
class T,
class... Args>
243 typename std::enable_if<
244 std::is_base_of<HudDecor, T>::value,
249 auto sharedChild = NewChild<T>(std::forward<Args>(args)...);
250 sharedChild->SetPlayer(player);
251 sharedChild->SetTrack(track);
252 sharedChild->SetHudScale(hudScale);
256 auto &elems = hudChildren[alignment];
257 if (!elems.empty()) {
258 RemoveChild(elems.back().decor);
265 auto &children = hudChildren[alignment];
266 children.emplace_back(sharedChild);
269 children.back().sizeChangedConn =
270 sharedChild->GetSizeChangedSignal().connect(
280 for (
auto &children : hudChildren) {
287 template<
typename Fn>
290 for (
auto &children : hudChildren) {
291 for (
auto &child : children) {
298 void SetPlayer(std::shared_ptr<Player::Player> player);
301 std::shared_ptr<Model::Track>
ShareTrack()
const {
return track; }
302 void SetTrack(std::shared_ptr<Model::Track> track);
308 void OnScreenSizeChanged();
312 double startX,
double startY,
313 double scaleX,
double scaleY);
316 double startX,
double startY,
317 double scaleX,
double scaleY);
319 virtual void Layout();
325 std::shared_ptr<Model::Track>
track;
Southeast corner, stacked right-to-left.
Definition: Hud.h:88
HudCell GetCell() const
Definition: Hud.h:304
Northeast corner, stacked top-to-bottom.
Definition: Hud.h:84
Southeast corner, only top is visible.
Definition: Hud.h:87
static Alignment AlignmentFor(type t)
Definition: Hud.h:120
Hud & hud
Definition: Hud.h:204
std::shared_ptr< Model::Track > track
Definition: Hud.h:325
virtual ~Hud()
Definition: Hud.h:212
Base class for UI (2D) components.
Definition: UiViewModel.h:56
Alignment
Imagine the component pinned to the container with a thumbtack.
Definition: UiViewModel.h:77
std::shared_ptr< HudDecor > decor
Definition: Hud.h:165
Northeast corner, only top is visible.
Definition: Hud.h:83
Center-west, stacked top-to-bottom.
Definition: Hud.h:93
Model::Track * GetTrack() const
Definition: Hud.h:300
Southwest corner, stacked bottom-to-top.
Definition: Hud.h:92
HudLocProxy(Hud &hud, HudAlignment::type alignment)
Definition: Hud.h:175
Base class for widgets that contain other widgets.
Definition: BaseContainer.h:63
Centered in the top-half of the screen.
Definition: Hud.h:79
static bool IsCorner(type t)
Definition: Hud.h:116
#define MR_DllDeclare
Definition: Hud.h:38
MR_UInt32 uiLayoutFlags_t
Definition: UiLayoutFlags.h:53
Northeast corner, stacked right-to-left.
Definition: Hud.h:82
The container for the heads-up display.
Definition: Hud.h:63
First index for subclasses.
Definition: Hud.h:73
std::shared_ptr< Player::Player > player
Definition: Hud.h:326
Base class for display managers.
Definition: Display.h:73
boost::signals2::scoped_connection sizeChangedConn
Definition: Hud.h:166
A track level.
Definition: Track.h:57
Center-east, stacked top-to-bottom.
Definition: Hud.h:85
Centered in the bottom-half of the screen.
Definition: Hud.h:80
std::vector< HudChild > hudChildList_t
Definition: Hud.h:329
virtual void Clear()
Remove all child elements.
Definition: Hud.h:278
Center-south, stacked left-to-right.
Definition: Hud.h:89
Center-north, stacked left-to-right.
Definition: Hud.h:81
boost::signals2::scoped_connection displayConfigChangedConn
Definition: Hud.h:331
std::array< hudChildList_t, HudAlignment::NUM > hudChildren
Definition: Hud.h:330
Southeast corner, stacked bottom-to-top.
Definition: Hud.h:86
Northwest corner, stacked left-to-right.
Definition: Hud.h:96
std::shared_ptr< Model::Track > ShareTrack() const
Definition: Hud.h:301
Definition: Announcement.h:24
std::enable_if< std::is_base_of< HudDecor, T >::value, std::shared_ptr< T > >::type NewChild(Args &&...args)
Append a child element at this location.
Definition: Hud.h:198
HudCell cell
Definition: Hud.h:327
Base exception, providing constructors for setting the message.
Definition: Exception.h:42
Northwest corner, only top is visible.
Definition: Hud.h:95
A reference to a HUD location; useful for adding new HUD elements.
Definition: Hud.h:172
HudCell
Split-screen HUD grid locations.
Definition: HudCell.h:28
static type FromInt(int t)
Safely convert from an int.
Definition: Hud.h:107
HudLocProxy At(HudAlignment::type alignment)
Access a HUD location.
Definition: Hud.h:228
Northwest corner, stacked top-to-bottom.
Definition: Hud.h:94
std::enable_if< std::is_base_of< HudDecor, T >::value, std::shared_ptr< T > >::type NewHudChild(HudAlignment::type alignment, Args &&...args)
Append a child element to the end of the list.
Definition: Hud.h:247
Southwest corner, stacked left-to-right.
Definition: Hud.h:90
MR_Int64 timestamp_t
Definition: OS.h:55
HudAlignment::type alignment
Definition: Hud.h:205
void ForEachHudChild(Fn fn)
Definition: Hud.h:288
void RequestLayout()
Indicate that the current layout is out-of-date and needs to be adjusted.
Definition: ViewModel.h:79
Southwest corner, only top is visible.
Definition: Hud.h:91
Vec2 hudScale
Definition: Hud.h:328