|
|
@ -1,6 +1,8 @@
|
|
|
|
#include "classicscenegraphicsmanager.h"
|
|
|
|
#include "classicscenegraphicsmanager.h"
|
|
|
|
#include "game/classicarrownote.h"
|
|
|
|
#include "game/classicarrownote.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
|
|
ClassicSceneGraphicsManager::ClassicSceneGraphicsManager(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
|
|
|
|
ClassicSceneGraphicsManager::ClassicSceneGraphicsManager(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
|
|
|
|
const std::shared_ptr<ClassicGraphicsFactory>& factory,
|
|
|
|
const std::shared_ptr<ClassicGraphicsFactory>& factory,
|
|
|
|
const kku::microsec& visibility_offset) :
|
|
|
|
const kku::microsec& visibility_offset) :
|
|
|
@ -33,7 +35,9 @@ void ClassicSceneGraphicsManager::display() const
|
|
|
|
|
|
|
|
|
|
|
|
for (auto it = _first; it != _last; ++it)
|
|
|
|
for (auto it = _first; it != _last; ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
(*it)->draw(shared_from_this());
|
|
|
|
const auto note = *it;
|
|
|
|
|
|
|
|
if (note->getState() != ClassicNote::State::DEAD)
|
|
|
|
|
|
|
|
note->draw(shared_from_this());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -48,9 +52,18 @@ void ClassicSceneGraphicsManager::update(const kku::microsec &offset)
|
|
|
|
void ClassicSceneGraphicsManager::update(const kku::microsec& offset, ClassicArrowNote* note)
|
|
|
|
void ClassicSceneGraphicsManager::update(const kku::microsec& offset, ClassicArrowNote* note)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool hasGraphics = (note->getElements()[0].sprite != nullptr);
|
|
|
|
bool hasGraphics = (note->getElements()[0].sprite != nullptr);
|
|
|
|
if (isVisiblyClose(note, offset) && (!hasGraphics))
|
|
|
|
|
|
|
|
|
|
|
|
if (isVisiblyClose(note, offset) && !hasGraphics)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << note->getId() << ": set graphics!\n" << std::flush;
|
|
|
|
setGraphics(note->getElements(), kku::TimeRange{note->getPerfectOffset() - _visibility_offset, note->getPerfectOffset()});
|
|
|
|
setGraphics(note->getElements(), kku::TimeRange{note->getPerfectOffset() - _visibility_offset, note->getPerfectOffset()});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << note->getId() << ": remove graphics!\n" << std::flush;
|
|
|
|
|
|
|
|
removeGraphics(note->getElements());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicSceneGraphicsManager::draw(const std::vector<ArrowElement>& elements) const
|
|
|
|
void ClassicSceneGraphicsManager::draw(const std::vector<ArrowElement>& elements) const
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -87,6 +100,20 @@ void ClassicSceneGraphicsManager::setGraphics(std::vector<ArrowElement>& element
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicSceneGraphicsManager::removeGraphics(std::vector<ArrowElement>& elements)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (auto& element : elements)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_sprite_container.resetSprite(element.sprite, element.type);
|
|
|
|
|
|
|
|
element.sprite = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
element.animations[ClassicNote::State::NONE] = nullptr;
|
|
|
|
|
|
|
|
element.animations[ClassicNote::State::FLYING] = nullptr;
|
|
|
|
|
|
|
|
element.animations[ClassicNote::State::DYING] = nullptr;
|
|
|
|
|
|
|
|
element.animations[ClassicNote::State::DEAD] = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ClassicSceneGraphicsManager::nothingToDraw() const noexcept
|
|
|
|
bool ClassicSceneGraphicsManager::nothingToDraw() const noexcept
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _timeline->isExpired(_first)
|
|
|
|
return _timeline->isExpired(_first)
|
|
|
|