osuplusplus/include/config_def.hpp
jacekpoz c5491dbc9f
refactor a huge part of the code
this allows for creating only input and output streams and allows me to
finally print out the generated config struct
2024-04-20 13:37:06 +02:00

265 lines
6.6 KiB
C++

#ifndef CONFIG
#define CONFIG_DEFINED
#define CONFIG(name, ...)
#define SECTION(name, ...)
#define VAR_UINT(section, name)
#define VAR_UINT_P(section, name, prefix)
#define VAR_UINT_D(section, name, default)
#define VAR_INT(section, name)
#define VAR_INT_P(section, name, prefix)
#define VAR_INT_D(section, name, default)
#define VAR_STRING(section, name)
#define VAR_STRING_P(section, name, prefix)
#define VAR_STRING_D(section, name, default)
#define VAR_BOOL(section, name)
#define VAR_BOOL_P(section, name, prefix)
#define VAR_BOOL_D(section, name, default)
#define VAR_FLOAT(section, name)
#define VAR_FLOAT_P(section, name, prefix)
#define VAR_FLOAT_D(section, name, default)
#define VAR_COLOUR(section, name)
#define VAR_COLOUR_P(section, name, prefix)
#define VAR_COLOUR_D(section, name, default)
#define ENUM(name, ...)
#define VAR_ENUM(section, name, enum_type)
#define VAR_ENUM_P(section, name, prefix)
#define VAR_ENUM_D(section, name, enum_type, default)
#define STRUCT(name, ...)
#define VAR_STRUCT(section, name, struct_type)
#define VAR_STRUCT_P(section, name, prefix)
#define VAR_STRUCT_D(section, name, struct_type, default)
#define STRUCT_INPUT_STREAM_OP(name, ...)
#define STRUCT_OUTPUT_STREAM_OP(name, ...)
#define STRUCT_STREAM_OPS(name, ...)
#define VAR_LIST(section, name, type)
#define VAR_LIST_SEP(section, name, type, sep)
#define VAR_LIST_NUMBERED(section, name, type)
#endif // CONFIG
ENUM(Countdown,
NONE,
NORMAL,
HALF,
DOUBLE
)
ENUM(SampleSet,
DEFAULT,
NORMAL,
SOFT,
DRUM
)
ENUM(Mode,
STANDARD,
TAIKO,
CATCH,
MANIA
)
ENUM(OverlayPosition,
NO_CHANGE,
BELOW,
ABOVE
)
STRUCT(TimingPoint,
VAR_UINT(, time)
VAR_FLOAT(, beatLength)
VAR_UINT(, meter)
VAR_ENUM(, sampleSet, SampleSet)
VAR_UINT(, sampleIndex)
VAR_UINT(, volume)
VAR_BOOL(, uninherited)
VAR_UINT(, effects)
)
STRUCT_STREAM_OPS(TimingPoint, time, beatLength, meter, sampleSet, sampleIndex, volume, uninherited, effects)
STRUCT(HitObjectType,
VAR_UINT(, hitCircle)
VAR_UINT(, slider)
VAR_UINT(, newCombo)
VAR_UINT(, spinner)
VAR_UINT(, colourHax)
VAR_UINT(, holdNote)
)
STRUCT_STREAM_OPS(HitObjectType, hitCircle, slider, newCombo, spinner, colourHax, holdNote)
STRUCT(HitSound,
VAR_UINT(, normal)
VAR_UINT(, whistle)
VAR_UINT(, finish)
VAR_UINT(, clap)
)
STRUCT_STREAM_OPS(HitSound, normal, whistle, finish, clap)
STRUCT(HitObject,
VAR_INT(, x)
VAR_INT(, y)
VAR_INT(, time)
VAR_STRUCT(, type, HitObjectType)
VAR_STRUCT(, hitSound ,HitSound)
)
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,
VAR_STRING(.general, audioFilename)
VAR_UINT_D(.general, audioLeadIn, 0)
VAR_INT_D(.general, previewTime, -1)
VAR_ENUM_D(.general, countdown, Countdown, NORMAL)
VAR_ENUM_D(.general, sampleSet, SampleSet, NORMAL)
VAR_FLOAT_D(.general, stackLeniency, 0.7)
VAR_ENUM_D(.general, mode, Mode, STANDARD)
VAR_BOOL_D(.general, letterboxInBreaks, false)
VAR_BOOL_D(.general, useSkinSprites, false)
VAR_ENUM_D(.general, overlayPosition, OverlayPosition, NO_CHANGE)
VAR_STRING(.general, skinPreference)
VAR_BOOL_D(.general, epilepsyWarning, false)
VAR_UINT_D(.general, countdownOffset, 0)
VAR_BOOL_D(.general, specialStyle, false)
VAR_BOOL_D(.general, widescreenStoryboard, false)
VAR_BOOL_D(.general, sampleMatchPlaybackRate, false)
)
SECTION(editor,
VAR_LIST_SEP(.editor, bookmarks, uint, ",")
VAR_FLOAT(.editor, distanceSpacing)
VAR_UINT(.editor, beatDivisor)
VAR_UINT(.editor, gridSize)
VAR_FLOAT(.editor, timelineZoom)
)
SECTION(metadata,
VAR_STRING(.metadata, title)
VAR_STRING(.metadata, titleUnicode)
VAR_STRING(.metadata, artist)
VAR_STRING(.metadata, artistUnicode)
VAR_STRING(.metadata, creator)
VAR_STRING(.metadata, version)
VAR_STRING(.metadata, source)
VAR_LIST_SEP(.metadata, tags, std::string, " ")
VAR_UINT(.metadata, beatmapID)
VAR_UINT(.metadata, beatmapSetID)
)
SECTION(difficulty,
VAR_FLOAT(.difficulty, hpDrainRate)
VAR_FLOAT(.difficulty, circleSize)
VAR_FLOAT(.difficulty, overallDifficulty)
VAR_FLOAT(.difficulty, approachRate)
VAR_FLOAT(.difficulty, sliderMultiplier)
VAR_FLOAT(.difficulty, sliderTickRate)
)
VAR_LIST(, timingPoints, TimingPoint)
SECTION(colours,
VAR_LIST_NUMBERED(.colours, combo, sf::Color)
VAR_COLOUR(.colours, sliderTrackOverride)
VAR_COLOUR(.colours, sliderBorder)
)
VAR_LIST(, hitObjects, HitObject)
)
STRUCT_OUTPUT_STREAM_OP(Difficulty,
formatVersion,
general.audioFilename,
general.audioLeadIn,
general.previewTime,
general.countdown,
general.sampleSet,
general.stackLeniency,
general.mode,
general.letterboxInBreaks,
general.useSkinSprites,
general.overlayPosition,
general.skinPreference,
general.epilepsyWarning,
general.countdownOffset,
general.specialStyle,
general.widescreenStoryboard,
general.sampleMatchPlaybackRate,
editor.bookmarks,
editor.distanceSpacing,
editor.beatDivisor,
editor.gridSize,
editor.timelineZoom,
metadata.title,
metadata.titleUnicode,
metadata.artist,
metadata.artistUnicode,
metadata.creator,
metadata.version,
metadata.source,
metadata.tags,
metadata.beatmapID,
metadata.beatmapSetID,
difficulty.hpDrainRate,
difficulty.circleSize,
difficulty.overallDifficulty,
difficulty.approachRate,
difficulty.sliderMultiplier,
difficulty.sliderTickRate,
timingPoints,
colours.combo,
colours.sliderTrackOverride,
colours.sliderBorder,
hitObjects
)
#ifdef CONFIG_DEFINED
#undef CONFIG
#undef SECTION
#undef VAR_UINT
#undef VAR_UINT_P
#undef VAR_UINT_D
#undef VAR_INT
#undef VAR_INT_P
#undef VAR_INT_D
#undef VAR_STRING
#undef VAR_STRING_P
#undef VAR_STRING_D
#undef VAR_BOOL
#undef VAR_BOOL_P
#undef VAR_BOOL_D
#undef VAR_FLOAT
#undef VAR_FLOAT_P
#undef VAR_FLOAT_D
#undef VAR_COLOUR
#undef VAR_COLOUR_P
#undef VAR_COLOUR_D
#undef ENUM
#undef VAR_ENUM
#undef VAR_ENUM_P
#undef VAR_ENUM_D
#undef STRUCT
#undef VAR_STRUCT
#undef VAR_STRUCT_P
#undef VAR_STRUCT_D
#undef STRUCT_INPUT_STREAM_OP
#undef STRUCT_OUTPUT_STREAM_OP
#undef STRUCT_STREAM_OPS
#undef VAR_LIST
#undef VAR_LIST_SEP
#undef VAR_LIST_NUMBERED
#endif // CONFIG_DEFINED