diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-04 16:50:42 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-04 16:50:42 +0100 |
commit | 9cce00687e9ee318d72fd66793d070da2424fcbc (patch) | |
tree | 792c7f74ceb6e15ca317b4d37ff601a5dd25b9af | |
parent | 2a2e991371fc1164015df045227a6535137e74bc (diff) |
feedback changes
-rw-r--r-- | src/crepe/api/Button.h | 6 | ||||
-rw-r--r-- | src/crepe/system/InputSystem.cpp | 7 | ||||
-rw-r--r-- | src/crepe/system/InputSystem.h | 9 |
3 files changed, 9 insertions, 13 deletions
diff --git a/src/crepe/api/Button.h b/src/crepe/api/Button.h index 290bb2f..06d64d6 100644 --- a/src/crepe/api/Button.h +++ b/src/crepe/api/Button.h @@ -42,7 +42,7 @@ public: * This function is invoked whenever the button is clicked. It can be set to any * function that matches the signature `void()`. */ - std::function<void()> on_click; + std::function<void()> on_click = nullptr; /** * \brief Callback function to be executed when the mouse enters the button's boundaries. @@ -50,7 +50,7 @@ public: * This function is triggered when the mouse cursor moves over the button, allowing * custom actions like visual effects, highlighting, or sound effects. */ - std::function<void()> on_enter; + std::function<void()> on_enter = nullptr; /** * \brief Callback function to be executed when the mouse exits the button's boundaries. @@ -58,7 +58,7 @@ public: * This function is triggered when the mouse cursor moves out of the button's area, * allowing custom actions like resetting visual effects or playing exit-related effects. */ - std::function<void()> on_exit; + std::function<void()> on_exit = nullptr; private: friend class InputSystem; diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp index 72d728c..dca621e 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -11,11 +11,11 @@ void InputSystem::update() { std::vector<SDLContext::EventData> event_list = SDLContext::get_instance().get_events(); RefVector<Button> buttons = mgr.get_components_by_type<Button>(); RefVector<Camera> cameras = mgr.get_components_by_type<Camera>(); - + OptionalRef<Camera> curr_cam_ref; // Find the active camera for (Camera & cam : cameras) { if (!cam.active) continue; - this->curr_cam_ref = cam; + curr_cam_ref = cam; break; } if (!curr_cam_ref) return; @@ -123,8 +123,7 @@ void InputSystem::handle_move(const SDLContext::EventData & event_data, for (Button & button : buttons) { RefVector<Transform> transform_vec = mgr.get_components_by_id<Transform>(button.game_object_id); - OptionalRef<Transform> transform(transform_vec.front().get()); - if (!transform) continue; + Transform & transform(transform_vec.front().get()); bool was_hovering = button.hover; if (button.active diff --git a/src/crepe/system/InputSystem.h b/src/crepe/system/InputSystem.h index 53f2c4e..e65ad30 100644 --- a/src/crepe/system/InputSystem.h +++ b/src/crepe/system/InputSystem.h @@ -1,8 +1,8 @@ #pragma once -#include "facade/SDLContext.h" -#include "types.h" -#include "util/OptionalRef.h" +#include "../facade/SDLContext.h" +#include "../types.h" +#include "../util/OptionalRef.h" #include "System.h" @@ -30,9 +30,6 @@ public: void update() override; private: - //! Reference to the currently active camera. - OptionalRef<Camera> curr_cam_ref; - //! Stores the last position of the mouse when the button was pressed. std::pair<int, int> last_mouse_down_position{INFINITY, INFINITY}; |