1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-01 10:33:32 +02:00
VVVVVV/desktop_version/src/UtilityClass.h
Misa cbceeccf78 Clean up and prevent unnecessary qualifiers to self
By "unnecessary qualifiers to self", I mean something like using the
'game.' qualifier for a variable on the Game class when you're inside a
function on the Game class itself. This patch is to enforce consistency
as most of the code doesn't have these unnecessary qualifiers.

To prevent further unnecessary qualifiers to self, I made it so the
extern in each header file can be omitted by using a define. That way,
if someone writes something referring to 'game.' on a Game function,
there will be a compile error.

However, if you really need to have a reference to the global name, and
you're within the same .cpp file as the implementation of that object,
you can just do the extern at the function-level. A good example of this
is editorinput()/editorrender()/editorlogic() in editor.cpp. In my
opinion, they should probably be split off into their own separate file
because editor.cpp is getting way too big, but this will do for now.
2020-09-28 01:34:40 -04:00

66 lines
1.3 KiB
C++

#ifndef UTILITYCLASS_H
#define UTILITYCLASS_H
#include <SDL.h>
#include <string>
#include <vector>
int ss_toi(std::string _s);
std::vector<std::string> split(const std::string &s, char delim, std::vector<std::string> &elems);
std::vector<std::string> split(const std::string &s, char delim);
bool is_number(const char* str);
bool is_positive_num(const std::string& str, bool hex);
bool endsWith(const std::string& str, const std::string& suffix);
#define INBOUNDS_VEC(index, vector) ((int) index >= 0 && (int) index < (int) vector.size())
#define INBOUNDS_ARR(index, array) ((int) index >= 0 && (int) index < (int) SDL_arraysize(array))
#define WHINE_ONCE(message) \
static bool whine = true; \
if (whine) \
{ \
whine = false; \
puts(message); \
}
//helperClass
class UtilityClass
{
public:
UtilityClass();
static std::string String(int _v);
static int Int(const char* str, int fallback = 0);
static std::string GCString(std::vector<SDL_GameControllerButton> buttons);
std::string twodigits(int t);
std::string timestring(int t);
std::string number(int _t);
static bool intersects( SDL_Rect A, SDL_Rect B );
void updateglow();
int glow;
int slowsine;
int glowdir;
int splitseconds[30];
};
#ifndef HELP_DEFINITION
extern UtilityClass help;
#endif
#endif /* UTILITYCLASS_H */