|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "timeline.h"
|
|
|
|
|
|
|
|
#include <SFML/Audio/Music.hpp>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class Note;
|
|
|
|
|
|
|
|
class ClassicTimeline : public Timeline
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ClassicTimeline();
|
|
|
|
virtual ~ClassicTimeline();
|
|
|
|
virtual void update() override;
|
|
|
|
virtual void run(std::vector<Note*>&& notes, const microsec& visibility) override;
|
|
|
|
virtual void clear() override;
|
|
|
|
|
|
|
|
virtual microsec currentMusicOffset() const override;
|
|
|
|
virtual void drawVisibleNotes() const override;
|
|
|
|
|
|
|
|
void fetchVisibleNotes();
|
|
|
|
void findLastVisibleNote(const microsec& music_offset);
|
|
|
|
void findFirstVisibleNote();
|
|
|
|
|
|
|
|
Iterator getActiveNote() noexcept;
|
|
|
|
|
|
|
|
bool isExpired(const Iterator& iterator) const;
|
|
|
|
inline void expire(Iterator& iterator);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<microsec> _input_intervals;
|
|
|
|
std::vector<Note*> _timeline;
|
|
|
|
microsec _visibility_offset;
|
|
|
|
|
|
|
|
sf::Music _music;
|
|
|
|
|
|
|
|
void updateVisibleSprites(const microsec& music_offset);
|
|
|
|
void checkCurrentActiveNote(const microsec& music_offset);
|
|
|
|
void checkForNextActiveNote(const microsec& music_offset);
|
|
|
|
bool isVisiblyClose(const Iterator& iterator, const microsec& music_offset) const;
|
|
|
|
inline bool nothingToDraw() const noexcept;
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
* */
|
|
|
|
|
|
|
|
Iterator _top_note;
|
|
|
|
Iterator _active_note;
|
|
|
|
Iterator _last_visible_note;
|
|
|
|
Iterator _first_visible_note;
|
|
|
|
};
|