SelectState.h 1.35 KiB
#pragma once
#include <BasicAbstractions/IState.h>
#include <BasicAbstractions/IWindowKeeper.h>
#include <BasicAbstractions/IDrawable.h>
#include <BasicAbstractions/Command.h>
class Button: public IDrawable {
public:
    Button() = default;
    void set(sf::Vector2f pos, sf::Vector2f size, const std::string& text, size_t font_size, std::unique_ptr<ISelectCommand> ptr_command);
    void select();
    void unselect();
    bool is_position_in(sf::Vector2f pos) const noexcept;
    void push() const;
    void draw_into(sf::RenderWindow& window) const override;
private:
    sf::Text m_text;
    sf::RectangleShape m_rectangle;
    std::unique_ptr<ISelectCommand> m_ptr_command;
class Menu: public IDrawable {
public:
    explicit Menu(IStateManager& state_manager);
    void process_mouse(sf::Vector2f pos, bool is_pressed);
    void draw_into(sf::RenderWindow& window) const override;
private:
    std::array<Button, 4> m_buttons;
class SelectState : public IState, public IWindowKeeper {
public:
    explicit SelectState(IStateManager& state_manager, const sf::VideoMode& video_mode, const sf::String& window_title) :
    IState(state_manager), IWindowKeeper(video_mode, window_title), m_menu(state_manager) {}
    bool do_step() override;
private:
    void event_handling() override;
    void update() override;
    void render() override;
private:
    Menu m_menu;