2021-10-05 14:48:28 -04:00
|
|
|
#pragma once
|
|
|
|
|
2021-12-29 09:59:18 -05:00
|
|
|
#include <algorithm>
|
2022-10-17 22:59:51 -04:00
|
|
|
#include <set>
|
2021-12-29 09:59:18 -05:00
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
#include "core/bpmsection.h"
|
2021-12-29 09:59:18 -05:00
|
|
|
#include "core/gameevent.h"
|
2021-12-03 14:21:27 -05:00
|
|
|
#include "core/updatedata.h"
|
2021-10-05 14:48:28 -04:00
|
|
|
|
2021-12-29 09:59:18 -05:00
|
|
|
namespace kku
|
|
|
|
{
|
|
|
|
|
2022-05-07 23:43:12 -04:00
|
|
|
/// Editor
|
|
|
|
///
|
|
|
|
/// Functional aggregation of
|
|
|
|
/// logic for Editor game mode
|
2021-10-05 14:48:28 -04:00
|
|
|
class Editor
|
|
|
|
{
|
2022-10-17 22:59:51 -04:00
|
|
|
public:
|
2021-10-05 14:48:28 -04:00
|
|
|
virtual ~Editor() = default;
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
virtual void input(GameEvent &&input) = 0;
|
|
|
|
virtual void update(UpdateData &&updatedata) = 0;
|
2021-12-28 13:04:50 -05:00
|
|
|
virtual void display() const = 0;
|
2022-10-17 22:59:51 -04:00
|
|
|
virtual void recalculate(const microsec ×tamp) = 0;
|
2021-10-05 14:48:28 -04:00
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
void setBPMSections(
|
|
|
|
const std::set<BPMSection, BPMSectionComparator> §ions) noexcept
|
2021-10-05 14:48:28 -04:00
|
|
|
{
|
|
|
|
_bpm_sections = sections;
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
void setBPMSections(
|
|
|
|
std::set<BPMSection, BPMSectionComparator> &§ions) noexcept
|
2021-10-05 14:48:28 -04:00
|
|
|
{
|
|
|
|
_bpm_sections = std::move(sections);
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
bool insertBPMSection(const BPMSection §ion)
|
2021-10-05 14:48:28 -04:00
|
|
|
{
|
2021-12-09 02:55:53 -05:00
|
|
|
return _bpm_sections.insert(section).second;
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
bool insertBPMSection(BPMSection &§ion)
|
2021-10-05 14:48:28 -04:00
|
|
|
{
|
2021-12-13 11:52:26 -05:00
|
|
|
return _bpm_sections.insert(section).second;
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
bool removeBPMSectionAt(const microsec &offset)
|
2021-10-05 14:48:28 -04:00
|
|
|
{
|
2022-10-17 22:59:51 -04:00
|
|
|
auto section_it =
|
|
|
|
std::find_if(_bpm_sections.rbegin(), _bpm_sections.rend(),
|
|
|
|
[offset](const auto §ion)
|
|
|
|
{ return section.offset_start < offset; });
|
2021-10-05 14:48:28 -04:00
|
|
|
|
|
|
|
if (section_it != _bpm_sections.rend())
|
2021-12-09 02:55:53 -05:00
|
|
|
{
|
|
|
|
++section_it;
|
|
|
|
_bpm_sections.erase(section_it.base());
|
2021-10-05 14:48:28 -04:00
|
|
|
|
2021-12-09 02:55:53 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
BPMSection getBPMSectionAt(const microsec &offset) const
|
2021-12-09 02:55:53 -05:00
|
|
|
{
|
2022-10-17 22:59:51 -04:00
|
|
|
auto section_it =
|
|
|
|
std::find_if(_bpm_sections.rbegin(), _bpm_sections.rend(),
|
|
|
|
[offset](const auto §ion)
|
|
|
|
{ return section.offset_start < offset; });
|
2021-12-09 02:55:53 -05:00
|
|
|
|
|
|
|
if (section_it != _bpm_sections.rend())
|
|
|
|
{
|
|
|
|
++section_it;
|
|
|
|
return *section_it.base();
|
|
|
|
}
|
|
|
|
|
|
|
|
return BPMSection();
|
|
|
|
}
|
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
void clearBPMSections() noexcept { _bpm_sections.clear(); }
|
2021-10-05 14:48:28 -04:00
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
protected:
|
2021-12-29 09:59:18 -05:00
|
|
|
std::set<BPMSection, BPMSectionComparator> _bpm_sections;
|
2021-10-05 14:48:28 -04:00
|
|
|
};
|
2021-12-29 09:59:18 -05:00
|
|
|
|
2022-10-17 22:59:51 -04:00
|
|
|
} // namespace kku
|