aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-23 20:14:00 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:57 +0200
commit15c7a8fda742cc393310d75e0e1be89c3042eac0 (patch)
tree47a98f3d51cc7006d0cf8a8dfbc3fc8206064227 /src
parent486ca3846b46dc229e5807968578809766ec1991 (diff)
fix: resolve statusline overlap bug
Diffstat (limited to 'src')
-rw-r--r--src/commands/toggle_pause.cpp7
-rw-r--r--src/game/statusline.cpp8
2 files changed, 11 insertions, 4 deletions
diff --git a/src/commands/toggle_pause.cpp b/src/commands/toggle_pause.cpp
index 8a3f44c..d978bc6 100644
--- a/src/commands/toggle_pause.cpp
+++ b/src/commands/toggle_pause.cpp
@@ -17,6 +17,9 @@ void TogglePauseCommand::execute() noexcept
_generation_tracker->set_is_paused(onoff);
- _statusline->set_status(StatusLineSection::B,
- fmt::format("Paused: {}", onoff ? "yes" : "no"));
+ _statusline->set_status(
+ StatusLineSection::B,
+ fmt::format("Paused: {} Generation: {}",
+ _generation_tracker->get_is_paused() ? "yes" : "no",
+ _generation_tracker->get_current_generation()));
}
diff --git a/src/game/statusline.cpp b/src/game/statusline.cpp
index 377fa75..221258c 100644
--- a/src/game/statusline.cpp
+++ b/src/game/statusline.cpp
@@ -12,7 +12,7 @@ StatusLine::StatusLine(std::shared_ptr<ICursorController> cursor_controller,
: _cursor_controller(std::move(cursor_controller)), _window(std::move(window))
{
constexpr uint32_t SECTION_A_LENGTH = 20;
- constexpr uint32_t SECTION_B_LENGTH = 15;
+ constexpr uint32_t SECTION_B_LENGTH = 30;
_sections_lengths[StatusLineSection::A] = SECTION_A_LENGTH;
_sections_lengths[StatusLineSection::B] = SECTION_B_LENGTH;
@@ -41,7 +41,11 @@ void StatusLine::set_status(StatusLineSection section,
auto background_color = get_background_esc_seq(STATUSBAR_COLOR);
- fmt::print("{}{}", background_color, str);
+ auto section_length = _sections_lengths[section];
+
+ auto status = str.length() > section_length ? str.substr(0, section_length) : str;
+
+ fmt::print("{}{}", background_color, status);
fmt::print(RESET_ALL_MODES, fmt::arg("esc", ESC));
_move_back(previous_position);