#include "corefactorysfml.h"

#include "rectanglesfml.h"
#include "musicsfml.h"
#include "textsfml.h"
#include "linesfml.h"

CoreFactorySFML::CoreFactorySFML(sf::RenderTarget * const render_target) :
    _render_target(render_target)
{
    auto gui_font = std::make_unique<sf::Font>();
    gui_font->loadFromFile("SourceCodePro-Regular.ttf");
    _font_holder.load(kku::Font::Id::GUI, std::move(gui_font));
}

std::shared_ptr<kku::Music> CoreFactorySFML::getMusic() const
{
    return std::make_unique<MusicSFML>();
}

std::shared_ptr<kku::Text> CoreFactorySFML::getText(kku::Font::Id id) const
{
    return std::make_unique<TextSFML>(_render_target, _font_holder.get(id));
}

std::shared_ptr<kku::Rectangle> CoreFactorySFML::getRectangle() const
{
    return std::make_unique<RectangleSFML>(_render_target);
}

 std::shared_ptr<kku::Line> CoreFactorySFML::getLine() const
 {
     return std::make_unique<LineSFML>(_render_target);
 }

kku::Vector2<std::size_t> CoreFactorySFML::getRenderSize() const
{
    const sf::Vector2u size = _render_target->getSize();
    return kku::makeVector(size.x, size.y);
}
