2021-10-05 20:48:28 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include "core/inputtype.h"
|
2021-12-03 20:21:27 +01:00
|
|
|
#include "core/updatedata.h"
|
2021-10-05 20:48:28 +02:00
|
|
|
#include "core/bpmsection.h"
|
|
|
|
|
|
|
|
class Editor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Editor() = default;
|
|
|
|
|
|
|
|
virtual void input(PlayerInput&& inputdata) = 0;
|
2021-12-03 20:21:27 +01:00
|
|
|
virtual void update(UpdateData&& updatedata) = 0;
|
2021-12-28 19:04:50 +01:00
|
|
|
virtual void display() const = 0;
|
2021-12-08 19:00:47 +01:00
|
|
|
virtual void recalculate(const microsec& timestamp) = 0;
|
2021-10-05 20:48:28 +02:00
|
|
|
|
2021-12-09 08:55:53 +01:00
|
|
|
void setBPMSections(const std::set<BPMSection, BPMSectionCompt>& sections) noexcept
|
2021-10-05 20:48:28 +02:00
|
|
|
{
|
|
|
|
_bpm_sections = sections;
|
|
|
|
}
|
|
|
|
|
2021-12-09 08:55:53 +01:00
|
|
|
void setBPMSections(std::set<BPMSection, BPMSectionCompt>&& sections) noexcept
|
2021-10-05 20:48:28 +02:00
|
|
|
{
|
|
|
|
_bpm_sections = std::move(sections);
|
|
|
|
}
|
|
|
|
|
2021-12-09 08:55:53 +01:00
|
|
|
bool insertBPMSection(const BPMSection& section)
|
2021-10-05 20:48:28 +02:00
|
|
|
{
|
2021-12-09 08:55:53 +01:00
|
|
|
return _bpm_sections.insert(section).second;
|
2021-10-05 20:48:28 +02:00
|
|
|
}
|
|
|
|
|
2021-12-09 08:55:53 +01:00
|
|
|
bool insertBPMSection(BPMSection&& section)
|
2021-10-05 20:48:28 +02:00
|
|
|
{
|
2021-12-13 17:52:26 +01:00
|
|
|
return _bpm_sections.insert(section).second;
|
2021-10-05 20:48:28 +02:00
|
|
|
}
|
|
|
|
|
2021-12-09 08:55:53 +01:00
|
|
|
bool removeBPMSectionAt(const microsec& offset)
|
2021-10-05 20:48:28 +02:00
|
|
|
{
|
2021-12-09 08:55:53 +01:00
|
|
|
auto section_it = std::find_if(_bpm_sections.rbegin(), _bpm_sections.rend(),
|
|
|
|
[offset](const auto& section)
|
|
|
|
{
|
|
|
|
return section.offset_start < offset;
|
|
|
|
});
|
2021-10-05 20:48:28 +02:00
|
|
|
|
|
|
|
if (section_it != _bpm_sections.rend())
|
2021-12-09 08:55:53 +01:00
|
|
|
{
|
|
|
|
++section_it;
|
|
|
|
_bpm_sections.erase(section_it.base());
|
2021-10-05 20:48:28 +02:00
|
|
|
|
2021-12-09 08:55:53 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
BPMSection getBPMSectionAt(const microsec& offset) const
|
|
|
|
{
|
|
|
|
auto section_it = std::find_if(_bpm_sections.rbegin(), _bpm_sections.rend(),
|
|
|
|
[offset](const auto& section)
|
|
|
|
{
|
|
|
|
return section.offset_start < offset;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (section_it != _bpm_sections.rend())
|
|
|
|
{
|
|
|
|
++section_it;
|
|
|
|
return *section_it.base();
|
|
|
|
}
|
|
|
|
|
|
|
|
return BPMSection();
|
|
|
|
}
|
|
|
|
|
|
|
|
void clearBPMSections() noexcept
|
2021-10-05 20:48:28 +02:00
|
|
|
{
|
|
|
|
_bpm_sections.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2021-11-02 18:03:27 +01:00
|
|
|
std::set<BPMSection, BPMSectionCompt> _bpm_sections;
|
2021-10-05 20:48:28 +02:00
|
|
|
};
|