@ -41,7 +41,7 @@ safemap<std::string,std::vector<std::unique_ptr<Command>>>VisualNovel::storyLeve
void VisualNovel : : Initialize ( ) {
void VisualNovel : : Initialize ( ) {
for ( int chapter = 1 ; chapter < = 6 ; chapter + + ) {
for ( int chapter = 1 ; chapter < = 6 ; chapter + + ) {
std : : string chapterFilename = " story_directory " _S + " Chapter " + std : : to_string ( chapter ) + " .txt " ;
std : : string chapterFilename = " assets/ " + " story_directory " _S + " Chapter " + std : : to_string ( chapter ) + " .txt " ;
std : : ifstream file ( chapterFilename ) ;
std : : ifstream file ( chapterFilename ) ;
if ( ! file ) ERR ( " Failed to open file " < < chapterFilename )
if ( ! file ) ERR ( " Failed to open file " < < chapterFilename )
std : : string line ;
std : : string line ;
@ -71,8 +71,6 @@ void VisualNovel::Initialize(){
line = trim ( line ) ;
line = trim ( line ) ;
if ( line . length ( ) = = 0 ) continue ; //It's a blank line, so we skip it.
if ( line . length ( ) = = 0 ) continue ; //It's a blank line, so we skip it.
auto & data = storyLevelData . at ( currentStory ) ;
switch ( line [ 0 ] ) {
switch ( line [ 0 ] ) {
case ' = ' : { //Initializes a new story section.
case ' = ' : { //Initializes a new story section.
currentStory = line . substr ( 3 , line . find ( ' = ' , 3 ) - 3 ) ;
currentStory = line . substr ( 3 , line . find ( ' = ' , 3 ) - 3 ) ;
@ -80,13 +78,18 @@ void VisualNovel::Initialize(){
storyLevelData [ currentStory ] ;
storyLevelData [ currentStory ] ;
} break ;
} break ;
case ' { ' : { //Start of a command.
case ' { ' : { //Start of a command.
auto & data = storyLevelData . at ( currentStory ) ;
size_t spacePos = line . find ( ' ' ) ;
size_t spacePos = line . find ( ' ' ) ;
if ( spacePos = = std : : string : : npos ) ERR ( " Cannot parse arguments from " < < line < < " : No space found " ) ;
std : : vector < std : : string > arguments ;
if ( spacePos ! = std : : string : : npos ) { //There are arguments to parse...
size_t endingBracePos = line . find ( ' } ' , spacePos + 1 ) ;
size_t endingBracePos = line . find ( ' } ' , spacePos + 1 ) ;
if ( endingBracePos = = std : : string : : npos ) ERR ( " Cannot parse arguments from " < < line < < " : No closing ending brace found " )
if ( endingBracePos = = std : : string : : npos ) ERR ( " Cannot parse arguments from " < < line < < " : No closing ending brace found " )
std : : string args = line . substr ( spacePos + 1 , endingBracePos - ( spacePos + 1 ) ) ;
std : : string args = line . substr ( spacePos + 1 , endingBracePos - ( spacePos + 1 ) ) ;
if ( args . find ( ' ' ) ! = std : : string : : npos | | args . find ( ' } ' ) ! = std : : string : : npos ) ERR ( " Cannot parse args, found invalid tokens in " < < args )
if ( line . size ( ) = = 0 | | line [ 0 ] = = ' ' | | args . find ( ' } ' ) ! = std : : string : : npos ) ERR ( " Cannot parse args, found invalid tokens in " < < args )
std : : vector < std : : string > arguments = ReadCSVArgs ( args ) ;
arguments = ReadCSVArgs ( args ) ;
}
if ( line . find ( " {LOCATION " ) ! = std : : string : : npos ) { //Location command
if ( line . find ( " {LOCATION " ) ! = std : : string : : npos ) { //Location command
if ( arguments . size ( ) ! = 1 ) ERR ( " Arguments size is " < < arguments . size ( ) < < " . Expecting only 1 argument. " )
if ( arguments . size ( ) ! = 1 ) ERR ( " Arguments size is " < < arguments . size ( ) < < " . Expecting only 1 argument. " )
@ -110,6 +113,8 @@ void VisualNovel::Initialize(){
}
}
} break ;
} break ;
case ' [ ' : {
case ' [ ' : {
auto & data = storyLevelData . at ( currentStory ) ;
size_t endingBracePos = line . find ( ' ] ' ) ;
size_t endingBracePos = line . find ( ' ] ' ) ;
if ( endingBracePos = = std : : string : : npos ) ERR ( " Cannot parse arguments from " < < line < < " : No closing ending bracket found " )
if ( endingBracePos = = std : : string : : npos ) ERR ( " Cannot parse arguments from " < < line < < " : No closing ending bracket found " )
std : : string args = line . substr ( 1 , endingBracePos - 1 ) ;
std : : string args = line . substr ( 1 , endingBracePos - 1 ) ;
@ -123,6 +128,8 @@ void VisualNovel::Initialize(){
}
}
} break ;
} break ;
default : {
default : {
auto & data = storyLevelData . at ( currentStory ) ;
data . push_back ( std : : make_unique < DialogCommand > ( line ) ) ;
data . push_back ( std : : make_unique < DialogCommand > ( line ) ) ;
} break ;
} break ;
}
}
@ -143,50 +150,59 @@ void VisualNovel::Draw(){
}
}
VisualNovel : : VisualNovel ( ) { }
Command : : Command ( ) { }
Command : : Command ( ) { }
void LocationCommand : : Execute ( VisualNovel & vn ) {
void LocationCommand : : Execute ( VisualNovel & vn ) {
}
}
LocationCommand : : LocationCommand ( std : : string location ) {
LocationCommand : : LocationCommand ( std : : string location )
: location ( location ) {
}
}
void BackgroundCommand : : Execute ( VisualNovel & vn ) {
void BackgroundCommand : : Execute ( VisualNovel & vn ) {
}
}
BackgroundCommand : : BackgroundCommand ( std : : string backgroundFilename ) {
BackgroundCommand : : BackgroundCommand ( std : : string backgroundFilename )
: backgroundFilename ( backgroundFilename ) {
}
}
void LeftCommand : : Execute ( VisualNovel & vn ) {
void LeftCommand : : Execute ( VisualNovel & vn ) {
}
}
LeftCommand : : LeftCommand ( std : : vector < std : : string > characters ) {
LeftCommand : : LeftCommand ( std : : vector < std : : string > characters )
: characters ( characters ) {
}
}
void RightCommand : : Execute ( VisualNovel & vn ) {
void RightCommand : : Execute ( VisualNovel & vn ) {
}
}
RightCommand : : RightCommand ( std : : vector < std : : string > characters ) {
RightCommand : : RightCommand ( std : : vector < std : : string > characters )
: characters ( characters ) {
}
}
void SpeakerCommand : : Execute ( VisualNovel & vn ) {
void SpeakerCommand : : Execute ( VisualNovel & vn ) {
}
}
SpeakerCommand : : SpeakerCommand ( std : : string speaker ) {
SpeakerCommand : : SpeakerCommand ( std : : string 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 ) {
}
}
void DialogCommand : : Execute ( VisualNovel & vn ) {
void DialogCommand : : Execute ( VisualNovel & vn ) {
}
}
DialogCommand : : DialogCommand ( std : : string dialog ) {
DialogCommand : : DialogCommand ( std : : string dialog )
: dialog ( dialog ) {
}
}