From 66fdcffaddb0ab31d12b6b1d7892a8edaa31af65 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Wed, 4 Dec 2024 20:13:09 +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 bbf2547..21ec24b 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -152,7 +152,7 @@ void InputSystem::handle_click(const MouseButton & mouse_button, const int world for (Button & button : buttons) { RefVector transform_vec = mgr.get_components_by_id(button.game_object_id); - Transform& transform(transform_vec.front().get()); + Transform & transform(transform_vec.front().get()); if (button.active && this->is_mouse_inside_button(world_mouse_x, world_mouse_y, button, transform)) { @@ -162,20 +162,17 @@ void InputSystem::handle_click(const MouseButton & mouse_button, const int world } bool InputSystem::is_mouse_inside_button(const int mouse_x, const int mouse_y, - const Button &button, const Transform &transform) { - int actual_x = transform.position.x + button.offset.x; - int actual_y = transform.position.y + button.offset.y; - - int half_width = button.dimensions.x / 2; - int half_height = button.dimensions.y / 2; - - // Check if the mouse is within the button's boundaries - return mouse_x >= actual_x - half_width - && mouse_x <= actual_x + half_width - && mouse_y >= actual_y - half_height - && mouse_y <= actual_y + half_height; -} + const Button & button, const Transform & transform) { + int actual_x = transform.position.x + button.offset.x; + int actual_y = transform.position.y + button.offset.y; + int half_width = button.dimensions.x / 2; + int half_height = button.dimensions.y / 2; + + // Check if the mouse is within the button's boundaries + return mouse_x >= actual_x - half_width && mouse_x <= actual_x + half_width + && mouse_y >= actual_y - half_height && mouse_y <= actual_y + half_height; +} void InputSystem::handle_button_press(Button & button) { //checks if the button is a toggle button -- cgit v1.2.3