aboutsummaryrefslogtreecommitdiff
path: root/src/game/status_manager.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-07 19:45:17 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:57:01 +0200
commit8805b1fe27344e8086cebabf869b7a02d2376f05 (patch)
treea90a2e2dda1bcb98fb4de5cd983138e5441c2222 /src/game/status_manager.cpp
parentf778317bae709f397345a2d5e04e23864c6391b3 (diff)
refactor: decouple statusline from scene & cursor controller
Might be slightly slower than previously though...
Diffstat (limited to 'src/game/status_manager.cpp')
-rw-r--r--src/game/status_manager.cpp27
1 files changed, 15 insertions, 12 deletions
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 &section,
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;
+}