|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include "timeline.h"
|
|
|
|
#include <SFML/Audio/Music.hpp>
|
|
|
|
|
|
|
|
class ClassicNote;
|
|
|
|
class ClassicViewManager;
|
|
|
|
|
|
|
|
class ClassicTimeline : public Timeline
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ClassicTimeline();
|
|
|
|
virtual ~ClassicTimeline();
|
|
|
|
virtual void update() override;
|
|
|
|
virtual void init() override;
|
|
|
|
virtual void clear() override;
|
|
|
|
|
|
|
|
virtual microsec currentMusicOffset() const override;
|
|
|
|
virtual void drawVisibleNotes(sf::RenderWindow& window) const override;
|
|
|
|
|
|
|
|
void fetchVisibleNotes(const std::unique_ptr<ClassicViewManager>& view_manager);
|
|
|
|
|
|
|
|
using Iterator = std::vector<ClassicNote*>::const_iterator;
|
|
|
|
|
|
|
|
Iterator getActiveNote() noexcept;
|
|
|
|
|
|
|
|
bool isExpired(const Iterator& iterator);
|
|
|
|
void expire(Iterator& iterator);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<ClassicNote*> _timeline;
|
|
|
|
Iterator _top_note;
|
|
|
|
Iterator _active_note;
|
|
|
|
Iterator _last_visible_note;
|
|
|
|
|
|
|
|
microsec _visibility_offset;
|
|
|
|
|
|
|
|
sf::Music _music;
|
|
|
|
|
|
|
|
void checkCurrentActiveNote(const microsec &music_offset);
|
|
|
|
void checkForNextActiveNote(const microsec &music_offset);
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
* */
|
|
|
|
};
|