forked from NaiJi/project-kyoku
Move HolderManager and ClassicGraphicsManager to context
This commit is contained in:
parent
14c201e28d
commit
c2b23a4c59
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "core/timeline.h"
|
||||
#include "game/classicgame.h"
|
||||
#include "game/gamecontext.h"
|
||||
#include "editor/classiceditor.h"
|
||||
#include "editor/selectionmanager.h"
|
||||
|
||||
|
@ -17,8 +18,11 @@ std::unique_ptr<kku::Game> classic::getGame(const std::shared_ptr<kku::CoreFacto
|
|||
const auto factory = std::make_shared<ClassicGraphicsFactory>(core_factory);
|
||||
const auto timeline = std::make_shared<kku::Timeline<ClassicNote>>();
|
||||
const auto graphics_manager = std::make_shared<ClassicSceneGraphicsManager<ClassicNote>>(timeline, factory, visibility_offset);
|
||||
const auto hold_manager = std::make_shared<HoldManager>();
|
||||
|
||||
return std::make_unique<ClassicGame>(timeline, graphics_manager);
|
||||
const auto context = std::make_shared<GameContext>(hold_manager, graphics_manager);
|
||||
|
||||
return std::make_unique<ClassicGame>(timeline, context);
|
||||
}
|
||||
|
||||
std::unique_ptr<kku::Editor> classic::getEditor(const std::shared_ptr<kku::CoreFactory>& core_factory)
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "classicmode/noteinitializer.h"
|
||||
#include "classicmode/elementinitializer.h"
|
||||
|
||||
struct MockArrowNoteInitializer
|
||||
{
|
||||
NoteInitializer initializer;
|
||||
std::vector<ElementInitializer> elements;
|
||||
};
|
|
@ -1,32 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "classicmode/classicactions.h"
|
||||
|
||||
#include "core/gameevent.h"
|
||||
#include "core/point.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
class ClassicAnimationScenario;
|
||||
class ClassicNoteGraphics;
|
||||
class ClassicSelectionGraphics;
|
||||
|
||||
struct MockElement
|
||||
{
|
||||
std::shared_ptr<ClassicNoteGraphics> sprite;
|
||||
std::shared_ptr<ClassicSelectionGraphics> selection;
|
||||
bool selected;
|
||||
|
||||
std::array<std::shared_ptr<ClassicAnimationScenario>, 5> animations;
|
||||
|
||||
kku::Point position;
|
||||
std::vector<kku::Point> falling_curve_interpolation;
|
||||
|
||||
Type type = Type::NONE;
|
||||
|
||||
// Each note may consist of several buttons.
|
||||
// For example, ↑ → or ↓ → ←
|
||||
// Note Element represents this idea.
|
||||
};
|
|
@ -14,7 +14,7 @@ public:
|
|||
|
||||
struct Init
|
||||
{
|
||||
const Context * const context;
|
||||
Context * const context;
|
||||
const kku::microsec perfect_offset = 0;
|
||||
|
||||
const std::vector<kku::microsec>& intervals = {};
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "classicgame.h"
|
||||
#include "classicmode/classicnote.h"
|
||||
#include "classicmapcreator.h"
|
||||
#include "gamecontext.h"
|
||||
#include "graphics/classicscenegraphicsmanager.h"
|
||||
#include "holdmanager.h"
|
||||
|
||||
ClassicGame::ClassicGame(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
|
||||
const std::shared_ptr<ClassicGraphicsManager>& graphics_manager) :
|
||||
const std::shared_ptr<GameContext>& context) :
|
||||
_timeline(timeline),
|
||||
_graphics_manager(graphics_manager),
|
||||
_hold_manager(std::make_unique<HoldManager>())
|
||||
_context(context)
|
||||
{}
|
||||
|
||||
ClassicGame::~ClassicGame()
|
||||
|
@ -16,7 +16,7 @@ ClassicGame::~ClassicGame()
|
|||
|
||||
void ClassicGame::run()
|
||||
{
|
||||
auto beatmap = classic::createBeatmap("aa", _hold_manager);
|
||||
auto beatmap = classic::createBeatmap("aa", _context);
|
||||
_timeline->setNotes(beatmap.notes);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ void ClassicGame::input(kku::GameEvent&& input)
|
|||
|
||||
case kku::SystemEvent::Type::KeyRelease:
|
||||
{
|
||||
_hold_manager->checkRelease(std::get<kku::SystemEvent::Key>(input.event.data).view);
|
||||
_context->getHoldManager()->checkRelease(std::get<kku::SystemEvent::Key>(input.event.data).view);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -61,10 +61,10 @@ void ClassicGame::update(kku::UpdateData&& updatedata)
|
|||
}*/
|
||||
|
||||
_timeline->update(updatedata.timestamp);
|
||||
_graphics_manager->update(updatedata.timestamp);
|
||||
_context->getGraphicsManager()->update(updatedata.timestamp);
|
||||
}
|
||||
|
||||
void ClassicGame::display() const
|
||||
{
|
||||
_graphics_manager->display();
|
||||
_context->getGraphicsManager()->display();
|
||||
}
|
||||
|
|
|
@ -10,12 +10,13 @@
|
|||
|
||||
class ClassicGraphicsManager;
|
||||
class HoldManager;
|
||||
class GameContext;
|
||||
|
||||
class ClassicGame final : public kku::Game
|
||||
{
|
||||
public:
|
||||
explicit ClassicGame(const std::shared_ptr<kku::Timeline<ClassicNote>>& timeline,
|
||||
const std::shared_ptr<ClassicGraphicsManager>& graphics_manager);
|
||||
const std::shared_ptr<GameContext>& context);
|
||||
virtual ~ClassicGame() override;
|
||||
|
||||
virtual void run() override;
|
||||
|
@ -26,6 +27,5 @@ public:
|
|||
|
||||
private:
|
||||
const std::shared_ptr<kku::Timeline<ClassicNote>> _timeline;
|
||||
const std::shared_ptr<ClassicGraphicsManager> _graphics_manager;
|
||||
const std::shared_ptr<HoldManager> _hold_manager;
|
||||
const std::shared_ptr<GameContext> _context;
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "graphics/animations/classicdyinganimationscenario.h"
|
||||
//
|
||||
|
||||
auto classic::createBeatmap(const std::string& filepath, const std::shared_ptr<HoldManager>& hold_manager) -> Beatmap
|
||||
auto classic::createBeatmap(const std::string& filepath, Context * const context) -> Beatmap
|
||||
{
|
||||
(void) filepath;
|
||||
|
||||
|
@ -31,7 +31,13 @@ auto classic::createBeatmap(const std::string& filepath, const std::shared_ptr<H
|
|||
|
||||
while (bpm_iterator < bpm_end)
|
||||
{
|
||||
ArrowNoteInitializer init;
|
||||
ClassicArrowNote::Init init
|
||||
{
|
||||
context,
|
||||
bpm_iterator,
|
||||
input_intervals,
|
||||
|
||||
};
|
||||
ArrowElementInitializer element;
|
||||
init.initializer.intervals = input_intervals;
|
||||
init.initializer.perfect_offset = bpm_iterator;
|
||||
|
@ -59,7 +65,7 @@ auto classic::createBeatmap(const std::string& filepath, const std::shared_ptr<H
|
|||
|
||||
init.elements = {element};
|
||||
|
||||
notes.insert(new ClassicArrowNote(std::move(init), hold_manager));
|
||||
notes.insert(new ClassicArrowNote(std::move(init)));
|
||||
|
||||
bpm_iterator += tempo_interval;
|
||||
x += 70;
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "core/time.h"
|
||||
#include "classicmode/classicnote.h"
|
||||
|
||||
class HoldManager;
|
||||
class Context;
|
||||
|
||||
namespace classic
|
||||
{
|
||||
|
@ -16,7 +18,7 @@ struct Beatmap
|
|||
kku::microsec visibility_offset;
|
||||
};
|
||||
|
||||
Beatmap createBeatmap(const std::string& filepath, const std::shared_ptr<HoldManager>& hold_manager);
|
||||
Beatmap createBeatmap(const std::string& filepath, Context * const context);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include "game/holdmanager.h"
|
||||
#include "graphics/animations/classicanimationscenario.h"
|
||||
|
||||
GameContext::GameContext(HoldManager *hold_manager, ClassicGraphicsManager *graphics_manager) :
|
||||
GameContext::GameContext(const std::shared_ptr<HoldManager>& hold_manager,
|
||||
const std::shared_ptr<ClassicGraphicsManager>& graphics_manager) :
|
||||
_hold_manager(hold_manager),
|
||||
_graphics_manager(graphics_manager)
|
||||
{}
|
||||
|
@ -83,3 +84,13 @@ void GameContext::update(ClassicArrowNote *note, const kku::microsec& music_offs
|
|||
if (element.animations[note->getState()])
|
||||
element.animations[note->getState()]->update(music_offset);
|
||||
}
|
||||
|
||||
std::shared_ptr<HoldManager> GameContext::getHoldManager() const
|
||||
{
|
||||
return _hold_manager;
|
||||
}
|
||||
|
||||
std::shared_ptr<ClassicGraphicsManager> GameContext::getGraphicsManager() const
|
||||
{
|
||||
return _graphics_manager;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "classicmode/context.h"
|
||||
|
||||
class HoldManager;
|
||||
|
@ -8,12 +9,17 @@ class ClassicGraphicsManager;
|
|||
class GameContext : public Context
|
||||
{
|
||||
public:
|
||||
explicit GameContext(HoldManager *hold_manager, ClassicGraphicsManager *graphics_manager);
|
||||
explicit GameContext(const std::shared_ptr<HoldManager>& hold_manager,
|
||||
const std::shared_ptr<ClassicGraphicsManager>& graphics_manager);
|
||||
|
||||
virtual void input(ClassicArrowNote *note, kku::GameEvent&& input) const override;
|
||||
virtual void update(ClassicArrowNote *note, const kku::microsec &music_offset) const override;
|
||||
|
||||
std::shared_ptr<HoldManager> getHoldManager() const;
|
||||
std::shared_ptr<ClassicGraphicsManager> getGraphicsManager() const;
|
||||
|
||||
|
||||
private:
|
||||
HoldManager * const _hold_manager;
|
||||
ClassicGraphicsManager * const _graphics_manager;
|
||||
const std::shared_ptr<HoldManager> _hold_manager;
|
||||
const std::shared_ptr<ClassicGraphicsManager> _graphics_manager;
|
||||
};
|
||||
|
|
|
@ -4,8 +4,6 @@ ClassicGraphicsFactory::ClassicGraphicsFactory(const std::shared_ptr<kku::CoreFa
|
|||
_core_factory(core_factory)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
auto ClassicGraphicsFactory::generate(Type type) const -> SpriteData
|
||||
{
|
||||
auto shape = _core_factory->getRectangle();
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "core/timeline.h"
|
||||
#include "core/spritecontainer.h"
|
||||
|
||||
#include "editor/mockelement.h"
|
||||
#include "game/arrowelement.h"
|
||||
|
||||
#include "graphics/animations/classicflyinganimationscenario.h"
|
||||
|
|
Loading…
Reference in New Issue