@@ -14,6 +14,8 @@ Hud::Hud(Services const& services) : ui::View(services), m_styles(&services.get<
14
14
15
15
void Hud::set_score (std::int64_t const score) { m_score->text .set_string (fmt::format (" {}" , score)); }
16
16
17
+ void Hud::set_hi_score (std::int64_t const score) { m_hi_score->text .set_string (fmt::format (" HI {}" , score)); }
18
+
17
19
void Hud::create_background () {
18
20
auto background = std::make_unique<ui::OutlineQuad>();
19
21
m_background = background.get ();
@@ -27,16 +29,29 @@ void Hud::create_background() {
27
29
void Hud::create_score (Services const & services) {
28
30
auto const & rgbas = m_styles->rgbas ;
29
31
30
- auto text = std::make_unique<ui::Text>(services);
32
+ auto make_text = [&] {
33
+ auto text = std::make_unique<ui::Text>(services);
34
+ text->text .set_height (TextHeight{60 });
35
+ text->text .transform .position = m_area.centre ();
36
+ text->text .tint = rgbas[" grey" ];
37
+ return text;
38
+ };
39
+
40
+ auto text = make_text ();
31
41
m_score = text.get ();
32
- text->text .set_height (TextHeight{60 });
33
42
text->text .set_string (" 9999999999" );
34
- auto const text_bounds = text->text .get_bounds ();
35
- auto const text_bounds_size = text_bounds.size ();
36
- text->text .transform .position = m_area.centre ();
43
+ auto const text_bounds_size = text->text .get_bounds ().size ();
44
+ text->text .transform .position .y -= 0 .5f * text_bounds_size.y ;
45
+ set_score (0 );
46
+
47
+ push (std::move (text));
48
+
49
+ text = make_text ();
50
+ m_hi_score = text.get ();
51
+ text->text .transform .position .x = m_area.rb .x - 50 .0f ;
37
52
text->text .transform .position .y -= 0 .5f * text_bounds_size.y ;
38
- text->text .set_string ( " 0 " );
39
- text-> text . tint = rgbas[ " grey " ] ;
53
+ text->text .set_align (bave::Text::Align::eLeft );
54
+ set_hi_score ( 0 ) ;
40
55
41
56
push (std::move (text));
42
57
}
0 commit comments