From 7307815e99a79dac42f2a9c06b0fe6171ea11ba0 Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 1 Jul 2022 16:01:04 +0200 Subject: refactor: use ranges --- src/game/components/statusline.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/game/components/statusline.cpp') diff --git a/src/game/components/statusline.cpp b/src/game/components/statusline.cpp index aac1c27..8344c22 100644 --- a/src/game/components/statusline.cpp +++ b/src/game/components/statusline.cpp @@ -1,12 +1,11 @@ #include "statusline.hpp" #include +#include #include #include "engine/data/vector2.hpp" #include "interfaces/matrix.hpp" -#include "util/ranges.hpp" -#include "util/ranges_impl.hpp" StatusLine::StatusLine(std::shared_ptr component_matrix) noexcept : _component_matrix(std::move(component_matrix)), _need_render(false) @@ -55,7 +54,8 @@ void StatusLine::set_section_status( auto pos = Vector2({.x = section_start + start, .y = 0}); - const auto column_cnt = static_cast(_component_matrix->get_column_cnt()); + const auto column_cnt = + static_cast(_component_matrix->get_column_cnt()); const auto section_length = _section_lengths[section]; @@ -73,7 +73,7 @@ void StatusLine::set_section_status( _component_matrix->set(pos, {.value = ' ', .style = section_style}); padding_remaining--; - for (auto index : IotaView(0U, padding_remaining)) + for (auto index : ranges::views::iota(0U, padding_remaining)) { pos += Vector2::right(); @@ -103,11 +103,13 @@ void StatusLine::set_section_status( _matrix_write_string( pos, - status.substr(status_offset_start, static_cast(final_status_length))); + status.substr( + status_offset_start, + static_cast(final_status_length))); pos = pos.to_direction(Vector2::right(), final_status_length); - for (auto index : IotaView(0U, section_style.padding_right)) + for (auto index : ranges::views::iota(0U, section_style.padding_right)) { _component_matrix->set(pos, {.value = ' '}); @@ -119,7 +121,9 @@ void StatusLine::set_section_status( set_need_render(true); } -void StatusLine::set_section_length(StatusLineSection section, std::int32_t length) noexcept +void StatusLine::set_section_length( + StatusLineSection section, + std::int32_t length) noexcept { _section_lengths[section] = length; } @@ -143,7 +147,8 @@ void StatusLine::_matrix_write_string( } } -auto StatusLine::_get_section_start_x(StatusLineSection section) const noexcept -> std::int32_t +auto StatusLine::_get_section_start_x(StatusLineSection section) const noexcept + -> std::int32_t { std::int32_t section_start = 0; @@ -169,7 +174,7 @@ void StatusLine::_clear_section(StatusLineSection section, std::int32_t start) n auto section_length = _section_lengths[section]; - for (auto index : IotaView(0, section_length - start)) + for (auto index : ranges::views::iota(0, section_length - start)) { _component_matrix->set(pos, ComponentElement({.value = ' '})); -- cgit v1.2.3-18-g5258