You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
project-kyoku/modes/classicmode/editor/classiceditor.cpp

79 lines
1.9 KiB
C++

#include "classiceditor.h"
ClassicEditor::ClassicEditor() :
_selected_type(Type::UP),
_current_time(0),
_scroll_step(500000)
{
std::set<MockClassicNote*, NotePtrCompt> set = {};
// VISIBILITY 1648648
_timeline.setNotes(set);
}
microsec ClassicEditor::adjustOffset(microsec offset) const noexcept
{
const auto& section = getBPMSectionAt(offset);
const microsec actual_offset = offset - section.offset_start;
return actual_offset + (actual_offset % section.interval);
}
void ClassicEditor::input(PlayerInput&& inputdata)
{
_current_time = inputdata.timestamp;
const auto& event = inputdata.event;
switch (event.type)
{
default:
break;
case sf::Event::MouseButtonPressed:
{
const auto note = _timeline.getNoteBy(_current_time);
if (_timeline.isExpired(note) && !_bpm_sections.empty() && _current_time >= (*_bpm_sections.begin()).offset_start)
{
NoteInitializer init;
init.context = &_context;
init.intervals = {};
init.perfect_offset = adjustOffset(_current_time);
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(UpdateData&& updatedata)
{
_timeline.update(updatedata.timestamp);
}
void ClassicEditor::draw() const
{
}
void ClassicEditor::recalculate(const microsec& timestamp)
{
_timeline.recalculate(timestamp);
}
void ClassicEditor::selectNoteType(Type type) noexcept
{
_selected_type = type;
}