mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
- some groundwork for wog optionality
- moved wog artifacts to wog mod
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "HeroBonus.h"
|
||||
#include "filesystem/CResourceLoader.h"
|
||||
#include "filesystem/ISimpleResourceLoader.h"
|
||||
#include "VCMI_Lib.h" //for identifier resolution
|
||||
#include "CModHandler.h"
|
||||
|
||||
@@ -387,6 +388,8 @@ void JsonWriter::writeNode(const JsonNode &node)
|
||||
writeContainer(node.Struct().begin(), node.Struct().end());
|
||||
out << prefix << "}";
|
||||
}
|
||||
if (!node.meta.empty()) // write metainf as comment
|
||||
out << " //" << node.meta;
|
||||
}
|
||||
|
||||
JsonWriter::JsonWriter(std::ostream &output, const JsonNode &node):
|
||||
@@ -1603,3 +1606,24 @@ JsonNode JsonUtils::assembleFromFiles(std::vector<std::string> files)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
JsonNode JsonUtils::assembleFromFiles(std::string filename)
|
||||
{
|
||||
JsonNode result;
|
||||
|
||||
auto & configList = CResourceHandler::get()->getResourcesWithName(ResourceID(filename, EResType::TEXT));
|
||||
|
||||
BOOST_FOREACH(auto & entry, configList)
|
||||
{
|
||||
// FIXME: some way to make this code more readable
|
||||
auto stream = entry.getLoader()->load(entry.getResourceName());
|
||||
std::unique_ptr<ui8[]> textData(new ui8[stream->getSize()]);
|
||||
stream->read(textData.get(), stream->getSize());
|
||||
|
||||
JsonNode section((char*)textData.get(), stream->getSize());
|
||||
//for debug
|
||||
//section.setMeta(entry.getLoader()->getOrigin());
|
||||
merge(result, section);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user