small change to json formatting of resourcepack
This commit is contained in:
parent
f8ddb91c8a
commit
4b82c32cb3
@ -26,18 +26,16 @@ void NewResourcePack::gui()
|
|||||||
|
|
||||||
if(ImGui::Button("Save resource pack"))
|
if(ImGui::Button("Save resource pack"))
|
||||||
{
|
{
|
||||||
// std::fstream file;
|
try{
|
||||||
// ObjectSaver saver;
|
std::ofstream outputStream("data/"+m_name+".pack");
|
||||||
// saver.addObject(this);
|
cereal::JSONOutputArchive output(outputStream);
|
||||||
// file.open("data/" + m_name + ".pack", std::ios_base::out);
|
NewResourcePack tmp;
|
||||||
// saver.saveAscii(file);
|
tmp.m_name = this->m_name;
|
||||||
//file.close();
|
tmp.m_resources = this->m_resources;
|
||||||
|
output(tmp);
|
||||||
std::ofstream outputStream("data/"+m_name+".pack");
|
}catch(cereal::Exception e){
|
||||||
cereal::JSONOutputArchive output(outputStream);
|
std::cerr << "WUT : " << e.what() << std::endl;
|
||||||
output(std::shared_ptr<NewResourcePack>(this));
|
}
|
||||||
outputStream.close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(ImGui::Button("Load resource pack"))
|
if(ImGui::Button("Load resource pack"))
|
||||||
{
|
{
|
||||||
@ -55,9 +53,9 @@ void NewResourcePack::gui()
|
|||||||
std::ifstream inputStream("data/"+m_name+".pack");
|
std::ifstream inputStream("data/"+m_name+".pack");
|
||||||
cereal::JSONInputArchive input(inputStream);
|
cereal::JSONInputArchive input(inputStream);
|
||||||
NewResourcePack tmp = NewResourcePack();
|
NewResourcePack tmp = NewResourcePack();
|
||||||
tmp.m_name = this->m_name;
|
|
||||||
tmp.m_resources = this->m_resources;
|
|
||||||
input(tmp);
|
input(tmp);
|
||||||
|
this->m_name = tmp.m_name;
|
||||||
|
this->m_resources = tmp.m_resources;
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ struct ResourceInterface
|
|||||||
|
|
||||||
template<class Archive>
|
template<class Archive>
|
||||||
void serialize(Archive & archive){
|
void serialize(Archive & archive){
|
||||||
archive(m_name);
|
archive(CEREAL_NVP(m_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void loadResource(float & progress) = 0;
|
virtual void loadResource(float & progress) = 0;
|
||||||
@ -44,16 +44,10 @@ struct NewResourcePack
|
|||||||
|
|
||||||
template<class Archive>
|
template<class Archive>
|
||||||
void serialize(Archive & archive){
|
void serialize(Archive & archive){
|
||||||
archive(m_name,CEREAL_NVP(m_resources));
|
archive(cereal::make_nvp("ResourcePack",m_name),CEREAL_NVP(m_resources));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*template<class Archive>
|
|
||||||
void serialize(Archive & archive, std::shared_ptr<NewResourcePack> respack)
|
|
||||||
{
|
|
||||||
archive(respack);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some LoadTask implementations
|
* Some LoadTask implementations
|
||||||
*/
|
*/
|
||||||
@ -75,11 +69,11 @@ public:
|
|||||||
template <class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive & archive)
|
void serialize(Archive & archive)
|
||||||
{
|
{
|
||||||
archive(cereal::base_class<ResourceInterface>(this),
|
archive(CEREAL_NVP(m_name),
|
||||||
m_path,
|
CEREAL_NVP(m_path),
|
||||||
m_bitsPerPixel,
|
CEREAL_NVP(m_bitsPerPixel),
|
||||||
m_isVerticallyReversed,
|
CEREAL_NVP(m_isVerticallyReversed),
|
||||||
m_needsMipMaps);
|
CEREAL_NVP(m_needsMipMaps));
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadResource(float & progress);
|
void loadResource(float & progress);
|
||||||
@ -111,18 +105,18 @@ public:
|
|||||||
template<class Archive>
|
template<class Archive>
|
||||||
void serialize(Archive & archive)
|
void serialize(Archive & archive)
|
||||||
{
|
{
|
||||||
archive(cereal::base_class<ResourceInterface>(this),
|
archive(CEREAL_NVP(m_name),
|
||||||
m_albedo,
|
CEREAL_NVP(m_albedo),
|
||||||
m_metallic,
|
CEREAL_NVP(m_metallic),
|
||||||
m_roughness,
|
CEREAL_NVP(m_roughness),
|
||||||
m_emission,
|
CEREAL_NVP(m_emission),
|
||||||
m_opacity,
|
CEREAL_NVP(m_opacity),
|
||||||
m_albedoTexture,
|
CEREAL_NVP(m_albedoTexture),
|
||||||
m_metallicTexture,
|
CEREAL_NVP(m_metallicTexture),
|
||||||
m_roughnessTexture,
|
CEREAL_NVP(m_roughnessTexture),
|
||||||
m_emissionTexture,
|
CEREAL_NVP(m_emissionTexture),
|
||||||
m_normalTexture,
|
CEREAL_NVP(m_normalTexture),
|
||||||
m_alphaMaskTexture);
|
CEREAL_NVP(m_alphaMaskTexture));
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadResource(float & progress);
|
void loadResource(float & progress);
|
||||||
@ -132,8 +126,9 @@ public:
|
|||||||
void gui();
|
void gui();
|
||||||
};
|
};
|
||||||
|
|
||||||
//CEREAL_REGISTER_TYPE(TextureResource)
|
CEREAL_REGISTER_TYPE(TextureResource)
|
||||||
|
CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,TextureResource)
|
||||||
//CEREAL_REGISTER_TYPE(MaterialResource)
|
//CEREAL_REGISTER_TYPE(MaterialResource)
|
||||||
|
//CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,MaterialResource)
|
||||||
|
|
||||||
#endif // NEWRESOURCEPACK_H
|
#endif // NEWRESOURCEPACK_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user