Separate graphics from game and editor logic

This commit is contained in:
NaiJi ✨ 2021-11-18 01:14:52 +03:00
parent 7f7045c920
commit b3bec61542
22 changed files with 35 additions and 21 deletions

View File

@ -4,8 +4,8 @@
struct BPMSection
{
int bpm = 0;
int fraction = 1;
int bpm = 120; // Hi, osu
int fraction = 2;
microsec offset_start = 0;
};

View File

@ -23,12 +23,12 @@ public:
_bpm_sections = std::move(sections);
}
inline void insertBPMSection(const BPMSection& section)
void insertBPMSection(const BPMSection& section)
{
_bpm_sections.insert(section);
}
inline void insertBPMSection(BPMSection&& section)
void insertBPMSection(BPMSection&& section)
{
_bpm_sections.insert(std::move(section));
}

View File

@ -6,7 +6,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(${CMAKE_SOURCE_DIR}/include)
file(GLOB_RECURSE HEADERS "shared/*.h" )
file(GLOB_RECURSE SOURCES "editor/*.h" "editor/*.cpp" "game/*.h" "game/*.cpp" "./classicfactory.cpp")
file(GLOB_RECURSE SOURCES "editor/*.h" "editor/*.cpp" "graphics/*.h" "graphics/*.cpp" "game/*.h" "game/*.cpp" "./classicfactory.cpp")
add_library(classicmode STATIC ${SOURCES} ${HEADERS})
target_include_directories(classicmode PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)

View File

@ -1,11 +1,18 @@
#include "shared/classicmode/classicfactory.h"
#include "game/classicgame.h"
#include "game/classicgraphicsmanager.h"
#include "graphics/classicgraphicsmanager.h"
#include "tools/music.h"
#include "editor/classiceditor.h"
#include <SFML/Graphics/RenderWindow.hpp>
std::unique_ptr<Game> classic::init(sf::RenderWindow& game_window)
std::unique_ptr<Game> classic::initGame(sf::RenderWindow& game_window)
{
return std::make_unique<ClassicGame>(std::make_unique<ClassicGraphicsManager>(game_window));
}
std::unique_ptr<Editor> classic::initEditor(sf::RenderWindow& game_window)
{
return std::make_unique<ClassicEditor>(std::make_unique<ClassicGraphicsManager>(game_window));
}

View File

@ -1,10 +1,10 @@
#include "classicarrownote.h"
#include "classicgraphicsmanager.h"
#include "graphics/classicgraphicsmanager.h"
#include "holdmanager.h"
// Replace with interface by dependency injection
#include "classicflyinganimationscenario.h"
#include "classicdyinganimationscenario.h"
#include "graphics/classicflyinganimationscenario.h"
#include "graphics/classicdyinganimationscenario.h"
//
ClassicArrowNote::ClassicArrowNote(ArrowNoteInitializer&& init) :

View File

@ -12,7 +12,8 @@
#include "context.h"
#include "classicnote.h"
#include "classicactions.h"
#include "classicmode/classicactions.h"
class ClassicGraphicsManager;
class HoldManager;

View File

@ -2,8 +2,8 @@
#include "classicarrownote.h"
// Replace with interface by dependency injection
#include "classicflyinganimationscenario.h"
#include "classicdyinganimationscenario.h"
#include "graphics/classicflyinganimationscenario.h"
#include "graphics/classicdyinganimationscenario.h"
//
auto classic::createBeatmap(const std::string& filepath, const Context &context) -> Beatmap

View File

@ -1,10 +1,10 @@
#include "classicnote.h"
#include "classicsprite.h"
#include "classicgraphicsmanager.h"
#include "graphics/classicsprite.h"
#include "graphics/classicgraphicsmanager.h"
// Replace with interface by dependency injection
#include "classicflyinganimationscenario.h"
#include "classicdyinganimationscenario.h"
#include "graphics/classicflyinganimationscenario.h"
#include "graphics/classicdyinganimationscenario.h"
//
ClassicNote::ClassicNote(NoteInitializer &&init) :

View File

@ -1,7 +1,7 @@
#pragma once
#include "elementinitializer.h"
#include "classicactions.h"
#include "classicmode/classicactions.h"
struct ArrowElementInitializer
{

View File

@ -1,7 +1,7 @@
#pragma once
#include "spritecontainer.h"
#include "classicactions.h"
#include "classicmode/classicactions.h"
#include "classicspritefactory.h"
#include <SFML/Graphics/RenderTarget.hpp>

View File

@ -1,7 +1,7 @@
#pragma once
#include <memory>
#include "classicactions.h"
#include "classicmode/classicactions.h"
#include "classicsprite.h"
class ClassicSpriteFactory

View File

@ -3,10 +3,13 @@
#include <memory>
class Game;
class Music;
class Editor;
namespace sf { class RenderWindow; }
namespace classic
{
std::unique_ptr<Game> init(sf::RenderWindow &game_window);
std::unique_ptr<Game> initGame(sf::RenderWindow& game_window);
std::unique_ptr<Editor> initEditor(sf::RenderWindow& game_window);
}

View File

@ -3,6 +3,7 @@
#include "widgets/group.h"
#include "widgets/menubar.h"
#include "widgets/window.h"
#include "widgets/editorwidget.h"
#include "widgets/bpmcalculatorwidget.h"
#include "tools/bpmcalculator.h"
@ -98,6 +99,8 @@ void EditorState::enter()
menu_bar->setVisibility(true);
auto editor_widget = std::make_unique<EditorWidget>(_edito)
_group = std::make_shared<Group>();
_group->addChild(menu_bar);
_group->addChild(bpm_widget);