Text navigation for visual novel added.
This commit is contained in:
parent
a7f13e0077
commit
88bafaec3f
@ -35,7 +35,7 @@ SUCH DAMAGE.
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 1
|
#define VERSION_PATCH 1
|
||||||
#define VERSION_BUILD 3212
|
#define VERSION_BUILD 3225
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -38,6 +38,7 @@ SUCH DAMAGE.
|
|||||||
#include "DEFINES.h"
|
#include "DEFINES.h"
|
||||||
#include "Unlock.h"
|
#include "Unlock.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
INCLUDE_game
|
INCLUDE_game
|
||||||
INCLUDE_GFX
|
INCLUDE_GFX
|
||||||
@ -177,6 +178,7 @@ void VisualNovel::LoadVisualNovel(std::string storyLevelName){
|
|||||||
}
|
}
|
||||||
void VisualNovel::Update(){
|
void VisualNovel::Update(){
|
||||||
if(game->KEY_CONFIRM.Pressed()){
|
if(game->KEY_CONFIRM.Pressed()){
|
||||||
|
activeText="";
|
||||||
novel.ExecuteNextCommand();
|
novel.ExecuteNextCommand();
|
||||||
}
|
}
|
||||||
locationDisplayTime=std::max(0.f,locationDisplayTime-game->GetElapsedTime());
|
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});
|
game->DrawShadowStringPropDecal(game->GetScreenSize()/2-textSize/2,locationDisplayText,WHITE,VERY_DARK_BLUE,{2.f,2.f});
|
||||||
}
|
}
|
||||||
if(activeText.length()>0){
|
if(activeText.length()>0){
|
||||||
Menu::DrawThemedWindow({24.f,game->GetScreenSize().y-60.f},{48.f,-12.f});
|
vf2d nameDisplayPos={24.f,game->GetScreenSize().y-60.f};
|
||||||
Menu::DrawThemedWindow({24.f,game->GetScreenSize().y-48.f},{game->GetScreenSize().x-48.f,20.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)
|
LocationCommand::LocationCommand(std::string location)
|
||||||
:location(location){}
|
:location(location){}
|
||||||
|
CommandType::CommandType LocationCommand::GetType(){return CommandType::LOCATION;}
|
||||||
|
|
||||||
void BackgroundCommand::Execute(VisualNovel&vn){
|
void BackgroundCommand::Execute(VisualNovel&vn){
|
||||||
vn.backgroundFilename=backgroundFilename;
|
vn.backgroundFilename=backgroundFilename;
|
||||||
@ -227,6 +236,7 @@ void BackgroundCommand::Execute(VisualNovel&vn){
|
|||||||
}
|
}
|
||||||
BackgroundCommand::BackgroundCommand(std::string backgroundFilename)
|
BackgroundCommand::BackgroundCommand(std::string backgroundFilename)
|
||||||
:backgroundFilename(backgroundFilename){}
|
:backgroundFilename(backgroundFilename){}
|
||||||
|
CommandType::CommandType BackgroundCommand::GetType(){return CommandType::BACKGROUND;}
|
||||||
|
|
||||||
void LeftCommand::Execute(VisualNovel&vn){
|
void LeftCommand::Execute(VisualNovel&vn){
|
||||||
vn.leftCharacters=characters;
|
vn.leftCharacters=characters;
|
||||||
@ -234,6 +244,7 @@ void LeftCommand::Execute(VisualNovel&vn){
|
|||||||
}
|
}
|
||||||
LeftCommand::LeftCommand(std::vector<std::string>characters)
|
LeftCommand::LeftCommand(std::vector<std::string>characters)
|
||||||
:characters(characters){}
|
:characters(characters){}
|
||||||
|
CommandType::CommandType LeftCommand::GetType(){return CommandType::LEFT;}
|
||||||
|
|
||||||
void RightCommand::Execute(VisualNovel&vn){
|
void RightCommand::Execute(VisualNovel&vn){
|
||||||
vn.rightCharacters=characters;
|
vn.rightCharacters=characters;
|
||||||
@ -241,6 +252,7 @@ void RightCommand::Execute(VisualNovel&vn){
|
|||||||
}
|
}
|
||||||
RightCommand::RightCommand(std::vector<std::string>characters)
|
RightCommand::RightCommand(std::vector<std::string>characters)
|
||||||
:characters(characters){}
|
:characters(characters){}
|
||||||
|
CommandType::CommandType RightCommand::GetType(){return CommandType::RIGHT;}
|
||||||
|
|
||||||
void SpeakerCommand::Execute(VisualNovel&vn){
|
void SpeakerCommand::Execute(VisualNovel&vn){
|
||||||
vn.speakerDisplayName=displayedName;
|
vn.speakerDisplayName=displayedName;
|
||||||
@ -251,12 +263,29 @@ SpeakerCommand::SpeakerCommand(std::string speaker)
|
|||||||
:displayedName(speaker),actualSpeakerName(speaker){}
|
:displayedName(speaker),actualSpeakerName(speaker){}
|
||||||
SpeakerCommand::SpeakerCommand(std::string displayedName,std::string speaker)
|
SpeakerCommand::SpeakerCommand(std::string displayedName,std::string speaker)
|
||||||
:displayedName(displayedName),actualSpeakerName(speaker){}
|
:displayedName(displayedName),actualSpeakerName(speaker){}
|
||||||
|
CommandType::CommandType SpeakerCommand::GetType(){return CommandType::SPEAKER;}
|
||||||
|
|
||||||
void DialogCommand::Execute(VisualNovel&vn){
|
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.commandIndex<vn.commands.size()){
|
||||||
|
CommandType::CommandType nextCommandType=vn.commands[vn.commandIndex]->GetType();
|
||||||
|
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)
|
DialogCommand::DialogCommand(std::string dialog)
|
||||||
:dialog(dialog){}
|
:dialog(dialog){}
|
||||||
|
CommandType::CommandType DialogCommand::GetType(){return CommandType::DIALOG;}
|
||||||
|
|
||||||
void PauseCommand::Execute(VisualNovel&vn){}
|
void PauseCommand::Execute(VisualNovel&vn){}
|
||||||
PauseCommand::PauseCommand(){}
|
PauseCommand::PauseCommand(){}
|
||||||
|
CommandType::CommandType PauseCommand::GetType(){return CommandType::PAUSE;}
|
@ -39,17 +39,32 @@ SUCH DAMAGE.
|
|||||||
|
|
||||||
class VisualNovel;
|
class VisualNovel;
|
||||||
|
|
||||||
|
namespace CommandType{
|
||||||
|
enum CommandType{
|
||||||
|
PAUSE,
|
||||||
|
DIALOG,
|
||||||
|
SPEAKER,
|
||||||
|
BACKGROUND,
|
||||||
|
RIGHT,
|
||||||
|
LEFT,
|
||||||
|
LOCATION
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class Command{
|
class Command{
|
||||||
friend class VisualNovel;
|
friend class VisualNovel;
|
||||||
virtual void Execute(VisualNovel&vn)=0;
|
virtual void Execute(VisualNovel&vn)=0;
|
||||||
protected:
|
protected:
|
||||||
Command();
|
Command();
|
||||||
|
public:
|
||||||
|
virtual CommandType::CommandType GetType()=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PauseCommand final:public Command{
|
class PauseCommand final:public Command{
|
||||||
public:
|
public:
|
||||||
void Execute(VisualNovel&vn)override;
|
void Execute(VisualNovel&vn)override;
|
||||||
PauseCommand();
|
PauseCommand();
|
||||||
|
CommandType::CommandType GetType()final override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DialogCommand final:public Command{
|
class DialogCommand final:public Command{
|
||||||
@ -57,6 +72,7 @@ class DialogCommand final:public Command{
|
|||||||
public:
|
public:
|
||||||
void Execute(VisualNovel&vn)override;
|
void Execute(VisualNovel&vn)override;
|
||||||
DialogCommand(std::string dialog);
|
DialogCommand(std::string dialog);
|
||||||
|
CommandType::CommandType GetType()final override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpeakerCommand final:public Command{
|
class SpeakerCommand final:public Command{
|
||||||
@ -66,6 +82,7 @@ public:
|
|||||||
void Execute(VisualNovel&vn)override;
|
void Execute(VisualNovel&vn)override;
|
||||||
SpeakerCommand(std::string speaker);
|
SpeakerCommand(std::string speaker);
|
||||||
SpeakerCommand(std::string displayedName,std::string speaker);
|
SpeakerCommand(std::string displayedName,std::string speaker);
|
||||||
|
CommandType::CommandType GetType()final override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BackgroundCommand final:public Command{
|
class BackgroundCommand final:public Command{
|
||||||
@ -73,6 +90,7 @@ class BackgroundCommand final:public Command{
|
|||||||
public:
|
public:
|
||||||
void Execute(VisualNovel&vn)override;
|
void Execute(VisualNovel&vn)override;
|
||||||
BackgroundCommand(std::string backgroundFilename);
|
BackgroundCommand(std::string backgroundFilename);
|
||||||
|
CommandType::CommandType GetType()final override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RightCommand final:public Command{
|
class RightCommand final:public Command{
|
||||||
@ -80,6 +98,7 @@ class RightCommand final:public Command{
|
|||||||
public:
|
public:
|
||||||
void Execute(VisualNovel&vn)override;
|
void Execute(VisualNovel&vn)override;
|
||||||
RightCommand(std::vector<std::string>characters);
|
RightCommand(std::vector<std::string>characters);
|
||||||
|
CommandType::CommandType GetType()final override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LeftCommand final:public Command{
|
class LeftCommand final:public Command{
|
||||||
@ -87,6 +106,7 @@ class LeftCommand final:public Command{
|
|||||||
public:
|
public:
|
||||||
void Execute(VisualNovel&vn)override;
|
void Execute(VisualNovel&vn)override;
|
||||||
LeftCommand(std::vector<std::string>characters);
|
LeftCommand(std::vector<std::string>characters);
|
||||||
|
CommandType::CommandType GetType()final override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LocationCommand final:public Command{
|
class LocationCommand final:public Command{
|
||||||
@ -94,6 +114,7 @@ class LocationCommand final:public Command{
|
|||||||
public:
|
public:
|
||||||
void Execute(VisualNovel&vn)override;
|
void Execute(VisualNovel&vn)override;
|
||||||
LocationCommand(std::string location);
|
LocationCommand(std::string location);
|
||||||
|
CommandType::CommandType GetType()final override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VisualNovel{
|
class VisualNovel{
|
||||||
@ -114,6 +135,8 @@ class VisualNovel{
|
|||||||
std::vector<std::string>leftCharacters;
|
std::vector<std::string>leftCharacters;
|
||||||
std::vector<std::string>rightCharacters;
|
std::vector<std::string>rightCharacters;
|
||||||
std::string backgroundFilename;
|
std::string backgroundFilename;
|
||||||
|
std::string prevBackgroundFilename;
|
||||||
|
float transitionTime=0;
|
||||||
std::vector<Command*>commands;
|
std::vector<Command*>commands;
|
||||||
int commandIndex=0;
|
int commandIndex=0;
|
||||||
std::string locationDisplayText="";
|
std::string locationDisplayText="";
|
||||||
|
BIN
Crawler/assets/backgrounds/rest.png
Normal file
BIN
Crawler/assets/backgrounds/rest.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
@ -106,7 +106,7 @@ What shall I do. I can't return to the Kingdom without it.
|
|||||||
[You]
|
[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.
|
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.
|
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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user