2021-04-08 09:34:03 -04:00
|
|
|
#ifndef TIMELINE_H
|
|
|
|
#define TIMELINE_H
|
|
|
|
|
|
|
|
#include <SFML/Config.hpp>
|
2021-04-09 09:28:45 -04:00
|
|
|
#include <SFML/Graphics/RectangleShape.hpp>
|
2021-04-08 09:34:03 -04:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
using microsec = sf::Int64;
|
|
|
|
class Note;
|
2021-04-17 12:14:36 -04:00
|
|
|
class TimelineViewManager;
|
2021-04-08 09:34:03 -04:00
|
|
|
|
2021-04-09 09:28:45 -04:00
|
|
|
class Timeline : public sf::Drawable // Probably it's bad
|
2021-04-08 09:34:03 -04:00
|
|
|
{
|
|
|
|
public:
|
2021-04-17 12:14:36 -04:00
|
|
|
explicit Timeline(std::unique_ptr<TimelineViewManager> view_manager);
|
2021-04-09 09:28:45 -04:00
|
|
|
virtual ~Timeline();
|
2021-04-08 09:34:03 -04:00
|
|
|
|
2021-04-09 09:28:45 -04:00
|
|
|
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
|
|
|
|
|
|
|
void update(const microsec& music_offset);
|
2021-04-15 11:03:35 -04:00
|
|
|
Note *fetchActiveNote(const microsec &music_offset) noexcept;
|
2021-04-09 09:28:45 -04:00
|
|
|
|
|
|
|
/* void init(); */
|
|
|
|
void clear();
|
2021-04-08 09:34:03 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Note*> _timeline;
|
2021-04-09 09:28:45 -04:00
|
|
|
std::vector<Note*>::const_iterator _top_note;
|
2021-04-08 09:34:03 -04:00
|
|
|
Note* _active_note;
|
|
|
|
|
2021-04-09 09:28:45 -04:00
|
|
|
std::vector<Note*>::const_iterator _last_visible_note;
|
|
|
|
microsec _visibility_offset;
|
|
|
|
|
2021-04-17 12:14:36 -04:00
|
|
|
std::unique_ptr<TimelineViewManager> _view_manager;
|
|
|
|
|
2021-04-09 09:28:45 -04:00
|
|
|
void checkCurrentActiveNote(const microsec &music_offset);
|
|
|
|
void checkForNextActiveNote(const microsec &music_offset);
|
|
|
|
void prepareNotesToDraw(const microsec &music_offset);
|
2021-04-08 09:34:03 -04:00
|
|
|
|
|
|
|
/* Difference between top and active note is that
|
|
|
|
* top note is the note handling input right now
|
|
|
|
* OR it's the closest note from current music offset
|
|
|
|
* position, not necessarily active. A note stops being top only
|
|
|
|
* after dying or being tapped by player, even if it's already
|
|
|
|
* past her perfect offset.
|
|
|
|
*
|
|
|
|
* Meanwhile active note is the note which is currently handling
|
|
|
|
* player input for grade.
|
|
|
|
*
|
|
|
|
* An active note is always top note but a top note
|
|
|
|
* is not always active note.
|
|
|
|
* */
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TIMELINE_H
|