name section structs in Difficulty

This commit is contained in:
jacekpoz 2024-04-26 20:00:24 +02:00
parent e139115ede
commit 3aa342d46b
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
8 changed files with 15 additions and 27 deletions

View file

@ -1,6 +1,6 @@
#pragma once
#include <beatmaps.hpp>
#include <config.hpp>
#include <TextureManager.hpp>
#include <osuparser.hpp>
@ -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);
};

View file

@ -1,12 +0,0 @@
#pragma once
#include <filesystem>
namespace fs = std::filesystem;
struct DifficultySettings {
double hpDrainRate;
double circleSize;
double approachRate;
double overallDifficulty;
};

View file

@ -17,8 +17,8 @@
__VA_ARGS__\
};
#define SECTION(name, ...) \
struct {\
#define SECTION(name, type_name, ...) \
struct type_name {\
__VA_ARGS__\
} name;

View file

@ -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)

View file

@ -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)

View file

@ -4,7 +4,7 @@
#include <iostream>
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"));

View file

@ -1,6 +1,6 @@
#include <HitObjectDrawable.hpp>
#include <beatmaps.hpp>
#include <TextureManager.hpp>
#include <config.hpp>
#include <osuparser.hpp>
#include <util_stream_ops.hpp>
@ -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;

View file

@ -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__\
}