2020-02-10 03:21:19 +01:00
|
|
|
#if !defined(NO_CUSTOM_LEVELS)
|
2020-02-10 01:53:01 +01:00
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
#ifndef EDITOR_H
|
|
|
|
#define EDITOR_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "Script.h"
|
|
|
|
|
|
|
|
class edentities{
|
|
|
|
public:
|
2020-06-12 02:57:04 +02:00
|
|
|
int x, y, t;
|
|
|
|
//parameters
|
|
|
|
int p1, p2, p3, p4, p5, p6;
|
|
|
|
std::string scriptname;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class edlevelclass{
|
|
|
|
public:
|
|
|
|
edlevelclass();
|
2020-06-12 02:57:04 +02:00
|
|
|
int tileset, tilecol;
|
|
|
|
std::string roomname;
|
|
|
|
int warpdir;
|
|
|
|
int platx1, platy1, platx2, platy2, platv;
|
|
|
|
int enemyx1, enemyy1, enemyx2, enemyy2, enemytype;
|
|
|
|
int directmode;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LevelMetaData
|
|
|
|
{
|
2020-06-12 02:57:04 +02:00
|
|
|
std::string title;
|
|
|
|
std::string creator;
|
|
|
|
std::string Desc1;
|
|
|
|
std::string Desc2;
|
|
|
|
std::string Desc3;
|
|
|
|
std::string website;
|
|
|
|
std::string filename;
|
|
|
|
|
|
|
|
std::string modifier;
|
|
|
|
std::string timeCreated;
|
|
|
|
std::string timeModified;
|
|
|
|
|
|
|
|
int version;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-03-01 21:24:43 +01:00
|
|
|
extern std::vector<edentities> edentity;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
class EditorData
|
|
|
|
{
|
2020-06-12 02:57:04 +02:00
|
|
|
public:
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-06-12 02:57:04 +02:00
|
|
|
static EditorData& GetInstance()
|
|
|
|
{
|
|
|
|
static EditorData instance; // Guaranteed to be destroyed.
|
|
|
|
// Instantiated on first use.
|
|
|
|
return instance;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
|
2020-06-12 02:57:04 +02:00
|
|
|
std::string title;
|
|
|
|
std::string creator;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-06-12 02:57:04 +02:00
|
|
|
std::string modifier;
|
|
|
|
std::string timeCreated;
|
|
|
|
std::string timeModified;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
2020-06-12 02:57:04 +02:00
|
|
|
EditorData()
|
|
|
|
{
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
struct GhostInfo {
|
|
|
|
int rx; // game.roomx-100
|
|
|
|
int ry; // game.roomy-100
|
|
|
|
int x; // .xp
|
|
|
|
int y; // .yp
|
|
|
|
int col; // .colour
|
|
|
|
int frame; // .drawframe
|
|
|
|
};
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
class editorclass{
|
|
|
|
//Special class to handle ALL editor variables locally
|
|
|
|
public:
|
|
|
|
editorclass();
|
|
|
|
|
|
|
|
std::string Desc1;
|
|
|
|
std::string Desc2;
|
|
|
|
std::string Desc3;
|
2020-06-12 02:57:04 +02:00
|
|
|
std::string website;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
std::vector<std::string> directoryList;
|
|
|
|
std::vector<LevelMetaData> ListOfMetaData;
|
|
|
|
|
2020-06-03 20:05:09 +02:00
|
|
|
void loadZips();
|
2020-01-01 21:29:24 +01:00
|
|
|
void getDirectoryData();
|
|
|
|
bool getLevelMetaData(std::string& filename, LevelMetaData& _data );
|
|
|
|
|
|
|
|
void saveconvertor();
|
|
|
|
void reset();
|
2020-05-22 04:23:21 +02:00
|
|
|
std::vector<int> loadlevel(int rxi, int ryi);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void placetile(int x, int y, int t);
|
|
|
|
|
|
|
|
void placetilelocal(int x, int y, int t);
|
|
|
|
|
|
|
|
int getenemyframe(int t);
|
|
|
|
int base(int x, int y);
|
|
|
|
|
|
|
|
int backbase(int x, int y);
|
|
|
|
|
|
|
|
int at(int x, int y);
|
|
|
|
|
|
|
|
int freewrap(int x, int y);
|
|
|
|
|
|
|
|
int backonlyfree(int x, int y);
|
|
|
|
|
|
|
|
int backfree(int x, int y);
|
|
|
|
|
|
|
|
int spikefree(int x, int y);
|
|
|
|
int free(int x, int y);
|
|
|
|
int absfree(int x, int y);
|
|
|
|
|
|
|
|
int match(int x, int y);
|
|
|
|
int warpzonematch(int x, int y);
|
|
|
|
int outsidematch(int x, int y);
|
|
|
|
|
|
|
|
int backmatch(int x, int y);
|
|
|
|
|
2020-06-02 12:59:54 +02:00
|
|
|
bool load(std::string& _path);
|
|
|
|
bool save(std::string& _path);
|
2020-03-31 21:52:10 +02:00
|
|
|
void generatecustomminimap();
|
2020-01-01 21:29:24 +01:00
|
|
|
int edgetile(int x, int y);
|
|
|
|
int warpzoneedgetile(int x, int y);
|
|
|
|
int outsideedgetile(int x, int y);
|
|
|
|
|
|
|
|
int backedgetile(int x, int y);
|
|
|
|
|
|
|
|
int labspikedir(int x, int y, int t);
|
|
|
|
int spikedir(int x, int y);
|
|
|
|
int findtrinket(int t);
|
|
|
|
int findcrewmate(int t);
|
|
|
|
int findwarptoken(int t);
|
2020-03-31 21:52:10 +02:00
|
|
|
void findstartpoint();
|
2020-01-01 21:29:24 +01:00
|
|
|
int getlevelcol(int t);
|
|
|
|
int getenemycol(int t);
|
|
|
|
int entcol;
|
|
|
|
|
|
|
|
//Colouring stuff
|
|
|
|
int getwarpbackground(int rx, int ry);
|
|
|
|
|
|
|
|
std::vector<std::string> getLevelDirFileNames( );
|
|
|
|
std::vector <int> contents;
|
|
|
|
std::vector <int> vmult;
|
2020-04-09 07:09:11 +02:00
|
|
|
int numtrinkets();
|
2020-04-09 07:13:43 +02:00
|
|
|
int numcrewmates();
|
2020-01-01 21:29:24 +01:00
|
|
|
edlevelclass level[400]; //Maxwidth*maxheight
|
2020-01-31 04:06:16 +01:00
|
|
|
int kludgewarpdir[400]; //Also maxwidth*maxheight
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int temp;
|
|
|
|
int notedelay;
|
|
|
|
std::string note;
|
|
|
|
std::string keybuffer;
|
|
|
|
std::string filename;
|
|
|
|
|
|
|
|
int drawmode;
|
|
|
|
int tilex, tiley;
|
|
|
|
int keydelay, lclickdelay;
|
|
|
|
bool savekey, loadkey;
|
|
|
|
int levx, levy;
|
|
|
|
int entframe, entframedelay;
|
|
|
|
|
|
|
|
bool roomtextmod;
|
|
|
|
|
|
|
|
bool scripttextmod;
|
2020-01-27 11:15:25 +01:00
|
|
|
int textent;
|
2020-01-01 21:29:24 +01:00
|
|
|
int scripttexttype;
|
2020-01-27 11:15:25 +01:00
|
|
|
std::string oldenttext;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-06-17 23:49:57 +02:00
|
|
|
bool xmod, zmod, cmod, vmod, bmod, hmod, spacemod, warpmod, roomnamemod, textentry, savemod, loadmod;
|
2020-01-01 21:29:24 +01:00
|
|
|
bool titlemod, creatormod, desc1mod, desc2mod, desc3mod, websitemod;
|
|
|
|
|
|
|
|
int roomnamehide;
|
|
|
|
bool saveandquit;
|
|
|
|
bool shiftmenu, shiftkey;
|
|
|
|
int spacemenu;
|
|
|
|
bool settingsmod, settingskey;
|
|
|
|
int warpent;
|
|
|
|
bool updatetiles, changeroom;
|
|
|
|
int deletekeyheld;
|
|
|
|
|
|
|
|
int boundarymod, boundarytype;
|
|
|
|
int boundx1, boundx2, boundy1, boundy2;
|
|
|
|
|
|
|
|
int levmusic;
|
|
|
|
int mapwidth, mapheight; //Actual width and height of stage
|
|
|
|
int maxwidth, maxheight; //Special; the physical max the engine allows
|
|
|
|
|
|
|
|
int version;
|
|
|
|
|
|
|
|
//Script editor stuff
|
|
|
|
void removeline(int t);
|
|
|
|
void insertline(int t);
|
|
|
|
|
|
|
|
bool scripteditmod;
|
|
|
|
int scripthelppage, scripthelppagedelay;
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
std::vector<std::string> sb;
|
2020-01-01 21:29:24 +01:00
|
|
|
std::string sbscript;
|
|
|
|
int sbx, sby;
|
|
|
|
int pagey;
|
|
|
|
|
|
|
|
std::string author;
|
|
|
|
std::string description;
|
|
|
|
std::string title;
|
|
|
|
|
|
|
|
//Functions for interfacing with the script:
|
|
|
|
void addhook(std::string t);
|
|
|
|
void removehook(std::string t);
|
|
|
|
void addhooktoscript(std::string t);
|
|
|
|
void removehookfromscript(std::string t);
|
|
|
|
void loadhookineditor(std::string t);
|
|
|
|
void clearscriptbuffer();
|
|
|
|
void gethooks();
|
|
|
|
bool checkhook(std::string t);
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
std::vector<std::string> hooklist;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int hookmenupage, hookmenu;
|
|
|
|
|
|
|
|
//Direct Mode variables
|
|
|
|
int dmtile;
|
|
|
|
int dmtileeditor;
|
2020-02-10 03:23:12 +01:00
|
|
|
|
2020-02-11 06:34:01 +01:00
|
|
|
int returneditoralpha;
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
|
|
|
|
std::vector<GhostInfo> ghosts;
|
2020-06-13 00:27:21 +02:00
|
|
|
int currentghosts;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void addedentity(int xp, int yp, int tp, int p1=0, int p2=0, int p3=0, int p4=0, int p5=320, int p6=240);
|
|
|
|
|
|
|
|
void removeedentity(int t);
|
|
|
|
|
|
|
|
int edentat(int xp, int yp);
|
|
|
|
|
|
|
|
|
|
|
|
bool edentclear(int xp, int yp);
|
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
void fillbox(int x, int y, int x2, int y2, int c);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
void fillboxabs(int x, int y, int x2, int y2, int c);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
void editorrender();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
void editorlogic();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-03-31 21:52:10 +02:00
|
|
|
void editorinput();
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-05-18 19:14:12 +02:00
|
|
|
extern editorclass ed;
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
#endif /* EDITOR_H */
|
2020-02-10 01:53:01 +01:00
|
|
|
|
2020-03-01 21:24:43 +01:00
|
|
|
#endif /* NO_CUSTOM_LEVELS */
|