diff options
author | HampusM <hampus@hampusmat.com> | 2022-06-12 18:23:10 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:57:02 +0200 |
commit | 521ef3688069f5fc6b06a835454404fddaca6e80 (patch) | |
tree | dda147c27d8932697a12f02a78232382026659b9 /src/game/game.cpp | |
parent | 7399afb9ec9776dfa131dbf27ed6fb7524aec81b (diff) |
fix: add statusline length check
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r-- | src/game/game.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index 2f6c09c..e969fe1 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -16,6 +16,7 @@ #include <cstdlib> #include <filesystem> #include <iostream> +#include <stdexcept> #include <utility> Game::Game( @@ -42,7 +43,7 @@ Game::Game( { } -void Game::on_start() noexcept +void Game::on_start() { const auto scene_size = _scene->size(); @@ -55,8 +56,20 @@ void Game::on_start() noexcept const auto statusline_section_d_length = 20; const auto statusline_section_e_length = 25; const auto statusline_section_f_length = 30; - const auto statusline_section_g_length = 30; - const auto statusline_section_h_length = 20; + const auto statusline_section_g_length = 20; + const auto statusline_section_h_length = 3; + + const auto statusline_section_length_total = + statusline_section_a_length + statusline_section_b_length + + statusline_section_c_length + statusline_section_d_length + + statusline_section_e_length + statusline_section_f_length + + statusline_section_g_length + statusline_section_h_length; + + if (statusline_section_length_total > scene_size.get_width()) + { + throw std::runtime_error( + "To small window terminal size. The statusline doesn't fit"); + } statusline->set_section_length(StatusLineSection::A, statusline_section_a_length); statusline->set_section_length(StatusLineSection::B, statusline_section_b_length); |