From f88887a149e84750bc04ff1ecbf379db47895327 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 28 Nov 2023 20:34:01 -0600 Subject: [PATCH] Add some text transition effects. --- Crawler/Menu.h | 5 +++-- Crawler/Version.h | 2 +- Crawler/VisualNovel.cpp | 11 ++++++++++- Crawler/VisualNovel.h | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Crawler/Menu.h b/Crawler/Menu.h index d3a20e00..ade0eb4c 100644 --- a/Crawler/Menu.h +++ b/Crawler/Menu.h @@ -107,6 +107,9 @@ public: virtual void Cleanup(); static void DrawThemedWindow(vf2d menuPos,vf2d size,Pixel renderColor=WHITE); + + //X (0-2), Y (0-2) for specific 9-patch tile (tiled version). + static Renderable&GetPatchPart(int x,int y); private: Menu(vf2d pos,vf2d size); static MenuType lastMenuTypeCreated; @@ -126,8 +129,6 @@ private: static void InitializeOverworldMapLevelWindow(); static void InitializeItemLoadoutWindow(); static void InitializeLevelCompleteWindow(); - //X (0-2), Y (0-2) for specific 9-patch tile (tiled version). - static Renderable&GetPatchPart(int x,int y); void KeyboardButtonNavigation(Crawler*game,vf2d menuPos); static void DrawScaledWindowBackground(Crawler*game,vf2d menuPos,vf2d size,Pixel renderColor); diff --git a/Crawler/Version.h b/Crawler/Version.h index ae31bbe5..7b7e0b09 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -35,7 +35,7 @@ SUCH DAMAGE. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 3232 +#define VERSION_BUILD 3259 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/VisualNovel.cpp b/Crawler/VisualNovel.cpp index c8e5d190..a9e01276 100644 --- a/Crawler/VisualNovel.cpp +++ b/Crawler/VisualNovel.cpp @@ -183,6 +183,7 @@ void VisualNovel::Update(){ } locationDisplayTime=std::max(0.f,locationDisplayTime-game->GetElapsedTime()); transitionTime=std::max(0.f,transitionTime-game->GetElapsedTime()); + textScrollTime=std::max(0.f,textScrollTime-game->GetElapsedTime()); } void VisualNovel::ExecuteNextCommand(){ if(commandIndexGetScreenSize().y-48.f}; - Menu::DrawThemedWindow(dialogDisplayPos,{game->GetScreenSize().x-48.f,20.f}); + vf2d dialogDisplaySize={game->GetScreenSize().x-48.f,20.f}; + Menu::DrawThemedWindow(dialogDisplayPos,dialogDisplaySize); vf2d speakerTextSize=game->GetTextSizeProp(speakerDisplayName); game->DrawShadowStringPropDecal(nameDisplayPos-vf2d{10,8}+(nameDisplayWindowSize+vf2d{24,0})/2-speakerTextSize/2,speakerDisplayName); game->DrawShadowStringPropDecal(dialogDisplayPos-vf2d{10,10},activeText); + float yOffset=util::lerp(dialogDisplaySize.y+12,-8,textScrollTime/maxTextScrollTime); + game->DrawPolygonDecal( + Menu::GetPatchPart(1,1).Decal(), + {dialogDisplayPos-vf2d{12,-yOffset},dialogDisplayPos+vf2d{-12,dialogDisplaySize.y+12},dialogDisplayPos+dialogDisplaySize+vf2d{12,12},dialogDisplayPos+vf2d{dialogDisplaySize.x+12,yOffset}}, + {{0,0},{0,1},{1,1},{1,0}}, + {{255,255,255,240},{255,255,255,255},{255,255,255,255},{255,255,255,240}}); } } std::string VisualNovel::GetCharacterImage(std::string name){ @@ -299,6 +307,7 @@ SpeakerCommand::SpeakerCommand(std::string displayedName,std::string speaker) CommandType::CommandType SpeakerCommand::GetType(){return CommandType::SPEAKER;} void DialogCommand::Execute(VisualNovel&vn){ + vn.textScrollTime=VisualNovel::maxTextScrollTime; bool mustDisplay=vn.activeText.length()==0; std::string newText=util::WrapText(game,vn.activeText+(vn.activeText.length()>0?" ":"")+dialog,game->GetScreenSize().x-48,true,{1,1}); if(game->GetTextSizeProp(newText).y>40){//Hit the maximum of 3 lines. diff --git a/Crawler/VisualNovel.h b/Crawler/VisualNovel.h index a5870317..acf320b5 100644 --- a/Crawler/VisualNovel.h +++ b/Crawler/VisualNovel.h @@ -143,6 +143,8 @@ class VisualNovel{ std::string locationDisplayText=""; float locationDisplayTime=0; std::string prevTheme=""; + float textScrollTime=0; + static constexpr float maxTextScrollTime=1.0f; static std::setgraphicsToLoad; static safemap>>storyLevelData;