From 9d60b7b70abd832dc229c59114e465d457fcd0a3 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Wed, 27 Nov 2024 14:59:03 +0100 Subject: make format --- src/crepe/system/InputSystem.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/crepe/system/InputSystem.cpp') diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp index bb67e5f..070f804 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -1,6 +1,6 @@ +#include "ComponentManager.h" #include "api/Button.h" #include "api/EventManager.h" -#include "ComponentManager.h" #include "InputSystem.h" @@ -41,7 +41,7 @@ void InputSystem::update() { int delta_x = event.mouse_position.first - last_mouse_down_position.first; int delta_y = event.mouse_position.second - last_mouse_down_position.second; - + if (last_mouse_button == event.mouse_button && std::abs(delta_x) <= click_tolerance && std::abs(delta_y) <= click_tolerance) { @@ -53,8 +53,7 @@ void InputSystem::update() { handle_click(event); } - } - break; + } break; case SDLContext::EventType::MOUSEMOVE: event_mgr.queue_event(MouseMoveEvent{ .mouse_x = event.mouse_position.first, @@ -113,20 +112,18 @@ void InputSystem::handle_click(const SDLContext::EventData & event_data) { } } +OptionalRef +InputSystem::find_transform_for_button(Button & button, RefVector & transforms) { -OptionalRef InputSystem::find_transform_for_button( - Button & button, RefVector& transforms) { - - for (auto& transform : transforms) { - if (button.game_object_id == transform.get().game_object_id) { - return OptionalRef(transform); - } - } + for (auto & transform : transforms) { + if (button.game_object_id == transform.get().game_object_id) { + return OptionalRef(transform); + } + } - return OptionalRef(); + return OptionalRef(); } - bool InputSystem::is_mouse_inside_button(const SDLContext::EventData & event_data, const Button & button, const Transform & transform) { return event_data.mouse_position.first >= transform.position.x -- cgit v1.2.3