forked from NaiJi/project-kyoku
Implement timeline graphics manager
This commit is contained in:
parent
6768aeabdf
commit
9216fc9f84
|
@ -0,0 +1,121 @@
|
||||||
|
#include "classictimelinegraphicsmanager.h"
|
||||||
|
|
||||||
|
#include "editor/mockelement.h"
|
||||||
|
#include "game/arrowelement.h"
|
||||||
|
|
||||||
|
ClassicTimelineGraphicsManager::ClassicTimelineGraphicsManager(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
|
||||||
|
const std::shared_ptr<ClassicGraphicsFactory>& factory,
|
||||||
|
const kku::microsec& visibility_offset) :
|
||||||
|
ClassicGraphicsManager(visibility_offset),
|
||||||
|
_sprite_container({Type::UP, Type::DOWN,
|
||||||
|
Type::LEFT, Type::RIGHT},
|
||||||
|
factory),
|
||||||
|
_factory(factory),
|
||||||
|
_timeline(timeline)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::input(kku::GameEvent&& input)
|
||||||
|
{
|
||||||
|
(void)input;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::display() const
|
||||||
|
{
|
||||||
|
if (nothingToDraw())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::update(const kku::microsec &offset)
|
||||||
|
{
|
||||||
|
fetchLastNote(offset);
|
||||||
|
fetchFirstNote(offset);
|
||||||
|
|
||||||
|
updateVisibleNotes(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::display(const std::vector<ArrowElement>& elements) const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < elements.size(); ++i)
|
||||||
|
{
|
||||||
|
const auto& sprite = elements[i].sprite;
|
||||||
|
|
||||||
|
if (i >= 1)
|
||||||
|
{
|
||||||
|
//const auto& neighbor_sprite = elements[i - 1].sprite;
|
||||||
|
|
||||||
|
//const auto c1 = neighbor_sprite->trailPosition();
|
||||||
|
//const auto c2 = sprite->trailPosition();
|
||||||
|
|
||||||
|
//_render_target->draw(makeLine(c1, c2));
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite->display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::setGraphics(std::vector<ArrowElement>& elements, kku::TimeRange &&range)
|
||||||
|
{
|
||||||
|
(void)elements; (void)range;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::display(const std::vector<MockElement>& elements) const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < elements.size(); ++i)
|
||||||
|
{
|
||||||
|
const auto& sprite = elements[i].sprite;
|
||||||
|
|
||||||
|
if (i >= 1)
|
||||||
|
{
|
||||||
|
//const auto& neighbor_sprite = elements[i - 1].sprite;
|
||||||
|
|
||||||
|
//const auto c1 = neighbor_sprite->trailPosition();
|
||||||
|
//const auto c2 = sprite->trailPosition();
|
||||||
|
|
||||||
|
//_render_target->draw(makeLine(c1, c2));
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite->display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::setGraphics(std::vector<MockElement>& elements, kku::TimeRange &&range)
|
||||||
|
{
|
||||||
|
(void)elements; (void)range;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*sf::VertexArray ClassicSceneGraphicsSFML::makeLine(const kku::Point& c1, const kku::Point& c2) const
|
||||||
|
{
|
||||||
|
sf::VertexArray line(sf::LinesStrip, 2);
|
||||||
|
line[0].color = sf::Color::Yellow;
|
||||||
|
line[0].position = {c1.x + 10, c1.y};
|
||||||
|
line[1].color = sf::Color::Blue;
|
||||||
|
line[1].position = {c2.x + 10, c2.y};
|
||||||
|
|
||||||
|
return line;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::updateVisibleNotes(const kku::microsec &offset)
|
||||||
|
{
|
||||||
|
(void)offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::fetchFirstNote(const kku::microsec& offset)
|
||||||
|
{
|
||||||
|
(void)offset; // ????
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicTimelineGraphicsManager::fetchLastNote(const kku::microsec& offset)
|
||||||
|
{
|
||||||
|
(void)offset; // ????
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClassicTimelineGraphicsManager::nothingToDraw() const noexcept
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClassicTimelineGraphicsManager::isVisiblyClose(const ClassicNote * const note, const kku::microsec& music_offset) const noexcept
|
||||||
|
{
|
||||||
|
return note && music_offset;
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#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);
|
||||||
|
};
|
Loading…
Reference in New Issue