|
|
|
@ -50,10 +50,12 @@ INCLUDE_GFX |
|
|
|
|
VisualNovel VisualNovel::novel; |
|
|
|
|
safemap<std::string,std::vector<std::unique_ptr<Command>>>VisualNovel::storyLevelData; |
|
|
|
|
std::set<std::string>VisualNovel::graphicsToLoad; |
|
|
|
|
Font VisualNovel::font; |
|
|
|
|
Font VisualNovel::font,VisualNovel::narratorFont,VisualNovel::locationFont; |
|
|
|
|
|
|
|
|
|
void VisualNovel::Initialize(){ |
|
|
|
|
font=Font("GFX_Prefix"_S+"dialog_font_size"_s[0]+".ttf","dialog_font_size"_i[1]); |
|
|
|
|
narratorFont=Font("GFX_Prefix"_S+"narrator_font_size"_s[0]+".ttf","narrator_font_size"_i[1]); |
|
|
|
|
locationFont=Font("GFX_Prefix"_S+"location_font_size"_s[0]+".ttf","location_font_size"_i[1]); |
|
|
|
|
for(int chapter=1;chapter<=6;chapter++){ |
|
|
|
|
std::string chapterFilename="assets/"+"story_directory"_S+"Chapter "+std::to_string(chapter)+".txt"; |
|
|
|
|
std::ifstream file(chapterFilename); |
|
|
|
@ -172,8 +174,9 @@ void VisualNovel::LoadVisualNovel(std::string storyLevelName){ |
|
|
|
|
novel.activeText=U""; |
|
|
|
|
novel.leftCharacters.clear(); |
|
|
|
|
novel.rightCharacters.clear(); |
|
|
|
|
novel.backgroundFilename=""; |
|
|
|
|
novel.backgroundFilename=novel.prevBackgroundFilename=""; |
|
|
|
|
novel.commands.clear(); |
|
|
|
|
novel.commandIndex=0; |
|
|
|
|
for(std::unique_ptr<Command>&command:storyLevelData.at(storyLevelName)){ |
|
|
|
|
novel.commands.push_back(command.get()); |
|
|
|
|
} |
|
|
|
@ -230,10 +233,13 @@ void VisualNovel::Draw(){ |
|
|
|
|
game->DrawRotatedDecal(game->GetScreenSize()-vi2d{i*64+int(spriteWidth)/2,72+168},GFX[GetCharacterImage(character)].Decal(),0,vf2d{spriteWidth/2,0.f},{-1,1},fadeColor); |
|
|
|
|
} |
|
|
|
|
if(locationDisplayTime>0){ |
|
|
|
|
vi2d textSize=game->GetTextSizeProp(locationDisplayText)*2; |
|
|
|
|
game->FillRectDecal(game->GetScreenSize()/2-textSize/2-vi2d{4,4},textSize+vi2d{8,8},BLACK); |
|
|
|
|
game->DrawRectDecal(game->GetScreenSize()/2-textSize/2-vi2d{4,4},textSize+vi2d{8,8},WHITE); |
|
|
|
|
game->DrawShadowStringPropDecal(game->GetScreenSize()/2-textSize/2,locationDisplayText,WHITE,VERY_DARK_BLUE,{2.f,2.f}); |
|
|
|
|
std::u32string locationStr=std::u32string(locationDisplayText.begin(),locationDisplayText.end()); |
|
|
|
|
FontRect textSize=locationFont.GetStringBounds(locationStr); |
|
|
|
|
textSize.offset*=2; |
|
|
|
|
textSize.size*=2; |
|
|
|
|
game->FillRectDecal(game->GetScreenSize()/2-textSize.size/2-vi2d{4,4}+textSize.offset/2,textSize.size+vi2d{8,8},BLACK); |
|
|
|
|
game->DrawRectDecal(game->GetScreenSize()/2-textSize.size/2-vi2d{4,4}+textSize.offset/2,textSize.size+vi2d{8,8},WHITE); |
|
|
|
|
game->DrawShadowStringDecal(locationFont,game->GetScreenSize()/2-textSize.size/2+textSize.offset/2,locationStr,WHITE,VERY_DARK_BLUE,{2.f,2.f}); |
|
|
|
|
} |
|
|
|
|
if(activeText.length()>0){ |
|
|
|
|
vf2d nameDisplayPos={24.f,game->GetScreenSize().y-60.f}; |
|
|
|
@ -244,9 +250,14 @@ void VisualNovel::Draw(){ |
|
|
|
|
vf2d dialogDisplayPos={24.f,game->GetScreenSize().y-48.f}; |
|
|
|
|
vf2d dialogDisplaySize={game->GetScreenSize().x-48.f,20.f}; |
|
|
|
|
Menu::DrawThemedWindow(dialogDisplayPos,dialogDisplaySize); |
|
|
|
|
FontRect dialogTextSize=font.GetStringBounds(activeText); |
|
|
|
|
FontRect speakerTextSize=font.GetStringBounds(speakerDisplayName); |
|
|
|
|
game->DrawStringDecal(font,nameDisplayPos-vf2d{10,8}+(nameDisplayWindowSize+vf2d{24,0})/2-speakerTextSize.size/2,speakerDisplayName); |
|
|
|
|
game->DrawStringDecal(font,dialogDisplayPos-vf2d{10,10},activeText); |
|
|
|
|
if(speakerDisplayName.length()>0){ |
|
|
|
|
game->DrawShadowStringDecal(font,nameDisplayPos-vf2d{10,7}+(nameDisplayWindowSize+vf2d{24,0})/2-speakerTextSize.size/2+speakerTextSize.offset/2,speakerDisplayName); |
|
|
|
|
game->DrawShadowStringDecal(font,dialogDisplayPos-vf2d{10,6}+dialogTextSize.offset,activeText); |
|
|
|
|
}else{ |
|
|
|
|
game->DrawDropShadowStringDecal(narratorFont,dialogDisplayPos-vf2d{10,6}+dialogTextSize.offset,activeText); |
|
|
|
|
} |
|
|
|
|
float yOffset=util::lerp(dialogDisplaySize.y+12,-8,textScrollTime/maxTextScrollTime); |
|
|
|
|
game->DrawPolygonDecal( |
|
|
|
|
Menu::GetPatchPart(1,1).Decal(), |
|
|
|
@ -315,10 +326,14 @@ CommandType::CommandType SpeakerCommand::GetType(){return CommandType::SPEAKER;} |
|
|
|
|
void DialogCommand::Execute(VisualNovel&vn){ |
|
|
|
|
vn.textScrollTime=VisualNovel::maxTextScrollTime; |
|
|
|
|
bool mustDisplay=vn.activeText.length()==0; |
|
|
|
|
std::u32string newText=util::WrapText(game,vn.activeText+(vn.activeText.length()>0?U" ":U"")+std::u32string(dialog.begin(),dialog.end()),game->GetScreenSize().x-48,VisualNovel::font,{1,1}); |
|
|
|
|
if(VisualNovel::font.GetStringBounds(newText).size.y>40){//Hit the maximum of 3 lines.
|
|
|
|
|
Font*displayFont=&VisualNovel::font; |
|
|
|
|
if(vn.actualSpeakerName.length()==0)displayFont=&VisualNovel::narratorFont; |
|
|
|
|
std::u32string newText=util::WrapText(game,vn.activeText+(vn.activeText.length()>0?U" ":U"")+std::u32string(dialog.begin(),dialog.end()),game->GetScreenSize().x-24,*displayFont,{1,1}); |
|
|
|
|
if(VisualNovel::font.GetStringBounds(newText).size.y>48){//Hit the maximum of 3 lines.
|
|
|
|
|
if(!mustDisplay){ |
|
|
|
|
vn.commandIndex--; |
|
|
|
|
}else{ |
|
|
|
|
vn.activeText=newText; |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
vn.activeText=newText; |
|
|
|
|