Corrected missing header dependencies in safemap. Story file parser implementation and command data storage works proper.
This commit is contained in:
parent
90d465fd7b
commit
67bc955f83
@ -329,6 +329,7 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="State_MainMenu.h" />
|
||||
<ClInclude Include="State_OverworldMap.h" />
|
||||
<ClInclude Include="State_Story.h" />
|
||||
<ClInclude Include="VisualNovel.h" />
|
||||
<ClInclude Include="Test.h" />
|
||||
<ClInclude Include="Theme.h" />
|
||||
@ -391,6 +392,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="State_MainMenu.cpp" />
|
||||
<ClCompile Include="State_OverworldMap.cpp" />
|
||||
<ClCompile Include="State_Story.cpp" />
|
||||
<ClCompile Include="Test.cpp" />
|
||||
<ClCompile Include="TestMenu.cpp" />
|
||||
<ClCompile Include="TestSubMenu.cpp" />
|
||||
|
@ -270,6 +270,9 @@
|
||||
<ClInclude Include="VisualNovel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="State_Story.h">
|
||||
<Filter>Header Files\State</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Player.cpp">
|
||||
@ -452,6 +455,9 @@
|
||||
<ClCompile Include="VisualNovel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="State_Story.cpp">
|
||||
<Filter>Source Files\Game States</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
@ -35,7 +35,7 @@ SUCH DAMAGE.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 3160
|
||||
#define VERSION_BUILD 3172
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -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){
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,12 @@ SUCH DAMAGE.
|
||||
|
||||
class VisualNovel;
|
||||
|
||||
class Command{
|
||||
virtual void Execute(VisualNovel&vn)=0;
|
||||
protected:
|
||||
Command();
|
||||
};
|
||||
|
||||
class PauseCommand final:public Command{
|
||||
public:
|
||||
void Execute(VisualNovel&vn)override;
|
||||
@ -88,12 +94,6 @@ public:
|
||||
LocationCommand(std::string location);
|
||||
};
|
||||
|
||||
class Command{
|
||||
virtual void Execute(VisualNovel&vn)=0;
|
||||
protected:
|
||||
Command();
|
||||
};
|
||||
|
||||
class VisualNovel{
|
||||
std::string storyLevel;
|
||||
std::string activeText;
|
||||
@ -101,13 +101,13 @@ class VisualNovel{
|
||||
std::vector<std::string>rightCharacters;
|
||||
std::string backgroundFilename;
|
||||
std::vector<Command*>commands;
|
||||
int commandIndex;
|
||||
int commandIndex=0;
|
||||
|
||||
static safemap<std::string,std::vector<std::unique_ptr<Command>>>storyLevelData;
|
||||
|
||||
static VisualNovel novel;
|
||||
VisualNovel();
|
||||
public:
|
||||
VisualNovel()=delete;
|
||||
VisualNovel(VisualNovel&)=delete;
|
||||
VisualNovel(VisualNovel&&)=delete;
|
||||
static void Initialize();
|
||||
|
@ -33,6 +33,9 @@ SUCH DAMAGE.
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
#include "Error.h"
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
//A class that has an initialization lock so that when the lock is activated, any further gets that are missing items in it will report themselves for easier debugging detection.
|
||||
template<typename T,typename O>
|
||||
|
Loading…
x
Reference in New Issue
Block a user