Abstract returning-to-editor code to Game::returntoeditor()

This way I can easily move it around without moving around a bunch of
lines of code.
This commit is contained in:
Misa 2020-05-09 12:35:17 -07:00 committed by Ethan Lee
parent 915100b370
commit 51971fa84c
3 changed files with 32 additions and 21 deletions

View File

@ -7381,3 +7381,30 @@ void Game::returntolab()
music.play(11);
}
#if !defined(NO_CUSTOM_LEVELS)
void Game::returntoeditor()
{
game.gamestate = EDITORMODE;
graphics.textboxremove();
game.hascontrol = true;
game.advancetext = false;
game.completestop = false;
game.state = 0;
graphics.showcutscenebars = false;
graphics.fademode = 0;
graphics.backgrounddrawn=false;
music.fadeout();
//If warpdir() is used during playtesting, we need to set it back after!
for (int j = 0; j < ed.maxheight; j++)
{
for (int i = 0; i < ed.maxwidth; i++)
{
ed.level[i+(j*ed.maxwidth)].warpdir=ed.kludgewarpdir[i+(j*ed.maxwidth)];
}
}
map.scrolldir = 0;
}
#endif

View File

@ -385,6 +385,10 @@ public:
int fadetomenudelay;
bool fadetolab;
int fadetolabdelay;
#if !defined(NO_CUSTOM_LEVELS)
void returntoeditor();
#endif
};
extern Game game;

View File

@ -1537,27 +1537,7 @@ void gameinput()
game.activeactivity = -1;
}
}else{
game.gamestate = EDITORMODE;
graphics.textboxremove();
game.hascontrol = true;
game.advancetext = false;
game.completestop = false;
game.state = 0;
graphics.showcutscenebars = false;
graphics.fademode = 0;
graphics.backgrounddrawn=false;
music.fadeout();
//If warpdir() is used during playtesting, we need to set it back after!
for (int j = 0; j < ed.maxheight; j++)
{
for (int i = 0; i < ed.maxwidth; i++)
{
ed.level[i+(j*ed.maxwidth)].warpdir=ed.kludgewarpdir[i+(j*ed.maxwidth)];
}
}
map.scrolldir = 0;
game.returntoeditor();
}
}
}