2020-01-01 21:29:24 +01:00
|
|
|
#ifndef GAME_H
|
|
|
|
#define GAME_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "SDL.h"
|
|
|
|
#include "Maths.h"
|
|
|
|
#include "UtilityClass.h"
|
|
|
|
#include "GraphicsUtil.h"
|
|
|
|
|
2020-04-15 06:11:10 +02:00
|
|
|
struct MenuOption
|
|
|
|
{
|
|
|
|
std::string text;
|
|
|
|
bool active;
|
|
|
|
};
|
|
|
|
|
2020-04-16 06:53:36 +02:00
|
|
|
//Menu IDs
|
|
|
|
namespace Menu
|
|
|
|
{
|
|
|
|
enum MenuName
|
|
|
|
{
|
|
|
|
mainmenu,
|
|
|
|
playerworlds,
|
|
|
|
levellist,
|
|
|
|
quickloadlevel,
|
|
|
|
youwannaquit,
|
|
|
|
errornostart,
|
|
|
|
graphicoptions,
|
|
|
|
ed_settings,
|
|
|
|
ed_desc,
|
|
|
|
ed_music,
|
|
|
|
ed_quit,
|
|
|
|
options,
|
|
|
|
accessibility,
|
|
|
|
controller,
|
|
|
|
cleardatamenu,
|
|
|
|
setinvincibility,
|
2020-04-17 01:02:01 +02:00
|
|
|
setslowdown,
|
2020-04-16 06:53:36 +02:00
|
|
|
unlockmenu,
|
|
|
|
credits,
|
|
|
|
credits2,
|
|
|
|
credits25,
|
|
|
|
credits3,
|
|
|
|
credits4,
|
|
|
|
credits5,
|
|
|
|
credits6,
|
|
|
|
play,
|
|
|
|
unlocktimetrial,
|
|
|
|
unlocktimetrials,
|
|
|
|
unlocknodeathmode,
|
|
|
|
unlockintermission,
|
|
|
|
unlockflipmode,
|
|
|
|
newgamewarning,
|
|
|
|
playmodes,
|
|
|
|
intermissionmenu,
|
|
|
|
playint1,
|
|
|
|
playint2,
|
|
|
|
continuemenu,
|
|
|
|
startnodeathmode,
|
|
|
|
gameover,
|
|
|
|
gameover2,
|
|
|
|
unlockmenutrials,
|
|
|
|
timetrials,
|
|
|
|
nodeathmodecomplete,
|
|
|
|
nodeathmodecomplete2,
|
|
|
|
timetrialcomplete,
|
|
|
|
timetrialcomplete2,
|
|
|
|
timetrialcomplete3,
|
|
|
|
gamecompletecontinue,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-17 01:22:40 +02:00
|
|
|
struct MenuStackFrame
|
|
|
|
{
|
|
|
|
int option;
|
|
|
|
enum Menu::MenuName name;
|
|
|
|
};
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
class Game
|
|
|
|
{
|
|
|
|
public:
|
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
|
|
|
void init(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
~Game(void);
|
|
|
|
|
|
|
|
|
|
|
|
int crewrescued();
|
|
|
|
|
|
|
|
std::string unrescued();
|
|
|
|
|
|
|
|
void resetgameclock();
|
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void customsavequick(std::string savfile);
|
|
|
|
void savequick();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void gameclock();
|
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
std::string giventimestring(int hrs, int min, int sec);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
std::string timestring();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
std::string partimestring();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
std::string resulttimestring();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
std::string timetstring(int t);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-04-17 04:16:40 +02:00
|
|
|
void returnmenu();
|
2020-04-26 02:36:36 +02:00
|
|
|
void returntomenu(enum Menu::MenuName t);
|
2020-04-17 04:04:36 +02:00
|
|
|
void createmenu(enum Menu::MenuName t, bool samemenu = false);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void lifesequence();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void gethardestroom();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void updatestate();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void unlocknum(int t);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void loadstats();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void savestats();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void deletestats();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void deletequick();
|
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void savetele();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void loadtele();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void deletetele();
|
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void customstart();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void start();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void startspecial(int t);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void starttrial(int t);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void swnpenalty();
|
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void deathsequence();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void customloadquick(std::string savfile);
|
|
|
|
void loadquick();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void loadsummary();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 02:16:02 +02:00
|
|
|
void initteleportermode();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-04-02 22:01:55 +02:00
|
|
|
std::string saveFilePath;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
int door_left;
|
|
|
|
int door_right;
|
|
|
|
int door_up;
|
|
|
|
int door_down;
|
|
|
|
int roomx, roomy, roomchangedir;
|
2020-01-27 23:46:11 +01:00
|
|
|
int prevroomx, prevroomy;
|
2020-04-17 01:08:56 +02:00
|
|
|
int j, k;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int savex, savey, saverx, savery;
|
|
|
|
int savegc, savedir;
|
|
|
|
|
|
|
|
//Added for port
|
|
|
|
int edsavex, edsavey, edsaverx, edsavery;
|
|
|
|
int edsavegc, edsavedir;
|
|
|
|
|
|
|
|
//State logic stuff
|
|
|
|
int state, statedelay;
|
|
|
|
|
2020-04-02 22:01:55 +02:00
|
|
|
bool glitchrunkludge;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-04-02 22:01:55 +02:00
|
|
|
int usingmmmmmm;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int gamestate;
|
|
|
|
bool hascontrol, jumpheld;
|
|
|
|
int jumppressed;
|
|
|
|
int gravitycontrol;
|
|
|
|
|
|
|
|
bool infocus;
|
|
|
|
bool muted;
|
|
|
|
int mutebutton;
|
2020-04-19 21:40:59 +02:00
|
|
|
bool musicmuted;
|
|
|
|
int musicmutebutton;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int tapleft, tapright;
|
|
|
|
|
|
|
|
//Menu interaction stuff
|
|
|
|
bool mapheld;
|
|
|
|
int menupage;
|
|
|
|
//public var crewstats:Array = new Array();
|
|
|
|
int lastsaved;
|
|
|
|
int deathcounts;
|
|
|
|
|
|
|
|
int frames, seconds, minutes, hours;
|
|
|
|
bool gamesaved;
|
|
|
|
std::string savetime;
|
|
|
|
std::string savearea;
|
|
|
|
int savetrinkets;
|
|
|
|
bool startscript;
|
|
|
|
std::string newscript;
|
|
|
|
|
|
|
|
int mainmenu;
|
|
|
|
bool menustart;
|
|
|
|
|
|
|
|
//Teleporting
|
|
|
|
bool teleport_to_new_area;
|
|
|
|
int teleport_to_x, teleport_to_y;
|
|
|
|
std::string teleportscript;
|
|
|
|
bool useteleporter;
|
|
|
|
int teleport_to_teleporter;
|
|
|
|
|
|
|
|
//Main Menu Variables
|
Refactor menu creation code
Firstly, menu options are no longer ad-hoc objects, and are added by
using Game::option() (this is the biggest change). This removes the
vector Game::menuoptionsactive, and Game::menuoptions is now a vector of
MenuOption instead of std::string.
Secondly, the manual tracker variable of the amount of menu options,
Game::nummenuoptions, has been removed, in favor of using vectors
properly and using Game::menuoptions::size().
As a result, a lot of copy-pasted code has been removed from
Game::createmenu(), mostly due to having to have different versions of
menus depending on whether or not we have certain defines, or having an
mmmmmm.vvv file inside the VVVVVV directory. In the old days, you
couldn't just add or remove a menu option conveniently, you had to
shuffle around the position of every other menu option too, which
resulted in lots of copy-pasted code. But now this copy-pasted code has
been de-duplicated, at least in Game::createmenu().
2020-04-15 06:50:17 +02:00
|
|
|
std::vector<MenuOption> menuoptions;
|
|
|
|
int currentmenuoption ;
|
2020-04-17 05:09:22 +02:00
|
|
|
enum Menu::MenuName currentmenuname;
|
2020-02-12 05:45:58 +01:00
|
|
|
int current_credits_list_index;
|
2020-01-01 21:29:24 +01:00
|
|
|
int menuxoff, menuyoff;
|
2020-04-17 03:52:40 +02:00
|
|
|
std::vector<MenuStackFrame> menustack;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-04-15 06:12:24 +02:00
|
|
|
void inline option(std::string text, bool active = true)
|
|
|
|
{
|
|
|
|
MenuOption menuoption;
|
|
|
|
menuoption.text = text;
|
|
|
|
menuoption.active = active;
|
|
|
|
menuoptions.push_back(menuoption);
|
|
|
|
}
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
int menucountdown;
|
2020-04-16 06:53:36 +02:00
|
|
|
enum Menu::MenuName menudest;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int creditposx, creditposy, creditposdelay;
|
|
|
|
|
|
|
|
|
|
|
|
//Sine Wave Ninja Minigame
|
|
|
|
bool swnmode;
|
|
|
|
int swngame, swnstate, swnstate2, swnstate3, swnstate4, swndelay, swndeaths;
|
|
|
|
int swntimer, swncolstate, swncoldelay;
|
|
|
|
int swnrecord, swnbestrank, swnrank, swnmessage;
|
|
|
|
|
|
|
|
//SuperCrewMate Stuff
|
|
|
|
bool supercrewmate, scmhurt, scmmoveme;
|
|
|
|
int scmprogress;
|
|
|
|
|
|
|
|
//Accessibility Options
|
|
|
|
bool colourblindmode;
|
|
|
|
bool noflashingmode;
|
|
|
|
int slowdown;
|
|
|
|
Uint32 gameframerate;
|
|
|
|
|
|
|
|
bool nodeathmode;
|
|
|
|
int gameoverdelay;
|
|
|
|
bool nocutscenes;
|
|
|
|
|
|
|
|
//Time Trials
|
|
|
|
bool intimetrial, timetrialparlost;
|
|
|
|
int timetrialcountdown, timetrialshinytarget, timetriallevel;
|
|
|
|
int timetrialpar, timetrialresulttime, timetrialrank;
|
|
|
|
|
|
|
|
int creditposition;
|
2020-01-17 02:14:56 +01:00
|
|
|
int creditmaxposition;
|
|
|
|
std::vector<const char*> superpatrons;
|
|
|
|
std::vector<const char*> patrons;
|
|
|
|
std::vector<const char*> githubfriends;
|
2020-01-01 21:29:24 +01:00
|
|
|
bool insecretlab;
|
|
|
|
|
|
|
|
bool inintermission;
|
|
|
|
|
|
|
|
std::vector<bool> crewstats;
|
|
|
|
|
|
|
|
bool alarmon;
|
|
|
|
int alarmdelay;
|
|
|
|
bool blackout;
|
|
|
|
|
|
|
|
std::vector<bool> tele_crewstats;
|
|
|
|
|
|
|
|
std::vector<bool> quick_crewstats;
|
|
|
|
|
|
|
|
std::vector<int> unlock;
|
|
|
|
std::vector<int> unlocknotify;
|
2020-04-26 21:43:30 +02:00
|
|
|
bool anything_unlocked();
|
2020-01-01 21:29:24 +01:00
|
|
|
int stat_trinkets;
|
|
|
|
bool fullscreen;
|
|
|
|
int bestgamedeaths;
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<int>besttimes;
|
|
|
|
std::vector<int>besttrinkets;
|
|
|
|
std::vector<int>bestlives;
|
|
|
|
std::vector<int> bestrank;
|
|
|
|
|
|
|
|
std::string tele_gametime;
|
|
|
|
int tele_trinkets;
|
|
|
|
std::string tele_currentarea;
|
|
|
|
std::string quick_gametime;
|
|
|
|
int quick_trinkets;
|
|
|
|
std::string quick_currentarea;
|
|
|
|
|
|
|
|
int mx, my;
|
|
|
|
int screenshake, flashlight;
|
|
|
|
bool advancetext, pausescript;
|
|
|
|
|
|
|
|
int deathseq, lifeseq;
|
|
|
|
|
2020-04-10 00:58:24 +02:00
|
|
|
int trinkets();
|
|
|
|
int crewmates();
|
2020-04-09 07:27:13 +02:00
|
|
|
int savepoint, teleportxpos;
|
|
|
|
bool teleport;
|
2020-01-01 21:29:24 +01:00
|
|
|
int edteleportent;
|
|
|
|
bool completestop;
|
|
|
|
|
|
|
|
float inertia;
|
|
|
|
|
|
|
|
int companion;
|
|
|
|
bool roomchange;
|
|
|
|
SDL_Rect teleblock;
|
|
|
|
bool activetele;
|
|
|
|
int readytotele;
|
|
|
|
int activity_r, activity_g, activity_b;
|
|
|
|
std::string activity_lastprompt;
|
|
|
|
|
|
|
|
std::string telesummary, quicksummary, customquicksummary;
|
2020-04-26 22:41:35 +02:00
|
|
|
bool save_exists();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
bool backgroundtext;
|
|
|
|
|
|
|
|
int activeactivity, act_fade;
|
|
|
|
|
|
|
|
bool press_left, press_right, press_action, press_map;
|
|
|
|
|
|
|
|
//Some stats:
|
|
|
|
int totalflips;
|
|
|
|
std::string hardestroom;
|
|
|
|
int hardestroomdeaths, currentroomdeaths;
|
|
|
|
|
|
|
|
bool savemystats;
|
|
|
|
|
|
|
|
|
|
|
|
bool advanced_mode;
|
|
|
|
bool fullScreenEffect_badSignal;
|
2020-04-02 22:01:55 +02:00
|
|
|
bool useLinearFilter;
|
|
|
|
int stretchMode;
|
|
|
|
int controllerSensitivity;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
bool quickrestartkludge;
|
|
|
|
|
|
|
|
//Custom stuff
|
|
|
|
std::string customscript[50];
|
|
|
|
int customcol;
|
|
|
|
int levelpage;
|
|
|
|
int playcustomlevel;
|
|
|
|
std::string customleveltitle;
|
|
|
|
std::string customlevelfilename;
|
|
|
|
|
|
|
|
void clearcustomlevelstats();
|
|
|
|
void loadcustomlevelstats();
|
|
|
|
void savecustomlevelstats();
|
|
|
|
void updatecustomlevelstats(std::string clevel, int cscore);
|
|
|
|
|
|
|
|
std::string customlevelstats[200]; //string array containing level filenames
|
|
|
|
int customlevelscore[200];//0 - not played, 1 - finished, 2 - all trinkets, 3 - finished, all trinkets
|
|
|
|
int numcustomlevelstats;
|
|
|
|
bool customlevelstatsloaded;
|
|
|
|
|
|
|
|
|
2020-04-02 22:01:55 +02:00
|
|
|
std::vector<SDL_GameControllerButton> controllerButton_map;
|
|
|
|
std::vector<SDL_GameControllerButton> controllerButton_flip;
|
|
|
|
std::vector<SDL_GameControllerButton> controllerButton_esc;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-01-13 02:45:44 +01:00
|
|
|
bool skipfakeload;
|
2020-04-09 21:03:24 +02:00
|
|
|
|
|
|
|
bool cliplaytest;
|
|
|
|
int playx;
|
|
|
|
int playy;
|
|
|
|
int playrx;
|
|
|
|
int playry;
|
|
|
|
int playgc;
|
2020-05-07 23:38:19 +02:00
|
|
|
|
|
|
|
void quittomenu();
|
2020-05-08 00:17:04 +02:00
|
|
|
void returntolab();
|
2020-05-08 00:23:55 +02:00
|
|
|
bool fadetomenu;
|
|
|
|
int fadetomenudelay;
|
2020-05-08 00:30:26 +02:00
|
|
|
bool fadetolab;
|
|
|
|
int fadetolabdelay;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
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 Game game;
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
#endif /* GAME_H */
|