Adjust editor process to new editor context
parent
c24ecc0acc
commit
90292750fb
@ -0,0 +1,103 @@
|
||||
#include "editorcontext.h"
|
||||
#include "game/classicarrownote.h"
|
||||
#include "graphics/animations/classicanimationscenario.h"
|
||||
#include "graphics/classicgraphicsmanager.h"
|
||||
#include "graphics/classicnotegraphics.h"
|
||||
|
||||
EditorContext::EditorContext(const std::shared_ptr<SelectionManager<ClassicNote>>& selection_manager,
|
||||
std::vector<std::shared_ptr<ClassicGraphicsManager>>&& graphics_managers) :
|
||||
_selection_manager(selection_manager),
|
||||
_graphics_managers(std::move(graphics_managers))
|
||||
{}
|
||||
|
||||
void EditorContext::input(ClassicArrowNote *note, kku::GameEvent&& input) const
|
||||
{
|
||||
(void)note;
|
||||
switch (input.event.type)
|
||||
{
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
/*case kku::SystemEvent::Type::MousePress:
|
||||
{
|
||||
bool selection_changed = false;
|
||||
std::size_t amount_selected = 0;
|
||||
|
||||
const auto position = std::get<kku::SystemEvent::Mouse>(input.event.data).position;
|
||||
for (auto& element : note->getElements())
|
||||
{
|
||||
if (element.sprite->getRectangle()->contains(position))
|
||||
{
|
||||
element.selected = !element.selected;
|
||||
selection_changed = true;
|
||||
if (element.selected)
|
||||
++amount_selected;
|
||||
}
|
||||
}
|
||||
|
||||
if (selection_changed)
|
||||
{
|
||||
if (amount_selected > 0)
|
||||
_selection_manager->fetch(note);
|
||||
else
|
||||
_selection_manager->remove(note);
|
||||
}
|
||||
|
||||
break;
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EditorContext::update(ClassicArrowNote *note, const kku::microsec& music_offset) const
|
||||
{
|
||||
auto& elements = note->getElements();
|
||||
|
||||
switch (note->getState())
|
||||
{
|
||||
default: return;
|
||||
break;
|
||||
|
||||
case ClassicArrowNote::State::INITIAL:
|
||||
note->setState(ClassicArrowNote::State::FLYING);
|
||||
for (auto& manager : _graphics_managers)
|
||||
manager->update(music_offset, note);
|
||||
break;
|
||||
|
||||
case ClassicArrowNote::State::FLYING:
|
||||
if (!note->isActive(music_offset) && music_offset > note->getPerfectOffset())
|
||||
{
|
||||
note->setState(ClassicArrowNote::State::DYING);
|
||||
for (auto& element : elements)
|
||||
element.animations[note->getState()]->launch(element.sprite, music_offset, note->getPerfectOffset());
|
||||
}
|
||||
break;
|
||||
|
||||
case ClassicArrowNote::State::DYING:
|
||||
if (elements[0].animations[note->getState()]->isDone())
|
||||
note->setState(ClassicArrowNote::State::DEAD);
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto& element : elements)
|
||||
if (element.animations[note->getState()])
|
||||
element.animations[note->getState()]->update(music_offset);
|
||||
}
|
||||
|
||||
std::shared_ptr<SelectionManager<ClassicNote>> EditorContext::getSelectionManager() const
|
||||
{
|
||||
return _selection_manager;
|
||||
}
|
||||
|
||||
void EditorContext::updateGraphics(const kku::microsec& music_offset)
|
||||
{
|
||||
for (auto& manager : _graphics_managers)
|
||||
manager->update(music_offset);
|
||||
}
|
||||
|
||||
void EditorContext::displayGraphics() const
|
||||
{
|
||||
for (const auto& manager : _graphics_managers)
|
||||
manager->display();
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "classicmode/classicnote.h"
|
||||
#include "classicmode/context.h"
|
||||
#include "editor/selectionmanager.h"
|
||||
|
||||
class ClassicGraphicsManager;
|
||||
|
||||
class EditorContext : public Context
|
||||
{
|
||||
public:
|
||||
explicit EditorContext(const std::shared_ptr<SelectionManager<ClassicNote>>& selection_manager,
|
||||
std::vector<std::shared_ptr<ClassicGraphicsManager>>&& graphics_managers);
|
||||
|
||||
virtual void input(ClassicArrowNote *note, kku::GameEvent&& input) const override;
|
||||
virtual void update(ClassicArrowNote *note, const kku::microsec &music_offset) const override;
|
||||
|
||||
void updateGraphics(const kku::microsec& music_offset);
|
||||
void displayGraphics() const;
|
||||
|
||||
std::shared_ptr<SelectionManager<ClassicNote>> getSelectionManager() const;
|
||||
|
||||
private:
|
||||
const std::shared_ptr<SelectionManager<ClassicNote>> _selection_manager;
|
||||
const std::vector<std::shared_ptr<ClassicGraphicsManager>> _graphics_managers;
|
||||
};
|
Loading…
Reference in New Issue