forked from NaiJi/project-kyoku
Add Editor interface
parent
8579dc5507
commit
c097ac0da5
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "tools/mathutils.h"
|
||||||
|
|
||||||
|
struct BPMSection
|
||||||
|
{
|
||||||
|
int bpm = 0;
|
||||||
|
int fraction = 1;
|
||||||
|
microsec offset_start = 0;
|
||||||
|
|
||||||
|
inline bool operator<(const BPMSection& right)
|
||||||
|
{
|
||||||
|
return offset_start < right.offset_start;
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include "core/inputtype.h"
|
||||||
|
#include "core/bpmsection.h"
|
||||||
|
|
||||||
|
class Editor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Editor() = default;
|
||||||
|
|
||||||
|
virtual void input(PlayerInput&& inputdata) = 0;
|
||||||
|
virtual void update() = 0;
|
||||||
|
virtual void draw() const = 0;
|
||||||
|
|
||||||
|
inline void setBPMSections(const std::set<BPMSection>& sections)
|
||||||
|
{
|
||||||
|
_bpm_sections = sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void setBPMSections(std::set<BPMSection>&& sections)
|
||||||
|
{
|
||||||
|
_bpm_sections = std::move(sections);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void insertBPMSection(const BPMSection& section)
|
||||||
|
{
|
||||||
|
_bpm_sections.insert(section);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void insertBPMSection(BPMSection&& section)
|
||||||
|
{
|
||||||
|
_bpm_sections.insert(std::move(section));
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeBPMSectionAt(const microsec& offset)
|
||||||
|
{
|
||||||
|
const auto section_it = std::find_if(_bpm_sections.rbegin(), _bpm_sections.rend(),
|
||||||
|
[offset](const auto& section)
|
||||||
|
{
|
||||||
|
return section.start_offset < offset;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (section_it != _bpm_sections.rend())
|
||||||
|
_bpm_sections.erase((section_it + 1).base());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void clearBPMSections()
|
||||||
|
{
|
||||||
|
_bpm_sections.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::set<BPMSection> _bpm_sections;
|
||||||
|
};
|
@ -0,0 +1,6 @@
|
|||||||
|
#include "classiceditor.h"
|
||||||
|
|
||||||
|
ClassicEditor::ClassicEditor()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
#include "classiceditor.h"
|
||||||
|
|
||||||
|
ClassicEditor::ClassicEditor(std::shared_ptr<ClassicGraphicsManager>&& manager)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/editor.h"
|
||||||
|
|
||||||
|
class ClassicEditor : public Editor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ClassicEditor();
|
||||||
|
|
||||||
|
virtual void input(PlayerInput&& inputdata) = 0;
|
||||||
|
virtual void update() = 0;
|
||||||
|
virtual void draw() const = 0;
|
||||||
|
};
|
@ -0,0 +1,50 @@
|
|||||||
|
#include "editorwidget.h"
|
||||||
|
|
||||||
|
EditorWidget::EditorWidget(const std::shared_ptr<Editor>& editor) :
|
||||||
|
_editor(editor)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void EditorWidget::input(const sf::Event& event)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWidget::update(const sf::Time& dt)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWidget::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWidget::move(const sf::Vector2f& delta)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EditorWidget::isUnderMouse(int mouse_x, int mouse_y) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWidget::setRect(const sf::FloatRect& rect)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sf::FloatRect EditorWidget::rect() const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWidget::setPosition(const sf::Vector2f& position)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sf::Vector2f EditorWidget::position() const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "widget.h"
|
||||||
|
|
||||||
|
class Editor;
|
||||||
|
|
||||||
|
class EditorWidget : public Widget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit EditorWidget(const std::shared_ptr<Editor>& editor);
|
||||||
|
|
||||||
|
virtual void input(const sf::Event& event) override;
|
||||||
|
virtual void update(const sf::Time& dt) override;
|
||||||
|
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
||||||
|
virtual void move(const sf::Vector2f& delta) override;
|
||||||
|
virtual bool isUnderMouse(int mouse_x, int mouse_y) const override;
|
||||||
|
|
||||||
|
virtual void setRect(const sf::FloatRect& rect) override;
|
||||||
|
virtual sf::FloatRect rect() const override;
|
||||||
|
|
||||||
|
virtual void setPosition(const sf::Vector2f& position) override;
|
||||||
|
virtual sf::Vector2f position() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<Editor> _editor;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue