This commit is contained in:
Christian Kaiser 2025-07-23 18:49:17 -04:00 committed by GitHub
commit 257e2b7b57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View File

@ -273,6 +273,7 @@ Doc* generate_sprite_sheet_from_params(DocExporter& exporter,
exporter.setSplitTags(splitTags); exporter.setSplitTags(splitTags);
exporter.setIgnoreEmptyCels(ignoreEmpty); exporter.setIgnoreEmptyCels(ignoreEmpty);
exporter.setMergeDuplicates(mergeDuplicates); exporter.setMergeDuplicates(mergeDuplicates);
exporter.setSelectedTag(tagName);
if (listLayers) if (listLayers)
exporter.setListLayers(true); exporter.setListLayers(true);
if (listTags) if (listTags)

View File

@ -1529,6 +1529,10 @@ void DocExporter::createDataFile(const Samples& samples, std::ostream& os, doc::
includedSprites.insert(sprite->id()); includedSprites.insert(sprite->id());
for (Tag* tag : sprite->tags()) { for (Tag* tag : sprite->tags()) {
// Ignore unselected tags if we picked a specific one.
if (!m_selectedTagName.empty() && m_selectedTagName != tag->name())
continue;
if (firstTag) if (firstTag)
firstTag = false; firstTag = false;
else else
@ -1539,12 +1543,22 @@ void DocExporter::createDataFile(const Samples& samples, std::ostream& os, doc::
format = "{tag}"; format = "{tag}";
} }
frame_t fromFrame = tag->fromFrame();
frame_t toFrame = tag->toFrame();
// Reset the frame offset when we're only exporting one frame tag so they're consistent
// with the exported frame list.
if (!m_selectedTagName.empty()) {
toFrame = toFrame - fromFrame;
fromFrame = 0;
}
FilenameInfo fnInfo; FilenameInfo fnInfo;
fnInfo.filename(doc->filename()).innerTagName(tag->name()); fnInfo.filename(doc->filename()).innerTagName(tag->name());
std::string tagname = filename_formatter(format, fnInfo); std::string tagname = filename_formatter(format, fnInfo);
os << "\n { \"name\": \"" << escape_for_json(tagname) << "\"," os << "\n { \"name\": \"" << escape_for_json(tagname) << "\","
<< " \"from\": " << (tag->fromFrame()) << "," << " \"from\": " << fromFrame << ","
<< " \"to\": " << (tag->toFrame()) << " \"to\": " << toFrame
<< "," << ","
" \"direction\": \"" " \"direction\": \""
<< escape_for_json(convert_anidir_to_string(tag->aniDir())) << "\""; << escape_for_json(convert_anidir_to_string(tag->aniDir())) << "\"";

View File

@ -79,6 +79,7 @@ public:
void setListLayers(bool value) { m_listLayers = value; } void setListLayers(bool value) { m_listLayers = value; }
void setListLayerHierarchy(bool value) { m_listLayerHierarchy = value; } void setListLayerHierarchy(bool value) { m_listLayerHierarchy = value; }
void setListSlices(bool value) { m_listSlices = value; } void setListSlices(bool value) { m_listSlices = value; }
void setSelectedTag(const std::string& tagName) { m_selectedTagName = tagName; }
void addImage(Doc* doc, const doc::ImageRef& image); void addImage(Doc* doc, const doc::ImageRef& image);
@ -153,6 +154,7 @@ private:
std::string m_textureFilename; std::string m_textureFilename;
std::string m_filenameFormat; std::string m_filenameFormat;
std::string m_tagnameFormat; std::string m_tagnameFormat;
std::string m_selectedTagName;
int m_textureWidth; int m_textureWidth;
int m_textureHeight; int m_textureHeight;
int m_textureColumns; int m_textureColumns;