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.
61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
#include "application/about.h"
|
|
#include "widgets/group.h"
|
|
#include "widgets/pushbutton.h"
|
|
|
|
About::About(const std::shared_ptr<kku::CoreFactory> &factory,
|
|
About::Callbacks &&callbacks)
|
|
: _callbacks(std::move(callbacks)), _core_factory(factory),
|
|
_sfml_logo(factory->getSprite(kku::GUISprite::Id::SFML_LOGO)),
|
|
_cryptopp_logo(factory->getSprite(kku::GUISprite::Id::CRYPTOPP_LOGO)),
|
|
_powered_by_text(factory->getText(kku::Font::Id::GUI)),
|
|
_buttons(std::make_shared<Group>())
|
|
{
|
|
_powered_by_text->setString("Powered by: ");
|
|
_powered_by_text->move(kku::Vector2<float>{0., 60});
|
|
_sfml_logo->move(kku::Vector2<float>{230., 60});
|
|
_cryptopp_logo->move(kku::Vector2<float>{250., 180});
|
|
}
|
|
|
|
void About::input(const kku::SystemEvent &event)
|
|
{
|
|
_buttons->input(event);
|
|
}
|
|
|
|
void About::update(const kku::microsec &dt)
|
|
{
|
|
_buttons->update(dt);
|
|
}
|
|
|
|
void About::display() const
|
|
{
|
|
_buttons->display();
|
|
_sfml_logo->display();
|
|
_cryptopp_logo->display();
|
|
_powered_by_text->display();
|
|
}
|
|
|
|
void About::enter()
|
|
{
|
|
const auto render_size = _core_factory->getRenderSize();
|
|
const float window_width = render_size.first;
|
|
const float window_height = render_size.second;
|
|
|
|
if (!_exit_button)
|
|
{
|
|
_exit_button =
|
|
std::make_shared<PushButton>("Return", _core_factory, 48);
|
|
_exit_button->setCallback(_callbacks.onLeaveAboutState);
|
|
_buttons->addChild(_exit_button);
|
|
}
|
|
|
|
_exit_button->setRect(
|
|
kku::Area<float>{window_width / 3.f, window_height / 7.f * 4,
|
|
window_width / 3.f, window_height / 7.f});
|
|
_buttons->setVisibility();
|
|
}
|
|
|
|
void About::leave()
|
|
{
|
|
_buttons->setVisibility(false);
|
|
}
|