mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-06-02 11:03:32 +02:00
cbceeccf78
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.
76 lines
1.2 KiB
C++
76 lines
1.2 KiB
C++
#ifndef SCRIPT_H
|
|
#define SCRIPT_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <SDL.h>
|
|
|
|
#define filllines(lines) commands.insert(commands.end(), lines, lines + SDL_arraysize(lines))
|
|
|
|
|
|
struct Script
|
|
{
|
|
std::string name;
|
|
std::vector<std::string> contents;
|
|
};
|
|
|
|
class scriptclass
|
|
{
|
|
public:
|
|
|
|
|
|
scriptclass();
|
|
|
|
void load(const std::string& name);
|
|
void loadother(const char* t);
|
|
void loadcustom(const std::string& t);
|
|
|
|
void inline add(const std::string& t)
|
|
{
|
|
commands.push_back(t);
|
|
}
|
|
|
|
void clearcustom();
|
|
|
|
void tokenize(const std::string& t);
|
|
|
|
void run();
|
|
|
|
void resetgametomenu();
|
|
|
|
void startgamemode(int t);
|
|
|
|
void teleport();
|
|
|
|
void hardreset();
|
|
|
|
//Script contents
|
|
std::vector<std::string> commands;
|
|
std::string words[40];
|
|
std::vector<std::string> txt;
|
|
std::string scriptname;
|
|
int position;
|
|
int looppoint, loopcount;
|
|
|
|
int scriptdelay;
|
|
bool running, dontrunnextframe;
|
|
|
|
//Textbox stuff
|
|
int textx;
|
|
int texty;
|
|
int r,g,b;
|
|
|
|
//Misc
|
|
int i, j, k;
|
|
|
|
//Custom level stuff
|
|
std::vector<Script> customscripts;
|
|
};
|
|
|
|
#ifndef SCRIPT_DEFINITION
|
|
extern scriptclass script;
|
|
#endif
|
|
|
|
#endif /* SCRIPT_H */
|