aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-05-15 19:57:02 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:59 +0200
commit019337908e37ffee9b624b313e9d7f885bff9781 (patch)
tree7f8ba5e8b12fff7723b1af2317c3fba52c0c7011 /src/game
parent741a6008e806abb8e5aaa8f8fb91827fa97ece9d (diff)
style: change braced list & bracket style
Diffstat (limited to 'src/game')
-rw-r--r--src/game/game.cpp76
-rw-r--r--src/game/game.hpp3
-rw-r--r--src/game/status_manager.cpp6
-rw-r--r--src/game/status_manager.hpp6
-rw-r--r--src/game/statusline_subscriber_adapter.hpp3
-rw-r--r--src/game/statusline_subscriber_adapter.tpp2
6 files changed, 37 insertions, 59 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 02a0f65..4201b7b 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -17,8 +17,7 @@ Game::Game(
std::shared_ptr<IGenerationTracker> generation_tracker,
std::shared_ptr<IStatusManager> status_manager,
IStatusLineSubscriberAdapterFactory<Vector2>
- vector2_statusline_subscriber_adapter_factory
-) noexcept
+ vector2_statusline_subscriber_adapter_factory) noexcept
: _window(std::move(window)),
_scene(std::move(scene)),
_cursor_controller(std::move(cursor_controller)),
@@ -26,8 +25,7 @@ Game::Game(
_generation_tracker(std::move(generation_tracker)),
_status_manager(std::move(status_manager)),
_vector2_statusline_subscriber_adapter_factory(
- vector2_statusline_subscriber_adapter_factory
- )
+ vector2_statusline_subscriber_adapter_factory)
{
}
@@ -44,36 +42,31 @@ void Game::on_start() noexcept
std::shared_ptr<ISubscriber<Vector2>> vector2_statusline_subscriber_adapter =
_vector2_statusline_subscriber_adapter_factory(
_status_manager,
- { StatusLineSection::B, StatusLineSection::C }
- );
+ {StatusLineSection::B, StatusLineSection::C});
_cursor_controller->subscribe(
CursorEvent::POSITION_CHANGE,
- vector2_statusline_subscriber_adapter
- );
+ vector2_statusline_subscriber_adapter);
const auto window_size = _window->size();
- const auto center_position =
- Vector2({ .x = static_cast<Vector2::Value>(window_size.get_width()) / 2,
- .y = static_cast<Vector2::Value>(window_size.get_height()) / 2 });
+ const auto center_position = Vector2(
+ {.x = static_cast<Vector2::Value>(window_size.get_width()) / 2,
+ .y = static_cast<Vector2::Value>(window_size.get_height()) / 2});
_cursor_controller->move_to(center_position);
_status_manager->set_section_body(
StatusLineSection::B,
- fmt::format("{}", center_position.get_x())
- );
+ fmt::format("{}", center_position.get_x()));
_status_manager->set_section_body(
StatusLineSection::C,
- fmt::format("{}", center_position.get_y())
- );
+ fmt::format("{}", center_position.get_y()));
_status_manager->set_section_body(
StatusLineSection::D,
- _generation_tracker->get_is_paused() ? "yes" : "no"
- );
+ _generation_tracker->get_is_paused() ? "yes" : "no");
_status_manager->set_section_body(StatusLineSection::E, "0");
}
@@ -99,33 +92,24 @@ auto Game::get_input_config() const noexcept
-> std::unordered_map<char, std::shared_ptr<ICommand>>
{
return {
- { 'q', std::make_shared<QuitCommand>() },
- { 'i', std::make_shared<InsertCellCommand>(_cursor_controller, _scene) },
- { 'p',
- std::make_shared<TogglePauseCommand>(_generation_tracker, _status_manager) },
- { 'k',
- std::make_shared<MoveCursorCommand>(
- Vector2::up(),
- _cursor_controller,
- _window
- ) },
- { 'j',
- std::make_shared<MoveCursorCommand>(
- Vector2::down(),
- _cursor_controller,
- _window
- ) },
- { 'h',
- std::make_shared<MoveCursorCommand>(
- Vector2::left(),
- _cursor_controller,
- _window
- ) },
- { 'l',
- std::make_shared<MoveCursorCommand>(
- Vector2::right(),
- _cursor_controller,
- _window
- ) }
- };
+ {'q', std::make_shared<QuitCommand>()},
+ {'i', std::make_shared<InsertCellCommand>(_cursor_controller, _scene)},
+ {'p', std::make_shared<TogglePauseCommand>(_generation_tracker, _status_manager)},
+ {'k',
+ std::make_shared<MoveCursorCommand>(Vector2::up(), _cursor_controller, _window)},
+ {'j',
+ std::make_shared<MoveCursorCommand>(
+ Vector2::down(),
+ _cursor_controller,
+ _window)},
+ {'h',
+ std::make_shared<MoveCursorCommand>(
+ Vector2::left(),
+ _cursor_controller,
+ _window)},
+ {'l',
+ std::make_shared<MoveCursorCommand>(
+ Vector2::right(),
+ _cursor_controller,
+ _window)}};
}
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 9689215..fac9061 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -22,8 +22,7 @@ public:
std::shared_ptr<IGenerationTracker> generation_tracker,
std::shared_ptr<IStatusManager> status_manager,
IStatusLineSubscriberAdapterFactory<Vector2>
- vector2_statusline_subscriber_adapter_factory
- ) noexcept;
+ vector2_statusline_subscriber_adapter_factory) noexcept;
void on_start() noexcept override;
diff --git a/src/game/status_manager.cpp b/src/game/status_manager.cpp
index 727452c..927f645 100644
--- a/src/game/status_manager.cpp
+++ b/src/game/status_manager.cpp
@@ -18,8 +18,7 @@ StatusManager::StatusManager(std::shared_ptr<IStatusLine> statusline) noexcept
void StatusManager::set_section_title(
const StatusLineSection &section,
- const std::string_view &title
-) noexcept
+ const std::string_view &title) noexcept
{
if (_title_lengths.count(section) != 0)
{
@@ -34,8 +33,7 @@ void StatusManager::set_section_title(
void StatusManager::set_section_body(
const StatusLineSection &section,
- const std::string_view &body
-) noexcept
+ const std::string_view &body) noexcept
{
auto section_title_length = _title_lengths[section];
diff --git a/src/game/status_manager.hpp b/src/game/status_manager.hpp
index 62b5bc7..cdc9de5 100644
--- a/src/game/status_manager.hpp
+++ b/src/game/status_manager.hpp
@@ -17,13 +17,11 @@ public:
void set_section_title(
const StatusLineSection &section,
- const std::string_view &title
- ) noexcept override;
+ const std::string_view &title) noexcept override;
void set_section_body(
const StatusLineSection &section,
- const std::string_view &body
- ) noexcept override;
+ const std::string_view &body) noexcept override;
private:
std::shared_ptr<IStatusLine> _statusline;
diff --git a/src/game/statusline_subscriber_adapter.hpp b/src/game/statusline_subscriber_adapter.hpp
index d53ae04..c0c5805 100644
--- a/src/game/statusline_subscriber_adapter.hpp
+++ b/src/game/statusline_subscriber_adapter.hpp
@@ -15,8 +15,7 @@ public:
StatusLineSubscriberAdapter(
std::shared_ptr<IStatusManager> status_manager,
std::string (*format_func)(std::size_t section_index, const Context &context),
- const std::vector<StatusLineSection> &sections
- ) noexcept;
+ const std::vector<StatusLineSection> &sections) noexcept;
void update(const Context &context) noexcept override;
diff --git a/src/game/statusline_subscriber_adapter.tpp b/src/game/statusline_subscriber_adapter.tpp
index 1de459c..9054772 100644
--- a/src/game/statusline_subscriber_adapter.tpp
+++ b/src/game/statusline_subscriber_adapter.tpp
@@ -10,7 +10,7 @@ StatusLineSubscriberAdapter<Context>::StatusLineSubscriberAdapter(
std::string (*format_func)(std::size_t section_index, const Context &context),
const std::vector<StatusLineSection> &sections
-) noexcept
+ ) noexcept
: _status_manager(std::move(status_manager)),
_format_func(format_func),
_sections(sections)