From 76a69b534df78b79348ba56c3a7ab79996869115 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Mon, 24 May 2021 20:18:44 +0300 Subject: [PATCH] Reorganize folders and project structure --- CMakeLists.txt | 5 +- application.h => include/application.h | 0 debughelper.h => include/debughelper.h | 0 include/inputtype.h | 20 ++++ include/note.h | 29 ++++++ {notesprites => include}/notegraphicsentity.h | 0 timeline.h => include/timeline.h | 0 .../timelineviewmanager.h | 0 note.h | 97 ------------------- application.cpp => src/application.cpp | 0 src/classicgame/classicactions.h | 17 ++++ .../classicgame}/classicarrow.cpp | 0 .../classicgame}/classicarrow.h | 0 src/classicgame/classicinputtype.cpp | 19 ++++ src/classicgame/classicinputtype.h | 20 ++++ .../classicgame}/classicviewmanager.cpp | 0 .../classicgame}/classicviewmanager.h | 0 debughelper.cpp => src/debughelper.cpp | 0 src/inputtype.cpp | 13 +++ main.cpp => src/main.cpp | 0 note.cpp => src/note.cpp | 0 {notesprites => src}/notegraphicsentity.cpp | 0 timeline.cpp => src/timeline.cpp | 0 .../timelineviewmanager.cpp | 0 24 files changed, 120 insertions(+), 100 deletions(-) rename application.h => include/application.h (100%) rename debughelper.h => include/debughelper.h (100%) create mode 100644 include/inputtype.h create mode 100644 include/note.h rename {notesprites => include}/notegraphicsentity.h (100%) rename timeline.h => include/timeline.h (100%) rename {timelineviews => include}/timelineviewmanager.h (100%) delete mode 100644 note.h rename application.cpp => src/application.cpp (100%) create mode 100644 src/classicgame/classicactions.h rename {notesprites => src/classicgame}/classicarrow.cpp (100%) rename {notesprites => src/classicgame}/classicarrow.h (100%) create mode 100644 src/classicgame/classicinputtype.cpp create mode 100644 src/classicgame/classicinputtype.h rename {timelineviews => src/classicgame}/classicviewmanager.cpp (100%) rename {timelineviews => src/classicgame}/classicviewmanager.h (100%) rename debughelper.cpp => src/debughelper.cpp (100%) create mode 100644 src/inputtype.cpp rename main.cpp => src/main.cpp (100%) rename note.cpp => src/note.cpp (100%) rename {notesprites => src}/notegraphicsentity.cpp (100%) rename timeline.cpp => src/timeline.cpp (100%) rename {timelineviews => src}/timelineviewmanager.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d190bb..2f43d8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(project-kyoku LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -file(GLOB SOURCES "*.h" "*.cpp" "*/*.h" "*/*.cpp") +file(GLOB SOURCES "src/*.cpp" "src/classicgame/*") # STATIC # # You need to build SFML from sources with cmake @@ -15,8 +15,7 @@ set(SFML_LIB_DIR ${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-window.so.2.5 ${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-audio.so.2.5) set(SFML_INCL_DIR ${CMAKE_SOURCE_DIR}/SFML-2.5.1/include) -include_directories(${SFML_INCL_DIR}) -include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/notesprites ${CMAKE_SOURCE_DIR}/timelineviews) +include_directories(${SFML_INCL_DIR} ${CMAKE_SOURCE_DIR}/include) add_executable(project-kyoku ${SOURCES}) target_link_libraries(project-kyoku ${SFML_LIB_DIR}) diff --git a/application.h b/include/application.h similarity index 100% rename from application.h rename to include/application.h diff --git a/debughelper.h b/include/debughelper.h similarity index 100% rename from debughelper.h rename to include/debughelper.h diff --git a/include/inputtype.h b/include/inputtype.h new file mode 100644 index 0000000..66946c8 --- /dev/null +++ b/include/inputtype.h @@ -0,0 +1,20 @@ +#ifndef INPUTTYPE_H +#define INPUTTYPE_H + +#include + +using microsec = sf::Int64; + +class InputType +{ +public: + explicit InputType(const microsec& timestamp); + virtual ~InputType() = 0; + + const microsec& timestamp() const; + +private: + microsec _timestamp; +}; + +#endif // INPUTTYPE_H diff --git a/include/note.h b/include/note.h new file mode 100644 index 0000000..7c06672 --- /dev/null +++ b/include/note.h @@ -0,0 +1,29 @@ +#ifndef PRECISIONEVALUATOR_H +#define PRECISIONEVALUATOR_H + +#include + +using microsec = sf::Int64; + +template +class PrecisionEvaluator +{ +public: + + PrecisionEvaluator(microsec offset, microsec life_span_offset); + + microsec offset() const noexcept; + bool isActive(microsec music_play_offset) const noexcept; + GRADE calculatePrecision(microsec odds) const; + + static void resetPrecisionQualifier(microsec qualifier = 500000); + +private: + microsec _offset; + microsec _start_handling_offset; + microsec _end_handling_offset; + + static microsec _precision_qualifier; +}; + +#endif // PRECISIONEVALUATOR_H diff --git a/notesprites/notegraphicsentity.h b/include/notegraphicsentity.h similarity index 100% rename from notesprites/notegraphicsentity.h rename to include/notegraphicsentity.h diff --git a/timeline.h b/include/timeline.h similarity index 100% rename from timeline.h rename to include/timeline.h diff --git a/timelineviews/timelineviewmanager.h b/include/timelineviewmanager.h similarity index 100% rename from timelineviews/timelineviewmanager.h rename to include/timelineviewmanager.h diff --git a/note.h b/note.h deleted file mode 100644 index 824efe3..0000000 --- a/note.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef NOTE_H -#define NOTE_H - -#include -#include -#include // TEMP MOCK -#include - -#include - -//////////////////////////////// - -using microsec = sf::Int64; -using coordinates = sf::Vector2i; - -class Sprite : public sf::Drawable // MOCK -{ -public: - Sprite(sf::RectangleShape shape) : _shape(shape), _attached(false) {}; - bool isAttached() const noexcept - { return _attached; } - - virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override - { - target.draw(_shape, states); - } - - void setCoordinates(coordinates cords) noexcept - { _shape.setPosition(cords.x, cords.y); } - - void setAttachment(bool attached) noexcept - { _attached = attached; } - -private: - sf::RectangleShape _shape; - bool _attached; -}; - -struct NoteGrade -{ - int score; - enum class Rating - { - WRONG, - BAD, - GOOD, - GREAT - } rating; - - NoteGrade(int s, Rating r) : score(s), rating(r) {} -}; - -//////////////////////////////// - -class Note : public sf::Drawable -{ -public: - enum class Arrow - { - UP, - RIGHT, - DOWN, - LEFT, - - NONE - }; - - Note(microsec offset, microsec life_span_offset, Note::Arrow type = Note::Arrow::UP); - - void setPosition(coordinates position); - coordinates position() const noexcept; - microsec offset() const noexcept; - Note::Arrow type() const noexcept; - - NoteGrade onTap(Arrow arrow_type, microsec tap_time_stamp); - bool isActive(microsec music_play_offset) const noexcept; - - void resetSprite(const std::shared_ptr& sprite = nullptr) noexcept; - - virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override; - - static void resetPrecisionQualifier(microsec qualifier = 500000); - -private: - coordinates _position; - microsec _offset; - microsec _start_handling_offset; - microsec _end_handling_offset; - Arrow _type = Arrow::UP; - - static microsec _precision_qualifier; - NoteGrade calculatePrecision(microsec odds) const; - - std::shared_ptr _sprite; -}; - -#endif // NOTE_H diff --git a/application.cpp b/src/application.cpp similarity index 100% rename from application.cpp rename to src/application.cpp diff --git a/src/classicgame/classicactions.h b/src/classicgame/classicactions.h new file mode 100644 index 0000000..058f7f7 --- /dev/null +++ b/src/classicgame/classicactions.h @@ -0,0 +1,17 @@ +#ifndef CLASSICACTIONS_H +#define CLASSICACTIONS_H + +enum class Action +{ + NONE, + + PRESS_UP, RELEASE_UP, + PRESS_RIGHT, RELEASE_RIGHT, + PRESS_DOWN, RELEASE_DOWN, + PRESS_LEFT, RELEASE_LEFT, + + PRESS_SLIDER_RIGHT, RELEASE_SLIDER_RIGHT, + PRESS_SLIDER_LEFT, RELEASE_SLIDER_LEFT +}; + +#endif // CLASSICACTIONS_H diff --git a/notesprites/classicarrow.cpp b/src/classicgame/classicarrow.cpp similarity index 100% rename from notesprites/classicarrow.cpp rename to src/classicgame/classicarrow.cpp diff --git a/notesprites/classicarrow.h b/src/classicgame/classicarrow.h similarity index 100% rename from notesprites/classicarrow.h rename to src/classicgame/classicarrow.h diff --git a/src/classicgame/classicinputtype.cpp b/src/classicgame/classicinputtype.cpp new file mode 100644 index 0000000..473aa38 --- /dev/null +++ b/src/classicgame/classicinputtype.cpp @@ -0,0 +1,19 @@ +#include "classicinputtype.h" + +ClassicInputType::ClassicInputType(const microsec& timestamp, Action action) : + InputType(timestamp), + _action(action) +{} + +ClassicInputType::~ClassicInputType() +{} + +bool ClassicInputType::operator==(const Action& comparing_action) const +{ + return _action == comparing_action; +} + +bool ClassicInputType::operator==(const ClassicInputType& comparing_action) const +{ + return _action == comparing_action._action; +} diff --git a/src/classicgame/classicinputtype.h b/src/classicgame/classicinputtype.h new file mode 100644 index 0000000..c233b55 --- /dev/null +++ b/src/classicgame/classicinputtype.h @@ -0,0 +1,20 @@ +#ifndef CLASSICINPUTTYPE_H +#define CLASSICINPUTTYPE_H + +#include "classicactions.h" +#include "inputtype.h" + +class ClassicInputType : public InputType +{ +public: + explicit ClassicInputType(const microsec& timestamp, Action action); + virtual ~ClassicInputType() override; + + bool operator==(const Action& comparing_action) const; + bool operator==(const ClassicInputType& comparing_action) const; + +private: + Action _action; +}; + +#endif // CLASSICINPUTTYPE_H diff --git a/timelineviews/classicviewmanager.cpp b/src/classicgame/classicviewmanager.cpp similarity index 100% rename from timelineviews/classicviewmanager.cpp rename to src/classicgame/classicviewmanager.cpp diff --git a/timelineviews/classicviewmanager.h b/src/classicgame/classicviewmanager.h similarity index 100% rename from timelineviews/classicviewmanager.h rename to src/classicgame/classicviewmanager.h diff --git a/debughelper.cpp b/src/debughelper.cpp similarity index 100% rename from debughelper.cpp rename to src/debughelper.cpp diff --git a/src/inputtype.cpp b/src/inputtype.cpp new file mode 100644 index 0000000..e35b1d2 --- /dev/null +++ b/src/inputtype.cpp @@ -0,0 +1,13 @@ +#include "inputtype.h" + +InputType::InputType(const microsec ×tamp) : + _timestamp(timestamp) +{} + +InputType::~InputType() +{} + +const microsec& InputType::timestamp() const +{ + return _timestamp; +} diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp diff --git a/note.cpp b/src/note.cpp similarity index 100% rename from note.cpp rename to src/note.cpp diff --git a/notesprites/notegraphicsentity.cpp b/src/notegraphicsentity.cpp similarity index 100% rename from notesprites/notegraphicsentity.cpp rename to src/notegraphicsentity.cpp diff --git a/timeline.cpp b/src/timeline.cpp similarity index 100% rename from timeline.cpp rename to src/timeline.cpp diff --git a/timelineviews/timelineviewmanager.cpp b/src/timelineviewmanager.cpp similarity index 100% rename from timelineviews/timelineviewmanager.cpp rename to src/timelineviewmanager.cpp