forked from NaiJi/project-kyoku
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
#include "mainmenu.h"
|
|
#include "widgets/button.h"
|
|
#include "widgets/group.h"
|
|
|
|
MainMenu::MainMenu(sf::RenderWindow& game_window, Callbacks&& callbacks) :
|
|
_buttons(std::make_shared<Group>()),
|
|
_game_window(game_window)
|
|
{
|
|
std::shared_ptr<Button> button_start = std::make_shared<Button>("Start");
|
|
button_start->setRect(sf::FloatRect(140, 140, 500, 100));
|
|
button_start->setCallback(callbacks.onAppendGameState);
|
|
|
|
std::shared_ptr<Button> button_exit = std::make_shared<Button>("Exit");
|
|
button_exit->setRect(sf::FloatRect(140, 140, 400, 100));
|
|
button_exit->setPosition({240, 340});
|
|
button_exit->setCallback([&]()
|
|
{
|
|
_game_window.close();
|
|
});
|
|
|
|
_buttons->addChild(button_start);
|
|
_buttons->addChild(button_exit);
|
|
}
|
|
|
|
void MainMenu::input(const sf::Event& event)
|
|
{
|
|
_buttons->input(event);
|
|
}
|
|
|
|
void MainMenu::update()
|
|
{
|
|
_buttons->update();
|
|
}
|
|
|
|
void MainMenu::draw() const
|
|
{
|
|
_game_window.draw(*_buttons);
|
|
}
|
|
|
|
void MainMenu::enter()
|
|
{
|
|
_buttons->setVisibility();
|
|
}
|
|
|
|
void MainMenu::leave()
|
|
{
|
|
_buttons->setVisibility(false);
|
|
}
|
|
|