#pragma once #include #include struct SDL_Texture; bool Osu_HasPrefix(const char* str, const char* prefix); bool Osu_HasSuffix(const char* str, const char* suffix); struct SDL_FRect Osu_GetTextureRect(struct SDL_Texture* texture); void Osu_Panic(const char* title, const char* description); int Osu_Random(int min, int max); enum { OSU_LOG_CATEGORY_AUDIO = SDL_LOG_CATEGORY_CUSTOM, OSU_LOG_CATEGORY_BEATMAP_PARSER, }; #define OSU_LOG_TRACEF(fmt, ...) \ { \ char realFmt[512]; \ snprintf(realFmt, 512, "%s: %s", "(%u) %s:%u", fmt); \ SDL_LogTrace(OSU_LOG_CATEGORY_BEATMAP_PARSER, realFmt, SDL_GetTicks(), __FILE__, __LINE__, __VA_ARGS__); \ } #define OSU_LOG_TRACE(msg) OSU_LOG_TRACEF("%s", msg) #define SDL_SAFEASSN(target, funcname, ...) \ { \ target = funcname(__VA_ARGS__); \ if (!target) \ Osu_Panic(#funcname " failed", SDL_GetError()); \ } #define SDL_SAFECALL(funcname, ...) \ if (!funcname(__VA_ARGS__)) \ Osu_Panic(#funcname " failed", SDL_GetError());