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