1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-20 11:38:30 +02:00

Add option to allow custom levels when the editor is disabled

This commit is contained in:
Matt Penny 2020-02-09 21:21:19 -05:00 committed by Ethan Lee
parent 7d35c5ce4e
commit 1b00d12600
10 changed files with 59 additions and 27 deletions

View File

@ -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 $<$<BOOL:${ENABLE_WERROR}>:/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})

View File

@ -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")
{

View File

@ -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);

View File

@ -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;

View File

@ -13,7 +13,7 @@
#include "Music.h"
#include "editor.h"
#if !defined(NO_EDITOR)
#if !defined(NO_CUSTOM_LEVELS)
extern editorclass ed;
#endif

View File

@ -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);

View File

@ -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 */
#endif /* NO_CUSTOM_LEVELS */

View File

@ -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 */
#endif /* NO_CUSTOM_LEVELS */

View File

@ -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;

View File

@ -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);