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