Add polymorphic draw for classic notes
This commit is contained in:
parent
0d97e61f4b
commit
45132ff82a
|
@ -1,5 +1,6 @@
|
|||
#include "game/classicarrownote.h"
|
||||
#include "classicmode/context.h"
|
||||
#include "graphics/classicgraphicsmanager.h"
|
||||
|
||||
ClassicArrowNote::ClassicArrowNote(Init&& init) :
|
||||
ClassicNote(init.perfect_offset),
|
||||
|
@ -33,12 +34,22 @@ void ClassicArrowNote::input(kku::GameEvent&& input)
|
|||
_context->input(this, std::move(input));
|
||||
}
|
||||
|
||||
void ClassicArrowNote::setGraphics(const std::shared_ptr<const ClassicGraphicsManager>& graphics_manager, kku::TimeRange&& range) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ClassicArrowNote::draw(const std::shared_ptr<const ClassicGraphicsManager>& graphics_manager) const
|
||||
{
|
||||
graphics_manager->draw(this);
|
||||
}
|
||||
|
||||
bool ClassicArrowNote::isHold() const
|
||||
{
|
||||
return _is_holding;
|
||||
}
|
||||
|
||||
std::vector<ArrowElement>& ClassicArrowNote::getElements()
|
||||
const std::vector<ArrowElement>& ClassicArrowNote::getElements() const
|
||||
{
|
||||
return _elements;
|
||||
}
|
||||
|
|
|
@ -35,9 +35,11 @@ public:
|
|||
virtual bool isActive(const kku::microsec& offset) const override;
|
||||
virtual void update(const kku::microsec &music_offset) override;
|
||||
virtual void input(kku::GameEvent&& input) override;
|
||||
virtual void setGraphics(const std::shared_ptr<const ClassicGraphicsManager>& graphics_manager, kku::TimeRange&& range) const override;
|
||||
virtual void draw(const std::shared_ptr<const ClassicGraphicsManager> &graphics_manager) const override;
|
||||
|
||||
bool isHold() const;
|
||||
std::vector<ArrowElement>& getElements();
|
||||
const std::vector<ArrowElement>& getElements() const;
|
||||
Grade calculatePrecision(const kku::microsec& offset) const;
|
||||
bool isPressedAs(kku::SystemEvent::Key::Code key) const;
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ public:
|
|||
virtual void update(const kku::microsec& offset, ClassicArrowNote* note) = 0;
|
||||
// virtual void update(const kku::microsec& offset, ClassicSliderNote* note) = 0;
|
||||
|
||||
virtual void draw(const ClassicArrowNote* note) const = 0;
|
||||
// virtual void draw(ClassicSliderNote* note) const = 0;
|
||||
|
||||
protected:
|
||||
kku::microsec _visibility_offset;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "classicscenegraphicsmanager.h"
|
||||
#include "game/classicarrownote.h"
|
||||
|
||||
ClassicSceneGraphicsManager::ClassicSceneGraphicsManager(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
|
||||
const std::shared_ptr<ClassicGraphicsFactory>& factory,
|
||||
|
@ -32,7 +33,7 @@ void ClassicSceneGraphicsManager::display() const
|
|||
|
||||
for (auto it = _first; it != _last; ++it)
|
||||
{
|
||||
//display((*it)->getElements());
|
||||
(*it)->draw(shared_from_this());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +47,9 @@ void ClassicSceneGraphicsManager::update(const kku::microsec& offset, ClassicArr
|
|||
updateVisibleNotes(offset);
|
||||
}
|
||||
|
||||
void ClassicSceneGraphicsManager::display(const std::vector<ArrowElement>& elements) const
|
||||
void ClassicSceneGraphicsManager::draw(const ClassicArrowNote* note) const
|
||||
{
|
||||
auto& elements = note->getElements();
|
||||
for (std::size_t i = 0; i < elements.size(); ++i)
|
||||
{
|
||||
const auto& sprite = elements[i].sprite;
|
||||
|
@ -55,10 +57,8 @@ void ClassicSceneGraphicsManager::display(const std::vector<ArrowElement>& eleme
|
|||
if (i >= 1)
|
||||
{
|
||||
//const auto& neighbor_sprite = elements[i - 1].sprite;
|
||||
|
||||
//const auto c1 = neighbor_sprite->trailPosition();
|
||||
//const auto c2 = sprite->trailPosition();
|
||||
|
||||
//_render_target->draw(makeLine(c1, c2));
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ void ClassicSceneGraphicsManager::fetchFirstNote(const kku::microsec& offset)
|
|||
&& offset <= note->getPerfectOffset())
|
||||
{
|
||||
note->setState(ClassicNote::State::FLYING);
|
||||
//setGraphics(note, kku::TimeRange{note->getPerfectOffset() - _visibility_offset, note->getPerfectOffset()});
|
||||
note->setGraphics(shared_from_this(), kku::TimeRange{note->getPerfectOffset() - _visibility_offset, note->getPerfectOffset()});
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -150,7 +150,7 @@ void ClassicSceneGraphicsManager::fetchLastNote(const kku::microsec& offset)
|
|||
&& offset <= note->getPerfectOffset())
|
||||
{
|
||||
note->setState(ClassicNote::State::FLYING);
|
||||
//note->setGraphics(this, kku::TimeRange{note->getPerfectOffset() - _visibility_offset, note->getPerfectOffset()});
|
||||
note->setGraphics(shared_from_this(), kku::TimeRange{note->getPerfectOffset() - _visibility_offset, note->getPerfectOffset()});
|
||||
}
|
||||
|
||||
++note_iterator;
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
virtual void display() const override;
|
||||
|
||||
virtual void update(const kku::microsec& offset, ClassicArrowNote* note) override;
|
||||
virtual void display(const std::vector<ArrowElement>& elements) const;
|
||||
virtual void draw(const ClassicArrowNote* note) const override;
|
||||
virtual void setGraphics(std::vector<ArrowElement>& elements, kku::TimeRange&& range);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "core/note.h"
|
||||
|
||||
class ClassicGraphicsManager;
|
||||
|
||||
class ClassicNote : public kku::Note
|
||||
{
|
||||
public:
|
||||
|
@ -20,9 +23,11 @@ public:
|
|||
|
||||
virtual bool isActive(const kku::microsec& offset) const override = 0;
|
||||
virtual void update(const kku::microsec &music_offset) override = 0;
|
||||
|
||||
virtual void input(kku::GameEvent&& input) override = 0;
|
||||
|
||||
virtual void setGraphics(const std::shared_ptr<const ClassicGraphicsManager>& graphics_manager, kku::TimeRange&& range) const = 0;
|
||||
virtual void draw(const std::shared_ptr<const ClassicGraphicsManager>& graphics_manager) const = 0;
|
||||
|
||||
void setState(State state) noexcept;
|
||||
State getState() const noexcept;
|
||||
|
||||
|
|
Loading…
Reference in New Issue