2020-01-01 21:29:24 +01:00
|
|
|
#ifndef UTILITYCLASS_H
|
|
|
|
#define UTILITYCLASS_H
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2020-06-16 02:31:54 +02:00
|
|
|
bool is_positive_num(const std::string& str, bool hex);
|
2020-04-17 23:52:09 +02:00
|
|
|
|
2020-06-14 03:22:05 +02:00
|
|
|
#define INBOUNDS(index, vector) ((int) index >= 0 && (int) index < (int) vector.size())
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
//helperClass
|
|
|
|
class UtilityClass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UtilityClass();
|
|
|
|
|
|
|
|
static std::string String(int _v);
|
|
|
|
|
|
|
|
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 globaltemp;
|
|
|
|
int temp;
|
|
|
|
int temp2;
|
|
|
|
std::vector<int> splitseconds;
|
|
|
|
};
|
|
|
|
|
Allow using help/graphics/music/game/key/map/obj everywhere
This commit makes `help`, `graphics`, `music`, `game`, `key`, `map`, and
`obj` essentially static global objects that can be used everywhere.
This is useful in case we ever need to add a new function in the future,
so we don't have to bother with passing a new argument in which means we
have to pass a new argument in to the function that calls that function
which means having to pass a new argument into the function that calls
THAT function, etc. which is a real headache when working on fan mods of
the source code.
Note that this changes NONE of the existing function signatures, it
merely just makes those variables accessible everywhere in the same way
`script` and `ed` are.
Also note that some classes had to be initialized after the filesystem
was initialized, but C++ would keep initializing them before the
filesystem got initialized, because I *had* to put them at the top of
`main.cpp`, or else they wouldn't be global variables.
The only way to work around this was to use entityclass's initialization
style (which I'm pretty sure entityclass of all things doesn't need to
be initialized this way), where you actually initialize the class in an
`init()` function, and so then you do `graphics.init()` after the
filesystem initialization, AFTER doing `Graphics graphics` up at the
top.
I've had to do this for `graphics` (but only because its child
GraphicsResources `grphx` needs to be initialized this way), `music`,
and `game`. I don't think this will affect anything. Other than that,
`help`, `key`, and `map` are still using the C++-intended method of
having ClassName::ClassName() functions.
2020-01-29 08:35:03 +01:00
|
|
|
extern UtilityClass help;
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
#endif /* UTILITYCLASS_H */
|