From cb8540d7bd579e7b32e634d256510a5fa66f78d1 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 25 Jun 2020 14:41:44 -0700 Subject: [PATCH] Restore janky gamestate-based quit-to-title system in glitchrunnermode This was fixed in 2.3 because one of the side effects of this janky system was being able to accidentally immediately quit to the title if the screen was black during a cutscene, which is something very likely to happen to casual players. Anyway, credits warp uses this gamestate-based system because it utilizes quitting to the title screen doing gamestate 80. From there, you increment the gamestate to gamestate 94 to use the Space Station 2 expo script. --- desktop_version/src/Input.cpp | 49 ++++++++++++++++++++++++++++++---- desktop_version/src/Render.cpp | 5 +++- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 58b9b534..925602d1 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1916,7 +1916,41 @@ void mapinput() game.press_action = false; game.press_map = false; - if (game.fadetomenu) + if (game.glitchrunnermode && graphics.fademode == 1 && graphics.menuoffset == 0) + { + // Deliberate re-addition of the glitchy gamestate-based fadeout! + + // First of all, detecting a black screen means if the glitchy fadeout + // gets interrupted but you're still on a black screen, opening a menu + // immediately quits you to the title. This has the side effect that if + // you accidentally press Esc during a cutscene when it's black, you'll + // immediately be quit and lose all your progress, but that's fair in + // glitchrunner mode. + // Also have to check graphics.menuoffset so this doesn't run every frame + + // Have to close the menu in order to run gamestates. This adds + // about an extra half second of completely black screen. + graphics.resumegamemode = true; + + // Technically this was in <=2.2 as well + obj.removeallblocks(); + + if (game.menupage >= 20 && game.menupage <= 21) + { + game.state = 96; + game.statedelay = 0; + } + else + { + // Produces more glitchiness! Necessary for credits warp to work. + script.hardreset(); + + game.state = 80; + game.statedelay = 0; + } + } + + if (game.fadetomenu && !game.glitchrunnermode) { if (game.fadetomenudelay > 0) { @@ -1929,7 +1963,7 @@ void mapinput() } } - if (game.fadetolab) + if (game.fadetolab && !game.glitchrunnermode) { if (game.fadetolabdelay > 0) { @@ -1942,7 +1976,9 @@ void mapinput() } } - if(graphics.menuoffset==0 && game.fadetomenudelay <= 0 && game.fadetolabdelay <= 0) + if(graphics.menuoffset==0 + && (!game.glitchrunnermode || graphics.fademode == 0) + && game.fadetomenudelay <= 0 && game.fadetolabdelay <= 0) { if (graphics.flipmode) { @@ -2119,8 +2155,11 @@ void mapmenuactionpress() graphics.fademode = 2; music.fadeout(); map.nexttowercolour(); - game.fadetomenu = true; - game.fadetomenudelay = 16; + if (!game.glitchrunnermode) + { + game.fadetomenu = true; + game.fadetomenudelay = 16; + } break; case 20: diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 09cfc15f..e8cd1f43 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -2356,7 +2356,10 @@ void maprender() - if (graphics.fademode == 3 || graphics.fademode == 5) + // We need to draw the black screen above the menu in order to disguise it + // being jankily brought down in glitchrunner mode when exiting to the title + // Otherwise, there's no reason to obscure the menu + if (game.glitchrunnermode || graphics.fademode == 3 || graphics.fademode == 5) { graphics.drawfade(); }