diff --git a/Crawler/Version.h b/Crawler/Version.h index a89c6e83..97ffe9fc 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 3212 +#define VERSION_BUILD 3225 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/VisualNovel.cpp b/Crawler/VisualNovel.cpp index a2e246c4..5ea17963 100644 --- a/Crawler/VisualNovel.cpp +++ b/Crawler/VisualNovel.cpp @@ -38,6 +38,7 @@ SUCH DAMAGE. #include "DEFINES.h" #include "Unlock.h" #include "Menu.h" +#include "util.h" INCLUDE_game INCLUDE_GFX @@ -177,6 +178,7 @@ void VisualNovel::LoadVisualNovel(std::string storyLevelName){ } void VisualNovel::Update(){ if(game->KEY_CONFIRM.Pressed()){ + activeText=""; novel.ExecuteNextCommand(); } locationDisplayTime=std::max(0.f,locationDisplayTime-game->GetElapsedTime()); @@ -204,8 +206,14 @@ void VisualNovel::Draw(){ game->DrawShadowStringPropDecal(game->GetScreenSize()/2-textSize/2,locationDisplayText,WHITE,VERY_DARK_BLUE,{2.f,2.f}); } if(activeText.length()>0){ - Menu::DrawThemedWindow({24.f,game->GetScreenSize().y-60.f},{48.f,-12.f}); - Menu::DrawThemedWindow({24.f,game->GetScreenSize().y-48.f},{game->GetScreenSize().x-48.f,20.f}); + vf2d nameDisplayPos={24.f,game->GetScreenSize().y-60.f}; + vf2d nameDisplayWindowSize={48.f,-12.f}; + Menu::DrawThemedWindow(nameDisplayPos,nameDisplayWindowSize); + vf2d dialogDisplayPos={24.f,game->GetScreenSize().y-48.f}; + Menu::DrawThemedWindow(dialogDisplayPos,{game->GetScreenSize().x-48.f,20.f}); + 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); } } @@ -220,6 +228,7 @@ void LocationCommand::Execute(VisualNovel&vn){ } LocationCommand::LocationCommand(std::string location) :location(location){} +CommandType::CommandType LocationCommand::GetType(){return CommandType::LOCATION;} void BackgroundCommand::Execute(VisualNovel&vn){ vn.backgroundFilename=backgroundFilename; @@ -227,6 +236,7 @@ void BackgroundCommand::Execute(VisualNovel&vn){ } BackgroundCommand::BackgroundCommand(std::string backgroundFilename) :backgroundFilename(backgroundFilename){} +CommandType::CommandType BackgroundCommand::GetType(){return CommandType::BACKGROUND;} void LeftCommand::Execute(VisualNovel&vn){ vn.leftCharacters=characters; @@ -234,6 +244,7 @@ void LeftCommand::Execute(VisualNovel&vn){ } LeftCommand::LeftCommand(std::vectorcharacters) :characters(characters){} +CommandType::CommandType LeftCommand::GetType(){return CommandType::LEFT;} void RightCommand::Execute(VisualNovel&vn){ vn.rightCharacters=characters; @@ -241,6 +252,7 @@ void RightCommand::Execute(VisualNovel&vn){ } RightCommand::RightCommand(std::vectorcharacters) :characters(characters){} +CommandType::CommandType RightCommand::GetType(){return CommandType::RIGHT;} void SpeakerCommand::Execute(VisualNovel&vn){ vn.speakerDisplayName=displayedName; @@ -251,12 +263,29 @@ SpeakerCommand::SpeakerCommand(std::string speaker) :displayedName(speaker),actualSpeakerName(speaker){} SpeakerCommand::SpeakerCommand(std::string displayedName,std::string speaker) :displayedName(displayedName),actualSpeakerName(speaker){} +CommandType::CommandType SpeakerCommand::GetType(){return CommandType::SPEAKER;} void DialogCommand::Execute(VisualNovel&vn){ - vn.activeText=dialog; + 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. + if(!mustDisplay){ + vn.commandIndex--; + } + }else{ + vn.activeText=newText; + if(vn.commandIndexGetType(); + if(nextCommandType==CommandType::DIALOG){ //Only add to dialog when the next command type is a dialog as well. + vn.ExecuteNextCommand(); + } + } + } } DialogCommand::DialogCommand(std::string dialog) :dialog(dialog){} +CommandType::CommandType DialogCommand::GetType(){return CommandType::DIALOG;} void PauseCommand::Execute(VisualNovel&vn){} -PauseCommand::PauseCommand(){} \ No newline at end of file +PauseCommand::PauseCommand(){} +CommandType::CommandType PauseCommand::GetType(){return CommandType::PAUSE;} \ No newline at end of file diff --git a/Crawler/VisualNovel.h b/Crawler/VisualNovel.h index 866b98d6..b5b90277 100644 --- a/Crawler/VisualNovel.h +++ b/Crawler/VisualNovel.h @@ -39,17 +39,32 @@ SUCH DAMAGE. class VisualNovel; +namespace CommandType{ + enum CommandType{ + PAUSE, + DIALOG, + SPEAKER, + BACKGROUND, + RIGHT, + LEFT, + LOCATION + }; +} + class Command{ friend class VisualNovel; virtual void Execute(VisualNovel&vn)=0; protected: Command(); +public: + virtual CommandType::CommandType GetType()=0; }; class PauseCommand final:public Command{ public: void Execute(VisualNovel&vn)override; PauseCommand(); + CommandType::CommandType GetType()final override; }; class DialogCommand final:public Command{ @@ -57,6 +72,7 @@ class DialogCommand final:public Command{ public: void Execute(VisualNovel&vn)override; DialogCommand(std::string dialog); + CommandType::CommandType GetType()final override; }; class SpeakerCommand final:public Command{ @@ -66,6 +82,7 @@ public: void Execute(VisualNovel&vn)override; SpeakerCommand(std::string speaker); SpeakerCommand(std::string displayedName,std::string speaker); + CommandType::CommandType GetType()final override; }; class BackgroundCommand final:public Command{ @@ -73,6 +90,7 @@ class BackgroundCommand final:public Command{ public: void Execute(VisualNovel&vn)override; BackgroundCommand(std::string backgroundFilename); + CommandType::CommandType GetType()final override; }; class RightCommand final:public Command{ @@ -80,6 +98,7 @@ class RightCommand final:public Command{ public: void Execute(VisualNovel&vn)override; RightCommand(std::vectorcharacters); + CommandType::CommandType GetType()final override; }; class LeftCommand final:public Command{ @@ -87,6 +106,7 @@ class LeftCommand final:public Command{ public: void Execute(VisualNovel&vn)override; LeftCommand(std::vectorcharacters); + CommandType::CommandType GetType()final override; }; class LocationCommand final:public Command{ @@ -94,6 +114,7 @@ class LocationCommand final:public Command{ public: void Execute(VisualNovel&vn)override; LocationCommand(std::string location); + CommandType::CommandType GetType()final override; }; class VisualNovel{ @@ -114,6 +135,8 @@ class VisualNovel{ std::vectorleftCharacters; std::vectorrightCharacters; std::string backgroundFilename; + std::string prevBackgroundFilename; + float transitionTime=0; std::vectorcommands; int commandIndex=0; std::string locationDisplayText=""; diff --git a/Crawler/assets/backgrounds/rest.png b/Crawler/assets/backgrounds/rest.png new file mode 100644 index 00000000..5b695b3b Binary files /dev/null and b/Crawler/assets/backgrounds/rest.png differ diff --git a/Crawler/assets/config/story/Chapter 1.txt b/Crawler/assets/config/story/Chapter 1.txt index 1aed8d86..6e1c415a 100644 --- a/Crawler/assets/config/story/Chapter 1.txt +++ b/Crawler/assets/config/story/Chapter 1.txt @@ -106,7 +106,7 @@ What shall I do. I can't return to the Kingdom without it. [You] First you should rest. Once you are able to walk on your own again, we can think about a solution for your lost object. - +{BACKGROUND sea.png} [] You set up a tent and a campfire a little outside of the main camp where the tragedy happened and help Sherman to move over.