Add some text transition effects.

pull/28/head
sigonasr2 1 year ago
parent 16e0fe4042
commit f88887a149
  1. 5
      Crawler/Menu.h
  2. 2
      Crawler/Version.h
  3. 11
      Crawler/VisualNovel.cpp
  4. 2
      Crawler/VisualNovel.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);

@ -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

@ -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(commandIndex<commands.size()){
@ -235,10 +236,17 @@ void VisualNovel::Draw(){
Menu::DrawThemedWindow(nameDisplayPos,nameDisplayWindowSize);
}
vf2d dialogDisplayPos={24.f,game->GetScreenSize().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.

@ -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::set<std::string>graphicsToLoad;
static safemap<std::string,std::vector<std::unique_ptr<Command>>>storyLevelData;

Loading…
Cancel
Save