|
|
@ -1,21 +1,18 @@
|
|
|
|
#include "classicgraphicsmanager.h"
|
|
|
|
#include "classicgamegraphicsmanager.h"
|
|
|
|
#include "graphics/classicsprite.h"
|
|
|
|
#include "graphics/classicsprite.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "graphics/classicflyinganimationscenario.h"
|
|
|
|
#include "graphics/classicflyinganimationscenario.h"
|
|
|
|
#include "graphics/classicdyinganimationscenario.h"
|
|
|
|
#include "graphics/classicdyinganimationscenario.h"
|
|
|
|
|
|
|
|
|
|
|
|
ClassicGraphicsManager::ClassicGraphicsManager(Timeline<ClassicNote> &timeline, const microsec& visibility_offset) :
|
|
|
|
ClassicGameGraphicsManager::ClassicGameGraphicsManager(Timeline<ClassicNote> &timeline, const microsec& visibility_offset) :
|
|
|
|
_sprite_container({Type::UP, Type::DOWN,
|
|
|
|
ClassicGraphicsManager(visibility_offset),
|
|
|
|
Type::LEFT, Type::RIGHT},
|
|
|
|
_timeline(&timeline)
|
|
|
|
std::make_unique<ClassicSpriteFactory>()),
|
|
|
|
|
|
|
|
_timeline(&timeline),
|
|
|
|
|
|
|
|
_visibility_offset(visibility_offset)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_timeline->expire(_first);
|
|
|
|
_timeline->expire(_first);
|
|
|
|
_timeline->expire(_last);
|
|
|
|
_timeline->expire(_last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGraphicsManager::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
|
|
|
void ClassicGameGraphicsManager::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (nothingToDraw())
|
|
|
|
if (nothingToDraw())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -26,7 +23,7 @@ void ClassicGraphicsManager::draw(sf::RenderTarget& target, sf::RenderStates sta
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGraphicsManager::draw(const std::vector<ClassicArrowNote::ArrowElement>& elements, sf::RenderTarget& target, sf::RenderStates states) const
|
|
|
|
void ClassicGameGraphicsManager::draw(const std::vector<ClassicArrowNote::ArrowElement>& elements, sf::RenderTarget& target, sf::RenderStates states) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (std::size_t i = 0; i < elements.size(); ++i)
|
|
|
|
for (std::size_t i = 0; i < elements.size(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -46,7 +43,7 @@ void ClassicGraphicsManager::draw(const std::vector<ClassicArrowNote::ArrowEleme
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sf::VertexArray ClassicGraphicsManager::makeLine(const Coordinates& c1, const Coordinates& c2) const
|
|
|
|
sf::VertexArray ClassicGameGraphicsManager::makeLine(const Coordinates& c1, const Coordinates& c2) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sf::VertexArray line(sf::LinesStrip, 2);
|
|
|
|
sf::VertexArray line(sf::LinesStrip, 2);
|
|
|
|
line[0].color = sf::Color::Yellow;
|
|
|
|
line[0].color = sf::Color::Yellow;
|
|
|
@ -57,7 +54,7 @@ sf::VertexArray ClassicGraphicsManager::makeLine(const Coordinates& c1, const Co
|
|
|
|
return line;
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGraphicsManager::setGraphics(std::vector<ClassicArrowNote::ArrowElement>& elements, TimeRange &&range)
|
|
|
|
void ClassicGameGraphicsManager::setGraphics(std::vector<ClassicArrowNote::ArrowElement>& elements, TimeRange &&range)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (auto& element : elements)
|
|
|
|
for (auto& element : elements)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -74,13 +71,21 @@ void ClassicGraphicsManager::setGraphics(std::vector<ClassicArrowNote::ArrowElem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGraphicsManager::update(const microsec &offset)
|
|
|
|
void ClassicGameGraphicsManager::update(const microsec &offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fetchLastNote(offset);
|
|
|
|
fetchLastNote(offset);
|
|
|
|
fetchFirstNote(offset);
|
|
|
|
fetchFirstNote(offset);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateVisibleNotes(offset);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGameGraphicsManager::updateVisibleNotes(const microsec &offset)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (auto it = _first; it != _last; ++it)
|
|
|
|
|
|
|
|
(*it)->update(offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGraphicsManager::fetchFirstNote(const microsec& offset)
|
|
|
|
void ClassicGameGraphicsManager::fetchFirstNote(const microsec& offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
(void)offset; // ????
|
|
|
|
(void)offset; // ????
|
|
|
|
|
|
|
|
|
|
|
@ -98,7 +103,7 @@ void ClassicGraphicsManager::fetchFirstNote(const microsec& offset)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicGraphicsManager::fetchLastNote(const microsec& offset)
|
|
|
|
void ClassicGameGraphicsManager::fetchLastNote(const microsec& offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Iterator note_iterator = _timeline->getTopNote();
|
|
|
|
Iterator note_iterator = _timeline->getTopNote();
|
|
|
|
while (!_timeline->isExpired(note_iterator) && isVisiblyClose(note_iterator, offset))
|
|
|
|
while (!_timeline->isExpired(note_iterator) && isVisiblyClose(note_iterator, offset))
|
|
|
@ -120,13 +125,13 @@ void ClassicGraphicsManager::fetchLastNote(const microsec& offset)
|
|
|
|
_last = note_iterator;
|
|
|
|
_last = note_iterator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ClassicGraphicsManager::nothingToDraw() const noexcept
|
|
|
|
bool ClassicGameGraphicsManager::nothingToDraw() const noexcept
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _timeline->isExpired(_first)
|
|
|
|
return _timeline->isExpired(_first)
|
|
|
|
|| _timeline->isExpired(_last);
|
|
|
|
|| _timeline->isExpired(_last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ClassicGraphicsManager::isVisiblyClose(const Iterator& iterator, const microsec& music_offset) const noexcept
|
|
|
|
bool ClassicGameGraphicsManager::isVisiblyClose(const Iterator& iterator, const microsec& music_offset) const noexcept
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return ((*iterator)->offset() - _visibility_offset) <= music_offset;
|
|
|
|
return ((*iterator)->offset() - _visibility_offset) <= music_offset;
|
|
|
|
}
|
|
|
|
}
|