diff --git a/.gitignore b/.gitignore index fcf34915..0ae42b62 100644 --- a/.gitignore +++ b/.gitignore @@ -401,4 +401,5 @@ test.cpp /x64/Release/Adventures in Lestoria_web.zip /x64/Release/AdventuresInLestoria_web.zip packkey.cpp -desktop.ini \ No newline at end of file +desktop.ini +.tmp.driveupload \ No newline at end of file diff --git a/Adventures in Lestoria/MonsterData.cpp b/Adventures in Lestoria/MonsterData.cpp index 2b185829..209aec0e 100644 --- a/Adventures in Lestoria/MonsterData.cpp +++ b/Adventures in Lestoria/MonsterData.cpp @@ -91,26 +91,26 @@ void MonsterData::InitializeMonsterData(){ if(!DATA["Monsters"][MonsterName].HasProperty("Animations"))ERR(std::format("WARNING! Could not find any animations to load for monster {}! Please check the Monsters.txt configuration file!",MonsterName)); if(DATA["Monsters"][MonsterName]["Animations"].GetKeys().size()<4)ERR(std::format("WARNING! Monster {} does not have at least 4 animations. The animations should be defined in this order: a standing, walking, attack, and death animation",MonsterName)); - for(size_t animationRow=0;auto&[animationName,size]:DATA["Monsters"][MonsterName]["Animations"]){ + for(size_t animationRow=0;auto&[animationName,data]:DATA["Monsters"][MonsterName]["Animations"].GetOrderedKeys()){ Animate2D::Style style=Animate2D::Style::Repeat; - if(DATA["Monsters"][MonsterName]["Animations"][animationName].GetString(2)=="Repeat"){ + if(data.GetString(2)=="Repeat"){ style=Animate2D::Style::Repeat; }else - if(DATA["Monsters"][MonsterName]["Animations"][animationName].GetString(2)=="OneShot"){ + if(data.GetString(2)=="OneShot"){ style=Animate2D::Style::OneShot; }else - if(DATA["Monsters"][MonsterName]["Animations"][animationName].GetString(2)=="PingPong"){ + if(data.GetString(2)=="PingPong"){ style=Animate2D::Style::PingPong; }else - if(DATA["Monsters"][MonsterName]["Animations"][animationName].GetString(2)=="Reverse"){ + if(data.GetString(2)=="Reverse"){ style=Animate2D::Style::Reverse; }else{ ERR(std::format("WARNING! Invalid Animation Style specified: {}",int(style))); } - int frameCount=DATA["Monsters"][MonsterName]["Animations"][animationName].GetInt(0); + int frameCount=data.GetInt(0); vf2d frameSize=vf2d{float(DATA["Monsters"][MonsterName]["SheetFrameSize"].GetInt(0)),float(DATA["Monsters"][MonsterName]["SheetFrameSize"].GetInt(1))}; - CreateHorizontalAnimationSequence(*MonsterData::imgs[MonsterName],frameCount,frameSize,std::format("{}_{}",MonsterName,animationName),animationRow,AnimationData{float(DATA["Monsters"][MonsterName]["Animations"][animationName].GetReal(1)),style}); + CreateHorizontalAnimationSequence(*MonsterData::imgs[MonsterName],frameCount,frameSize,std::format("{}_{}",MonsterName,animationName),animationRow,AnimationData{float(data.GetReal(1)),style}); animations.push_back(animationName); @@ -218,26 +218,26 @@ void MonsterData::InitializeNPCData(){ if(!DATA["NPCs"][NPCName].HasProperty("Animations"))ERR(std::format("WARNING! Could not find any animations to load for monster {}! Please check the Monsters.txt configuration file!",NPCName)); if(DATA["NPCs"][NPCName]["Animations"].GetKeys().size()<4)ERR(std::format("WARNING! Monster {} does not have at least 4 animations. The animations should be defined in this order: a standing, walking, attack, and death animation",NPCName)); - for(size_t animationRow=0;auto&[animationName,size]:DATA["NPCs"][NPCName]["Animations"]){ + for(size_t animationRow=0;auto&[animationName,data]:DATA["NPCs"][NPCName]["Animations"].GetOrderedKeys()){ Animate2D::Style style=Animate2D::Style::Repeat; - if(DATA["NPCs"][NPCName]["Animations"][animationName].GetString(2)=="Repeat"){ + if(data.GetString(2)=="Repeat"){ style=Animate2D::Style::Repeat; }else - if(DATA["NPCs"][NPCName]["Animations"][animationName].GetString(2)=="OneShot"){ + if(data.GetString(2)=="OneShot"){ style=Animate2D::Style::OneShot; }else - if(DATA["NPCs"][NPCName]["Animations"][animationName].GetString(2)=="PingPong"){ + if(data.GetString(2)=="PingPong"){ style=Animate2D::Style::PingPong; }else - if(DATA["NPCs"][NPCName]["Animations"][animationName].GetString(2)=="Reverse"){ + if(data.GetString(2)=="Reverse"){ style=Animate2D::Style::Reverse; }else{ ERR(std::format("WARNING! Invalid Animation Style specified: {}",int(style))); } - int frameCount=DATA["NPCs"][NPCName]["Animations"][animationName].GetInt(0); + int frameCount=data.GetInt(0); vf2d frameSize=vf2d{float(DATA["NPCs"][NPCName]["SheetFrameSize"].GetInt(0)),float(DATA["NPCs"][NPCName]["SheetFrameSize"].GetInt(1))}; - CreateHorizontalAnimationSequence(*MonsterData::imgs[NPCName],frameCount,frameSize,std::format("{}_{}",NPCName,animationName),animationRow,AnimationData{float(DATA["NPCs"][NPCName]["Animations"][animationName].GetReal(1)),style}); + CreateHorizontalAnimationSequence(*MonsterData::imgs[NPCName],frameCount,frameSize,std::format("{}_{}",NPCName,animationName),animationRow,AnimationData{float(data.GetReal(1)),style}); animations.push_back(animationName); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index c1492211..7afeb6c4 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 9125 +#define VERSION_BUILD 9126 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/olcUTIL_DataFile.h b/Adventures in Lestoria/olcUTIL_DataFile.h index d80c2af1..22b01417 100644 --- a/Adventures in Lestoria/olcUTIL_DataFile.h +++ b/Adventures in Lestoria/olcUTIL_DataFile.h @@ -166,8 +166,11 @@ namespace olc::utils return m_mapObjects; } - inline std::vector>&GetOrderedKeys(){ - return m_vecObjects; + //This function is slightly expensive due to a filtering function required to remove all comments! + inline std::vector> GetOrderedKeys(){ + std::vector>orderedKeys; + std::copy_if(m_vecObjects.begin(),m_vecObjects.end(),std::back_inserter(orderedKeys),[&](const std::pair&data){return !datafile::IsComment(data);}); + return orderedKeys; } // Checks if a property exists - useful to avoid creating properties @@ -514,6 +517,10 @@ namespace olc::utils inline static std::string lastAccessedProperty=""; inline static std::string BLANK=""; + inline static bool IsComment(const std::pair&data){ + return data.first.length()>0&&data.first[0]=='#'; + } + protected: // Used to identify if a property is a comment or not, not user facing bool m_bIsComment = false; diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index e86de2cb..a8e5ac72 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ