aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-17 20:12:54 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-12-17 20:12:54 +0100
commitf68fdab4d46cea640fe1a40266ef1cd32e6d7426 (patch)
treedd31829c60dcb7000949621b762ac1b1624e03ac /src
parenteb9c76082d7d0ee0c3e55cb8eadfa5f8978bd8f2 (diff)
make format
Diffstat (limited to 'src')
-rw-r--r--src/crepe/api/Button.h2
-rw-r--r--src/crepe/system/InputSystem.cpp6
-rw-r--r--src/crepe/system/InputSystem.h18
-rw-r--r--src/test/InputTest.cpp11
4 files changed, 16 insertions, 21 deletions
diff --git a/src/crepe/api/Button.h b/src/crepe/api/Button.h
index 5d4156b..25d74e2 100644
--- a/src/crepe/api/Button.h
+++ b/src/crepe/api/Button.h
@@ -2,9 +2,9 @@
#include <functional>
-#include "UIObject.h"
#include "Event.h"
#include "Metadata.h"
+#include "UIObject.h"
namespace crepe {
diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp
index 5d1537d..e42eaeb 100644
--- a/src/crepe/system/InputSystem.cpp
+++ b/src/crepe/system/InputSystem.cpp
@@ -155,7 +155,7 @@ void InputSystem::handle_non_mouse_event(const EventData & event) {
void InputSystem::handle_move(const EventData & event_data, const vec2 & mouse_pos) {
ComponentManager & mgr = this->mediator.component_manager;
- EventManager& event_mgr = this->mediator.event_manager;
+ EventManager & event_mgr = this->mediator.event_manager;
RefVector<Button> buttons = mgr.get_components_by_type<Button>();
for (Button & button : buttons) {
@@ -183,9 +183,9 @@ void InputSystem::handle_move(const EventData & event_data, const vec2 & mouse_p
void InputSystem::handle_click(const MouseButton & mouse_button, const vec2 & mouse_pos) {
ComponentManager & mgr = this->mediator.component_manager;
- EventManager& event_mgr = this->mediator.event_manager;
+ EventManager & event_mgr = this->mediator.event_manager;
RefVector<Button> buttons = mgr.get_components_by_type<Button>();
-
+
for (Button & button : buttons) {
if (!button.active) continue;
RefVector<Metadata> metadata_vec
diff --git a/src/crepe/system/InputSystem.h b/src/crepe/system/InputSystem.h
index 9cad178..5afe641 100644
--- a/src/crepe/system/InputSystem.h
+++ b/src/crepe/system/InputSystem.h
@@ -3,11 +3,10 @@
#include "../api/Config.h"
#include "../facade/EventData.h"
+#include "../api/Event.h"
+#include "../api/Metadata.h"
#include "../types.h"
#include "../util/OptionalRef.h"
-#include "../api/Metadata.h"
-#include "../api/Event.h"
-
#include "System.h"
@@ -21,18 +20,19 @@ class Transform;
*/
class ButtonPressEvent : public Event {
public:
- const Metadata& meta_data;
- ButtonPressEvent(const Metadata& meta_data) : meta_data(meta_data){};;
+ const Metadata & meta_data;
+ ButtonPressEvent(const Metadata & meta_data) : meta_data(meta_data){};
+ ;
};
class ButtonEnterEvent : public Event {
public:
- const Metadata& meta_data;
- ButtonEnterEvent(const Metadata& meta_data) : meta_data(meta_data){};
+ const Metadata & meta_data;
+ ButtonEnterEvent(const Metadata & meta_data) : meta_data(meta_data){};
};
class ButtonExitEvent : public Event {
public:
- const Metadata& meta_data;
- ButtonExitEvent(const Metadata& meta_data) : meta_data(meta_data){};
+ const Metadata & meta_data;
+ ButtonExitEvent(const Metadata & meta_data) : meta_data(meta_data){};
};
/**
diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp
index 6c40235..097667a 100644
--- a/src/test/InputTest.cpp
+++ b/src/test/InputTest.cpp
@@ -217,8 +217,7 @@ TEST_F(InputTest, testButtonClick) {
button_clicked = true;
EXPECT_EQ(event.meta_data.game_object_id, button_obj.id);
return false;
- }
- );
+ });
auto & button = button_obj.add_component<Button>(vec2{100, 100}, vec2{0, 0});
bool hover = false;
@@ -241,14 +240,12 @@ TEST_F(InputTest, testButtonHover) {
button_hover = true;
EXPECT_EQ(event.meta_data.game_object_id, button_obj.id);
return false;
- }
- );
+ });
event_manager.subscribe<ButtonExitEvent>([&](const ButtonExitEvent & event) {
button_hover = false;
EXPECT_EQ(event.meta_data.game_object_id, button_obj.id);
return false;
- }
- );
+ });
auto & button = button_obj.add_component<Button>(vec2{100, 100}, vec2{0, 0});
button.active = true;
// Mouse on button
@@ -279,6 +276,4 @@ TEST_F(InputTest, testButtonHover) {
event_manager.dispatch_events();
EXPECT_FALSE(button.hover);
EXPECT_FALSE(button_hover);
-
-
}