Implemented LessRoundBox custom font and FT2 extension font rendering. Enabled Emscripten compatible FT2 extension capabilities. Replaced original TTF PGEX with newline compatible version.
This commit is contained in:
+17
-15
@@ -50,8 +50,10 @@ 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;
|
||||
|
||||
void VisualNovel::Initialize(){
|
||||
font=Font("GFX_Prefix"_S+"dialog_font_size"_s[0]+".ttf","dialog_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);
|
||||
@@ -167,7 +169,7 @@ void VisualNovel::Initialize(){
|
||||
};
|
||||
void VisualNovel::LoadVisualNovel(std::string storyLevelName){
|
||||
novel.storyLevel=storyLevelName;
|
||||
novel.activeText="";
|
||||
novel.activeText=U"";
|
||||
novel.leftCharacters.clear();
|
||||
novel.rightCharacters.clear();
|
||||
novel.backgroundFilename="";
|
||||
@@ -182,7 +184,7 @@ void VisualNovel::LoadVisualNovel(std::string storyLevelName){
|
||||
}
|
||||
void VisualNovel::Update(){
|
||||
if(transitionTime==0&&game->KEY_CONFIRM.Pressed()){
|
||||
activeText="";
|
||||
activeText=U"";
|
||||
novel.ExecuteNextCommand();
|
||||
}
|
||||
locationDisplayTime=std::max(0.f,locationDisplayTime-game->GetElapsedTime());
|
||||
@@ -192,7 +194,7 @@ void VisualNovel::Update(){
|
||||
void VisualNovel::ExecuteNextCommand(){
|
||||
if(commandIndex<commands.size()){
|
||||
commandIndex++;
|
||||
commands[commandIndex-1]->Execute(novel);
|
||||
commands[size_t(commandIndex-1)]->Execute(novel);
|
||||
}else{
|
||||
Unlock::UnlockCurrentMap();
|
||||
Menu::themeSelection=novel.prevTheme;
|
||||
@@ -214,14 +216,14 @@ void VisualNovel::Draw(){
|
||||
}
|
||||
for(int i=leftCharacters.size()-1;i>=0;i--){
|
||||
//Start 72 from the bottom.
|
||||
std::string character=leftCharacters[i];
|
||||
std::u32string character(leftCharacters[i].begin(),leftCharacters[i].end());
|
||||
Pixel fadeColor=WHITE;
|
||||
if(character!=actualSpeakerName)fadeColor={128,128,128,255};
|
||||
game->DrawDecal(vi2d{0,game->GetScreenSize().y}-vi2d{-i*64,72+168},GFX[GetCharacterImage(character)].Decal(),{1,1},fadeColor);
|
||||
}
|
||||
for(int i=rightCharacters.size()-1;i>=0;i--){
|
||||
//Start 72 from the bottom.
|
||||
std::string character=rightCharacters[i];
|
||||
std::u32string character(rightCharacters[i].begin(),rightCharacters[i].end());
|
||||
Pixel fadeColor=WHITE;
|
||||
if(character!=actualSpeakerName)fadeColor={128,128,128,255};
|
||||
float spriteWidth=GFX[GetCharacterImage(character)].Sprite()->width;
|
||||
@@ -242,9 +244,9 @@ 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);
|
||||
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);
|
||||
FontRect speakerTextSize=font.GetStringBounds(speakerDisplayName);
|
||||
game->DrawShadowStringDecal(font,nameDisplayPos-vf2d{10,8}+(nameDisplayWindowSize+vf2d{24,0})/2-speakerTextSize.size/2,speakerDisplayName);
|
||||
game->DrawShadowStringDecal(font,dialogDisplayPos-vf2d{10,10},activeText);
|
||||
float yOffset=util::lerp(dialogDisplaySize.y+12,-8,textScrollTime/maxTextScrollTime);
|
||||
game->DrawPolygonDecal(
|
||||
Menu::GetPatchPart(1,1).Decal(),
|
||||
@@ -253,11 +255,11 @@ void VisualNovel::Draw(){
|
||||
{{255,255,255,240},{255,255,255,255},{255,255,255,255},{255,255,255,240}});
|
||||
}
|
||||
}
|
||||
std::string VisualNovel::GetCharacterImage(std::string name){
|
||||
if(name=="You"){ //Assume we are using female player avatar for now!
|
||||
std::string VisualNovel::GetCharacterImage(std::u32string name){
|
||||
if(name==U"You"){ //Assume we are using female player avatar for now!
|
||||
return "character_image_location"_S+"Player_F.png";
|
||||
}
|
||||
return "character_image_location"_S+name+".png";
|
||||
return "character_image_location"_S+std::string(name.begin(),name.end())+".png";
|
||||
}
|
||||
|
||||
VisualNovel::VisualNovel(){}
|
||||
@@ -300,8 +302,8 @@ RightCommand::RightCommand(std::vector<std::string>characters)
|
||||
CommandType::CommandType RightCommand::GetType(){return CommandType::RIGHT;}
|
||||
|
||||
void SpeakerCommand::Execute(VisualNovel&vn){
|
||||
vn.speakerDisplayName=displayedName;
|
||||
vn.actualSpeakerName=actualSpeakerName;
|
||||
vn.speakerDisplayName.assign(displayedName.begin(),displayedName.end());
|
||||
vn.actualSpeakerName.assign(actualSpeakerName.begin(),actualSpeakerName.end());
|
||||
vn.ExecuteNextCommand();
|
||||
}
|
||||
SpeakerCommand::SpeakerCommand(std::string speaker)
|
||||
@@ -313,8 +315,8 @@ 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.
|
||||
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.
|
||||
if(!mustDisplay){
|
||||
vn.commandIndex--;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user