Move all editor-specific attributes to a new editorclass

This is a pretty hefty commit! But essentially, I made a new editorclass
object, and moved all functions and variables that only get used in the
in-game level editor to that class. This cleanly demarcates which things
are in the editor and which things are just general custom level stuff.

Then I fixed up all the callers. I also fixed up some NO_CUSTOM_LEVELS
and NO_EDITOR ifdefs, too, in several places.
This commit is contained in:
Misa
2021-02-20 15:40:11 -08:00
committed by Misa Elizabeth Kai
parent 987ae88909
commit a23014350f
13 changed files with 1336 additions and 1268 deletions

View File

@@ -2,6 +2,7 @@
#include "Credits.h"
#include "CustomLevels.h"
#include "Editor.h"
#include "Entity.h"
#include "Enums.h"
#include "FileSystemUtils.h"
@@ -414,7 +415,7 @@ static void menuactionpress(void)
#if !defined(NO_CUSTOM_LEVELS)
case Menu::levellist:
{
const bool nextlastoptions = ed.ListOfMetaData.size() > 8;
const bool nextlastoptions = cl.ListOfMetaData.size() > 8;
if(game.currentmenuoption==(int)game.menuoptions.size()-1){
//go back to menu
music.playef(11);
@@ -424,7 +425,7 @@ static void menuactionpress(void)
//previous page
music.playef(11);
if(game.levelpage==0){
game.levelpage=(ed.ListOfMetaData.size()-1)/8;
game.levelpage=(cl.ListOfMetaData.size()-1)/8;
}else{
game.levelpage--;
}
@@ -434,7 +435,7 @@ static void menuactionpress(void)
}else if(nextlastoptions && game.currentmenuoption==(int)game.menuoptions.size()-3){
//next page
music.playef(11);
if((size_t) ((game.levelpage*8)+8) >= ed.ListOfMetaData.size()){
if((size_t) ((game.levelpage*8)+8) >= cl.ListOfMetaData.size()){
game.levelpage=0;
}else{
game.levelpage++;
@@ -447,10 +448,10 @@ static void menuactionpress(void)
//PLAY CUSTOM LEVEL HOOK
music.playef(11);
game.playcustomlevel=(game.levelpage*8)+game.currentmenuoption;
game.customleveltitle=ed.ListOfMetaData[game.playcustomlevel].title;
game.customlevelfilename=ed.ListOfMetaData[game.playcustomlevel].filename;
game.customleveltitle=cl.ListOfMetaData[game.playcustomlevel].title;
game.customlevelfilename=cl.ListOfMetaData[game.playcustomlevel].filename;
std::string name = "saves/" + ed.ListOfMetaData[game.playcustomlevel].filename.substr(7) + ".vvv";
std::string name = "saves/" + cl.ListOfMetaData[game.playcustomlevel].filename.substr(7) + ".vvv";
tinyxml2::XMLDocument doc;
if (!FILESYSTEM_loadTiXml2Document(name.c_str(), doc)){
startmode(22);
@@ -494,7 +495,7 @@ static void menuactionpress(void)
game.returnmenu();
break;
case 1:
game.customdeletequick(ed.ListOfMetaData[game.playcustomlevel].filename);
game.customdeletequick(cl.ListOfMetaData[game.playcustomlevel].filename);
game.returntomenu(Menu::levellist);
game.flashlight = 5;
game.screenshake = 15;
@@ -515,7 +516,7 @@ static void menuactionpress(void)
music.playef(11);
game.levelpage=0;
ed.getDirectoryData();
cl.getDirectoryData();
game.loadcustomlevelstats(); //Should only load a file if it's needed
game.createmenu(Menu::levellist);
if (FILESYSTEM_levelDirHasError())
@@ -2039,7 +2040,7 @@ void gameinput(void)
}
//Returning to editor mode must always be possible
#if !defined(NO_CUSTOM_LEVELS)
#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR)
if (map.custommode && !map.custommodeforreal)
{
if ((game.press_map || key.isDown(27)) && !game.mapheld)
@@ -2601,7 +2602,7 @@ static void mapmenuactionpress(const bool version2_2)
#if !defined(NO_CUSTOM_LEVELS)
if(map.custommodeforreal)
{
success = game.customsavequick(ed.ListOfMetaData[game.playcustomlevel].filename);
success = game.customsavequick(cl.ListOfMetaData[game.playcustomlevel].filename);
}
else
#endif