@@ -14,6 +14,8 @@ Hud::Hud(Services const& services) : ui::View(services), m_styles(&services.get<
1414
1515void Hud::set_score (std::int64_t const score) { m_score->text .set_string (fmt::format (" {}" , score)); }
1616
17+ void Hud::set_hi_score (std::int64_t const score) { m_hi_score->text .set_string (fmt::format (" HI {}" , score)); }
18+
1719void Hud::create_background () {
1820 auto background = std::make_unique<ui::OutlineQuad>();
1921 m_background = background.get ();
@@ -27,16 +29,29 @@ void Hud::create_background() {
2729void Hud::create_score (Services const & services) {
2830 auto const & rgbas = m_styles->rgbas ;
2931
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 ();
3141 m_score = text.get ();
32- text->text .set_height (TextHeight{60 });
3342 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 ;
3752 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 ) ;
4055
4156 push (std::move (text));
4257}
0 commit comments