2022-02-06 02:33:09 +01:00
|
|
|
#include "classicgraphicsfactory.h"
|
|
|
|
|
|
|
|
ClassicGraphicsFactory::ClassicGraphicsFactory(const std::shared_ptr<kku::CoreFactory>& core_factory) :
|
|
|
|
_core_factory(core_factory)
|
|
|
|
{}
|
|
|
|
|
|
|
|
auto ClassicGraphicsFactory::generate(Type type) const -> SpriteData
|
|
|
|
{
|
|
|
|
auto shape = _core_factory->getRectangle();
|
|
|
|
auto trail = _core_factory->getRectangle();
|
|
|
|
shape->setRect(kku::Area<float>{0.f, 0.f, 20.f, 20.f});
|
|
|
|
trail->setRect(kku::Area<float>{0.f, 0.f, 20.f, 20.f});
|
|
|
|
|
|
|
|
kku::Color color;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case Type::UP:
|
|
|
|
color = kku::Color{255, 0, 0, 255};
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Type::DOWN:
|
|
|
|
color = kku::Color{0, 255, 0, 255};
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Type::LEFT:
|
|
|
|
color = kku::Color{0, 0, 255, 255};
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Type::RIGHT:
|
|
|
|
color = kku::Color{255, 0, 255, 255};
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // yellow
|
|
|
|
color = kku::Color{255, 239, 0, 255};
|
|
|
|
}
|
|
|
|
|
|
|
|
shape->setColor(color);
|
|
|
|
trail->setColor(color);
|
|
|
|
|
|
|
|
return SpriteData{shape, trail, color};
|
|
|
|
}
|
|
|
|
|
2022-03-10 18:45:19 +01:00
|
|
|
std::shared_ptr<ClassicNoteGraphics> ClassicGraphicsFactory::createSprite(Type type) const
|
2022-02-06 02:33:09 +01:00
|
|
|
{
|
|
|
|
const auto data = generate(type);
|
2022-03-10 18:45:19 +01:00
|
|
|
return std::make_shared<ClassicNoteGraphics>(ClassicNoteGraphics::Init{data.shape, data.trail, data.color});
|
2022-02-06 02:33:09 +01:00
|
|
|
}
|
|
|
|
|
2022-03-10 18:45:19 +01:00
|
|
|
std::shared_ptr<ClassicSelectionGraphics> ClassicGraphicsFactory::createSelection() const
|
2022-02-06 02:33:09 +01:00
|
|
|
{
|
|
|
|
const auto shape = _core_factory->getRectangle();
|
2022-03-10 18:45:19 +01:00
|
|
|
return std::make_shared<ClassicSelectionGraphics>(ClassicSelectionGraphics::Init{shape, kku::Color{51, 153, 255, 120}});
|
2022-02-06 02:33:09 +01:00
|
|
|
}
|