aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/system')
-rw-r--r--src/crepe/system/InputSystem.cpp18
-rw-r--r--src/crepe/system/InputSystem.h18
2 files changed, 13 insertions, 23 deletions
diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp
index e42eaeb..34aad06 100644
--- a/src/crepe/system/InputSystem.cpp
+++ b/src/crepe/system/InputSystem.cpp
@@ -10,10 +10,8 @@ using namespace crepe;
void InputSystem::update() {
ComponentManager & mgr = this->mediator.component_manager;
-
SDLContext & context = this->mediator.sdl_context;
std::vector<EventData> event_list = context.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;
@@ -160,12 +158,8 @@ void InputSystem::handle_move(const EventData & event_data, const vec2 & mouse_p
for (Button & button : buttons) {
if (!button.active) continue;
- RefVector<Transform> transform_vec
- = mgr.get_components_by_id<Transform>(button.game_object_id);
- Transform & transform = transform_vec.front().get();
- RefVector<Metadata> metadata_vec
- = mgr.get_components_by_id<Metadata>(button.game_object_id);
- Metadata & metadata = metadata_vec.front().get();
+ Metadata & metadata = mgr.get_components_by_id<Metadata>(button.game_object_id).front();
+ Transform & transform = mgr.get_components_by_id<Transform>(button.game_object_id).front();
bool was_hovering = button.hover;
if (this->is_mouse_inside_button(mouse_pos, button, transform)) {
button.hover = true;
@@ -188,12 +182,8 @@ void InputSystem::handle_click(const MouseButton & mouse_button, const vec2 & mo
for (Button & button : buttons) {
if (!button.active) continue;
- RefVector<Metadata> metadata_vec
- = mgr.get_components_by_id<Metadata>(button.game_object_id);
- Metadata & metadata = metadata_vec.front().get();
- RefVector<Transform> transform_vec
- = mgr.get_components_by_id<Transform>(button.game_object_id);
- Transform & transform = transform_vec.front().get();
+ Metadata & metadata = mgr.get_components_by_id<Metadata>(button.game_object_id).front();
+ Transform & transform = mgr.get_components_by_id<Transform>(button.game_object_id).front();
if (this->is_mouse_inside_button(mouse_pos, button, transform)) {
event_mgr.trigger_event<ButtonPressEvent>(metadata);
diff --git a/src/crepe/system/InputSystem.h b/src/crepe/system/InputSystem.h
index 45c593a..e580d8e 100644
--- a/src/crepe/system/InputSystem.h
+++ b/src/crepe/system/InputSystem.h
@@ -19,31 +19,31 @@ class Transform;
class ButtonPressEvent : public Event {
public:
//! Metadata of the button.
- const Metadata & meta_data;
+ const Metadata & metadata;
/**
- * \param meta_data Metadata of the button pressed
+ * \param metadata Metadata of the button pressed
*/
- ButtonPressEvent(const Metadata & meta_data) : meta_data(meta_data){};
+ ButtonPressEvent(const Metadata & metadata) : metadata(metadata){};
};
//! Event triggered when the mouse enters a button
class ButtonEnterEvent : public Event {
public:
//! Metadata of the button.
- const Metadata & meta_data;
+ const Metadata & metadata;
/**
- * \param meta_data Metadata of the button pressed
+ * \param metadata Metadata of the button pressed
*/
- ButtonEnterEvent(const Metadata & meta_data) : meta_data(meta_data){};
+ ButtonEnterEvent(const Metadata & metadata) : metadata(metadata){};
};
//! Event triggered when the mouse leaves a button
class ButtonExitEvent : public Event {
public:
//! Metadata of the button.
- const Metadata & meta_data;
+ const Metadata & metadata;
/**
- * \param meta_data Metadata of the button pressed
+ * \param metadata Metadata of the button pressed
*/
- ButtonExitEvent(const Metadata & meta_data) : meta_data(meta_data){};
+ ButtonExitEvent(const Metadata & metadata) : metadata(metadata){};
};
/**