diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt index 035b8034..052d9a72 100644 --- a/desktop_version/CMakeLists.txt +++ b/desktop_version/CMakeLists.txt @@ -7,6 +7,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) OPTION(ENABLE_WARNINGS "Enable compilation warnings" ON) OPTION(ENABLE_WERROR "Treat compilation warnings as errors" OFF) +SET(CUSTOM_LEVEL_SUPPORT ENABLED CACHE STRING "Optionally disable playing and/or editing of custom levels") +SET_PROPERTY(CACHE CUSTOM_LEVEL_SUPPORT PROPERTY STRINGS ENABLED NO_EDITOR DISABLED) + # Architecture Flags IF(APPLE) # Wow, Apple is a huge jerk these days huh? @@ -24,7 +27,6 @@ IF(APPLE) ENDIF() PROJECT(VVVVVV) -OPTION(NO_EDITOR "Compile without the level editor" OFF) IF(APPLE) MESSAGE(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}") @@ -96,10 +98,8 @@ SET(VVV_SRC src/SteamNetwork.c src/GOGNetwork.c ) -IF (NOT NO_EDITOR) +IF(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED") LIST(APPEND VVV_SRC src/editor.cpp) -ELSE() - ADD_DEFINITIONS(-DNO_EDITOR) ENDIF() SET(XML_SRC @@ -144,6 +144,12 @@ IF(ENABLE_WARNINGS) /W4 $<$:/WX>>) ENDIF() +IF(CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR") + ADD_DEFINITIONS(-DNO_EDITOR) +ELSEIF(CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED") + ADD_DEFINITIONS(-DNO_CUSTOM_LEVELS -DNO_EDITOR) +ENDIF() + # Library information ADD_LIBRARY(tinyxml-static STATIC ${XML_SRC}) ADD_LIBRARY(physfs-static STATIC ${PFS_SRC} ${PFSP_SRC}) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 96eb5f33..220c1d8c 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -2057,7 +2057,7 @@ void Game::updatestate( Graphics& dwgfx, mapclass& map, entityclass& obj, Utilit dwgfx.textboxcenterx(); } break; -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) case 1013: dwgfx.textboxremove(); hascontrol = true; @@ -6772,7 +6772,7 @@ void Game::createmenu( std::string t ) menuxoff = -16; menuyoff = -10; #elif !defined(MAKEANDPLAY) - #if defined(NO_EDITOR) + #if defined(NO_CUSTOM_LEVELS) menuoptions[0] = "start game"; menuoptionsactive[0] = true; menuoptions[1] = "graphic options"; @@ -6805,9 +6805,10 @@ void Game::createmenu( std::string t ) #endif #endif } -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) else if (t == "playerworlds") { + #if !defined(NO_EDITOR) menuoptions[0] = "play a level"; menuoptionsactive[0] = true; menuoptions[1] = "level editor"; @@ -6819,6 +6820,15 @@ void Game::createmenu( std::string t ) nummenuoptions = 3; menuxoff = -30; menuyoff = -40; + #else + menuoptions[0] = "play a level"; + menuoptionsactive[0] = true; + menuoptions[1] = "back to menu"; + menuoptionsactive[1] = true; + nummenuoptions = 2; + menuxoff = -30; + menuyoff = -40; + #endif } else if (t == "levellist") { diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 5a5de1f6..1914704f 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -274,7 +274,7 @@ void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game, entity } } #elif !defined(MAKEANDPLAY) - #if defined(NO_EDITOR) + #if defined(NO_CUSTOM_LEVELS) if (game.currentmenuoption == 0) { //Play @@ -394,7 +394,7 @@ void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game, entity #endif } #endif - #if !defined(NO_EDITOR) + #if !defined(NO_CUSTOM_LEVELS) else if(game.currentmenuname=="levellist") { if(game.currentmenuoption==game.nummenuoptions-1){ @@ -448,9 +448,10 @@ void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game, entity map.nexttowercolour(); } } - #if !defined(NO_EDITOR) + #if !defined(NO_CUSTOM_LEVELS) else if(game.currentmenuname=="playerworlds") { + #if !defined(NO_EDITOR) if(game.currentmenuoption==0){ music.playef(11, 10); @@ -481,6 +482,21 @@ SDL_assert(0 && "Remove open level dir"); game.createmenu("mainmenu"); map.nexttowercolour(); } + #else + if(game.currentmenuoption==0){ + music.playef(11, 10); + game.levelpage=0; + ed.getDirectoryData(); + game.loadcustomlevelstats(); //Should only load a file if it's needed + game.createmenu("levellist"); + map.nexttowercolour(); + }else if(game.currentmenuoption==1){ + //back + music.playef(11, 10); + game.createmenu("mainmenu"); + map.nexttowercolour(); + } + #endif } #endif else if(game.currentmenuname=="errornostart"){ @@ -1955,7 +1971,7 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, } //Returning to editor mode must always be possible -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) if(map.custommode && !map.custommodeforreal){ if ((game.press_map || key.isDown(27)) && !game.mapheld){ game.mapheld = true; @@ -2402,7 +2418,7 @@ void mapinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111) game.savearea = "The Ship"; - #if !defined(NO_EDITOR) + #if !defined(NO_CUSTOM_LEVELS) if(map.custommodeforreal) { game.customsavequick(ed.ListOfMetaData[game.playcustomlevel].filename, map, obj, music); diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 22371991..a52c9f9f 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -2,7 +2,7 @@ #include "MakeAndPlay.h" -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) extern editorclass ed; #endif @@ -978,7 +978,7 @@ void mapclass::gotoroom(int rx, int ry, Graphics& dwgfx, Game& game, entityclass if (game.roomx == 46 && game.roomy == 54) music.niceplay(15); //Final level remix } } -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) else if (custommode) { game.roomx = rx; @@ -1589,7 +1589,7 @@ void mapclass::loadlevel(int rx, int ry, Graphics& dwgfx, Game& game, entityclas } break; #endif -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) case 12: //Custom level int curlevel=(rx-100)+((ry-100)*ed.maxwidth); game.customcol=ed.getlevelcol(curlevel)+1; diff --git a/desktop_version/src/Map.h b/desktop_version/src/Map.h index 477fa4d3..9f4935b1 100644 --- a/desktop_version/src/Map.h +++ b/desktop_version/src/Map.h @@ -13,7 +13,7 @@ #include "Music.h" #include "editor.h" -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) extern editorclass ed; #endif diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 860227fc..a05978f9 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -92,7 +92,7 @@ void scriptclass::run( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, obj.entities[player].yp += ss_toi(words[2]); scriptdelay = 1; } - #if !defined(NO_EDITOR) + #if !defined(NO_CUSTOM_LEVELS) if (words[0] == "warpdir") { int temprx=ss_toi(words[1])-1; @@ -3158,7 +3158,7 @@ void scriptclass::startgamemode( int t, KeyPoll& key, Graphics& dwgfx, Game& gam load("intermission_2"); break; -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) case 20: //Level editor hardreset(key, dwgfx, game, map, obj, help, music); diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index bf804264..53097053 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -1,4 +1,4 @@ -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) #include "editor.h" @@ -5386,4 +5386,4 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti } } -#endif /* NO_EDITOR */ \ No newline at end of file +#endif /* NO_CUSTOM_LEVELS */ \ No newline at end of file diff --git a/desktop_version/src/editor.h b/desktop_version/src/editor.h index f1dd43a3..6e367c07 100644 --- a/desktop_version/src/editor.h +++ b/desktop_version/src/editor.h @@ -1,4 +1,4 @@ -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) #ifndef EDITOR_H #define EDITOR_H @@ -264,4 +264,4 @@ void editorinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, #endif /* EDITOR_H */ -#endif /* NO_EDITOR */ \ No newline at end of file +#endif /* NO_CUSTOM_LEVELS */ \ No newline at end of file diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 44745656..be4547c6 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -31,7 +31,7 @@ scriptclass script; -#if !defined(NO_EDITOR) +#if !defined(NO_CUSTOM_LEVELS) edentities edentity[3000]; editorclass ed; #endif @@ -369,7 +369,7 @@ int main(int argc, char *argv[]) //Render preloaderrender(graphics, game, help); break; - #if !defined(NO_EDITOR) + #if !defined(NO_CUSTOM_LEVELS) case EDITORMODE: graphics.flipmode = false; //Input @@ -514,7 +514,7 @@ int main(int argc, char *argv[]) } //Mute button - #if !defined(NO_EDITOR) + #if !defined(NO_CUSTOM_LEVELS) bool inEditor = ed.textentry || ed.scripthelppage == 1; #else bool inEditor = false; diff --git a/desktop_version/src/titlerender.cpp b/desktop_version/src/titlerender.cpp index 76621c43..832f516c 100644 --- a/desktop_version/src/titlerender.cpp +++ b/desktop_version/src/titlerender.cpp @@ -92,7 +92,7 @@ void titlerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, U dwgfx.Print( 10, 230, "[MMMMMM Mod Installed]", tr/2, tg/2, tb/2); } } - #if !defined(NO_EDITOR) + #if !defined(NO_CUSTOM_LEVELS) else if (game.currentmenuname == "levellist") { if(ed.ListOfMetaData.size()==0){ @@ -2301,7 +2301,7 @@ void maprender(Graphics& dwgfx, Game& game, mapclass& map, entityclass& obj, Uti dwgfx.Print(0, 105, "Press ACTION to warp to the ship.", 196, 196, 255 - help.glow, true); } - #if !defined(NO_EDITOR) + #if !defined(NO_CUSTOM_LEVELS) else if(map.custommode){ dwgfx.Print(30, 220, "MAP", 64,64,64); dwgfx.Print(103-8, 220, "[CREW]", 196, 196, 255 - help.glow);