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/src/modes/classicmode/editor/classiceditor.cpp

88 lines
2.4 KiB
C++

#include "classiceditor.h"
#include "game/classicarrownote.h"
// Replace with interface by dependency injection
#include "graphics/animations/classicflyinganimationscenario.h"
#include "graphics/animations/classicdyinganimationscenario.h"
//
ClassicEditor::ClassicEditor(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
const std::shared_ptr<ClassicGraphicsManager>& graphics_manager) :
_timeline(timeline),
_graphics_manager(graphics_manager),
_selected_type(Type::UP),
_current_time(0),
_scroll_step(500000)
{
_timeline->setNotes({});
}
kku::microsec ClassicEditor::adjustOffset(kku::microsec offset) const noexcept
{
const auto& section = getBPMSectionAt(offset);
const kku::microsec actual_offset = offset - section.offset_start;
return actual_offset + (actual_offset % section.interval);
}
void ClassicEditor::input(kku::GameEvent&& input)
{
_current_time = input.timestamp;
const auto& event = input.event;
switch (input.event.type)
{
default:
break;
case kku::SystemEvent::Type::MousePress:
{
const auto note = _timeline->getNoteBy(_current_time);
if (_timeline->isExpired(note) && !_bpm_sections.empty() && _current_time >= (*_bpm_sections.begin()).offset_start)
{
ArrowNoteInitializer init;
ArrowElementInitializer element;
init.initializer.intervals = {};
init.initializer.perfect_offset = input.timestamp;
init.hold = false;
init.initializer.context = nullptr;
element.element.position = std::get<kku::SystemEvent::Mouse>(event.data).position;
element.element.falling_curve_interpolation = {};
element.keys = {kku::SystemEvent::Key::Code::W,
kku::SystemEvent::Key::Code::Up};
element.element.type = Type::UP;
init.elements = { element };
_timeline->insertNote(new ClassicArrowNote(std::move(init)));
}
break;
}
}
}
void ClassicEditor::update(kku::UpdateData&& updatedata)
{
_timeline->update(updatedata.timestamp);
}
void ClassicEditor::display() const
{
}
void ClassicEditor::recalculate(const kku::microsec& timestamp)
{
_timeline->recalculate(timestamp);
}
void ClassicEditor::selectNoteType(Type type) noexcept
{
_selected_type = type;
}