add sprite user data when exporting documents

This commit is contained in:
Michele Caini 2024-02-04 00:24:28 +01:00 committed by GitHub
parent 5900605549
commit b0e5db7fb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1434,6 +1434,31 @@ void DocExporter::createDataFile(const Samples& samples,
<< "\"h\": " << texture->height() << " },\n"
<< " \"scale\": \"1\"";
{
bool firstDoc = true;
std::set<doc::ObjectId> includedSprites;
for (auto& item : m_documents) {
if (firstDoc)
firstDoc = false;
else
os << ",";
Doc* doc = item.doc;
Sprite* sprite = doc->sprite();
// Avoid including the same document more than once
if (includedSprites.find(sprite->id()) != includedSprites.end())
continue;
includedSprites.insert(sprite->id());
os << "\n { \"name\": \"" << doc->name() << "\"" << sprite->userData() << " }";
}
os << "\n ]";
}
// meta.frameTags
if (m_listTags) {
os << ",\n"