diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index 3a16a63a..07c4c835 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -1,6 +1,6 @@ #if !defined(NO_CUSTOM_LEVELS) -#define ED_DEFINITION +#define CL_DEFINITION #include "CustomLevels.h" #include @@ -9,6 +9,7 @@ #include #include +#include "Editor.h" #include "Enums.h" #include "FileSystemUtils.h" #include "Game.h" @@ -52,7 +53,7 @@ edlevelclass::edlevelclass(void) directmode=0; } -editorclass::editorclass(void) +customlevelclass::customlevelclass(void) { for (size_t i = 0; i < SDL_arraysize(vmult); i++) { @@ -93,7 +94,7 @@ static void levelZipCallback(const char* filename) } } -void editorclass::loadZips(void) +void customlevelclass::loadZips(void) { FILESYSTEM_enumerateLevelDirFileNames(levelZipCallback); } @@ -205,7 +206,7 @@ TAG_FINDER(find_website, "website") static void levelMetaDataCallback(const char* filename) { - extern editorclass ed; + extern customlevelclass cl; LevelMetaData temp; std::string filename_ = filename; @@ -216,13 +217,13 @@ static void levelMetaDataCallback(const char* filename) return; } - if (ed.getLevelMetaData(filename_, temp)) + if (cl.getLevelMetaData(filename_, temp)) { - ed.ListOfMetaData.push_back(temp); + cl.ListOfMetaData.push_back(temp); } } -void editorclass::getDirectoryData(void) +void customlevelclass::getDirectoryData(void) { ListOfMetaData.clear(); @@ -245,7 +246,7 @@ void editorclass::getDirectoryData(void) } } -bool editorclass::getLevelMetaData(std::string& _path, LevelMetaData& _data ) +bool customlevelclass::getLevelMetaData(std::string& _path, LevelMetaData& _data ) { unsigned char *uMem; FILESYSTEM_loadFileToMemory(_path.c_str(), &uMem, NULL, true); @@ -277,7 +278,7 @@ bool editorclass::getLevelMetaData(std::string& _path, LevelMetaData& _data ) return true; } -void editorclass::reset(void) +void customlevelclass::reset(void) { version=2; //New smaller format change is 2 @@ -286,69 +287,9 @@ void editorclass::reset(void) EditorData::GetInstance().title="Untitled Level"; EditorData::GetInstance().creator="Unknown"; - Desc1=""; - Desc2=""; - Desc3=""; - website=""; - roomnamehide=0; - zmod=false; - xmod=false; - cmod=false; - vmod=false; - hmod=false; - bmod=false; - spacemod=false; - spacemenu=0; - shiftmenu=false; - shiftkey=false; - saveandquit=false; - note=""; - notedelay=0; - oldnotedelay=0; - deletekeyheld=false; - textmod = TEXT_NONE; - - titlemod=false; - creatormod=false; - desc1mod=false; - desc2mod=false; - desc3mod=false; - websitemod=false; - settingsmod=false; - warpmod=false; //Two step process - warpent=-1; - - boundarymod=0; - boundarytype=0; - boundx1=0; - boundx2=0; - boundy1=0; - boundy2=0; - - textent=0; - scripttexttype=0; - - drawmode=0; - dmtile=0; - dmtileeditor=0; - entcol=0; - - tilex=0; - tiley=0; - levx=0; - levy=0; - keydelay=0; - lclickdelay=0; - savekey=false; - loadkey=false; - updatetiles=true; - changeroom=true; levmusic=0; - entframe=0; - entframedelay=0; - edentity.clear(); levmusic=0; @@ -371,173 +312,17 @@ void editorclass::reset(void) level[i+(j*maxwidth)].enemyy2=240; level[i+(j*maxwidth)].enemytype=0; level[i+(j*maxwidth)].directmode=0; - kludgewarpdir[i+(j*maxwidth)]=0; } } SDL_zeroa(contents); - hooklist.clear(); - - sb.clear(); - - clearscriptbuffer(); - sbx=0; - sby=0; - pagey=0; - scripteditmod=false; - sbscript="null"; - scripthelppage=0; - scripthelppagedelay=0; - - hookmenupage=0; - hookmenu=0; script.clearcustom(); - returneditoralpha = 0; - oldreturneditoralpha = 0; - - ghosts.clear(); - currentghosts = 0; - onewaycol_override = false; - - loaded_filepath = ""; } -void editorclass::gethooks(void) -{ - //Scan through the script and create a hooks list based on it - hooklist.clear(); - for (size_t i = 0; i < script.customscripts.size(); i++) - { - Script& script_ = script.customscripts[i]; - - hooklist.push_back(script_.name); - } -} - -void editorclass::loadhookineditor(std::string t) -{ - //Find hook t in the scriptclass, then load it into the editor - clearscriptbuffer(); - - for(size_t i = 0; i < script.customscripts.size(); i++) - { - Script& script_ = script.customscripts[i]; - - if(script_.name == t) - { - sb = script_.contents; - break; - } - } - - if(sb.empty()) - { - //Always have one line or we'll have problems - sb.resize(1); - } -} - -void editorclass::addhooktoscript(std::string t) -{ - //Adds hook+the scriptbuffer to the end of the scriptclass - removehookfromscript(t); - Script script_; - script_.name = t; - script_.contents = sb; - script.customscripts.push_back(script_); -} - -void editorclass::removehookfromscript(std::string t) -{ - /* Find hook t in the scriptclass, then removes it (and any other code with it) - * When this loop reaches the end, it wraps to SIZE_MAX; SIZE_MAX + 1 is 0 */ - size_t i; - for (i = script.customscripts.size() - 1; i + 1 > 0; --i) - { - if (script.customscripts[i].name == t) - { - script.customscripts.erase(script.customscripts.begin() + i); - } - } -} - -void editorclass::removehook(std::string t) -{ - //Check the hooklist for the hook t. If it's there, remove it from here and the script - size_t i; - removehookfromscript(t); - /* When this loop reaches the end, it wraps to SIZE_MAX; SIZE_MAX + 1 is 0 */ - for (i = hooklist.size() - 1; i + 1 > 0; --i) - { - if (hooklist[i] == t) - { - hooklist.erase(hooklist.begin() + i); - } - } -} - -void editorclass::addhook(std::string t) -{ - //Add an empty function to the list in both editor and script - removehook(t); - hooklist.push_back(t); - addhooktoscript(t); -} - -bool editorclass::checkhook(std::string t) -{ - //returns true if hook t already is in the list - for(size_t i=0; i1) - { - sb.erase(sb.begin() + t); - } -} - -void editorclass::insertline(int t) -{ - //insert a blank line into script at line t - sb.insert(sb.begin() + t, ""); -} - -void editorclass::getlin(const enum textmode mode, const std::string& prompt, std::string* ptr) -{ - textmod = mode; - textptr = ptr; - textdesc = prompt; - key.enabletextentry(); - if (ptr) - { - key.keybuffer = *ptr; - } - else - { - key.keybuffer = ""; - textptr = &(key.keybuffer); - } - - oldenttext = key.keybuffer; -} - -const int* editorclass::loadlevel( int rxi, int ryi ) +const int* customlevelclass::loadlevel( int rxi, int ryi ) { //Set up our buffer array to be picked up by mapclass rxi -= 100; @@ -560,7 +345,7 @@ const int* editorclass::loadlevel( int rxi, int ryi ) return result; } -int editorclass::getlevelcol(const int tileset, const int tilecol) +int customlevelclass::getlevelcol(const int tileset, const int tilecol) { if(tileset==0) //Space Station { @@ -585,7 +370,7 @@ int editorclass::getlevelcol(const int tileset, const int tilecol) return 0; } -int editorclass::getenemycol(int t) +int customlevelclass::getenemycol(int t) { switch(t) { @@ -677,7 +462,7 @@ int editorclass::getenemycol(int t) } } -int editorclass::getwarpbackground(int rx, int ry) +int customlevelclass::getwarpbackground(int rx, int ry) { const edlevelclass* const room = getroomprop(rx, ry); switch(room->tileset) @@ -914,47 +699,7 @@ int editorclass::getwarpbackground(int rx, int ry) } } -int editorclass::getenemyframe(int t) -{ - switch(t) - { - case 0: - return 78; - break; - case 1: - return 88; - break; - case 2: - return 36; - break; - case 3: - return 164; - break; - case 4: - return 68; - break; - case 5: - return 48; - break; - case 6: - return 176; - break; - case 7: - return 168; - break; - case 8: - return 112; - break; - case 9: - return 114; - break; - default: - return 78; - break; - } -} - -int editorclass::gettileidx( +int customlevelclass::gettileidx( const int rx, const int ry, const int x, @@ -978,7 +723,7 @@ int editorclass::gettileidx( return idx; } -void editorclass::settile( +void customlevelclass::settile( const int rx, const int ry, const int x, @@ -995,7 +740,7 @@ void editorclass::settile( contents[idx] = t; } -int editorclass::gettile( +int customlevelclass::gettile( const int rx, const int ry, const int x, @@ -1011,7 +756,7 @@ int editorclass::gettile( return contents[idx]; } -int editorclass::getabstile(const int x, const int y) +int customlevelclass::getabstile(const int x, const int y) { int idx; int yoff; @@ -1036,12 +781,12 @@ int editorclass::getabstile(const int x, const int y) } -int editorclass::getroompropidx(const int rx, const int ry) +int customlevelclass::getroompropidx(const int rx, const int ry) { return rx + ry*maxwidth; } -const edlevelclass* editorclass::getroomprop(const int rx, const int ry) +const edlevelclass* customlevelclass::getroomprop(const int rx, const int ry) { const int idx = getroompropidx(rx, ry); @@ -1059,7 +804,7 @@ const edlevelclass* editorclass::getroomprop(const int rx, const int ry) } #define FOREACH_PROP(NAME, TYPE) \ -void editorclass::setroom##NAME(const int rx, const int ry, const TYPE NAME) \ +void customlevelclass::setroom##NAME(const int rx, const int ry, const TYPE NAME) \ { \ const int idx = getroompropidx(rx, ry); \ \ @@ -1076,271 +821,7 @@ ROOM_PROPERTIES #undef FOREACH_PROP -void editorclass::placetilelocal( int x, int y, int t ) -{ - if(x>=0 && y>=0 && x<40 && y<30) - { - settile(levx, levy, x, y, t); - } - updatetiles=true; -} - -int editorclass::base( int x, int y ) -{ - //Return the base tile for the given tileset and colour - const edlevelclass* const room = getroomprop(x, y); - if(room->tileset==0) //Space Station - { - if(room->tilecol>=22) - { - return 483 + ((room->tilecol-22)*3); - } - else if(room->tilecol>=11) - { - return 283 + ((room->tilecol-11)*3); - } - else - { - return 83 + (room->tilecol*3); - } - } - else if(room->tileset==1) //Outside - { - return 480 + (room->tilecol*3); - } - else if(room->tileset==2) //Lab - { - return 280 + (room->tilecol*3); - } - else if(room->tileset==3) //Warp Zone/Intermission - { - return 80 + (room->tilecol*3); - } - else if(room->tileset==4) //SHIP - { - return 101 + (room->tilecol*3); - } - return 0; -} - -int editorclass::backbase( int x, int y ) -{ - //Return the base tile for the background of the given tileset and colour - const edlevelclass* const room = getroomprop(x, y); - if(room->tileset==0) //Space Station - { - //Pick depending on tilecol - switch(room->tilecol) - { - case 0: - case 5: - case 26: - return 680; //Blue - break; - case 3: - case 16: - case 23: - return 683; //Yellow - break; - case 9: - case 12: - case 21: - return 686; //Greeny Cyan - break; - case 4: - case 8: - case 24: - case 28: - case 30: - return 689; //Green - break; - case 20: - case 29: - return 692; //Orange - break; - case 2: - case 6: - case 11: - case 22: - case 27: - return 695; //Red - break; - case 1: - case 10: - case 15: - case 19: - case 31: - return 698; //Pink - break; - case 14: - case 18: - return 701; //Dark Blue - break; - case 7: - case 13: - case 17: - case 25: - return 704; //Cyan - break; - default: - return 680; - break; - } - - } - else if(room->tileset==1) //outside - { - return 680 + (room->tilecol*3); - } - else if(room->tileset==2) //Lab - { - return 0; - } - else if(room->tileset==3) //Warp Zone/Intermission - { - return 120 + (room->tilecol*3); - } - else if(room->tileset==4) //SHIP - { - return 741 + (room->tilecol*3); - } - return 0; -} - -int editorclass::at( int x, int y ) -{ - if(x<0) return at(0,y); - if(y<0) return at(x,0); - if(x>=40) return at(39,y); - if(y>=30) return at(x,29); - - if(x>=0 && y>=0 && x<40 && y<30) - { - return gettile(levx, levy, x, y); - } - return 0; -} - - -int editorclass::freewrap( int x, int y ) -{ - if(x<0) return freewrap(x+(mapwidth*40),y); - if(y<0) return freewrap(x,y+(mapheight*30)); - if(x>=(mapwidth*40)) return freewrap(x-(mapwidth*40),y); - if(y>=(mapheight*30)) return freewrap(x,y-(mapheight*30)); - - if(x>=0 && y>=0 && x<(mapwidth*40) && y<(mapheight*30)) - { - if(getabstile(x, y)==0) - { - return 0; - } - else - { - if(getabstile(x, y)>=2 && getabstile(x, y)<80) - { - return 0; - } - if(getabstile(x, y)>=680) - { - return 0; - } - } - } - return 1; -} - -int editorclass::backonlyfree( int x, int y ) -{ - //Returns 1 if tile is a background tile, 0 otherwise - if(x<0) return backonlyfree(0,y); - if(y<0) return backonlyfree(x,0); - if(x>=40) return backonlyfree(39,y); - if(y>=30) return backonlyfree(x,29); - - if(x>=0 && y>=0 && x<40 && y<30) - { - if(gettile(levx, levy, x, y)>=680) - { - return 1; - } - } - return 0; -} - -int editorclass::backfree( int x, int y ) -{ - //Returns 0 if tile is not a block or background tile, 1 otherwise - if(x<0) return backfree(0,y); - if(y<0) return backfree(x,0); - if(x>=40) return backfree(39,y); - if(y>=30) return backfree(x,29); - - if(x>=0 && y>=0 && x<40 && y<30) - { - if(gettile(levx, levy, x, y)==0) - { - return 0; - } - } - return 1; -} - -int editorclass::spikefree( int x, int y ) -{ - //Returns 0 if tile is not a block or spike, 1 otherwise - if(x==-1) return free(0,y); - if(y==-1) return free(x,0); - if(x==40) return free(39,y); - if(y==30) return free(x,29); - - if(x>=0 && y>=0 && x<40 && y<30) - { - if(gettile(levx, levy, x, y)==0) - { - return 0; - } - else - { - if(gettile(levx, levy, x, y)>=680) - { - return 0; - } - } - } - return 1; -} - -int editorclass::free( int x, int y ) -{ - //Returns 0 if tile is not a block, 1 otherwise - if(x==-1) return free(0,y); - if(y==-1) return free(x,0); - if(x==40) return free(39,y); - if(y==30) return free(x,29); - - if(x>=0 && y>=0 && x<40 && y<30) - { - if(gettile(levx, levy, x, y)==0) - { - return 0; - } - else - { - if(gettile(levx, levy, x, y)>=2 && gettile(levx, levy, x, y)<80) - { - return 0; - } - if(gettile(levx, levy, x, y)>=680) - { - return 0; - } - } - } - return 1; -} - -int editorclass::absfree( int x, int y ) +int customlevelclass::absfree( int x, int y ) { //Returns 0 if tile is not a block, 1 otherwise, abs on grid if(x>=0 && y>=0 && xtileset; - - if (reversed) - { - tiles--; - } - else - { - tiles++; - } - - const int modulus = SDL_arraysize(tilesets); - tiles = (tiles % modulus + modulus) % modulus; - setroomtileset(levx, levy, tiles); - - clamp_tilecol(levx, levy, false); - - char buffer[64]; - SDL_snprintf(buffer, sizeof(buffer), "Now using %s Tileset", tilesets[tiles]); - - note = buffer; - notedelay = 45; - updatetiles = true; -} - -void editorclass::switch_tilecol(const bool reversed) -{ - int tilecol = getroomprop(levx, levy)->tilecol; - - if (reversed) - { - tilecol--; - } - else - { - tilecol++; - } - - setroomtilecol(levx, levy, tilecol); - - clamp_tilecol(levx, levy, true); - - notedelay = 45; - note = "Tileset Colour Changed"; - updatetiles = true; -} - -void editorclass::clamp_tilecol(const int rx, const int ry, const bool wrap) -{ - const edlevelclass* const room = getroomprop(rx, ry); - const int tileset = room->tileset; - int tilecol = room->tilecol; - - int mincol = -1; - int maxcol = 5; - - // Only Space Station allows tileset -1 - if (tileset != 0) - { - mincol = 0; - } - - switch (tileset) - { - case 0: - maxcol = 31; - break; - case 1: - maxcol = 7; - break; - case 2: - if (room->directmode) - { - maxcol = 6; - } - break; - case 3: - maxcol = 6; - break; - case 5: - maxcol = 29; - break; - } - - // If wrap is true, wrap-around, otherwise just cap - if (tilecol > maxcol) - { - tilecol = (wrap ? mincol : maxcol); - } - if (tilecol < mincol) - { - tilecol = (wrap ? maxcol : mincol); - } - - setroomtilecol(rx, ry, tilecol); -} - -void editorclass::switch_enemy(const bool reversed) -{ - const edlevelclass* const room = getroomprop(levx, levy); - - int enemy = room->enemytype; - - if (reversed) - { - enemy--; - } - else - { - enemy++; - } - - const int modulus = 10; - enemy = (enemy % modulus + modulus) % modulus; - setroomenemytype(levx, levy, enemy); - - note = "Enemy Type Changed"; - notedelay = 45; -} - -void editorclass::switch_warpdir(const bool reversed) -{ - static const int modulus = 4; - const edlevelclass* const room = getroomprop(levx, levy); - - int warpdir = room->warpdir; - - if (reversed) - { - --warpdir; - } - else - { - ++warpdir; - } - - warpdir = (warpdir % modulus + modulus) % modulus; - setroomwarpdir(levx, levy, warpdir); - - switch (warpdir) - { - default: - note = "Room warping disabled"; - break; - case 1: - note = "Room warps horizontally"; - break; - case 2: - note = "Room warps vertically"; - break; - case 3: - note = "Room warps in all directions"; - break; - } - - notedelay = 45; -} - -bool editorclass::load(std::string& _path) +bool customlevelclass::load(std::string& _path) { tinyxml2::XMLDocument doc; tinyxml2::XMLHandle hDoc(&doc); tinyxml2::XMLElement* pElem; reset(); +#ifndef NO_EDITOR + ed.reset(); +#endif static const char *levelDir = "levels/"; if (_path.compare(0, SDL_strlen(levelDir), levelDir) != 0) @@ -1826,7 +957,9 @@ bool editorclass::load(std::string& _path) goto fail; } - loaded_filepath = _path; +#ifndef NO_EDITOR + ed.loaded_filepath = _path; +#endif version = 0; @@ -2118,7 +1251,10 @@ next: } } - gethooks(); +#ifndef NO_EDITOR + ed.gethooks(); +#endif + version=2; return true; @@ -2127,20 +1263,22 @@ fail: return false; } -bool editorclass::save(std::string& _path) +#ifndef NO_EDITOR +bool customlevelclass::save(std::string& _path) { tinyxml2::XMLDocument doc; std::string newpath("levels/" + _path); // Try to preserve the XML of the currently-loaded one - bool already_exists = !loaded_filepath.empty() && FILESYSTEM_loadTiXml2Document(loaded_filepath.c_str(), doc); - if (!already_exists && !loaded_filepath.empty()) + bool already_exists = !ed.loaded_filepath.empty() + && FILESYSTEM_loadTiXml2Document(ed.loaded_filepath.c_str(), doc); + if (!already_exists && !ed.loaded_filepath.empty()) { - vlog_error("Currently-loaded %s not found", loaded_filepath.c_str()); + vlog_error("Currently-loaded %s not found", ed.loaded_filepath.c_str()); } - loaded_filepath = newpath; + ed.loaded_filepath = newpath; tinyxml2::XMLElement* msg; @@ -2305,9 +1443,10 @@ bool editorclass::save(std::string& _path) return FILESYSTEM_saveTiXml2Document(newpath.c_str(), doc); } +#endif /* NO_EDITOR */ -void editorclass::generatecustomminimap(void) +void customlevelclass::generatecustomminimap(void) { map.customwidth=mapwidth; map.customheight=mapheight; @@ -2428,7 +1567,7 @@ void editorclass::generatecustomminimap(void) // Return a graphics-ready color based off of the given tileset and tilecol // Much kudos to Dav999 for saving me a lot of work, because I stole these colors from const.lua in Ved! -Info Teddy -Uint32 editorclass::getonewaycol(const int rx, const int ry) +Uint32 customlevelclass::getonewaycol(const int rx, const int ry) { const edlevelclass* const room = getroomprop(rx, ry); switch (room->tileset) { @@ -2587,18 +1726,25 @@ Uint32 editorclass::getonewaycol(const int rx, const int ry) } // This version detects the room automatically -Uint32 editorclass::getonewaycol(void) +Uint32 customlevelclass::getonewaycol(void) { +#ifndef NO_EDITOR if (game.gamestate == EDITORMODE) - return getonewaycol(levx, levy); - else if (map.custommode) + { + return getonewaycol(ed.levx, ed.levy); + } + else +#endif + if (map.custommode) + { return getonewaycol(game.roomx - 100, game.roomy - 100); + } // Uh, I guess return solid white return graphics.getRGB(255, 255, 255); } -int editorclass::numtrinkets(void) +int customlevelclass::numtrinkets(void) { int temp = 0; for (size_t i = 0; i < edentity.size(); i++) @@ -2611,7 +1757,7 @@ int editorclass::numtrinkets(void) return temp; } -int editorclass::numcrewmates(void) +int customlevelclass::numcrewmates(void) { int temp = 0; for (size_t i = 0; i < edentity.size(); i++) diff --git a/desktop_version/src/CustomLevels.h b/desktop_version/src/CustomLevels.h index 17544514..75a55385 100644 --- a/desktop_version/src/CustomLevels.h +++ b/desktop_version/src/CustomLevels.h @@ -7,31 +7,6 @@ #include #include -// Text entry field type -enum textmode { - TEXT_NONE, - - // In-editor text fields - TEXT_LOAD, - TEXT_SAVE, - TEXT_ROOMNAME, - TEXT_SCRIPT, - TEXT_ROOMTEXT, - TEXT_GOTOROOM, - LAST_EDTEXT = TEXT_GOTOROOM, - - // Settings-mode text fields - TEXT_TITLE, - TEXT_DESC, - TEXT_WEBSITE, - TEXT_CREATOR, - NUM_TEXTMODES, - - // Text modes with an entity - FIRST_ENTTEXT = TEXT_SCRIPT, - LAST_ENTTEXT = TEXT_ROOMTEXT -}; - class edentities{ public: int x, y, t; @@ -104,20 +79,10 @@ class EditorData std::string modifier; }; -struct GhostInfo { - int rx; // game.roomx-100 - int ry; // game.roomy-100 - int x; // .xp - int y; // .yp - int col; // .colour - Uint32 realcol; - int frame; // .drawframe -}; - -class editorclass{ - public: - editorclass(void); - +class customlevelclass +{ +public: + customlevelclass(void); std::string Desc1; std::string Desc2; std::string Desc3; @@ -130,7 +95,6 @@ class editorclass{ bool getLevelMetaData(std::string& filename, LevelMetaData& _data ); void reset(void); - void getlin(const enum textmode mode, const std::string& prompt, std::string* ptr); const int* loadlevel(int rxi, int ryi); int gettileidx( @@ -161,54 +125,20 @@ class editorclass{ ROOM_PROPERTIES #undef FOREACH_PROP - 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 outsidematch(int x, int y); - - int backmatch(int x, int y); - - void switch_tileset(const bool reversed); - void switch_tilecol(const bool reversed); - void clamp_tilecol(const int rx, const int ry, const bool wrap); - void switch_enemy(const bool reversed); - void switch_warpdir(const bool reversed); - bool load(std::string& _path); +#ifndef NO_EDITOR bool save(std::string& _path); +#endif void generatecustomminimap(void); - int edgetile(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); void findstartpoint(void); int getlevelcol(const int tileset, const int tilecol); int getenemycol(int t); - int entcol; - Uint32 entcolreal; //Colouring stuff int getwarpbackground(int rx, int ry); @@ -220,93 +150,19 @@ class editorclass{ int numtrinkets(void); int numcrewmates(void); edlevelclass level[numrooms]; //Maxwidth*maxheight - int kludgewarpdir[numrooms]; //Also maxwidth*maxheight - - int notedelay; - int oldnotedelay; - std::string note; - std::string keybuffer; - std::string filename; - std::string loaded_filepath; - - int drawmode; - int tilex, tiley; - int keydelay, lclickdelay; - bool savekey, loadkey; - int levx, levy; - int entframe, entframedelay; - - int scripttexttype; - std::string oldenttext; - - enum textmode textmod; // In text entry - std::string* textptr; // Pointer to text we're changing - std::string textdesc; // Description (for editor mode text fields) - union { - int desc; // Which description row we're changing - int textent; // Entity ID for text prompt - }; - bool xmod, zmod, cmod, vmod, bmod, hmod, spacemod, warpmod; - 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 version; - //Script editor stuff - void removeline(int t); - void insertline(int t); - - bool scripteditmod; - int scripthelppage, scripthelppagedelay; - std::vector sb; - std::string sbscript; - int sbx, sby; - int pagey; - - //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); - void gethooks(void); - bool checkhook(std::string t); - std::vector hooklist; - - int hookmenupage, hookmenu; - - //Direct Mode variables - int dmtile; - int dmtileeditor; - Uint32 getonewaycol(const int rx, const int ry); Uint32 getonewaycol(void); bool onewaycol_override; - - int returneditoralpha; - int oldreturneditoralpha; - - std::vector ghosts; - int currentghosts; }; -#ifndef ED_DEFINITION -extern editorclass ed; +#ifndef CL_DEFINITION +extern customlevelclass cl; #endif #endif /* CUSTOMLEVELS_H */ diff --git a/desktop_version/src/Editor.cpp b/desktop_version/src/Editor.cpp index 5501ae82..71cb2672 100644 --- a/desktop_version/src/Editor.cpp +++ b/desktop_version/src/Editor.cpp @@ -1,10 +1,12 @@ #if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR) -#include "CustomLevels.h" +#define ED_DEFINITION +#include "Editor.h" #include #include +#include "CustomLevels.h" #include "DeferCallbacks.h" #include "Entity.h" #include "Enums.h" @@ -17,6 +19,230 @@ #include "Script.h" #include "UtilityClass.h" +editorclass::editorclass(void) +{ + reset(); +} + +void editorclass::reset(void) +{ + roomnamehide=0; + zmod=false; + xmod=false; + cmod=false; + vmod=false; + hmod=false; + bmod=false; + spacemod=false; + spacemenu=0; + shiftmenu=false; + shiftkey=false; + saveandquit=false; + note=""; + notedelay=0; + oldnotedelay=0; + deletekeyheld=false; + textmod = TEXT_NONE; + + titlemod=false; + creatormod=false; + desc1mod=false; + desc2mod=false; + desc3mod=false; + websitemod=false; + settingsmod=false; + warpmod=false; //Two step process + warpent=-1; + + boundarymod=0; + boundarytype=0; + boundx1=0; + boundx2=0; + boundy1=0; + boundy2=0; + + textent=0; + scripttexttype=0; + + drawmode=0; + dmtile=0; + dmtileeditor=0; + entcol=0; + + tilex=0; + tiley=0; + levx=0; + levy=0; + keydelay=0; + lclickdelay=0; + savekey=false; + loadkey=false; + updatetiles=true; + changeroom=true; + + entframe=0; + entframedelay=0; + + SDL_zeroa(kludgewarpdir); + + hooklist.clear(); + + sb.clear(); + + clearscriptbuffer(); + sbx=0; + sby=0; + pagey=0; + scripteditmod=false; + sbscript="null"; + scripthelppage=0; + scripthelppagedelay=0; + + hookmenupage=0; + hookmenu=0; + + returneditoralpha = 0; + oldreturneditoralpha = 0; + + ghosts.clear(); + currentghosts = 0; + + loaded_filepath = ""; +} + +void editorclass::gethooks(void) +{ + //Scan through the script and create a hooks list based on it + hooklist.clear(); + for (size_t i = 0; i < script.customscripts.size(); i++) + { + Script& script_ = script.customscripts[i]; + + hooklist.push_back(script_.name); + } +} + +void editorclass::loadhookineditor(std::string t) +{ + //Find hook t in the scriptclass, then load it into the editor + clearscriptbuffer(); + + for(size_t i = 0; i < script.customscripts.size(); i++) + { + Script& script_ = script.customscripts[i]; + + if(script_.name == t) + { + sb = script_.contents; + break; + } + } + + if(sb.empty()) + { + //Always have one line or we'll have problems + sb.resize(1); + } +} + +void editorclass::addhooktoscript(std::string t) +{ + //Adds hook+the scriptbuffer to the end of the scriptclass + removehookfromscript(t); + Script script_; + script_.name = t; + script_.contents = sb; + script.customscripts.push_back(script_); +} + +void editorclass::removehookfromscript(std::string t) +{ + /* Find hook t in the scriptclass, then removes it (and any other code with it) + * When this loop reaches the end, it wraps to SIZE_MAX; SIZE_MAX + 1 is 0 */ + size_t i; + for (i = script.customscripts.size() - 1; i + 1 > 0; --i) + { + if (script.customscripts[i].name == t) + { + script.customscripts.erase(script.customscripts.begin() + i); + } + } +} + +void editorclass::removehook(std::string t) +{ + //Check the hooklist for the hook t. If it's there, remove it from here and the script + size_t i; + removehookfromscript(t); + /* When this loop reaches the end, it wraps to SIZE_MAX; SIZE_MAX + 1 is 0 */ + for (i = hooklist.size() - 1; i + 1 > 0; --i) + { + if (hooklist[i] == t) + { + hooklist.erase(hooklist.begin() + i); + } + } +} + +void editorclass::addhook(std::string t) +{ + //Add an empty function to the list in both editor and script + removehook(t); + hooklist.push_back(t); + addhooktoscript(t); +} + +bool editorclass::checkhook(std::string t) +{ + //returns true if hook t already is in the list + for(size_t i=0; i1) + { + sb.erase(sb.begin() + t); + } +} + +void editorclass::insertline(int t) +{ + //insert a blank line into script at line t + sb.insert(sb.begin() + t, ""); +} + +void editorclass::getlin(const enum textmode mode, const std::string& prompt, std::string* ptr) +{ + textmod = mode; + textptr = ptr; + textdesc = prompt; + key.enabletextentry(); + if (ptr) + { + key.keybuffer = *ptr; + } + else + { + key.keybuffer = ""; + textptr = &(key.keybuffer); + } + + oldenttext = key.keybuffer; +} + + static 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) { edentities entity; @@ -68,6 +294,7 @@ static void fillboxabs( int x, int y, int x2, int y2, int c ) static void editormenurender(int tr, int tg, int tb) { + extern editorclass ed; switch (game.currentmenuname) { case Menu::ed_settings: @@ -124,7 +351,7 @@ static void editormenurender(int tr, int tg, int tb) } else { - graphics.Print( -1, 70, ed.website, tr, tg, tb, true); + graphics.Print( -1, 70, cl.website, tr, tg, tb, true); } if(ed.desc1mod) { @@ -139,7 +366,7 @@ static void editormenurender(int tr, int tg, int tb) } else { - graphics.Print( -1, 90, ed.Desc1, tr, tg, tb, true); + graphics.Print( -1, 90, cl.Desc1, tr, tg, tb, true); } if(ed.desc2mod) { @@ -154,7 +381,7 @@ static void editormenurender(int tr, int tg, int tb) } else { - graphics.Print( -1, 100, ed.Desc2, tr, tg, tb, true); + graphics.Print( -1, 100, cl.Desc2, tr, tg, tb, true); } if(ed.desc3mod) { @@ -169,7 +396,7 @@ static void editormenurender(int tr, int tg, int tb) } else { - graphics.Print( -1, 110, ed.Desc3, tr, tg, tb, true); + graphics.Print( -1, 110, cl.Desc3, tr, tg, tb, true); } break; case Menu::ed_music: @@ -178,7 +405,7 @@ static void editormenurender(int tr, int tg, int tb) graphics.Print( -1, 85, "Current map music:", tr, tg, tb, true); std::string songname; - switch(ed.levmusic) + switch(cl.levmusic) { case 0: songname = "No background music"; @@ -247,7 +474,7 @@ static void editormenurender(int tr, int tg, int tb) void editorrender(void) { extern editorclass ed; - const edlevelclass* const room = ed.getroomprop(ed.levx, ed.levy); + const edlevelclass* const room = cl.getroomprop(ed.levx, ed.levy); //Draw grid @@ -278,15 +505,15 @@ void editorrender(void) switch(room->warpdir) { case 1: - graphics.rcol=ed.getwarpbackground(ed.levx, ed.levy); + graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy); graphics.drawbackground(3); break; case 2: - graphics.rcol=ed.getwarpbackground(ed.levx, ed.levy); + graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy); graphics.drawbackground(4); break; case 3: - graphics.rcol=ed.getwarpbackground(ed.levx, ed.levy); + graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy); graphics.drawbackground(5); break; default: @@ -302,7 +529,7 @@ void editorrender(void) { for (int i = 0; i < 40; i++) { - temp=ed.gettile(ed.levx, ed.levy, i, j); + temp=cl.gettile(ed.levx, ed.levy, i, j); if(temp>0) graphics.drawtile(i*8,j*8,temp); } } @@ -313,7 +540,7 @@ void editorrender(void) { for (int i = 0; i < 40; i++) { - temp=ed.gettile(ed.levx, ed.levy, i, j); + temp=cl.gettile(ed.levx, ed.levy, i, j); if(temp>0) graphics.drawtile2(i*8,j*8,temp); } } @@ -498,7 +725,7 @@ void editorrender(void) } else { - graphics.bprint((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8)-8,help.String(ed.findwarptoken(i)),210,210,255); + graphics.bprint((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),210,210,255); } break; case 15: //Crewmates @@ -631,7 +858,7 @@ void editorrender(void) } else { - graphics.bprint((edentity[i].p1*8)- (ed.levx*40*8),(edentity[i].p2*8)- (ed.levy*30*8)-8,help.String(ed.findwarptoken(i)),190,190,225); + graphics.bprint((edentity[i].p1*8)- (ed.levx*40*8),(edentity[i].p2*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),190,190,225); } } } @@ -1318,11 +1545,11 @@ void editorrender(void) void editorrenderfixed(void) { extern editorclass ed; - const edlevelclass* const room = ed.getroomprop(ed.levx, ed.levy); + const edlevelclass* const room = cl.getroomprop(ed.levx, ed.levy); graphics.updatetitlecolours(); - game.customcol=ed.getlevelcol(room->tileset, room->tilecol)+1; - ed.entcol=ed.getenemycol(game.customcol); + game.customcol=cl.getlevelcol(room->tileset, room->tilecol)+1; + ed.entcol=cl.getenemycol(game.customcol); graphics.setcol(ed.entcol); ed.entcolreal = graphics.ct.colour; @@ -1355,15 +1582,15 @@ void editorrenderfixed(void) switch(room->warpdir) { case 1: - graphics.rcol=ed.getwarpbackground(ed.levx, ed.levy); + graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy); graphics.updatebackground(3); break; case 2: - graphics.rcol=ed.getwarpbackground(ed.levx, ed.levy); + graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy); graphics.updatebackground(4); break; case 3: - graphics.rcol=ed.getwarpbackground(ed.levx, ed.levy); + graphics.rcol=cl.getwarpbackground(ed.levx, ed.levy); graphics.updatebackground(5); break; default: @@ -1426,7 +1653,7 @@ void editorrenderfixed(void) } } - if (ed.getroomprop(ed.levx, ed.levy)->directmode == 1) + if (cl.getroomprop(ed.levx, ed.levy)->directmode == 1) { if (ed.dmtileeditor > 0) { @@ -1438,7 +1665,7 @@ void editorrenderfixed(void) ed.dmtileeditor = 0; } - if (ed.getroomprop(ed.levx, ed.levy)->roomname != "") + if (cl.getroomprop(ed.levx, ed.levy)->roomname != "") { if (ed.tiley < 28) { @@ -1513,6 +1740,7 @@ static void nextbgcolor(void) static void editormenuactionpress(void) { + extern editorclass ed; switch (game.currentmenuname) { case Menu::ed_desc: @@ -1531,12 +1759,12 @@ static void editormenuactionpress(void) case 2: ed.desc1mod=true; key.enabletextentry(); - key.keybuffer=ed.Desc1; + key.keybuffer=cl.Desc1; break; case 3: ed.websitemod=true; key.enabletextentry(); - key.keybuffer=ed.website; + key.keybuffer=cl.website; break; case 4: game.returnmenu(); @@ -1571,7 +1799,7 @@ static void editormenuactionpress(void) music.playef(11); game.createmenu(Menu::ed_music); map.nexttowercolour(); - if(ed.levmusic>0) music.play(ed.levmusic); + if(cl.levmusic>0) music.play(cl.levmusic); break; case 3: music.playef(11); @@ -1623,16 +1851,16 @@ static void editormenuactionpress(void) switch (game.currentmenuoption) { case 0: - ed.levmusic++; + cl.levmusic++; break; case 1: - ed.levmusic--; + cl.levmusic--; break; } - ed.levmusic = (ed.levmusic % 16 + 16) % 16; - if(ed.levmusic>0) + cl.levmusic = (cl.levmusic % 16 + 16) % 16; + if(cl.levmusic>0) { - music.play(ed.levmusic); + music.play(cl.levmusic); } else { @@ -2077,15 +2305,15 @@ void editorinput(void) break; } - ed.levx = clamp(help.Int(coord_x) - 1, 0, ed.mapwidth - 1); - ed.levy = clamp(help.Int(coord_y) - 1, 0, ed.mapheight - 1); + ed.levx = clamp(help.Int(coord_x) - 1, 0, cl.mapwidth - 1); + ed.levy = clamp(help.Int(coord_y) - 1, 0, cl.mapheight - 1); graphics.backgrounddrawn = false; break; } case TEXT_LOAD: { std::string loadstring = ed.filename + ".vvvvvv"; - if (ed.load(loadstring)) + if (cl.load(loadstring)) { // don't use filename, it has the full path char buffer[64]; @@ -2102,7 +2330,7 @@ void editorinput(void) case TEXT_SAVE: { std::string savestring = ed.filename + ".vvvvvv"; - if (ed.save(savestring)) + if (cl.save(savestring)) { char buffer[64]; SDL_snprintf(buffer, sizeof(buffer), "[ Saved map: %s.vvvvvv ]", ed.filename.c_str()); @@ -2149,19 +2377,19 @@ void editorinput(void) } else if(ed.websitemod) { - ed.website=key.keybuffer; + cl.website=key.keybuffer; } else if(ed.desc1mod) { - ed.Desc1=key.keybuffer; + cl.Desc1=key.keybuffer; } else if(ed.desc2mod) { - ed.Desc2=key.keybuffer; + cl.Desc2=key.keybuffer; } else if(ed.desc3mod) { - ed.Desc3=key.keybuffer; + cl.Desc3=key.keybuffer; } if(!game.press_map && !key.isDown(27)) game.mapheld=false; @@ -2182,20 +2410,20 @@ void editorinput(void) } else if(ed.websitemod) { - ed.website=key.keybuffer; + cl.website=key.keybuffer; ed.websitemod=false; } else if(ed.desc1mod) { - ed.Desc1=key.keybuffer; + cl.Desc1=key.keybuffer; } else if(ed.desc2mod) { - ed.Desc2=key.keybuffer; + cl.Desc2=key.keybuffer; } else if(ed.desc3mod) { - ed.Desc3=key.keybuffer; + cl.Desc3=key.keybuffer; ed.desc3mod=false; } key.disabletextentry(); @@ -2206,7 +2434,7 @@ void editorinput(void) ed.desc2mod=true; key.enabletextentry(); - key.keybuffer=ed.Desc2; + key.keybuffer=cl.Desc2; } else if(ed.desc2mod) { @@ -2214,7 +2442,7 @@ void editorinput(void) ed.desc3mod=true; key.enabletextentry(); - key.keybuffer=ed.Desc3; + key.keybuffer=cl.Desc3; } music.playef(11); } @@ -2263,7 +2491,7 @@ void editorinput(void) { // Ctrl modifiers int numtiles; - if (ed.getroomprop(ed.levx, ed.levy)->tileset == 0) + if (cl.getroomprop(ed.levx, ed.levy)->tileset == 0) { numtiles = (((int) graphics.tiles.size()) / 40) * 40; } @@ -2331,26 +2559,26 @@ void editorinput(void) ed.keydelay=6; if(up_pressed) { - ed.mapheight--; + cl.mapheight--; } else if(down_pressed) { - ed.mapheight++; + cl.mapheight++; } else if(left_pressed) { - ed.mapwidth--; + cl.mapwidth--; } else if(right_pressed) { - ed.mapwidth++; + cl.mapwidth++; } - if(ed.mapwidth<1) ed.mapwidth=1; - if(ed.mapheight<1) ed.mapheight=1; - if(ed.mapwidth>=ed.maxwidth) ed.mapwidth=ed.maxwidth; - if(ed.mapheight>=ed.maxheight) ed.mapheight=ed.maxheight; - ed.note = "Mapsize is now [" + help.String(ed.mapwidth) + "," + help.String(ed.mapheight) + "]"; + if(cl.mapwidth<1) cl.mapwidth=1; + if(cl.mapheight<1) cl.mapheight=1; + if(cl.mapwidth>=cl.maxwidth) cl.mapwidth=cl.maxwidth; + if(cl.mapheight>=cl.maxheight) cl.mapheight=cl.maxheight; + ed.note = "Mapsize is now [" + help.String(cl.mapwidth) + "," + help.String(cl.mapheight) + "]"; ed.notedelay=45; } @@ -2402,20 +2630,20 @@ void editorinput(void) } if(key.keymap[SDLK_F10]) { - if(ed.getroomprop(ed.levx, ed.levy)->directmode==1) + if(cl.getroomprop(ed.levx, ed.levy)->directmode==1) { - ed.setroomdirectmode(ed.levx, ed.levy, 0); + cl.setroomdirectmode(ed.levx, ed.levy, 0); ed.note="Direct Mode Disabled"; /* Kludge fix for rainbow BG here... */ - if (ed.getroomprop(ed.levx, ed.levy)->tileset == 2 - && ed.getroomprop(ed.levx, ed.levy)->tilecol == 6) + if (cl.getroomprop(ed.levx, ed.levy)->tileset == 2 + && cl.getroomprop(ed.levx, ed.levy)->tilecol == 6) { - ed.setroomtilecol(ed.levx, ed.levy, 0); + cl.setroomtilecol(ed.levx, ed.levy, 0); } } else { - ed.setroomdirectmode(ed.levx, ed.levy, 1); + cl.setroomdirectmode(ed.levx, ed.levy, 1); ed.note="Direct Mode Enabled"; } graphics.backgrounddrawn=false; @@ -2451,7 +2679,7 @@ void editorinput(void) if(key.keymap[SDLK_e]) { ed.keydelay = 6; - ed.getlin(TEXT_ROOMNAME, "Enter new room name:", const_cast(&(ed.getroomprop(ed.levx, ed.levy)->roomname))); + ed.getlin(TEXT_ROOMNAME, "Enter new room name:", const_cast(&(cl.getroomprop(ed.levx, ed.levy)->roomname))); game.mapheld=true; } if (key.keymap[SDLK_g]) @@ -2637,10 +2865,10 @@ void editorinput(void) ed.changeroom=true; } - if(ed.levx<0) ed.levx+=ed.mapwidth; - if(ed.levx>= ed.mapwidth) ed.levx-=ed.mapwidth; - if(ed.levy<0) ed.levy+=ed.mapheight; - if(ed.levy>=ed.mapheight) ed.levy-=ed.mapheight; + if(ed.levx<0) ed.levx+=cl.mapwidth; + if(ed.levx>= cl.mapwidth) ed.levx-=cl.mapwidth; + if(ed.levy<0) ed.levy+=cl.mapheight; + if(ed.levy>=cl.mapheight) ed.levy-=cl.mapheight; if(key.keymap[SDLK_SPACE]) { ed.spacemod = !ed.spacemod; @@ -2688,18 +2916,18 @@ void editorinput(void) else if(ed.boundarytype==1) { //Enemy bounds - ed.setroomenemyx1(ed.levx, ed.levy, ed.boundx1); - ed.setroomenemyy1(ed.levx, ed.levy, ed.boundy1); - ed.setroomenemyx2(ed.levx, ed.levy, ed.boundx2); - ed.setroomenemyy2(ed.levx, ed.levy, ed.boundy2); + cl.setroomenemyx1(ed.levx, ed.levy, ed.boundx1); + cl.setroomenemyy1(ed.levx, ed.levy, ed.boundy1); + cl.setroomenemyx2(ed.levx, ed.levy, ed.boundx2); + cl.setroomenemyy2(ed.levx, ed.levy, ed.boundy2); } else if(ed.boundarytype==2) { //Platform bounds - ed.setroomplatx1(ed.levx, ed.levy, ed.boundx1); - ed.setroomplaty1(ed.levx, ed.levy, ed.boundy1); - ed.setroomplatx2(ed.levx, ed.levy, ed.boundx2); - ed.setroomplaty2(ed.levx, ed.levy, ed.boundy2); + cl.setroomplatx1(ed.levx, ed.levy, ed.boundx1); + cl.setroomplaty1(ed.levx, ed.levy, ed.boundy1); + cl.setroomplatx2(ed.levx, ed.levy, ed.boundx2); + cl.setroomplaty2(ed.levx, ed.levy, ed.boundy2); } else if(ed.boundarytype==3) { @@ -2759,7 +2987,7 @@ void editorinput(void) { //place tiles //Are we in direct mode? - if(ed.getroomprop(ed.levx, ed.levy)->directmode>=1) + if(cl.getroomprop(ed.levx, ed.levy)->directmode>=1) { if(ed.bmod) { @@ -2974,7 +3202,7 @@ void editorinput(void) { if(ed.drawmode==3) { - if(ed.numtrinkets()<100) + if(cl.numtrinkets()<100) { addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),9); ed.lclickdelay=1; @@ -3057,7 +3285,7 @@ void editorinput(void) } else if(ed.drawmode==15) //Crewmate { - if(ed.numcrewmates()<100) + if(cl.numcrewmates()<100) { addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),15,int(fRandom() * 6)); ed.lclickdelay=1; @@ -3232,33 +3460,33 @@ void editorinput(void) if(key.middlebutton) { - ed.dmtile=ed.gettile(ed.levx, ed.levy, ed.tilex, ed.tiley); + ed.dmtile=cl.gettile(ed.levx, ed.levy, ed.tilex, ed.tiley); } } } } - if(ed.updatetiles && ed.getroomprop(ed.levx, ed.levy)->directmode==0) + if(ed.updatetiles && cl.getroomprop(ed.levx, ed.levy)->directmode==0) { ed.updatetiles=false; //Correctly set the tiles in the current room - switch(ed.getroomprop(ed.levx, ed.levy)->tileset) + switch(cl.getroomprop(ed.levx, ed.levy)->tileset) { case 0: //The Space Station for(int j=0; j<30; j++) { for(int i=0; i<40; i++) { - int temp=ed.gettile(ed.levx, ed.levy, i, j); + int temp=cl.gettile(ed.levx, ed.levy, i, j); if(temp>=3 && temp<80) { //Fix spikes - ed.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j)); + cl.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j)); } else if(temp==2 || temp>=680) { //Fix background - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3269,7 +3497,7 @@ void editorinput(void) else if(temp>0) { //Fix tiles - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3285,16 +3513,16 @@ void editorinput(void) { for(int i=0; i<40; i++) { - int temp=ed.gettile(ed.levx, ed.levy, i, j); + int temp=cl.gettile(ed.levx, ed.levy, i, j); if(temp>=3 && temp<80) { //Fix spikes - ed.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j)); + cl.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j)); } else if(temp==2 || temp>=680) { //Fix background - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3305,7 +3533,7 @@ void editorinput(void) else if(temp>0) { //Fix tiles - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3321,11 +3549,11 @@ void editorinput(void) { for(int i=0; i<40; i++) { - int temp=ed.gettile(ed.levx, ed.levy, i, j); + int temp=cl.gettile(ed.levx, ed.levy, i, j); if(temp>=3 && temp<80) { //Fix spikes - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3333,19 +3561,19 @@ void editorinput(void) ed.labspikedir( i, j, - ed.getroomprop(ed.levx, ed.levy)->tilecol + cl.getroomprop(ed.levx, ed.levy)->tilecol ) ); } else if(temp==2 || temp>=680) { //Fix background - ed.settile(ed.levx, ed.levy, i, j, 713); + cl.settile(ed.levx, ed.levy, i, j, 713); } else if(temp>0) { //Fix tiles - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3361,21 +3589,21 @@ void editorinput(void) { for(int i=0; i<40; i++) { - int temp=ed.gettile(ed.levx, ed.levy, i, j); + int temp=cl.gettile(ed.levx, ed.levy, i, j); if(temp>=3 && temp<80) { //Fix spikes - ed.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j)); + cl.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j)); } else if(temp==2 || temp>=680) { //Fix background - ed.settile(ed.levx, ed.levy, i, j, 713); + cl.settile(ed.levx, ed.levy, i, j, 713); } else if(temp>0) { //Fix tiles - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3391,16 +3619,16 @@ void editorinput(void) { for(int i=0; i<40; i++) { - int temp=ed.gettile(ed.levx, ed.levy, i, j); + int temp=cl.gettile(ed.levx, ed.levy, i, j); if(temp>=3 && temp<80) { //Fix spikes - ed.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j)); + cl.settile(ed.levx, ed.levy, i, j, ed.spikedir(i, j)); } else if(temp==2 || temp>=680) { //Fix background - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3411,7 +3639,7 @@ void editorinput(void) else if(temp>0) { //Fix tiles - ed.settile( + cl.settile( ed.levx, ed.levy, i, @@ -3435,4 +3663,656 @@ void editorinput(void) } } } + +int editorclass::getenemyframe(int t) +{ + switch(t) + { + case 0: + return 78; + break; + case 1: + return 88; + break; + case 2: + return 36; + break; + case 3: + return 164; + break; + case 4: + return 68; + break; + case 5: + return 48; + break; + case 6: + return 176; + break; + case 7: + return 168; + break; + case 8: + return 112; + break; + case 9: + return 114; + break; + default: + return 78; + break; + } +} + +void editorclass::placetilelocal( int x, int y, int t ) +{ + if(x>=0 && y>=0 && x<40 && y<30) + { + cl.settile(levx, levy, x, y, t); + } + updatetiles=true; +} + +int editorclass::base( int x, int y ) +{ + //Return the base tile for the given tileset and colour + const edlevelclass* const room = cl.getroomprop(x, y); + if(room->tileset==0) //Space Station + { + if(room->tilecol>=22) + { + return 483 + ((room->tilecol-22)*3); + } + else if(room->tilecol>=11) + { + return 283 + ((room->tilecol-11)*3); + } + else + { + return 83 + (room->tilecol*3); + } + } + else if(room->tileset==1) //Outside + { + return 480 + (room->tilecol*3); + } + else if(room->tileset==2) //Lab + { + return 280 + (room->tilecol*3); + } + else if(room->tileset==3) //Warp Zone/Intermission + { + return 80 + (room->tilecol*3); + } + else if(room->tileset==4) //SHIP + { + return 101 + (room->tilecol*3); + } + return 0; +} + +int editorclass::backbase( int x, int y ) +{ + //Return the base tile for the background of the given tileset and colour + const edlevelclass* const room = cl.getroomprop(x, y); + if(room->tileset==0) //Space Station + { + //Pick depending on tilecol + switch(room->tilecol) + { + case 0: + case 5: + case 26: + return 680; //Blue + break; + case 3: + case 16: + case 23: + return 683; //Yellow + break; + case 9: + case 12: + case 21: + return 686; //Greeny Cyan + break; + case 4: + case 8: + case 24: + case 28: + case 30: + return 689; //Green + break; + case 20: + case 29: + return 692; //Orange + break; + case 2: + case 6: + case 11: + case 22: + case 27: + return 695; //Red + break; + case 1: + case 10: + case 15: + case 19: + case 31: + return 698; //Pink + break; + case 14: + case 18: + return 701; //Dark Blue + break; + case 7: + case 13: + case 17: + case 25: + return 704; //Cyan + break; + default: + return 680; + break; + } + + } + else if(room->tileset==1) //outside + { + return 680 + (room->tilecol*3); + } + else if(room->tileset==2) //Lab + { + return 0; + } + else if(room->tileset==3) //Warp Zone/Intermission + { + return 120 + (room->tilecol*3); + } + else if(room->tileset==4) //SHIP + { + return 741 + (room->tilecol*3); + } + return 0; +} + +int editorclass::at( int x, int y ) +{ + if(x<0) return at(0,y); + if(y<0) return at(x,0); + if(x>=40) return at(39,y); + if(y>=30) return at(x,29); + + if(x>=0 && y>=0 && x<40 && y<30) + { + return cl.gettile(levx, levy, x, y); + } + return 0; +} + +int editorclass::freewrap( int x, int y ) +{ + if(x<0) return freewrap(x+(cl.mapwidth*40),y); + if(y<0) return freewrap(x,y+(cl.mapheight*30)); + if(x>=(cl.mapwidth*40)) return freewrap(x-(cl.mapwidth*40),y); + if(y>=(cl.mapheight*30)) return freewrap(x,y-(cl.mapheight*30)); + + if(x>=0 && y>=0 && x<(cl.mapwidth*40) && y<(cl.mapheight*30)) + { + if(cl.getabstile(x, y)==0) + { + return 0; + } + else + { + if(cl.getabstile(x, y)>=2 && cl.getabstile(x, y)<80) + { + return 0; + } + if(cl.getabstile(x, y)>=680) + { + return 0; + } + } + } + return 1; +} + +int editorclass::backonlyfree( int x, int y ) +{ + //Returns 1 if tile is a background tile, 0 otherwise + if(x<0) return backonlyfree(0,y); + if(y<0) return backonlyfree(x,0); + if(x>=40) return backonlyfree(39,y); + if(y>=30) return backonlyfree(x,29); + + if(x>=0 && y>=0 && x<40 && y<30) + { + if(cl.gettile(levx, levy, x, y)>=680) + { + return 1; + } + } + return 0; +} + +int editorclass::backfree( int x, int y ) +{ + //Returns 0 if tile is not a block or background tile, 1 otherwise + if(x<0) return backfree(0,y); + if(y<0) return backfree(x,0); + if(x>=40) return backfree(39,y); + if(y>=30) return backfree(x,29); + + if(x>=0 && y>=0 && x<40 && y<30) + { + if(cl.gettile(levx, levy, x, y)==0) + { + return 0; + } + } + return 1; +} + +int editorclass::spikefree( int x, int y ) +{ + //Returns 0 if tile is not a block or spike, 1 otherwise + if(x==-1) return free(0,y); + if(y==-1) return free(x,0); + if(x==40) return free(39,y); + if(y==30) return free(x,29); + + if(x>=0 && y>=0 && x<40 && y<30) + { + if(cl.gettile(levx, levy, x, y)==0) + { + return 0; + } + else + { + if(cl.gettile(levx, levy, x, y)>=680) + { + return 0; + } + } + } + return 1; +} + +int editorclass::free( int x, int y ) +{ + //Returns 0 if tile is not a block, 1 otherwise + if(x==-1) return free(0,y); + if(y==-1) return free(x,0); + if(x==40) return free(39,y); + if(y==30) return free(x,29); + + if(x>=0 && y>=0 && x<40 && y<30) + { + if(cl.gettile(levx, levy, x, y)==0) + { + return 0; + } + else + { + if(cl.gettile(levx, levy, x, y)>=2 && cl.gettile(levx, levy, x, y)<80) + { + return 0; + } + if(cl.gettile(levx, levy, x, y)>=680) + { + return 0; + } + } + } + return 1; +} + +int editorclass::match( int x, int y ) +{ + if(free(x-1,y)==0 && free(x,y-1)==0 && free(x+1,y)==0 && free(x,y+1)==0) return 0; + + if(free(x-1,y)==0 && free(x,y-1)==0) return 10; + if(free(x+1,y)==0 && free(x,y-1)==0) return 11; + if(free(x-1,y)==0 && free(x,y+1)==0) return 12; + if(free(x+1,y)==0 && free(x,y+1)==0) return 13; + + if(free(x,y-1)==0) return 1; + if(free(x-1,y)==0) return 2; + if(free(x,y+1)==0) return 3; + if(free(x+1,y)==0) return 4; + if(free(x-1,y-1)==0) return 5; + if(free(x+1,y-1)==0) return 6; + if(free(x-1,y+1)==0) return 7; + if(free(x+1,y+1)==0) return 8; + + return 0; +} + +int editorclass::outsidematch( int x, int y ) +{ + + if(backonlyfree(x-1,y)==0 && backonlyfree(x+1,y)==0) return 2; + if(backonlyfree(x,y-1)==0 && backonlyfree(x,y+1)==0) return 1; + + return 0; +} + +int editorclass::backmatch( int x, int y ) +{ + //Returns the first position match for a border + // 5 1 6 + // 2 X 4 + // 7 3 8 + if(backfree(x-1,y)==0 && backfree(x,y-1)==0 && backfree(x+1,y)==0 && backfree(x,y+1)==0) return 0; + + if(backfree(x-1,y)==0 && backfree(x,y-1)==0) return 10; + if(backfree(x+1,y)==0 && backfree(x,y-1)==0) return 11; + if(backfree(x-1,y)==0 && backfree(x,y+1)==0) return 12; + if(backfree(x+1,y)==0 && backfree(x,y+1)==0) return 13; + + if(backfree(x,y-1)==0) return 1; + if(backfree(x-1,y)==0) return 2; + if(backfree(x,y+1)==0) return 3; + if(backfree(x+1,y)==0) return 4; + if(backfree(x-1,y-1)==0) return 5; + if(backfree(x+1,y-1)==0) return 6; + if(backfree(x-1,y+1)==0) return 7; + if(backfree(x+1,y+1)==0) return 8; + + return 0; +} + +int editorclass::edgetile( int x, int y ) +{ + switch(match(x,y)) + { + case 14: + return 0; + break; + case 10: + return 80; + break; + case 11: + return 82; + break; + case 12: + return 160; + break; + case 13: + return 162; + break; + case 1: + return 81; + break; + case 2: + return 120; + break; + case 3: + return 161; + break; + case 4: + return 122; + break; + case 5: + return 42; + break; + case 6: + return 41; + break; + case 7: + return 2; + break; + case 8: + return 1; + break; + case 0: + default: + return 0; + break; + } +} + +int editorclass::outsideedgetile( int x, int y ) +{ + switch(outsidematch(x,y)) + { + case 2: + return 0; + break; + case 1: + return 1; + break; + case 0: + default: + return 2; + break; + } +} + + +int editorclass::backedgetile( int x, int y ) +{ + switch(backmatch(x,y)) + { + case 14: + return 0; + break; + case 10: + return 80; + break; + case 11: + return 82; + break; + case 12: + return 160; + break; + case 13: + return 162; + break; + case 1: + return 81; + break; + case 2: + return 120; + break; + case 3: + return 161; + break; + case 4: + return 122; + break; + case 5: + return 42; + break; + case 6: + return 41; + break; + case 7: + return 2; + break; + case 8: + return 1; + break; + case 0: + default: + return 0; + break; + } +} + +int editorclass::labspikedir( int x, int y, int t ) +{ + // a slightly more tricky case + if(free(x,y+1)==1) return 63 + (t*2); + if(free(x,y-1)==1) return 64 + (t*2); + if(free(x-1,y)==1) return 51 + (t*2); + if(free(x+1,y)==1) return 52 + (t*2); + return 63 + (t*2); +} + +int editorclass::spikedir( int x, int y ) +{ + if(free(x,y+1)==1) return 8; + if(free(x,y-1)==1) return 9; + if(free(x-1,y)==1) return 49; + if(free(x+1,y)==1) return 50; + return 8; +} + +void editorclass::switch_tileset(const bool reversed) +{ + const char* tilesets[] = {"Space Station", "Outside", "Lab", "Warp Zone", "Ship"}; + + int tiles = cl.getroomprop(levx, levy)->tileset; + + if (reversed) + { + tiles--; + } + else + { + tiles++; + } + + const int modulus = SDL_arraysize(tilesets); + tiles = (tiles % modulus + modulus) % modulus; + cl.setroomtileset(levx, levy, tiles); + + clamp_tilecol(levx, levy, false); + + char buffer[64]; + SDL_snprintf(buffer, sizeof(buffer), "Now using %s Tileset", tilesets[tiles]); + + note = buffer; + notedelay = 45; + updatetiles = true; +} + +void editorclass::switch_tilecol(const bool reversed) +{ + int tilecol = cl.getroomprop(levx, levy)->tilecol; + + if (reversed) + { + tilecol--; + } + else + { + tilecol++; + } + + cl.setroomtilecol(levx, levy, tilecol); + + clamp_tilecol(levx, levy, true); + + notedelay = 45; + note = "Tileset Colour Changed"; + updatetiles = true; +} + +void editorclass::clamp_tilecol(const int rx, const int ry, const bool wrap) +{ + const edlevelclass* const room = cl.getroomprop(rx, ry); + const int tileset = room->tileset; + int tilecol = room->tilecol; + + int mincol = -1; + int maxcol = 5; + + // Only Space Station allows tileset -1 + if (tileset != 0) + { + mincol = 0; + } + + switch (tileset) + { + case 0: + maxcol = 31; + break; + case 1: + maxcol = 7; + break; + case 3: + maxcol = 6; + break; + case 5: + maxcol = 29; + break; + } + + // If wrap is true, wrap-around, otherwise just cap + if (tilecol > maxcol) + { + tilecol = (wrap ? mincol : maxcol); + } + if (tilecol < mincol) + { + tilecol = (wrap ? maxcol : mincol); + } + + cl.setroomtilecol(rx, ry, tilecol); +} + +void editorclass::switch_enemy(const bool reversed) +{ + const edlevelclass* const room = cl.getroomprop(levx, levy); + + int enemy = room->enemytype; + + if (reversed) + { + enemy--; + } + else + { + enemy++; + } + + const int modulus = 10; + enemy = (enemy % modulus + modulus) % modulus; + cl.setroomenemytype(levx, levy, enemy); + + note = "Enemy Type Changed"; + notedelay = 45; +} + +void editorclass::switch_warpdir(const bool reversed) +{ + static const int modulus = 4; + const edlevelclass* const room = cl.getroomprop(levx, levy); + + int warpdir = room->warpdir; + + if (reversed) + { + --warpdir; + } + else + { + ++warpdir; + } + + warpdir = (warpdir % modulus + modulus) % modulus; + cl.setroomwarpdir(levx, levy, warpdir); + + switch (warpdir) + { + default: + note = "Room warping disabled"; + break; + case 1: + note = "Room warps horizontally"; + break; + case 2: + note = "Room warps vertically"; + break; + case 3: + note = "Room warps in all directions"; + break; + } + + notedelay = 45; +} + #endif /* NO_CUSTOM_LEVELS and NO_EDITOR */ diff --git a/desktop_version/src/Editor.h b/desktop_version/src/Editor.h index c5f68d20..6abbffac 100644 --- a/desktop_version/src/Editor.h +++ b/desktop_version/src/Editor.h @@ -3,6 +3,175 @@ #ifndef EDITOR_H #define EDITOR_H +#include "CustomLevels.h" + +#include +#include +#include + +// Text entry field type +enum textmode +{ + TEXT_NONE, + + // In-editor text fields + TEXT_LOAD, + TEXT_SAVE, + TEXT_ROOMNAME, + TEXT_SCRIPT, + TEXT_ROOMTEXT, + TEXT_GOTOROOM, + LAST_EDTEXT = TEXT_GOTOROOM, + + // Settings-mode text fields + TEXT_TITLE, + TEXT_DESC, + TEXT_WEBSITE, + TEXT_CREATOR, + NUM_TEXTMODES, + + // Text modes with an entity + FIRST_ENTTEXT = TEXT_SCRIPT, + LAST_ENTTEXT = TEXT_ROOMTEXT +}; + +struct GhostInfo +{ + int rx; // game.roomx-100 + int ry; // game.roomy-100 + int x; // .xp + int y; // .yp + int col; // .colour + Uint32 realcol; + int frame; // .drawframe +}; + +class editorclass +{ +public: + editorclass(void); + void reset(void); + + void getlin(const enum textmode mode, const std::string& prompt, std::string* ptr); + + void placetilelocal(int x, int y, 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 match(int x, int y); + int outsidematch(int x, int y); + + int backmatch(int x, int y); + + int edgetile(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 getenemyframe(int t); + + void switch_tileset(const bool reversed); + void switch_tilecol(const bool reversed); + void clamp_tilecol(const int rx, const int ry, const bool wrap); + void switch_enemy(const bool reversed); + void switch_warpdir(const bool reversed); + + int entcol; + Uint32 entcolreal; + + int kludgewarpdir[customlevelclass::numrooms]; + + int notedelay; + int oldnotedelay; + std::string note; + std::string keybuffer; + std::string filename; + std::string loaded_filepath; + + int drawmode; + int tilex, tiley; + int keydelay, lclickdelay; + bool savekey, loadkey; + int levx, levy; + int entframe, entframedelay; + + int scripttexttype; + std::string oldenttext; + + enum textmode textmod; // In text entry + std::string* textptr; // Pointer to text we're changing + std::string textdesc; // Description (for editor mode text fields) + union + { + int desc; // Which description row we're changing + int textent; // Entity ID for text prompt + }; + bool xmod, zmod, cmod, vmod, bmod, hmod, spacemod, warpmod; + 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; + + //Script editor stuff + void removeline(int t); + void insertline(int t); + + bool scripteditmod; + int scripthelppage, scripthelppagedelay; + std::vector sb; + std::string sbscript; + int sbx, sby; + int pagey; + + //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); + void gethooks(void); + bool checkhook(std::string t); + std::vector hooklist; + + int hookmenupage, hookmenu; + + //Direct Mode variables + int dmtile; + int dmtileeditor; + + int returneditoralpha; + int oldreturneditoralpha; + + std::vector ghosts; + int currentghosts; +}; + void editorrender(void); void editorrenderfixed(void); @@ -11,6 +180,10 @@ void editorlogic(void); void editorinput(void); +#ifndef ED_DEFINITION +extern editorclass ed; +#endif + #endif /* EDITOR_H */ #endif /* NO_CUSTOM_LEVELS and NO_EDITOR */ diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index bb94bc24..9af8683a 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -1257,7 +1257,7 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int #if !defined(NO_CUSTOM_LEVELS) // Special case for gray Warp Zone tileset! - const edlevelclass* const room = ed.getroomprop(game.roomx - 100, game.roomy - 100); + const edlevelclass* const room = cl.getroomprop(game.roomx - 100, game.roomy - 100); bool custom_gray = room->tileset == 3 && room->tilecol == 6; #else bool custom_gray = false; diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 07bb811b..6f67f306 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -8,6 +8,7 @@ #include "CustomLevels.h" #include "DeferCallbacks.h" +#include "Editor.h" #include "Entity.h" #include "Enums.h" #include "FileSystemUtils.h" @@ -1836,7 +1837,7 @@ void Game::updatestate(void) #if !defined(NO_CUSTOM_LEVELS) if(map.custommode) { - graphics.createtextboxflipme(" " + help.number(trinkets()) + " out of " + help.number(ed.numtrinkets())+ " ", 50, 135, 174, 174, 174); + graphics.createtextboxflipme(" " + help.number(trinkets()) + " out of " + help.number(cl.numtrinkets())+ " ", 50, 135, 174, 174, 174); graphics.textboxcenterx(); } else @@ -1880,17 +1881,17 @@ void Game::updatestate(void) graphics.addline("You have found a lost crewmate!"); graphics.textboxcenterx(); - if(ed.numcrewmates()-crewmates()==0) + if(cl.numcrewmates()-crewmates()==0) { graphics.createtextboxflipme(" All crewmates rescued! ", 50, 135, 174, 174, 174); } - else if(ed.numcrewmates()-crewmates()==1) + else if(cl.numcrewmates()-crewmates()==1) { - graphics.createtextboxflipme(" " + help.number(ed.numcrewmates()-crewmates())+ " remains ", 50, 135, 174, 174, 174); + graphics.createtextboxflipme(" " + help.number(cl.numcrewmates()-crewmates())+ " remains ", 50, 135, 174, 174, 174); } else { - graphics.createtextboxflipme(" " + help.number(ed.numcrewmates()-crewmates())+ " remain ", 50, 135, 174, 174, 174); + graphics.createtextboxflipme(" " + help.number(cl.numcrewmates()-crewmates())+ " remain ", 50, 135, 174, 174, 174); } graphics.textboxcenterx(); break; @@ -1908,25 +1909,27 @@ void Game::updatestate(void) completestop = false; state = 0; - if(ed.numcrewmates()-crewmates()==0) + if(cl.numcrewmates()-crewmates()==0) { if(map.custommodeforreal) { graphics.fademode = 2; - if(!muted && ed.levmusic>0) music.fadeMusicVolumeIn(3000); - if(ed.levmusic>0) music.fadeout(); + if(!muted && cl.levmusic>0) music.fadeMusicVolumeIn(3000); + if(cl.levmusic>0) music.fadeout(); state=1014; } +#ifndef NO_EDITOR else { returntoeditor(); - if(!muted && ed.levmusic>0) music.fadeMusicVolumeIn(3000); - if(ed.levmusic>0) music.fadeout(); + if(!muted && cl.levmusic>0) music.fadeMusicVolumeIn(3000); + if(cl.levmusic>0) music.fadeout(); } +#endif } else { - if(!muted && ed.levmusic>0) music.fadeMusicVolumeIn(3000); + if(!muted && cl.levmusic>0) music.fadeMusicVolumeIn(3000); } graphics.showcutscenebars = false; break; @@ -1938,10 +1941,10 @@ void Game::updatestate(void) case 1015: #if !defined(NO_CUSTOM_LEVELS) //Update level stats - if(ed.numcrewmates()-crewmates()==0) + if(cl.numcrewmates()-crewmates()==0) { //Finished level - if (trinkets() >= ed.numtrinkets()) + if (trinkets() >= cl.numtrinkets()) { //and got all the trinkets! updatecustomlevelstats(customlevelfilename, 3); @@ -5914,14 +5917,14 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) maxspacing = 15; break; case Menu::levellist: - if(ed.ListOfMetaData.size()==0) + if(cl.ListOfMetaData.size()==0) { option("ok"); menuyoff = -20; } else { - for(int i=0; i<(int) ed.ListOfMetaData.size(); i++) // FIXME: int/size_t! -flibit + for(int i=0; i<(int) cl.ListOfMetaData.size(); i++) // FIXME: int/size_t! -flibit { if(i>=levelpage*8 && i< (levelpage*8)+8) { @@ -5929,7 +5932,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) int tvar=-1; for(size_t j=0; j 8) + if (cl.ListOfMetaData.size() > 8) { - if((size_t) ((levelpage*8)+8) = 14 && tilenum <= 17 && (!mounted - || ed.onewaycol_override)); + || cl.onewaycol_override)); } #endif @@ -884,7 +884,7 @@ void Graphics::drawtile( int x, int y, int t ) #if !defined(NO_CUSTOM_LEVELS) if (shouldrecoloroneway(t, tiles1_mounted)) { - colourTransform thect = {ed.getonewaycol()}; + colourTransform thect = {cl.getonewaycol()}; BlitSurfaceTinted(tiles[t], NULL, backBuffer, &rect, thect); } else @@ -908,7 +908,7 @@ void Graphics::drawtile2( int x, int y, int t ) #if !defined(NO_CUSTOM_LEVELS) if (shouldrecoloroneway(t, tiles2_mounted)) { - colourTransform thect = {ed.getonewaycol()}; + colourTransform thect = {cl.getonewaycol()}; BlitSurfaceTinted(tiles2[t], NULL, backBuffer, &rect, thect); } else @@ -1597,7 +1597,7 @@ void Graphics::drawmenu( int cr, int cg, int cb, bool levelmenu /*= false*/ ) if (levelmenu) { size_t separator; - if (ed.ListOfMetaData.size() > 8) + if (cl.ListOfMetaData.size() > 8) { separator = 3; } @@ -1896,7 +1896,7 @@ void Graphics::drawentity(const int i, const int yoff) #if !defined(NO_CUSTOM_LEVELS) // Special case for gray Warp Zone tileset! - const edlevelclass* const room = ed.getroomprop(game.roomx - 100, game.roomy - 100); + const edlevelclass* const room = cl.getroomprop(game.roomx - 100, game.roomy - 100); const bool custom_gray = room->tileset == 3 && room->tilecol == 6; #else const bool custom_gray = false; @@ -3368,7 +3368,7 @@ void Graphics::drawforetile(int x, int y, int t) #if !defined(NO_CUSTOM_LEVELS) if (shouldrecoloroneway(t, tiles1_mounted)) { - colourTransform thect = {ed.getonewaycol()}; + colourTransform thect = {cl.getonewaycol()}; BlitSurfaceTinted(tiles[t], NULL, foregroundBuffer, &rect, thect); } else @@ -3392,7 +3392,7 @@ void Graphics::drawforetile2(int x, int y, int t) #if !defined(NO_CUSTOM_LEVELS) if (shouldrecoloroneway(t, tiles2_mounted)) { - colourTransform thect = {ed.getonewaycol()}; + colourTransform thect = {cl.getonewaycol()}; BlitSurfaceTinted(tiles2[t], NULL, foregroundBuffer, &rect, thect); } else diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index b9062c7e..fabf0b5e 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -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 diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 67583351..3b6f402a 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -993,10 +993,10 @@ void mapclass::gotoroom(int rx, int ry) { game.roomx = rx; game.roomy = ry; - if (game.roomx < 100) game.roomx = 100 + ed.mapwidth-1; - if (game.roomy < 100) game.roomy = 100 + ed.mapheight-1; - if (game.roomx > 100 + ed.mapwidth-1) game.roomx = 100; - if (game.roomy > 100 + ed.mapheight-1) game.roomy = 100; + if (game.roomx < 100) game.roomx = 100 + cl.mapwidth-1; + if (game.roomy < 100) game.roomy = 100 + cl.mapheight-1; + if (game.roomx > 100 + cl.mapwidth-1) game.roomx = 100; + if (game.roomy > 100 + cl.mapheight-1) game.roomy = 100; } #endif else @@ -1562,8 +1562,8 @@ void mapclass::loadlevel(int rx, int ry) #if !defined(NO_CUSTOM_LEVELS) case 12: //Custom level { - const edlevelclass* const room = ed.getroomprop(rx - 100, ry - 100); - game.customcol = ed.getlevelcol(room->tileset, room->tilecol) + 1; + const edlevelclass* const room = cl.getroomprop(rx - 100, ry - 100); + game.customcol = cl.getlevelcol(room->tileset, room->tilecol) + 1; obj.customplatformtile = game.customcol * 12; switch (room->tileset) @@ -1607,24 +1607,24 @@ void mapclass::loadlevel(int rx, int ry) case 1: warpx = true; background = 3; - graphics.rcol = ed.getwarpbackground(rx - 100, ry - 100); + graphics.rcol = cl.getwarpbackground(rx - 100, ry - 100); break; case 2: warpy = true; background = 4; - graphics.rcol = ed.getwarpbackground(rx - 100, ry - 100); + graphics.rcol = cl.getwarpbackground(rx - 100, ry - 100); break; case 3: warpx = true; warpy = true; background = 5; - graphics.rcol = ed.getwarpbackground(rx - 100, ry - 100); + graphics.rcol = cl.getwarpbackground(rx - 100, ry - 100); break; } roomname = room->roomname; extrarow = 1; - const int* tmap = ed.loadlevel(rx, ry); + const int* tmap = cl.loadlevel(rx, ry); SDL_memcpy(contents, tmap, sizeof(contents)); @@ -1704,7 +1704,7 @@ void mapclass::loadlevel(int rx, int ry) obj.createentity(ex, ey, 3); break; case 9: // Trinkets - obj.createentity(ex, ey, 9, ed.findtrinket(edi)); + obj.createentity(ex, ey, 9, cl.findtrinket(edi)); break; case 10: // Checkpoints obj.createentity(ex, ey, 10, ent.p1, (rx + ry*100) * 20 + tempcheckpoints); @@ -1724,7 +1724,7 @@ void mapclass::loadlevel(int rx, int ry) obj.createentity(ex, ey, 13, ent.p1, ent.p2); break; case 15: // Collectable crewmate - obj.createentity(ex - 4, ey + 1, 55, ed.findcrewmate(edi), ent.p1, ent.p2); + obj.createentity(ex - 4, ey + 1, 55, cl.findcrewmate(edi), ent.p1, ent.p2); break; case 17: // Roomtext! { diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 72d087db..b185b13c 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -2,6 +2,7 @@ #include "Credits.h" #include "CustomLevels.h" +#include "Editor.h" #include "Entity.h" #include "FileSystemUtils.h" #include "GlitchrunnerMode.h" @@ -168,22 +169,22 @@ static void menurender(void) #if !defined(NO_CUSTOM_LEVELS) case Menu::levellist: { - if(ed.ListOfMetaData.size()==0){ + if(cl.ListOfMetaData.size()==0){ graphics.Print( -1, 100, "ERROR: No levels found.", tr, tg, tb, true); } int tmp=game.currentmenuoption+(game.levelpage*8); - if(INBOUNDS_VEC(tmp, ed.ListOfMetaData)){ - const bool nextlastoptions = ed.ListOfMetaData.size() > 8; + if(INBOUNDS_VEC(tmp, cl.ListOfMetaData)){ + const bool nextlastoptions = cl.ListOfMetaData.size() > 8; //Don't show next/previous page or return to menu options here! if(nextlastoptions && game.menuoptions.size() - game.currentmenuoption<=3){ }else{ - graphics.bigprint( -1, 15, ed.ListOfMetaData[tmp].title, tr, tg, tb, true); - graphics.Print( -1, 40, "by " + ed.ListOfMetaData[tmp].creator, tr, tg, tb, true); - graphics.Print( -1, 50, ed.ListOfMetaData[tmp].website, tr, tg, tb, true); - graphics.Print( -1, 70, ed.ListOfMetaData[tmp].Desc1, tr, tg, tb, true); - graphics.Print( -1, 80, ed.ListOfMetaData[tmp].Desc2, tr, tg, tb, true); - graphics.Print( -1, 90, ed.ListOfMetaData[tmp].Desc3, tr, tg, tb, true); + graphics.bigprint( -1, 15, cl.ListOfMetaData[tmp].title, tr, tg, tb, true); + graphics.Print( -1, 40, "by " + cl.ListOfMetaData[tmp].creator, tr, tg, tb, true); + graphics.Print( -1, 50, cl.ListOfMetaData[tmp].website, tr, tg, tb, true); + graphics.Print( -1, 70, cl.ListOfMetaData[tmp].Desc1, tr, tg, tb, true); + graphics.Print( -1, 80, cl.ListOfMetaData[tmp].Desc2, tr, tg, tb, true); + graphics.Print( -1, 90, cl.ListOfMetaData[tmp].Desc3, tr, tg, tb, true); } } break; @@ -1767,7 +1768,7 @@ void gamerender(void) } } -#if !defined(NO_CUSTOM_LEVELS) +#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR) if(map.custommode && !map.custommodeforreal && !game.advancetext){ //Return to level editor int alpha = graphics.lerp(ed.oldreturneditoralpha, ed.returneditoralpha); @@ -2388,7 +2389,7 @@ void maprender(void) } #if !defined(NO_CUSTOM_LEVELS) else if(map.custommode){ - LevelMetaData& meta = ed.ListOfMetaData[game.playcustomlevel]; + LevelMetaData& meta = cl.ListOfMetaData[game.playcustomlevel]; graphics.bigprint( -1, FLIP(45), meta.title, 196, 196, 255 - help.glow, true); graphics.Print( -1, FLIP(70), "by " + meta.creator, 196, 196, 255 - help.glow, true); @@ -2397,7 +2398,7 @@ void maprender(void) graphics.Print( -1, FLIP(110), meta.Desc2, 196, 196, 255 - help.glow, true); graphics.Print( -1, FLIP(120), meta.Desc3, 196, 196, 255 - help.glow, true); - int remaining = ed.numcrewmates() - game.crewmates(); + int remaining = cl.numcrewmates() - game.crewmates(); if(remaining==1){ graphics.Print(1,FLIP(165), help.number(remaining)+ " crewmate remains", 196, 196, 255 - help.glow, true); @@ -2475,7 +2476,7 @@ void maprender(void) if (graphics.flipmode) { graphics.Print(0, 164, "[Trinkets found]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 152, help.number(game.trinkets()) + " out of " + help.number(ed.numtrinkets()), 96,96,96, true); + graphics.Print(0, 152, help.number(game.trinkets()) + " out of " + help.number(cl.numtrinkets()), 96,96,96, true); graphics.Print(0, 114, "[Number of Deaths]", 196, 196, 255 - help.glow, true); graphics.Print(0, 102,help.String(game.deathcounts), 96,96,96, true); @@ -2486,7 +2487,7 @@ void maprender(void) else { graphics.Print(0, 52, "[Trinkets found]", 196, 196, 255 - help.glow, true); - graphics.Print(0, 64, help.number(game.trinkets()) + " out of "+help.number(ed.numtrinkets()), 96,96,96, true); + graphics.Print(0, 64, help.number(game.trinkets()) + " out of "+help.number(cl.numtrinkets()), 96,96,96, true); graphics.Print(0, 102, "[Number of Deaths]", 196, 196, 255 - help.glow, true); graphics.Print(0, 114,help.String(game.deathcounts), 96,96,96, true); diff --git a/desktop_version/src/RenderFixed.cpp b/desktop_version/src/RenderFixed.cpp index 92426907..08d25962 100644 --- a/desktop_version/src/RenderFixed.cpp +++ b/desktop_version/src/RenderFixed.cpp @@ -1,6 +1,7 @@ #include "CustomLevels.h" #include "Game.h" #include "Graphics.h" +#include "Editor.h" #include "Entity.h" #include "Enums.h" #include "Map.h" @@ -118,7 +119,7 @@ void gamerenderfixed(void) map.glitchname = map.getglitchname(game.roomx, game.roomy); } -#ifndef NO_CUSTOM_LEVELS +#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR) ed.oldreturneditoralpha = ed.returneditoralpha; if (map.custommode && !map.custommodeforreal && ed.returneditoralpha > 0) { diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index e885bfee..ea49d2e1 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -5,6 +5,7 @@ #include #include "CustomLevels.h" +#include "Editor.h" #include "Entity.h" #include "Enums.h" #include "Exit.h" @@ -159,9 +160,9 @@ void scriptclass::run(void) int temprx=ss_toi(words[1])-1; int tempry=ss_toi(words[2])-1; const edlevelclass* room; - ed.setroomwarpdir(temprx, tempry, ss_toi(words[3])); + cl.setroomwarpdir(temprx, tempry, ss_toi(words[3])); - room = ed.getroomprop(temprx, tempry); + room = cl.getroomprop(temprx, tempry); //Do we update our own room? if(game.roomx-100==temprx && game.roomy-100==tempry){ @@ -182,21 +183,21 @@ void scriptclass::run(void) }else if(room->warpdir==1){ map.warpx=true; map.background=3; - graphics.rcol = ed.getwarpbackground(temprx,tempry); + graphics.rcol = cl.getwarpbackground(temprx,tempry); }else if(room->warpdir==2){ map.warpy=true; map.background=4; - graphics.rcol = ed.getwarpbackground(temprx,tempry); + graphics.rcol = cl.getwarpbackground(temprx,tempry); }else if(room->warpdir==3){ map.warpx=true; map.warpy=true; map.background = 5; - graphics.rcol = ed.getwarpbackground(temprx,tempry); + graphics.rcol = cl.getwarpbackground(temprx,tempry); } } } if (words[0] == "ifwarp") { - const edlevelclass* const room = ed.getroomprop(ss_toi(words[1])-1, ss_toi(words[2])-1); + const edlevelclass* const room = cl.getroomprop(ss_toi(words[1])-1, ss_toi(words[2])-1); if (room->warpdir == ss_toi(words[3])) { load("custom_"+words[4]); @@ -1704,7 +1705,7 @@ void scriptclass::run(void) #if !defined(NO_CUSTOM_LEVELS) if (map.custommode) { - usethisnum = help.number(ed.numtrinkets()); + usethisnum = help.number(cl.numtrinkets()); } else #endif @@ -2811,10 +2812,12 @@ void scriptclass::startgamemode( int t ) load("intermission_2"); break; -#if !defined(NO_CUSTOM_LEVELS) +#ifndef NO_CUSTOM_LEVELS +# ifndef NO_EDITOR case 20: //Level editor hardreset(); + cl.reset(); ed.reset(); music.fadeout(); map.custommode = true; @@ -2838,11 +2841,11 @@ void scriptclass::startgamemode( int t ) music.fadeout(); hardreset(); //If warpdir() is used during playtesting, we need to set it back after! - for (int j = 0; j < ed.maxheight; j++) + for (int j = 0; j < cl.maxheight; j++) { - for (int i = 0; i < ed.maxwidth; i++) + for (int i = 0; i < cl.maxwidth; i++) { - ed.kludgewarpdir[i+(j*ed.maxwidth)]=ed.level[i+(j*ed.maxwidth)].warpdir; + ed.kludgewarpdir[i+(j*cl.maxwidth)]=cl.level[i+(j*cl.maxwidth)].warpdir; } } game.customstart(); @@ -2862,23 +2865,24 @@ void scriptclass::startgamemode( int t ) map.resetplayer(); map.gotoroom(game.saverx, game.savery); map.initmapdata(); - if(ed.levmusic>0){ - music.play(ed.levmusic); + if(cl.levmusic>0){ + music.play(cl.levmusic); }else{ music.currentsong=-1; } break; +# endif /* NO_EDITOR */ case 22: //play custom level (in game) { //Initilise the level //First up, find the start point - std::string filename = std::string(ed.ListOfMetaData[game.playcustomlevel].filename); - if (!ed.load(filename)) + std::string filename = std::string(cl.ListOfMetaData[game.playcustomlevel].filename); + if (!cl.load(filename)) { gotoerrorloadinglevel(); break; } - ed.findstartpoint(); + cl.findstartpoint(); game.gamestate = GAMEMODE; music.fadeout(); @@ -2900,10 +2904,10 @@ void scriptclass::startgamemode( int t ) map.gotoroom(game.saverx, game.savery); map.initmapdata(); - ed.generatecustomminimap(); + cl.generatecustomminimap(); map.customshowmm=true; - if(ed.levmusic>0){ - music.play(ed.levmusic); + if(cl.levmusic>0){ + music.play(cl.levmusic); }else{ music.currentsong=-1; } @@ -2914,13 +2918,13 @@ void scriptclass::startgamemode( int t ) { //Initilise the level //First up, find the start point - std::string filename = std::string(ed.ListOfMetaData[game.playcustomlevel].filename); - if (!ed.load(filename)) + std::string filename = std::string(cl.ListOfMetaData[game.playcustomlevel].filename); + if (!cl.load(filename)) { gotoerrorloadinglevel(); break; } - ed.findstartpoint(); + cl.findstartpoint(); game.gamestate = GAMEMODE; music.fadeout(); @@ -2929,7 +2933,7 @@ void scriptclass::startgamemode( int t ) map.custommode = true; game.customstart(); - game.customloadquick(ed.ListOfMetaData[game.playcustomlevel].filename); + game.customloadquick(cl.ListOfMetaData[game.playcustomlevel].filename); game.jumpheld = true; game.gravitycontrol = game.savegc; @@ -2944,11 +2948,11 @@ void scriptclass::startgamemode( int t ) map.resetplayer(); map.gotoroom(game.saverx, game.savery); map.initmapdata(); - ed.generatecustomminimap(); + cl.generatecustomminimap(); graphics.fademode = 4; break; } -#endif +#endif /* NO_CUSTOM_LEVELS */ case 100: VVV_exit(0); break; diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index f6b68663..86874547 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -31,9 +31,12 @@ scriptclass script; -#if !defined(NO_CUSTOM_LEVELS) +#ifndef NO_CUSTOM_LEVELS std::vector edentity; +customlevelclass cl; +# ifndef NO_EDITOR editorclass ed; +# endif #endif UtilityClass help; @@ -620,14 +623,14 @@ int main(int argc, char *argv[]) game.menustart = true; LevelMetaData meta; - if (ed.getLevelMetaData(playtestname, meta)) { - ed.ListOfMetaData.clear(); - ed.ListOfMetaData.push_back(meta); + if (cl.getLevelMetaData(playtestname, meta)) { + cl.ListOfMetaData.clear(); + cl.ListOfMetaData.push_back(meta); } else { - ed.loadZips(); - if (ed.getLevelMetaData(playtestname, meta)) { - ed.ListOfMetaData.clear(); - ed.ListOfMetaData.push_back(meta); + cl.loadZips(); + if (cl.getLevelMetaData(playtestname, meta)) { + cl.ListOfMetaData.clear(); + cl.ListOfMetaData.push_back(meta); } else { vlog_error("Level not found"); VVV_exit(1); @@ -635,8 +638,8 @@ int main(int argc, char *argv[]) } game.loadcustomlevelstats(); - 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; if (savefileplaytest) { game.playx = savex; game.playy = savey;