|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
#include "classicnote.h"
|
|
|
|
|
#include "classictimeline.h"
|
|
|
|
|
#include "classicnotemanager.h"
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
ClassicTimeline::ClassicTimeline() :
|
|
|
|
|
ClassicTimeline::ClassicTimeline(const std::shared_ptr<ClassicNoteManager>& manager) :
|
|
|
|
|
_note_manager(manager),
|
|
|
|
|
_current_offset(0)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void ClassicTimeline::run(std::vector<ClassicNote*>&& notes, const microsec& visibility)
|
|
|
|
|
void ClassicTimeline::setNotes(std::vector<ClassicNote *> &¬es, const microsec &visibility)
|
|
|
|
|
{
|
|
|
|
|
_visibility_offset = visibility;
|
|
|
|
|
_timeline = std::move(notes);
|
|
|
|
@ -48,7 +49,7 @@ void ClassicTimeline::checkCurrentActiveNote()
|
|
|
|
|
|
|
|
|
|
auto note = *_active_note;
|
|
|
|
|
|
|
|
|
|
if (!note->isActive())
|
|
|
|
|
if (!_note_manager->isActive(note))
|
|
|
|
|
{
|
|
|
|
|
expire(_active_note);
|
|
|
|
|
++_top_note;
|
|
|
|
@ -61,7 +62,7 @@ void ClassicTimeline::checkForNextActiveNote()
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto top_note = *_top_note;
|
|
|
|
|
if (top_note->isActive())
|
|
|
|
|
if (_note_manager->isActive(top_note))
|
|
|
|
|
_active_note = _top_note;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -70,10 +71,11 @@ void ClassicTimeline::updateVisibleSprites(const microsec& music_offset)
|
|
|
|
|
if (nothingToDraw())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const auto& note_manager = _note_manager;
|
|
|
|
|
std::for_each(_first_visible_note, _last_visible_note,
|
|
|
|
|
[&music_offset](const auto& note)
|
|
|
|
|
[¬e_manager, &music_offset](const auto& note)
|
|
|
|
|
{
|
|
|
|
|
note->update(music_offset);
|
|
|
|
|
note_manager->update(note, music_offset);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -113,8 +115,8 @@ void ClassicTimeline::findLastVisibleNote(const microsec &music_offset)
|
|
|
|
|
|
|
|
|
|
auto note = *note_iterator;
|
|
|
|
|
|
|
|
|
|
if (!note->isInGame())
|
|
|
|
|
note->putToGame(music_offset);
|
|
|
|
|
if (!_note_manager->isInGame(note))
|
|
|
|
|
_note_manager->putToGame(note, music_offset);
|
|
|
|
|
|
|
|
|
|
++note_iterator;
|
|
|
|
|
}
|
|
|
|
@ -131,7 +133,7 @@ void ClassicTimeline::findFirstVisibleNote()
|
|
|
|
|
while (note_iterator != _last_visible_note)
|
|
|
|
|
{
|
|
|
|
|
auto note = *note_iterator;
|
|
|
|
|
if (note->shouldRemove())
|
|
|
|
|
if (_note_manager->shouldRemove(note))
|
|
|
|
|
++_first_visible_note;
|
|
|
|
|
|
|
|
|
|
++note_iterator;
|
|
|
|
@ -148,10 +150,11 @@ void ClassicTimeline::drawVisibleNotes() const
|
|
|
|
|
if (nothingToDraw())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const auto& note_manager = _note_manager;
|
|
|
|
|
std::for_each(_first_visible_note, _last_visible_note,
|
|
|
|
|
[](const auto& note)
|
|
|
|
|
[¬e_manager](const auto& note)
|
|
|
|
|
{
|
|
|
|
|
note->draw();
|
|
|
|
|
note_manager->draw(note);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|