diff options
author | HampusM <hampus@hampusmat.com> | 2022-05-15 19:57:02 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:59 +0200 |
commit | 019337908e37ffee9b624b313e9d7f885bff9781 (patch) | |
tree | 7f8ba5e8b12fff7723b1af2317c3fba52c0c7011 /src/engine | |
parent | 741a6008e806abb8e5aaa8f8fb91827fa97ece9d (diff) |
style: change braced list & bracket style
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/data/vector2.cpp | 2 | ||||
-rw-r--r-- | src/engine/data/vector2.hpp | 8 | ||||
-rw-r--r-- | src/engine/engine.cpp | 12 | ||||
-rw-r--r-- | src/engine/engine.hpp | 6 | ||||
-rw-r--r-- | src/engine/graphics/scene.cpp | 5 | ||||
-rw-r--r-- | src/engine/graphics/scene.hpp | 3 | ||||
-rw-r--r-- | src/engine/graphics/statusline.cpp | 19 | ||||
-rw-r--r-- | src/engine/graphics/statusline.hpp | 10 | ||||
-rw-r--r-- | src/engine/graphics/window.cpp | 2 | ||||
-rw-r--r-- | src/engine/matrix_iterator.tpp | 3 | ||||
-rw-r--r-- | src/engine/user/cursor.cpp | 13 | ||||
-rw-r--r-- | src/engine/user/cursor.hpp | 10 | ||||
-rw-r--r-- | src/engine/user/input.cpp | 3 | ||||
-rw-r--r-- | src/engine/user/input.hpp | 3 |
14 files changed, 39 insertions, 60 deletions
diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp index 6d8ebad..0f203d0 100644 --- a/src/engine/data/vector2.cpp +++ b/src/engine/data/vector2.cpp @@ -25,7 +25,7 @@ void Vector2::set_y(Vector2::Value y) noexcept auto Vector2::to_direction(const Vector2 &direction, Vector2::Value amount) const noexcept -> Vector2 { - return *this + (direction * Vector2({ .x = amount, .y = amount })); + return *this + (direction * Vector2({.x = amount, .y = amount})); } auto Vector2::operator+=(const Vector2 &rhs) noexcept -> const Vector2 & diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp index a6de35e..15df88f 100644 --- a/src/engine/data/vector2.hpp +++ b/src/engine/data/vector2.hpp @@ -48,7 +48,7 @@ public: */ static constexpr auto up() noexcept -> Vector2 { - return Vector2({ .x = 0, .y = -1 }); + return Vector2({.x = 0, .y = -1}); } /** @@ -56,7 +56,7 @@ public: */ static constexpr auto down() noexcept -> Vector2 { - return Vector2({ .x = 0, .y = 1 }); + return Vector2({.x = 0, .y = 1}); } /** @@ -65,7 +65,7 @@ public: static constexpr auto left() noexcept -> Vector2 { - return Vector2({ .x = -1, .y = 0 }); + return Vector2({.x = -1, .y = 0}); } /** @@ -73,7 +73,7 @@ public: */ static constexpr auto right() noexcept -> Vector2 { - return Vector2({ .x = 1, .y = 0 }); + return Vector2({.x = 1, .y = 0}); } private: diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 3bf8503..4ac6a37 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -10,8 +10,7 @@ CLIGameEngine::CLIGameEngine( ISceneFactory scene_factory, std::shared_ptr<IInputHandler> input_handler, std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window -) noexcept + std::shared_ptr<IWindow> window) noexcept : _game_factory(std::move(game_factory)), _scene_factory(std::move(scene_factory)), _input_handler(std::move(input_handler)), @@ -38,8 +37,7 @@ void CLIGameEngine::start() noexcept _input_handler->leave_raw_mode(); game->on_exit(); - } - )); + })); _configure_input(game->get_input_config()); @@ -47,8 +45,7 @@ void CLIGameEngine::start() noexcept [this]() { _input_handler->listen(); - } - )); + })); while (true) { @@ -57,8 +54,7 @@ void CLIGameEngine::start() noexcept } void CLIGameEngine::_configure_input( - const std::unordered_map<char, std::shared_ptr<ICommand>> &input_config -) noexcept + const std::unordered_map<char, std::shared_ptr<ICommand>> &input_config) noexcept { for (const auto &config_pair : input_config) { diff --git a/src/engine/engine.hpp b/src/engine/engine.hpp index cf162d9..5073553 100644 --- a/src/engine/engine.hpp +++ b/src/engine/engine.hpp @@ -29,8 +29,7 @@ public: ISceneFactory scene_factory, std::shared_ptr<IInputHandler> input_handler, std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window - ) noexcept; + std::shared_ptr<IWindow> window) noexcept; void start() noexcept override; @@ -43,6 +42,5 @@ private: std::shared_ptr<IWindow> _window; void _configure_input( - const std::unordered_map<char, std::shared_ptr<ICommand>> &input_config - ) noexcept; + const std::unordered_map<char, std::shared_ptr<ICommand>> &input_config) noexcept; }; diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp index d5cf89b..73c1292 100644 --- a/src/engine/graphics/scene.cpp +++ b/src/engine/graphics/scene.cpp @@ -11,10 +11,9 @@ Scene::Scene( IMatrixFactory<std::string_view> matrix_factory, std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window -) noexcept + std::shared_ptr<IWindow> window) noexcept : _is_shown(false), - _matrix(matrix_factory(window->size() - Bounds({ .width = 0U, .height = 1U }))), + _matrix(matrix_factory(window->size() - Bounds({.width = 0U, .height = 1U}))), _cursor_controller(std::move(cursor_controller)), _window(std::move(window)) { diff --git a/src/engine/graphics/scene.hpp b/src/engine/graphics/scene.hpp index aaf0095..5e74725 100644 --- a/src/engine/graphics/scene.hpp +++ b/src/engine/graphics/scene.hpp @@ -18,8 +18,7 @@ public: explicit Scene( IMatrixFactory<std::string_view> matrix_factory, std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window - ) noexcept; + std::shared_ptr<IWindow> window) noexcept; void enter() noexcept override; diff --git a/src/engine/graphics/statusline.cpp b/src/engine/graphics/statusline.cpp index 1abb87b..3968fae 100644 --- a/src/engine/graphics/statusline.cpp +++ b/src/engine/graphics/statusline.cpp @@ -8,8 +8,7 @@ StatusLine::StatusLine( std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window -) noexcept + std::shared_ptr<IWindow> window) noexcept : _cursor_controller(std::move(cursor_controller)), _window(std::move(window)) { } @@ -29,8 +28,7 @@ void StatusLine::initialize_background() noexcept void StatusLine::set_status( const StatusLineSection §ion, const std::string_view &status, - std::size_t start -) noexcept + std::size_t start) noexcept { _clear_section(section, start); @@ -51,8 +49,7 @@ void StatusLine::set_status( void StatusLine::set_section_length( const StatusLineSection §ion, - uint32_t length -) noexcept + uint32_t length) noexcept { _sections_lengths[section] = length; } @@ -67,7 +64,7 @@ auto StatusLine::_move_to_statusline(int32_t x) noexcept -> Vector2 auto window_height = static_cast<Vector2::Value>(window_size.get_height()); - _cursor_controller->move_to(Vector2({ .x = x, .y = window_height }), true); + _cursor_controller->move_to(Vector2({.x = x, .y = window_height}), true); return previous_position; } @@ -87,9 +84,8 @@ auto StatusLine::_get_section_start_x(const StatusLineSection §ion) const no while (section_index > 0) { - section_start += - static_cast<int32_t>(_sections_lengths.at(StatusLineSection(section_index - 1) - )); + section_start += static_cast<int32_t>( + _sections_lengths.at(StatusLineSection(section_index - 1))); section_index--; } @@ -99,8 +95,7 @@ auto StatusLine::_get_section_start_x(const StatusLineSection §ion) const no void StatusLine::_clear_section( const StatusLineSection §ion, - std::size_t start -) noexcept + std::size_t start) noexcept { auto section_start = _get_section_start_x(section); diff --git a/src/engine/graphics/statusline.hpp b/src/engine/graphics/statusline.hpp index 181090d..add8e02 100644 --- a/src/engine/graphics/statusline.hpp +++ b/src/engine/graphics/statusline.hpp @@ -19,16 +19,14 @@ class StatusLine : public IStatusLine public: StatusLine( std::shared_ptr<ICursorController> cursor_controller, - std::shared_ptr<IWindow> window - ) noexcept; + std::shared_ptr<IWindow> window) noexcept; void initialize_background() noexcept override; void set_status( const StatusLineSection §ion, const std::string_view &status, - std::size_t start - ) noexcept override; + std::size_t start) noexcept override; void set_section_length(const StatusLineSection §ion, uint32_t length) noexcept override; @@ -43,8 +41,8 @@ private: void _move_back(Vector2 previous_position) noexcept; - [[nodiscard]] auto _get_section_start_x(const StatusLineSection §ion - ) const noexcept -> int32_t; + [[nodiscard]] auto + _get_section_start_x(const StatusLineSection §ion) const noexcept -> int32_t; void _clear_section(const StatusLineSection §ion, std::size_t start) noexcept; }; diff --git a/src/engine/graphics/window.cpp b/src/engine/graphics/window.cpp index 2d880fc..bb33402 100644 --- a/src/engine/graphics/window.cpp +++ b/src/engine/graphics/window.cpp @@ -9,5 +9,5 @@ auto Window::size() const noexcept -> Bounds // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) ioctl(0, TIOCGWINSZ, &window_size); - return Bounds({ window_size.ws_col, window_size.ws_row }); + return Bounds({window_size.ws_col, window_size.ws_row}); } diff --git a/src/engine/matrix_iterator.tpp b/src/engine/matrix_iterator.tpp index 9697861..4b2c785 100644 --- a/src/engine/matrix_iterator.tpp +++ b/src/engine/matrix_iterator.tpp @@ -73,8 +73,7 @@ auto MatrixRow<Element>::end() const noexcept -> MatrixRowIterator<Element> template <typename Element> MatrixIterator<Element>::MatrixIterator( RowPtr row_ptr, - const uint32_t &column_cnt -) noexcept + const uint32_t &column_cnt) noexcept : _row_ptr(row_ptr), _column_cnt(column_cnt) { } diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp index 71f02da..945433b 100644 --- a/src/engine/user/cursor.cpp +++ b/src/engine/user/cursor.cpp @@ -5,7 +5,7 @@ #include <cstdlib> #include <iostream> -CursorController::CursorController() noexcept : _position({ .x = 0, .y = 0 }) {} +CursorController::CursorController() noexcept : _position({.x = 0, .y = 0}) {} void CursorController::move(const Vector2 &direction, const uint32_t &amount) noexcept { @@ -14,8 +14,7 @@ void CursorController::move(const Vector2 &direction, const uint32_t &amount) no fmt::print( fmt::runtime(direction_format.data()), fmt::arg("esc", ESC), - fmt::arg("amount", amount) - ); + fmt::arg("amount", amount)); std::cout.flush(); _position = _position.to_direction(direction, static_cast<Vector2::Value>(amount)); @@ -29,8 +28,7 @@ void CursorController::move_to(const Vector2 &position, bool silent) noexcept MOVE_CURSOR_TO, fmt::arg("esc", ESC), fmt::arg("row", position.get_y()), - fmt::arg("column", position.get_x()) - ); + fmt::arg("column", position.get_x())); std::cout.flush(); _position = position; @@ -75,12 +73,11 @@ void CursorController::show() noexcept void CursorController::subscribe( const Event &event, - const Subscriber &subscriber -) noexcept + const Subscriber &subscriber) noexcept { if (_subscribers.count(event) == 0) { - _subscribers.insert({ event, std::vector<Subscriber>() }); + _subscribers.insert({event, std::vector<Subscriber>()}); } _subscribers.at(event).push_back(subscriber); diff --git a/src/engine/user/cursor.hpp b/src/engine/user/cursor.hpp index 080321e..ae6fe3c 100644 --- a/src/engine/user/cursor.hpp +++ b/src/engine/user/cursor.hpp @@ -24,11 +24,11 @@ constexpr fmt::string_view REQUEST_CURSOR_POSITION = "{esc}[6n"; constexpr fmt::string_view CURSOR_VISIBLE = "{esc}[?25h"; constexpr fmt::string_view CURSOR_INVISIBLE = "{esc}[?25l"; -const std::unordered_map<Vector2, std::string_view, Vector2Hasher> - direction_format_map = { { Vector2::up(), MOVE_CURSOR_UP }, - { Vector2::down(), MOVE_CURSOR_DOWN }, - { Vector2::left(), MOVE_CURSOR_LEFT }, - { Vector2::right(), MOVE_CURSOR_RIGHT } }; +const std::unordered_map<Vector2, std::string_view, Vector2Hasher> direction_format_map = + {{Vector2::up(), MOVE_CURSOR_UP}, + {Vector2::down(), MOVE_CURSOR_DOWN}, + {Vector2::left(), MOVE_CURSOR_LEFT}, + {Vector2::right(), MOVE_CURSOR_RIGHT}}; class CursorController : public ICursorController, public yacppdic::AutoWirable<ICursorController, CursorController> diff --git a/src/engine/user/input.cpp b/src/engine/user/input.cpp index d335fc9..7e9fe22 100644 --- a/src/engine/user/input.cpp +++ b/src/engine/user/input.cpp @@ -15,8 +15,7 @@ void InputHandler::listen() const noexcept void InputHandler::subscribe( const Event &event, - const std::shared_ptr<ISubscriber<Context>> &subscriber -) noexcept + const std::shared_ptr<ISubscriber<Context>> &subscriber) noexcept { auto event_index = _event_as_index(event); diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp index c88809d..f17472b 100644 --- a/src/engine/user/input.hpp +++ b/src/engine/user/input.hpp @@ -21,8 +21,7 @@ public: void subscribe( const Event &event, - const std::shared_ptr<ISubscriber<Context>> &subscriber - ) noexcept override; + const std::shared_ptr<ISubscriber<Context>> &subscriber) noexcept override; void notify_subscribers(const Event &event, const Context &context) const noexcept override; |