From 3aa342d46b962e0b1fe1459c427b2a5f1048a077 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 26 Apr 2024 20:00:24 +0200 Subject: [PATCH] name section structs in Difficulty --- include/HitObjectDrawable.hpp | 4 ++-- include/beatmaps.hpp | 12 ------------ include/config.hpp | 4 ++-- include/config_def.hpp | 10 +++++----- include/osuparser.hpp | 2 +- src/HitObjectDrawable.cpp | 2 +- src/main.cpp | 6 +++--- src/osuparser.cpp | 2 +- 8 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 include/beatmaps.hpp diff --git a/include/HitObjectDrawable.hpp b/include/HitObjectDrawable.hpp index b78fdd5..af6a43e 100644 --- a/include/HitObjectDrawable.hpp +++ b/include/HitObjectDrawable.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -32,7 +32,7 @@ struct HitObjectDrawable : public sf::Drawable { virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const; public: - HitObjectDrawable(TextureManager &tman, const HitObject &hitObject, const DifficultySettings &diff, const uint comboCount); + HitObjectDrawable(TextureManager &tman, const HitObject &hitObject, const Difficulty::DifficultySettings &diff, const uint comboCount); void update(const float deltaTime); }; diff --git a/include/beatmaps.hpp b/include/beatmaps.hpp deleted file mode 100644 index bc25601..0000000 --- a/include/beatmaps.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include - -namespace fs = std::filesystem; - -struct DifficultySettings { - double hpDrainRate; - double circleSize; - double approachRate; - double overallDifficulty; -}; diff --git a/include/config.hpp b/include/config.hpp index 488877f..e8a73d6 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -17,8 +17,8 @@ __VA_ARGS__\ }; -#define SECTION(name, ...) \ - struct {\ +#define SECTION(name, type_name, ...) \ + struct type_name {\ __VA_ARGS__\ } name; diff --git a/include/config_def.hpp b/include/config_def.hpp index 9677fb6..b92f9e6 100644 --- a/include/config_def.hpp +++ b/include/config_def.hpp @@ -118,7 +118,7 @@ STRUCT_STREAM_OPS(HitObject, x, y, time, type, hitSound) // https://osu.ppy.sh/wiki/en/Client/File_formats/osu_%28file_format%29 CONFIG(Difficulty, VAR_UINT_P(, formatVersion, "osu file format v") - SECTION(general, + SECTION(general, GeneralInfo, VAR_STRING(.general, audioFilename) VAR_UINT_D(.general, audioLeadIn, 0) VAR_INT_D(.general, previewTime, -1) @@ -136,14 +136,14 @@ CONFIG(Difficulty, VAR_BOOL_D(.general, widescreenStoryboard, false) VAR_BOOL_D(.general, sampleMatchPlaybackRate, false) ) - SECTION(editor, + SECTION(editor, EditorSettings, VAR_LIST_SEP(.editor, bookmarks, uint, ',') VAR_FLOAT(.editor, distanceSpacing) VAR_UINT(.editor, beatDivisor) VAR_UINT(.editor, gridSize) VAR_FLOAT(.editor, timelineZoom) ) - SECTION(metadata, + SECTION(metadata, Metadata, VAR_STRING(.metadata, title) VAR_STRING(.metadata, titleUnicode) VAR_STRING(.metadata, artist) @@ -155,7 +155,7 @@ CONFIG(Difficulty, VAR_UINT(.metadata, beatmapID) VAR_UINT(.metadata, beatmapSetID) ) - SECTION(difficulty, + SECTION(difficulty, DifficultySettings, VAR_FLOAT_P(.difficulty, hpDrainRate, "HPDrainRate:") VAR_FLOAT(.difficulty, circleSize) VAR_FLOAT(.difficulty, overallDifficulty) @@ -164,7 +164,7 @@ CONFIG(Difficulty, VAR_FLOAT(.difficulty, sliderTickRate) ) SECTION_LIST(timingPoints, TimingPoint) - SECTION(colours, + SECTION(colours, Colours, VAR_LIST_NUMBERED(.colours, combo, sf::Color) VAR_COLOUR(.colours, sliderTrackOverride) VAR_COLOUR(.colours, sliderBorder) diff --git a/include/osuparser.hpp b/include/osuparser.hpp index 69574b1..55b2ebf 100644 --- a/include/osuparser.hpp +++ b/include/osuparser.hpp @@ -9,7 +9,7 @@ namespace fs = std::filesystem; #define CONFIG(name, ...) name parse##name(fs::path configPath); -#define SECTION(name, ...) +#define SECTION(name, type_name, ...) #define VAR_UINT(section, name) #define VAR_UINT_D(section, name, default) diff --git a/src/HitObjectDrawable.cpp b/src/HitObjectDrawable.cpp index 467e9be..e31d68b 100644 --- a/src/HitObjectDrawable.cpp +++ b/src/HitObjectDrawable.cpp @@ -4,7 +4,7 @@ #include -HitObjectDrawable::HitObjectDrawable(TextureManager &tman, const HitObject &hitObject, const DifficultySettings &diff, const uint comboCount) +HitObjectDrawable::HitObjectDrawable(TextureManager &tman, const HitObject &hitObject, const Difficulty::DifficultySettings &diff, const uint comboCount) : tman(tman), hitObject(hitObject), timer(hitObject.time) { this->hitCircleSprite = sf::Sprite(this->tman.getTexture("hitcircle.png")); diff --git a/src/main.cpp b/src/main.cpp index 5374951..5f49394 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include @@ -102,11 +102,11 @@ int main(int argc, char *argv[]) { TextureManager tman(skinDir); - DifficultySettings diff{ + Difficulty::DifficultySettings diff{ .hpDrainRate = 3., .circleSize = 5., - .approachRate = 9., .overallDifficulty = 9., + .approachRate = 9., }; float deltaTime; diff --git a/src/osuparser.cpp b/src/osuparser.cpp index 5decc9a..4516fef 100644 --- a/src/osuparser.cpp +++ b/src/osuparser.cpp @@ -65,7 +65,7 @@ inline std::string checkAndRemove(const std::string &str, const std::string &pre return ret;\ } -#define SECTION(name, ...) \ +#define SECTION(name, type_name, ...) \ if (currentSection == #name) {\ __VA_ARGS__\ }