1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Add option to compile without the level editor

This commit is contained in:
Matt Penny 2020-02-09 19:53:01 -05:00 committed by Ethan Lee
parent 3273b4ab55
commit 7d35c5ce4e
11 changed files with 183 additions and 51 deletions

View file

@ -24,6 +24,7 @@ IF(APPLE)
ENDIF() ENDIF()
PROJECT(VVVVVV) PROJECT(VVVVVV)
OPTION(NO_EDITOR "Compile without the level editor" OFF)
IF(APPLE) IF(APPLE)
MESSAGE(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}") MESSAGE(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}")
@ -63,7 +64,6 @@ INCLUDE_DIRECTORIES(
SET(VVV_SRC SET(VVV_SRC
src/BinaryBlob.cpp src/BinaryBlob.cpp
src/BlockV.cpp src/BlockV.cpp
src/editor.cpp
src/Ent.cpp src/Ent.cpp
src/Entity.cpp src/Entity.cpp
src/FileSystemUtils.cpp src/FileSystemUtils.cpp
@ -96,6 +96,12 @@ SET(VVV_SRC
src/SteamNetwork.c src/SteamNetwork.c
src/GOGNetwork.c src/GOGNetwork.c
) )
IF (NOT NO_EDITOR)
LIST(APPEND VVV_SRC src/editor.cpp)
ELSE()
ADD_DEFINITIONS(-DNO_EDITOR)
ENDIF()
SET(XML_SRC SET(XML_SRC
../third_party/tinyxml/tinystr.cpp ../third_party/tinyxml/tinystr.cpp
../third_party/tinyxml/tinyxml.cpp ../third_party/tinyxml/tinyxml.cpp

View file

@ -2057,6 +2057,7 @@ void Game::updatestate( Graphics& dwgfx, mapclass& map, entityclass& obj, Utilit
dwgfx.textboxcenterx(); dwgfx.textboxcenterx();
} }
break; break;
#if !defined(NO_EDITOR)
case 1013: case 1013:
dwgfx.textboxremove(); dwgfx.textboxremove();
hascontrol = true; hascontrol = true;
@ -2087,6 +2088,7 @@ void Game::updatestate( Graphics& dwgfx, mapclass& map, entityclass& obj, Utilit
} }
dwgfx.showcutscenebars = false; dwgfx.showcutscenebars = false;
break; break;
#endif
case 1014: case 1014:
frames--; frames--;
if(dwgfx.fademode == 1) state++; if(dwgfx.fademode == 1) state++;
@ -6770,6 +6772,21 @@ void Game::createmenu( std::string t )
menuxoff = -16; menuxoff = -16;
menuyoff = -10; menuyoff = -10;
#elif !defined(MAKEANDPLAY) #elif !defined(MAKEANDPLAY)
#if defined(NO_EDITOR)
menuoptions[0] = "start game";
menuoptionsactive[0] = true;
menuoptions[1] = "graphic options";
menuoptionsactive[1] = true;
menuoptions[2] = "game options";
menuoptionsactive[2] = true;
menuoptions[3] = "view credits";
menuoptionsactive[3] = true;
menuoptions[4] = "quit game";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -16;
menuyoff = -10;
#else
menuoptions[0] = "start game"; menuoptions[0] = "start game";
menuoptionsactive[0] = true; menuoptionsactive[0] = true;
menuoptions[1] = "player levels"; menuoptions[1] = "player levels";
@ -6786,7 +6803,9 @@ void Game::createmenu( std::string t )
menuxoff = -16; menuxoff = -16;
menuyoff = -10; menuyoff = -10;
#endif #endif
#endif
} }
#if !defined(NO_EDITOR)
else if (t == "playerworlds") else if (t == "playerworlds")
{ {
menuoptions[0] = "play a level"; menuoptions[0] = "play a level";
@ -6801,36 +6820,6 @@ void Game::createmenu( std::string t )
menuxoff = -30; menuxoff = -30;
menuyoff = -40; menuyoff = -40;
} }
else if (t == "quickloadlevel")
{
menuoptions[0] = "continue from save";
menuoptionsactive[0] = true;
menuoptions[1] = "start from beginning";
menuoptionsactive[1] = true;
menuoptions[2] = "back to levels";
menuoptionsactive[2] = true;
nummenuoptions = 3;
menuxoff = -40;
menuyoff = -30;
}
else if (t == "youwannaquit")
{
menuoptions[0] = "yes, quit";
menuoptionsactive[0] = true;
menuoptions[1] = "no, return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 0;
menuyoff = -20;
}
else if (t == "errornostart")
{
menuoptions[0] = "ok";
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = 0;
menuyoff = -20;
}
else if (t == "levellist") else if (t == "levellist")
{ {
if(ed.ListOfMetaData.size()==0) if(ed.ListOfMetaData.size()==0)
@ -6903,6 +6892,37 @@ void Game::createmenu( std::string t )
menuyoff = 70-(tcount*10); menuyoff = 70-(tcount*10);
} }
} }
#endif
else if (t == "quickloadlevel")
{
menuoptions[0] = "continue from save";
menuoptionsactive[0] = true;
menuoptions[1] = "start from beginning";
menuoptionsactive[1] = true;
menuoptions[2] = "back to levels";
menuoptionsactive[2] = true;
nummenuoptions = 3;
menuxoff = -40;
menuyoff = -30;
}
else if (t == "youwannaquit")
{
menuoptions[0] = "yes, quit";
menuoptionsactive[0] = true;
menuoptions[1] = "no, return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 0;
menuyoff = -20;
}
else if (t == "errornostart")
{
menuoptions[0] = "ok";
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = 0;
menuyoff = -20;
}
else if (t == "graphicoptions") else if (t == "graphicoptions")
{ {
menuoptions[0] = "toggle fullscreen"; menuoptions[0] = "toggle fullscreen";

View file

@ -1,4 +1,5 @@
#include "Input.h" #include "Input.h"
#include "Script.h"
#include "MakeAndPlay.h" #include "MakeAndPlay.h"
@ -6,6 +7,8 @@
#include "FileSystemUtils.h" #include "FileSystemUtils.h"
extern scriptclass script;
// Found in titlerender.cpp // Found in titlerender.cpp
void updategraphicsmode(Game& game, Graphics& dwgfx); void updategraphicsmode(Game& game, Graphics& dwgfx);
@ -271,6 +274,62 @@ void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game, entity
} }
} }
#elif !defined(MAKEANDPLAY) #elif !defined(MAKEANDPLAY)
#if defined(NO_EDITOR)
if (game.currentmenuoption == 0)
{
//Play
if (game.telesummary == "" && game.quicksummary == "")
{
//No saves exist, just start a new game
game.mainmenu = 0;
dwgfx.fademode = 2;
}
else
{
//Bring you to the normal playmenu
music.playef(11, 10);
game.createmenu("play");
map.nexttowercolour();
}
}
else if (game.currentmenuoption == 1)
{
//Options
music.playef(11, 10);
game.createmenu("graphicoptions");
map.nexttowercolour();
}
else if (game.currentmenuoption == 2)
{
//Options
music.playef(11, 10);
game.createmenu("options");
//Add extra menu for mmmmmm mod
if(music.mmmmmm){
game.menuoptions[4] = "soundtrack";
game.menuoptionsactive[4] = true;
game.menuoptions[5] = "return";
game.menuoptionsactive[5] = true;
game.nummenuoptions = 6;
}
map.nexttowercolour();
}
else if (game.currentmenuoption == 3)
{
//Credits
music.playef(11, 10);
game.createmenu("credits");
map.nexttowercolour();
}
else if (game.currentmenuoption == 4)
{
//bye!
music.playef(2, 10);
game.mainmenu = 100;
dwgfx.fademode = 2;
}
#else
if (game.currentmenuoption == 0) if (game.currentmenuoption == 0)
{ {
//Play //Play
@ -332,8 +391,10 @@ void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game, entity
game.mainmenu = 100; game.mainmenu = 100;
dwgfx.fademode = 2; dwgfx.fademode = 2;
} }
#endif
} }
#endif #endif
#if !defined(NO_EDITOR)
else if(game.currentmenuname=="levellist") else if(game.currentmenuname=="levellist")
{ {
if(game.currentmenuoption==game.nummenuoptions-1){ if(game.currentmenuoption==game.nummenuoptions-1){
@ -371,6 +432,7 @@ void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game, entity
} }
} }
} }
#endif
else if(game.currentmenuname=="quickloadlevel") else if(game.currentmenuname=="quickloadlevel")
{ {
if(game.currentmenuoption==0){//continue save if(game.currentmenuoption==0){//continue save
@ -386,6 +448,7 @@ void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game, entity
map.nexttowercolour(); map.nexttowercolour();
} }
} }
#if !defined(NO_EDITOR)
else if(game.currentmenuname=="playerworlds") else if(game.currentmenuname=="playerworlds")
{ {
if(game.currentmenuoption==0){ if(game.currentmenuoption==0){
@ -419,6 +482,7 @@ SDL_assert(0 && "Remove open level dir");
map.nexttowercolour(); map.nexttowercolour();
} }
} }
#endif
else if(game.currentmenuname=="errornostart"){ else if(game.currentmenuname=="errornostart"){
music.playef(11, 10); music.playef(11, 10);
game.createmenu("mainmenu"); game.createmenu("mainmenu");
@ -1891,6 +1955,7 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
} }
//Returning to editor mode must always be possible //Returning to editor mode must always be possible
#if !defined(NO_EDITOR)
if(map.custommode && !map.custommodeforreal){ if(map.custommode && !map.custommodeforreal){
if ((game.press_map || key.isDown(27)) && !game.mapheld){ if ((game.press_map || key.isDown(27)) && !game.mapheld){
game.mapheld = true; game.mapheld = true;
@ -1924,6 +1989,7 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
} }
} }
} }
#endif
//Entity type 0 is player controled //Entity type 0 is player controled
for (int ie = 0; ie < obj.nentity; ++ie) for (int ie = 0; ie < obj.nentity; ++ie)
@ -2336,9 +2402,14 @@ 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 (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111) game.savearea = "The Ship";
if(map.custommodeforreal){ #if !defined(NO_EDITOR)
if(map.custommodeforreal)
{
game.customsavequick(ed.ListOfMetaData[game.playcustomlevel].filename, map, obj, music); game.customsavequick(ed.ListOfMetaData[game.playcustomlevel].filename, map, obj, music);
}else{ }
else
#endif
{
game.savequick(map, obj, music); game.savequick(map, obj, music);
} }
} }

View file

@ -1,7 +1,9 @@
#include "Logic.h" #include "Logic.h"
#include "Script.h"
#include "Network.h" #include "Network.h"
extern int temp; extern int temp;
extern scriptclass script;
void titlelogic( Graphics& dwgfx, Game& game, entityclass& obj, UtilityClass& help, musicclass& music, mapclass& map) void titlelogic( Graphics& dwgfx, Game& game, entityclass& obj, UtilityClass& help, musicclass& music, mapclass& map)
{ {

View file

@ -2,7 +2,9 @@
#include "MakeAndPlay.h" #include "MakeAndPlay.h"
extern editorclass ed; #if !defined(NO_EDITOR)
extern editorclass ed;
#endif
mapclass::mapclass() mapclass::mapclass()
{ {
@ -976,6 +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 (game.roomx == 46 && game.roomy == 54) music.niceplay(15); //Final level remix
} }
} }
#if !defined(NO_EDITOR)
else if (custommode) else if (custommode)
{ {
game.roomx = rx; game.roomx = rx;
@ -986,6 +989,7 @@ void mapclass::gotoroom(int rx, int ry, Graphics& dwgfx, Game& game, entityclass
if (game.roomx > 100 + ed.mapwidth-1) game.roomx = 100; if (game.roomx > 100 + ed.mapwidth-1) game.roomx = 100;
if (game.roomy > 100 + ed.mapheight-1) game.roomy = 100; if (game.roomy > 100 + ed.mapheight-1) game.roomy = 100;
} }
#endif
else else
{ {
game.roomx = rx; game.roomx = rx;
@ -1585,6 +1589,7 @@ void mapclass::loadlevel(int rx, int ry, Graphics& dwgfx, Game& game, entityclas
} }
break; break;
#endif #endif
#if !defined(NO_EDITOR)
case 12: //Custom level case 12: //Custom level
int curlevel=(rx-100)+((ry-100)*ed.maxwidth); int curlevel=(rx-100)+((ry-100)*ed.maxwidth);
game.customcol=ed.getlevelcol(curlevel)+1; game.customcol=ed.getlevelcol(curlevel)+1;
@ -1772,6 +1777,7 @@ void mapclass::loadlevel(int rx, int ry, Graphics& dwgfx, Game& game, entityclas
} }
}*/ }*/
break; break;
#endif
} }
//The room's loaded: now we fill out damage blocks based on the tiles. //The room's loaded: now we fill out damage blocks based on the tiles.
if (towermode) if (towermode)

View file

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

View file

@ -92,6 +92,7 @@ void scriptclass::run( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
obj.entities[player].yp += ss_toi(words[2]); obj.entities[player].yp += ss_toi(words[2]);
scriptdelay = 1; scriptdelay = 1;
} }
#if !defined(NO_EDITOR)
if (words[0] == "warpdir") if (words[0] == "warpdir")
{ {
int temprx=ss_toi(words[1])-1; int temprx=ss_toi(words[1])-1;
@ -138,6 +139,7 @@ void scriptclass::run( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
position--; position--;
} }
} }
#endif
if (words[0] == "destroy") if (words[0] == "destroy")
{ {
if(words[1]=="gravitylines"){ if(words[1]=="gravitylines"){
@ -3156,6 +3158,7 @@ void scriptclass::startgamemode( int t, KeyPoll& key, Graphics& dwgfx, Game& gam
load("intermission_2"); load("intermission_2");
break; break;
#if !defined(NO_EDITOR)
case 20: case 20:
//Level editor //Level editor
hardreset(key, dwgfx, game, map, obj, help, music); hardreset(key, dwgfx, game, map, obj, help, music);
@ -3308,6 +3311,7 @@ void scriptclass::startgamemode( int t, KeyPoll& key, Graphics& dwgfx, Game& gam
dwgfx.fademode = 4; dwgfx.fademode = 4;
//load("intro"); //load("intro");
break; break;
#endif
case 100: case 100:
game.savestats(map, dwgfx); game.savestats(map, dwgfx);

View file

@ -1,3 +1,5 @@
#if !defined(NO_EDITOR)
#include "editor.h" #include "editor.h"
#include "Graphics.h" #include "Graphics.h"
@ -5383,3 +5385,5 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti
} }
} }
} }
#endif /* NO_EDITOR */

View file

@ -1,3 +1,5 @@
#if !defined(NO_EDITOR)
#ifndef EDITOR_H #ifndef EDITOR_H
#define EDITOR_H #define EDITOR_H
@ -261,3 +263,5 @@ void editorinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
entityclass& obj, UtilityClass& help, musicclass& music); entityclass& obj, UtilityClass& help, musicclass& music);
#endif /* EDITOR_H */ #endif /* EDITOR_H */
#endif /* NO_EDITOR */

View file

@ -30,9 +30,11 @@
#include <string.h> #include <string.h>
scriptclass script; scriptclass script;
edentities edentity[3000];
#if !defined(NO_EDITOR)
edentities edentity[3000];
editorclass ed; editorclass ed;
#endif
UtilityClass help; UtilityClass help;
Graphics graphics; Graphics graphics;
@ -367,6 +369,7 @@ int main(int argc, char *argv[])
//Render //Render
preloaderrender(graphics, game, help); preloaderrender(graphics, game, help);
break; break;
#if !defined(NO_EDITOR)
case EDITORMODE: case EDITORMODE:
graphics.flipmode = false; graphics.flipmode = false;
//Input //Input
@ -376,6 +379,7 @@ int main(int argc, char *argv[])
////Logic ////Logic
editorlogic(key, graphics, game, obj, music, map, help); editorlogic(key, graphics, game, obj, music, map, help);
break; break;
#endif
case TITLEMODE: case TITLEMODE:
//Input //Input
titleinput(key, graphics, map, game, obj, help, music); titleinput(key, graphics, map, game, obj, help, music);
@ -510,7 +514,12 @@ int main(int argc, char *argv[])
} }
//Mute button //Mute button
if (key.isDown(KEYBOARD_m) && game.mutebutton<=0 && !ed.textentry && ed.scripthelppage != 1) #if !defined(NO_EDITOR)
bool inEditor = ed.textentry || ed.scripthelppage == 1;
#else
bool inEditor = false;
#endif
if (key.isDown(KEYBOARD_m) && game.mutebutton<=0 && !inEditor)
{ {
game.mutebutton = 8; game.mutebutton = 8;
if (game.muted) if (game.muted)

View file

@ -92,6 +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); dwgfx.Print( 10, 230, "[MMMMMM Mod Installed]", tr/2, tg/2, tb/2);
} }
} }
#if !defined(NO_EDITOR)
else if (game.currentmenuname == "levellist") else if (game.currentmenuname == "levellist")
{ {
if(ed.ListOfMetaData.size()==0){ if(ed.ListOfMetaData.size()==0){
@ -112,6 +113,7 @@ void titlerender(Graphics& dwgfx, mapclass& map, Game& game, entityclass& obj, U
} }
} }
} }
#endif
else if (game.currentmenuname == "errornostart") else if (game.currentmenuname == "errornostart")
{ {
dwgfx.Print( -1, 65, "ERROR: This level has", tr, tg, tb, true); dwgfx.Print( -1, 65, "ERROR: This level has", tr, tg, tb, true);
@ -2299,6 +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); dwgfx.Print(0, 105, "Press ACTION to warp to the ship.", 196, 196, 255 - help.glow, true);
} }
#if !defined(NO_EDITOR)
else if(map.custommode){ else if(map.custommode){
dwgfx.Print(30, 220, "MAP", 64,64,64); dwgfx.Print(30, 220, "MAP", 64,64,64);
dwgfx.Print(103-8, 220, "[CREW]", 196, 196, 255 - help.glow); dwgfx.Print(103-8, 220, "[CREW]", 196, 196, 255 - help.glow);
@ -2336,6 +2339,7 @@ void maprender(Graphics& dwgfx, Game& game, mapclass& map, entityclass& obj, Uti
} }
} }
} }
#endif
else else
{ {
dwgfx.Print(30, 220, "MAP", 64,64,64); dwgfx.Print(30, 220, "MAP", 64,64,64);