66 lines
1.5 KiB
C++
66 lines
1.5 KiB
C++
#include "classiceditor.h"
|
|
|
|
ClassicEditor::ClassicEditor(std::shared_ptr<ClassicGraphicsManager>&& manager) :
|
|
_graphics_manager(manager),
|
|
_selected_type(Type::UP)
|
|
{
|
|
_context.graphics_manager = _graphics_manager;
|
|
}
|
|
|
|
void ClassicEditor::input(PlayerInput&& inputdata)
|
|
{
|
|
const auto& event = inputdata.event;
|
|
const auto offset = _music.fetchOffset();
|
|
|
|
switch (event.type)
|
|
{
|
|
|
|
default:
|
|
break;
|
|
|
|
case sf::Event::MouseButtonPressed:
|
|
{
|
|
const auto note = _timeline.getNoteBy(offset);
|
|
if (_timeline.isExpired(note))
|
|
{
|
|
NoteInitializer init;
|
|
init.context = &_context;
|
|
init.intervals = {};
|
|
init.perfect_offset = offset;
|
|
|
|
ElementInitializer elem_init;
|
|
elem_init.type = _selected_type;
|
|
elem_init.coordinates = Coordinates{ event.mouseButton.x, event.mouseButton.y };
|
|
elem_init.falling_curve_interpolation = {};
|
|
|
|
MockArrowNoteInitializer mock_init;
|
|
mock_init.elements = {elem_init};
|
|
mock_init.initializer = init;
|
|
|
|
_timeline.insertNote(new MockClassicNote(std::move(mock_init)));
|
|
}
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
void ClassicEditor::update(const sf::Time& dt)
|
|
{
|
|
(void)dt;
|
|
// TODO!!!
|
|
|
|
_timeline.update(_music.fetchOffset());
|
|
_timeline.fetchVisibleNotes();
|
|
}
|
|
|
|
void ClassicEditor::draw() const
|
|
{
|
|
_timeline.drawVisibleNotes();
|
|
}
|
|
|
|
void ClassicEditor::selectNoteType(Type type) noexcept
|
|
{
|
|
_selected_type = type;
|
|
}
|