#pragma once

#include "classicmode/classicnote.h"
#include "graphics/classicgraphicsmanager.h"
#include "graphics/classicgraphicsfactory.h"
#include "core/timeline.h"
#include "core/spritecontainer.h"

class ClassicSprite;

class ClassicTimelineGraphicsManager : public ClassicGraphicsManager
{
public:
    explicit ClassicTimelineGraphicsManager(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
                                         const std::shared_ptr<ClassicGraphicsFactory>& factory,
                                         const kku::microsec& visibility_offset);

    virtual void input(kku::GameEvent&& input) override;

    virtual void display() const override;
    virtual void update(const kku::microsec& offset) override;

    virtual void display(const std::vector<ArrowElement>& elements) const override;
    virtual void setGraphics(std::vector<ArrowElement>& elements, kku::TimeRange&& range) override;

    virtual void display(const std::vector<MockElement>& elements) const override;
    virtual void setGraphics(std::vector<MockElement>& elements, kku::TimeRange&& range) override;

protected:
    kku::SpriteContainer<Type, ClassicGraphicsFactory, ClassicSprite> _sprite_container;
    const std::shared_ptr<const ClassicGraphicsFactory> _factory;

    const std::shared_ptr<kku::Timeline<ClassicNote>> _timeline;

    inline bool nothingToDraw() const noexcept;
    inline bool isVisiblyClose(const ClassicNote * const note, const kku::microsec& music_offset) const noexcept;
    //inline sf::VertexArray makeLine(const kku::Point& c1, const kku::Point& c2) const;

    void fetchFirstNote(const kku::microsec& offset);
    void fetchLastNote(const kku::microsec& offset);
    void updateVisibleNotes(const kku::microsec& offset);
};
