From ca9f44c3b8b820f162d0baf45bb7fff24fb20338 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 2 May 2020 10:42:39 -0700 Subject: [PATCH] Smoothly interpolate editor notedelay This makes editor notes fade out smoothly. And even though the notedelay only gets decremented by one every editor-frame (the editor runs at 1000/24 FPS fixed-timestep here), it actually gets multiplied by 4, so a floating-point interpolated value would make a difference here. --- desktop_version/src/editor.cpp | 7 +++++-- desktop_version/src/editor.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 539b9fe6..6cd1b7a6 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -305,6 +305,7 @@ void editorclass::reset() saveandquit=false; note=""; notedelay=0; + oldnotedelay=0; roomnamemod=false; textentry=false; savemod=false; @@ -3574,11 +3575,12 @@ void editorrender() } } - if(ed.notedelay>0) + if(ed.notedelay>0 || ed.oldnotedelay>0) { + float alpha = graphics.lerp(ed.oldnotedelay, ed.notedelay); FillRect(graphics.backBuffer, 0,115,320,18, graphics.getRGB(92,92,92)); FillRect(graphics.backBuffer, 0,116,320,16, graphics.getRGB(0,0,0)); - graphics.Print(0,121, ed.note,196-((45-ed.notedelay)*4), 196-((45-ed.notedelay)*4), 196-((45-ed.notedelay)*4), true); + graphics.Print(0,121, ed.note,196-((45.0f-alpha)*4), 196-((45.0f-alpha)*4), 196-((45.0f-alpha)*4), true); } graphics.drawfade(); @@ -3601,6 +3603,7 @@ void editorlogic() ed.entframedelay=8; } + ed.oldnotedelay = ed.notedelay; if(ed.notedelay>0) { ed.notedelay--; diff --git a/desktop_version/src/editor.h b/desktop_version/src/editor.h index 4975bee3..89840063 100644 --- a/desktop_version/src/editor.h +++ b/desktop_version/src/editor.h @@ -164,6 +164,7 @@ class editorclass{ int temp; int notedelay; + int oldnotedelay; std::string note; std::string keybuffer; std::string filename;