mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
[cli] Add -list-layer-hierarchy option
Example output: group1/ layer1.1 layer1.2 group1.1/ layer1.1.1 group2/ layer2.1
This commit is contained in:
parent
7ce9f85b39
commit
aa152963d4
@ -74,6 +74,7 @@ AppOptions::AppOptions(int argc, const char* argv[])
|
||||
, m_scriptParam(m_po.add("script-param").requiresValue("name=value").description("Parameter for a script executed from the\nCLI that you can access with app.params"))
|
||||
#endif
|
||||
, m_listLayers(m_po.add("list-layers").description("List layers of the next given sprite\nor include layers in JSON data"))
|
||||
, m_listLayerHierarchy(m_po.add("list-layer-hierarchy").description("List layers with groups of the next given sprite\nor include layers hierarchy in JSON data"))
|
||||
, m_listTags(m_po.add("list-tags").description("List tags of the next given sprite\nor include frame tags in JSON data"))
|
||||
, m_listSlices(m_po.add("list-slices").description("List slices of the next given sprite\nor include slices in JSON data"))
|
||||
, m_oneFrame(m_po.add("oneframe").description("Load just the first frame"))
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
const Option& scriptParam() const { return m_scriptParam; }
|
||||
#endif
|
||||
const Option& listLayers() const { return m_listLayers; }
|
||||
const Option& listLayerHierarchy() const { return m_listLayerHierarchy; }
|
||||
const Option& listTags() const { return m_listTags; }
|
||||
const Option& listSlices() const { return m_listSlices; }
|
||||
const Option& oneFrame() const { return m_oneFrame; }
|
||||
@ -164,6 +165,7 @@ private:
|
||||
Option& m_scriptParam;
|
||||
#endif
|
||||
Option& m_listLayers;
|
||||
Option& m_listLayerHierarchy;
|
||||
Option& m_listTags;
|
||||
Option& m_listSlices;
|
||||
Option& m_oneFrame;
|
||||
|
@ -37,6 +37,7 @@ namespace app {
|
||||
bool splitGrid = false;
|
||||
bool allLayers = false;
|
||||
bool listLayers = false;
|
||||
bool listLayerHierarchy = false;
|
||||
bool listTags = false;
|
||||
bool listSlices = false;
|
||||
bool ignoreEmpty = false;
|
||||
|
@ -587,6 +587,13 @@ int CliProcessor::process(Context* ctx)
|
||||
else
|
||||
cof.listLayers = true;
|
||||
}
|
||||
// --list-layer-hierarchy
|
||||
else if (opt == &m_options.listLayerHierarchy()) {
|
||||
if (m_exporter)
|
||||
m_exporter->setListLayerHierarchy(true);
|
||||
else
|
||||
cof.listLayerHierarchy = true;
|
||||
}
|
||||
// --list-tags
|
||||
else if (opt == &m_options.listTags()) {
|
||||
if (m_exporter)
|
||||
|
@ -67,6 +67,10 @@ void DefaultCliDelegate::afterOpenFile(const CliOpenFile& cof)
|
||||
std::cout << layer->name() << "\n";
|
||||
}
|
||||
|
||||
if (cof.listLayerHierarchy) {
|
||||
std::cout << cof.document->sprite()->visibleLayerHierarchyAsString() << "\n";
|
||||
}
|
||||
|
||||
if (cof.listTags) {
|
||||
for (doc::Tag* tag : cof.document->sprite()->tags())
|
||||
std::cout << tag->name() << "\n";
|
||||
|
@ -67,6 +67,9 @@ void PreviewCliDelegate::afterOpenFile(const CliOpenFile& cof)
|
||||
if (cof.listLayers)
|
||||
std::cout << " - List layers\n";
|
||||
|
||||
if (cof.listLayerHierarchy)
|
||||
std::cout << " - List layer hierarchy\n";
|
||||
|
||||
if (cof.listTags)
|
||||
std::cout << " - List tags\n";
|
||||
|
||||
|
@ -623,6 +623,7 @@ void DocExporter::reset()
|
||||
m_splitTags = false;
|
||||
m_listTags = false;
|
||||
m_listLayers = false;
|
||||
m_listLayerHierarchy = false;
|
||||
m_listSlices = false;
|
||||
m_documents.clear();
|
||||
}
|
||||
@ -1487,7 +1488,7 @@ void DocExporter::createDataFile(const Samples& samples,
|
||||
}
|
||||
|
||||
// meta.layers
|
||||
if (m_listLayers) {
|
||||
if (m_listLayers || m_listLayerHierarchy) {
|
||||
LayerList metaLayers;
|
||||
for (auto& item : m_documents) {
|
||||
if (item.isOneImageOnly())
|
||||
|
@ -77,6 +77,7 @@ namespace app {
|
||||
void setSplitTags(bool splitTags) { m_splitTags = splitTags; }
|
||||
void setListTags(bool value) { m_listTags = value; }
|
||||
void setListLayers(bool value) { m_listLayers = value; }
|
||||
void setListLayerHierarchy(bool value) { m_listLayerHierarchy = value; }
|
||||
void setListSlices(bool value) { m_listSlices = value; }
|
||||
|
||||
void addImage(
|
||||
@ -180,6 +181,7 @@ namespace app {
|
||||
bool m_splitTags;
|
||||
bool m_listTags;
|
||||
bool m_listLayers;
|
||||
bool m_listLayerHierarchy;
|
||||
bool m_listSlices;
|
||||
Items m_documents;
|
||||
|
||||
|
@ -540,6 +540,20 @@ void LayerGroup::allTilemaps(LayerList& list) const
|
||||
}
|
||||
}
|
||||
|
||||
std::string LayerGroup::visibleLayerHierarchyAsString(const std::string& indent) const
|
||||
{
|
||||
std::string str;
|
||||
for (Layer* child : m_layers) {
|
||||
if (!child->isVisible())
|
||||
continue;
|
||||
|
||||
str += indent + child->name() + (child->isGroup() ? "/" : "") + "\n";
|
||||
if (child->isGroup())
|
||||
str += static_cast<LayerGroup*>(child)->visibleLayerHierarchyAsString(indent+" ");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void LayerGroup::getCels(CelList& cels) const
|
||||
{
|
||||
for (const Layer* layer : m_layers)
|
||||
|
@ -215,6 +215,7 @@ namespace doc {
|
||||
void allVisibleReferenceLayers(LayerList& list) const;
|
||||
void allBrowsableLayers(LayerList& list) const;
|
||||
void allTilemaps(LayerList& list) const;
|
||||
std::string visibleLayerHierarchyAsString(const std::string& indent) const;
|
||||
|
||||
void getCels(CelList& cels) const override;
|
||||
void displaceFrames(frame_t fromThis, frame_t delta) override;
|
||||
|
@ -773,6 +773,11 @@ LayerList Sprite::allTilemaps() const
|
||||
return list;
|
||||
}
|
||||
|
||||
std::string Sprite::visibleLayerHierarchyAsString() const
|
||||
{
|
||||
return m_root->visibleLayerHierarchyAsString("");
|
||||
}
|
||||
|
||||
CelsRange Sprite::cels() const
|
||||
{
|
||||
SelectedFrames selFrames;
|
||||
|
@ -219,6 +219,7 @@ namespace doc {
|
||||
LayerList allVisibleReferenceLayers() const;
|
||||
LayerList allBrowsableLayers() const;
|
||||
LayerList allTilemaps() const;
|
||||
std::string visibleLayerHierarchyAsString() const;
|
||||
|
||||
CelsRange cels() const;
|
||||
CelsRange cels(frame_t frame) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user