diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/game.cpp | 2 | ||||
-rw-r--r-- | src/game/status_manager.cpp | 27 | ||||
-rw-r--r-- | src/game/status_manager.hpp | 4 |
3 files changed, 20 insertions, 13 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index 064b643..8d72324 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -27,6 +27,8 @@ Game::Game( void Game::on_start() noexcept { + _scene->register_component(_status_manager->get_statusline(), Vector2({0, 0})); + _status_manager->initialize(); _status_manager->set_section_title(StatusLineSection::A, ""); diff --git a/src/game/status_manager.cpp b/src/game/status_manager.cpp index 3f2df01..c7d80e9 100644 --- a/src/game/status_manager.cpp +++ b/src/game/status_manager.cpp @@ -12,23 +12,21 @@ StatusManager::StatusManager(std::shared_ptr<IStatusLine> statusline) noexcept void StatusManager::initialize() noexcept { - _statusline->set_section_length(StatusLineSection::A, 5U); - _statusline->set_section_length(StatusLineSection::B, 15U); - _statusline->set_section_length(StatusLineSection::C, 15U); - _statusline->set_section_length(StatusLineSection::D, 20U); - _statusline->set_section_length(StatusLineSection::E, 25U); - _statusline->set_section_length(StatusLineSection::F, 60U); - _statusline->set_section_length(StatusLineSection::G, 30U); - _statusline->set_section_length(StatusLineSection::H, 30U); - - _statusline->initialize_background(); + _statusline->set_section_length(StatusLineSection::A, 5); + _statusline->set_section_length(StatusLineSection::B, 15); + _statusline->set_section_length(StatusLineSection::C, 15); + _statusline->set_section_length(StatusLineSection::D, 20); + _statusline->set_section_length(StatusLineSection::E, 25); + _statusline->set_section_length(StatusLineSection::F, 60); + _statusline->set_section_length(StatusLineSection::G, 30); + _statusline->set_section_length(StatusLineSection::H, 30); } void StatusManager::set_section_title( const StatusLineSection §ion, const std::string_view &title) noexcept { - if (_title_lengths.count(section) != 0) + if (_title_lengths.contains(section)) { fmt::print(stderr, "Error: can't set statusbar section title more than once"); return; @@ -36,7 +34,7 @@ void StatusManager::set_section_title( _statusline->set_status(section, title); - _title_lengths[section] = title.length(); + _title_lengths[section] = static_cast<int>(title.length()); } void StatusManager::set_section_body( @@ -47,3 +45,8 @@ void StatusManager::set_section_body( _statusline->set_status(section, body, section_title_length + 1); } + +auto StatusManager::get_statusline() const noexcept -> std::shared_ptr<IStatusLine> +{ + return _statusline; +} diff --git a/src/game/status_manager.hpp b/src/game/status_manager.hpp index 7bb4f2f..245e888 100644 --- a/src/game/status_manager.hpp +++ b/src/game/status_manager.hpp @@ -24,8 +24,10 @@ public: const StatusLineSection §ion, const std::string_view &body) noexcept override; + auto get_statusline() const noexcept -> std::shared_ptr<IStatusLine> override; + private: std::shared_ptr<IStatusLine> _statusline; - std::unordered_map<StatusLineSection, std::size_t> _title_lengths; + std::unordered_map<StatusLineSection, int32_t> _title_lengths; }; |