olcUTIL_DataFile now properly parses out comments when using GetOrderedKeys(). Fixed monster animations not being read from the configuration file in the correct order. Release Build 9126.
This commit is contained in:
parent
70906d5594
commit
16c52bf397
1
.gitignore
vendored
1
.gitignore
vendored
@ -402,3 +402,4 @@ test.cpp
|
||||
/x64/Release/AdventuresInLestoria_web.zip
|
||||
packkey.cpp
|
||||
desktop.ini
|
||||
.tmp.driveupload
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -166,8 +166,11 @@ namespace olc::utils
|
||||
return m_mapObjects;
|
||||
}
|
||||
|
||||
inline std::vector<std::pair<std::string,datafile>>&GetOrderedKeys(){
|
||||
return m_vecObjects;
|
||||
//This function is slightly expensive due to a filtering function required to remove all comments!
|
||||
inline std::vector<std::pair<std::string,datafile>> GetOrderedKeys(){
|
||||
std::vector<std::pair<std::string,datafile>>orderedKeys;
|
||||
std::copy_if(m_vecObjects.begin(),m_vecObjects.end(),std::back_inserter(orderedKeys),[&](const std::pair<std::string,datafile>&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<std::string,datafile>&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;
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user