|
|
@ -43,6 +43,7 @@ All rights reserved. |
|
|
|
#include "Unlock.h" |
|
|
|
#include "Unlock.h" |
|
|
|
#include "Menu.h" |
|
|
|
#include "Menu.h" |
|
|
|
#include "util.h" |
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
#include "SaveFile.h" |
|
|
|
|
|
|
|
|
|
|
|
INCLUDE_game |
|
|
|
INCLUDE_game |
|
|
|
INCLUDE_GFX |
|
|
|
INCLUDE_GFX |
|
|
@ -180,7 +181,7 @@ void VisualNovel::LoadVisualNovel(std::string storyLevelName){ |
|
|
|
for(std::unique_ptr<Command>&command:storyLevelData.at(storyLevelName)){ |
|
|
|
for(std::unique_ptr<Command>&command:storyLevelData.at(storyLevelName)){ |
|
|
|
novel.commands.push_back(command.get()); |
|
|
|
novel.commands.push_back(command.get()); |
|
|
|
} |
|
|
|
} |
|
|
|
GameState::ChangeState(States::STORY,0.5f); |
|
|
|
GameState::ChangeState(States::STORY,0.5f,10U); |
|
|
|
novel.ExecuteNextCommand(); |
|
|
|
novel.ExecuteNextCommand(); |
|
|
|
novel.prevTheme=Menu::GetCurrentTheme().GetThemeName(); |
|
|
|
novel.prevTheme=Menu::GetCurrentTheme().GetThemeName(); |
|
|
|
Menu::themeSelection="Purple"; |
|
|
|
Menu::themeSelection="Purple"; |
|
|
@ -247,18 +248,29 @@ void VisualNovel::Draw(){ |
|
|
|
vf2d nameDisplayPos={24.f,game->GetScreenSize().y-60.f}; |
|
|
|
vf2d nameDisplayPos={24.f,game->GetScreenSize().y-60.f}; |
|
|
|
vf2d nameDisplayWindowSize={48.f,-12.f}; |
|
|
|
vf2d nameDisplayWindowSize={48.f,-12.f}; |
|
|
|
if(speakerDisplayName.length()>0){ |
|
|
|
if(speakerDisplayName.length()>0){ |
|
|
|
|
|
|
|
if(std::find_if(rightCharacters.begin(),rightCharacters.end(),[&](std::string&rightCharacter){ |
|
|
|
|
|
|
|
return rightCharacter==std::string(speakerDisplayName.begin(),speakerDisplayName.end()); |
|
|
|
|
|
|
|
})!=rightCharacters.end()){ //Found the character on the right side, so the box should also be drawn on the right side.
|
|
|
|
|
|
|
|
nameDisplayPos={game->ScreenWidth()-24.f-nameDisplayWindowSize.x,game->GetScreenSize().y-60.f}; |
|
|
|
|
|
|
|
} |
|
|
|
Menu::DrawThemedWindow(nameDisplayPos,nameDisplayWindowSize); |
|
|
|
Menu::DrawThemedWindow(nameDisplayPos,nameDisplayWindowSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
std::u32string displayedName=speakerDisplayName; |
|
|
|
|
|
|
|
std::u32string saveFileName; |
|
|
|
|
|
|
|
saveFileName.assign(SaveFile::GetSaveFileName().begin(),SaveFile::GetSaveFileName().end()); |
|
|
|
|
|
|
|
if(displayedName==U"You"){ |
|
|
|
|
|
|
|
displayedName=saveFileName; |
|
|
|
|
|
|
|
} |
|
|
|
vf2d dialogDisplayPos={24.f,game->GetScreenSize().y-48.f}; |
|
|
|
vf2d dialogDisplayPos={24.f,game->GetScreenSize().y-48.f}; |
|
|
|
vf2d dialogDisplaySize={game->GetScreenSize().x-48.f,20.f}; |
|
|
|
vf2d dialogDisplaySize={game->GetScreenSize().x-48.f,20.f}; |
|
|
|
Menu::DrawThemedWindow(dialogDisplayPos,dialogDisplaySize); |
|
|
|
Menu::DrawThemedWindow(dialogDisplayPos,dialogDisplaySize); |
|
|
|
FontRect dialogTextSize=font.GetStringBounds(activeText); |
|
|
|
FontRect dialogTextSize=font.GetStringBounds(activeText); |
|
|
|
FontRect speakerTextSize=font.GetStringBounds(speakerDisplayName); |
|
|
|
FontRect speakerTextSize=font.GetStringBounds(displayedName); |
|
|
|
if(speakerDisplayName.length()>0){ |
|
|
|
if(displayedName.length()>0){ |
|
|
|
game->DrawShadowStringDecal(font,nameDisplayPos-vf2d{10,7}+(nameDisplayWindowSize+vf2d{24,0})/2-speakerTextSize.size/2+speakerTextSize.offset/2,speakerDisplayName); |
|
|
|
game->DrawShadowStringDecal(font,nameDisplayPos-vf2d{10,7}+(nameDisplayWindowSize+vf2d{24,0})/2-speakerTextSize.size/2+speakerTextSize.offset/2,displayedName); |
|
|
|
game->DrawShadowStringDecal(font,dialogDisplayPos-vf2d{10,6}+dialogTextSize.offset,activeText); |
|
|
|
game->DrawShadowStringDecal(font,dialogDisplayPos-vf2d{10,6}+dialogTextSize.offset,activeText); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
game->DrawDropShadowStringDecal(narratorFont,dialogDisplayPos-vf2d{10,6}+dialogTextSize.offset,activeText); |
|
|
|
game->DrawDropShadowStringDecal(narratorFont,dialogDisplayPos-vf2d{10,6}+dialogTextSize.offset,activeText,{190,190,220}); |
|
|
|
} |
|
|
|
} |
|
|
|
float yOffset=util::lerp(dialogDisplaySize.y+12,-8,textScrollTime/maxTextScrollTime); |
|
|
|
float yOffset=util::lerp(dialogDisplaySize.y+12,-8,textScrollTime/maxTextScrollTime); |
|
|
|
game->DrawPolygonDecal( |
|
|
|
game->DrawPolygonDecal( |
|
|
@ -317,6 +329,9 @@ RightCommand::RightCommand(std::vector<std::string>characters) |
|
|
|
CommandType::CommandType RightCommand::GetType(){return CommandType::RIGHT;} |
|
|
|
CommandType::CommandType RightCommand::GetType(){return CommandType::RIGHT;} |
|
|
|
|
|
|
|
|
|
|
|
void SpeakerCommand::Execute(VisualNovel&vn){ |
|
|
|
void SpeakerCommand::Execute(VisualNovel&vn){ |
|
|
|
|
|
|
|
if(displayedName=="You"){ |
|
|
|
|
|
|
|
vn.speakerDisplayName.assign(SaveFile::GetSaveFileName().begin(),SaveFile::GetSaveFileName().end()); |
|
|
|
|
|
|
|
} |
|
|
|
vn.speakerDisplayName.assign(displayedName.begin(),displayedName.end()); |
|
|
|
vn.speakerDisplayName.assign(displayedName.begin(),displayedName.end()); |
|
|
|
vn.actualSpeakerName.assign(actualSpeakerName.begin(),actualSpeakerName.end()); |
|
|
|
vn.actualSpeakerName.assign(actualSpeakerName.begin(),actualSpeakerName.end()); |
|
|
|
vn.ExecuteNextCommand(); |
|
|
|
vn.ExecuteNextCommand(); |
|
|
@ -329,11 +344,23 @@ CommandType::CommandType SpeakerCommand::GetType(){return CommandType::SPEAKER;} |
|
|
|
|
|
|
|
|
|
|
|
void DialogCommand::Execute(VisualNovel&vn){ |
|
|
|
void DialogCommand::Execute(VisualNovel&vn){ |
|
|
|
if(dialog.size()<=0)return; |
|
|
|
if(dialog.size()<=0)return; |
|
|
|
|
|
|
|
#pragma region Process "[You]" in Dialog. |
|
|
|
|
|
|
|
std::u32string _dialog; |
|
|
|
|
|
|
|
_dialog.assign(dialog.begin(),dialog.end()); |
|
|
|
|
|
|
|
std::u32string processedDialog=_dialog; |
|
|
|
|
|
|
|
size_t playerNameReplacePos=processedDialog.find(U"[You]"); |
|
|
|
|
|
|
|
while(playerNameReplacePos!=std::u32string::npos){ |
|
|
|
|
|
|
|
std::u32string saveFileName; |
|
|
|
|
|
|
|
saveFileName.assign(SaveFile::GetSaveFileName().begin(),SaveFile::GetSaveFileName().end()); |
|
|
|
|
|
|
|
processedDialog=processedDialog.replace(playerNameReplacePos,U"[You]"s.length(),saveFileName); |
|
|
|
|
|
|
|
playerNameReplacePos=processedDialog.find(U"[You]"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#pragma endregion |
|
|
|
vn.textScrollTime=VisualNovel::maxTextScrollTime; |
|
|
|
vn.textScrollTime=VisualNovel::maxTextScrollTime; |
|
|
|
bool mustDisplay=vn.activeText.length()==0; |
|
|
|
bool mustDisplay=vn.activeText.length()==0; |
|
|
|
Font*displayFont=&VisualNovel::font; |
|
|
|
Font*displayFont=&VisualNovel::font; |
|
|
|
if(vn.actualSpeakerName.length()==0)displayFont=&VisualNovel::narratorFont; |
|
|
|
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}); |
|
|
|
std::u32string newText=util::WrapText(game,vn.activeText+(vn.activeText.length()>0?U" ":U"")+std::u32string(processedDialog.begin(),processedDialog.end()),game->GetScreenSize().x-24,*displayFont,{1,1}); |
|
|
|
if(VisualNovel::font.GetStringBounds(newText).size.y>48){//Hit the maximum of 3 lines.
|
|
|
|
if(VisualNovel::font.GetStringBounds(newText).size.y>48){//Hit the maximum of 3 lines.
|
|
|
|
if(!mustDisplay){ |
|
|
|
if(!mustDisplay){ |
|
|
|
vn.commandIndex--; |
|
|
|
vn.commandIndex--; |
|
|
|