diff options
author | HampusM <hampus@hampusmat.com> | 2022-05-02 22:36:21 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:58 +0200 |
commit | fb080f6fb911b1831c176a06259e384772541dd5 (patch) | |
tree | e18140e700cd974f84a5630f41fcb0b496b7e772 /src/game/statusline_subscriber_adapter.tpp | |
parent | 40d02748924aa7c48b04cf948204d8dacdfbbc74 (diff) |
refactor: seperate statusline related concerns
Diffstat (limited to 'src/game/statusline_subscriber_adapter.tpp')
-rw-r--r-- | src/game/statusline_subscriber_adapter.tpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/game/statusline_subscriber_adapter.tpp b/src/game/statusline_subscriber_adapter.tpp new file mode 100644 index 0000000..1de459c --- /dev/null +++ b/src/game/statusline_subscriber_adapter.tpp @@ -0,0 +1,31 @@ +#pragma once + +#include "statusline_subscriber_adapter.hpp" + +#include <utility> + +template <typename Context> +StatusLineSubscriberAdapter<Context>::StatusLineSubscriberAdapter( + std::shared_ptr<IStatusManager> status_manager, + std::string (*format_func)(std::size_t section_index, const Context &context), + const std::vector<StatusLineSection> §ions + +) noexcept + : _status_manager(std::move(status_manager)), + _format_func(format_func), + _sections(sections) +{ +} + +template <typename Context> +void StatusLineSubscriberAdapter<Context>::update(const Context &context) noexcept +{ + for (std::size_t index = 0; const auto §ion : _sections) + { + auto status = _format_func(index, context); + + _status_manager->set_section_body(_sections[index], status); + + index++; + } +} |