From 9256b4da56563b084a355efa11113f02850c8bbd Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 2 May 2020 10:49:41 -0700 Subject: [PATCH] Smoothly interpolate "[Press ENTER to return to editor]" fadeout Now it'll be real smooth at 60 FPS. Or above. Or whichever one you want above 30. --- desktop_version/src/Logic.cpp | 1 + desktop_version/src/Render.cpp | 3 ++- desktop_version/src/editor.cpp | 2 ++ desktop_version/src/editor.h | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 2cdef85b..a876fe17 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -1666,6 +1666,7 @@ void gamelogic() } #if !defined(NO_CUSTOM_LEVELS) + ed.oldreturneditoralpha = ed.returneditoralpha; if (map.custommode && !map.custommodeforreal && ed.returneditoralpha > 0) { ed.returneditoralpha -= 15; diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 82bf1301..1badcfb7 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1389,7 +1389,8 @@ void gamerender() #if !defined(NO_CUSTOM_LEVELS) if(map.custommode && !map.custommodeforreal && !game.advancetext){ //Return to level editor - graphics.bprintalpha(5, 5, "[Press ENTER to return to editor]", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), ed.returneditoralpha, false); + int alpha = graphics.lerp(ed.oldreturneditoralpha, ed.returneditoralpha); + graphics.bprintalpha(5, 5, "[Press ENTER to return to editor]", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), alpha, false); } #endif diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 6cd1b7a6..280239ae 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -407,6 +407,7 @@ void editorclass::reset() script.customscripts.clear(); returneditoralpha = 0; + oldreturneditoralpha = 0; ghosts.clear(); currentghosts = 0; @@ -4636,6 +4637,7 @@ void editorinput() music.haltdasmusik(); graphics.backgrounddrawn=false; ed.returneditoralpha = 1000; // Let's start it higher than 255 since it gets clamped + ed.oldreturneditoralpha = 1000; script.startgamemode(21); } } diff --git a/desktop_version/src/editor.h b/desktop_version/src/editor.h index 89840063..c7820d99 100644 --- a/desktop_version/src/editor.h +++ b/desktop_version/src/editor.h @@ -237,6 +237,7 @@ class editorclass{ int dmtileeditor; int returneditoralpha; + int oldreturneditoralpha; std::vector ghosts; int currentghosts;