2021-06-07 14:19:58 -04:00
|
|
|
#include "classicnote.h"
|
2021-06-09 14:08:58 -04:00
|
|
|
#include "classicsprite.h"
|
|
|
|
#include <SFML/Graphics/RenderTarget.hpp>
|
2021-06-07 14:19:58 -04:00
|
|
|
|
2021-06-09 14:08:58 -04:00
|
|
|
ClassicNote::ClassicNote(const std::vector<microsec>& intervals, microsec perfect_offset,
|
|
|
|
Action action, const Coordinates& coord) :
|
2021-06-07 14:19:58 -04:00
|
|
|
Note(perfect_offset),
|
2021-06-09 14:08:58 -04:00
|
|
|
_coordinates(coord),
|
2021-06-08 14:32:36 -04:00
|
|
|
_evaluator(intervals, _perfect_offset),
|
|
|
|
_action(action)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool ClassicNote::isActive(microsec music_offset) const
|
|
|
|
{
|
|
|
|
return _evaluator.isActive(music_offset);
|
|
|
|
}
|
|
|
|
|
2021-06-09 14:08:58 -04:00
|
|
|
void ClassicNote::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
|
|
|
{
|
|
|
|
target.draw(*_sprite, states);
|
|
|
|
}
|
|
|
|
|
2021-06-08 14:32:36 -04:00
|
|
|
ClassicNote::GRADE ClassicNote::input(ClassicInputType&& input_data)
|
2021-06-07 14:19:58 -04:00
|
|
|
{
|
2021-06-08 14:32:36 -04:00
|
|
|
if (input_data == _action)
|
|
|
|
{
|
|
|
|
return _evaluator.calculatePrecision(input_data.timestamp());
|
|
|
|
}
|
2021-06-07 14:19:58 -04:00
|
|
|
|
2021-06-08 14:32:36 -04:00
|
|
|
return ClassicNote::GRADE::BAD;
|
2021-06-07 14:19:58 -04:00
|
|
|
}
|
2021-06-09 14:08:58 -04:00
|
|
|
|
|
|
|
Action ClassicNote::action() const
|
|
|
|
{
|
|
|
|
return _action;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<ClassicSprite> ClassicNote::sprite() const noexcept
|
|
|
|
{
|
|
|
|
return _sprite;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClassicNote::setSprite(const std::shared_ptr<ClassicSprite>& sprite) noexcept
|
|
|
|
{
|
|
|
|
_sprite = sprite;
|
|
|
|
_sprite->setCoordinates(_coordinates.x, _coordinates.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const Coordinates& ClassicNote::getCoordinates() const noexcept
|
|
|
|
{
|
|
|
|
return _coordinates;
|
|
|
|
}
|