Files
2021-06-20 12:32:42 +02:00

48 lines
1.7 KiB
C++

//
// Created by Louis Auzuret on 06/03/21
//
#pragma once
#include "Component/Controllable/ControllableComponent.hpp"
#include "Models/Vector2.hpp"
#include "System/System.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "Component/Renderer/Drawable2DComponent.hpp"
#include "Component/Button/ButtonComponent.hpp"
namespace BBM
{
//! @brief A system to handle Controllable entities in a menu.
class MenuControllableSystem : public WAL::System<>
{
private:
//! @brief position of the mouse at the precedent scene (to know which controller event to watch)
Vector2f _oldMousePosition;
//! @brief update current button reference
//! @param selected lets know if te new selected button is 'pressed'
void _updateCurrentButton(bool selected, Vector2f move);
//! @return true if mouse on entity
bool _mouseOnButton(const Vector2f &mousePos, WAL::ViewEntity<OnClickComponent, OnHoverComponent, OnIdleComponent, PositionComponent, Drawable2DComponent> &entity) const;
public:
//! @brief index of the current button selected
WAL::Entity *currentButton;
//! @brief time (in millisecond) since last check
std::chrono::time_point<std::chrono::steady_clock> now;
//! @inherit
void onSelfUpdate(std::chrono::nanoseconds dtime) override;
//! @brief A default constructor
explicit MenuControllableSystem(WAL::Wal &wal);
//! @brief A MenuControllable system is not copy constructable
MenuControllableSystem(const MenuControllableSystem &) = delete;
//! @brief A default destructor
~MenuControllableSystem() override = default;
//! @brief A MenuControllable system is not assignable.
MenuControllableSystem &operator=(const MenuControllableSystem &) = delete;
};
}