mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-09 18:44:46 +00:00
parent
615e369cc4
commit
9ef3e1e134
@ -58,6 +58,7 @@
|
|||||||
#include "base/split_string.h"
|
#include "base/split_string.h"
|
||||||
#include "base/unique_ptr.h"
|
#include "base/unique_ptr.h"
|
||||||
#include "doc/document_observer.h"
|
#include "doc/document_observer.h"
|
||||||
|
#include "doc/frame_tag.h"
|
||||||
#include "doc/image.h"
|
#include "doc/image.h"
|
||||||
#include "doc/layer.h"
|
#include "doc/layer.h"
|
||||||
#include "doc/palette.h"
|
#include "doc/palette.h"
|
||||||
@ -222,6 +223,8 @@ void App::initialize(const AppOptions& options)
|
|||||||
Console console;
|
Console console;
|
||||||
bool splitLayers = false;
|
bool splitLayers = false;
|
||||||
bool splitLayersSaveAs = false;
|
bool splitLayersSaveAs = false;
|
||||||
|
bool listLayers = false;
|
||||||
|
bool listTags = false;
|
||||||
std::string importLayer;
|
std::string importLayer;
|
||||||
std::string importLayerSaveAs;
|
std::string importLayerSaveAs;
|
||||||
std::string filenameFormat;
|
std::string filenameFormat;
|
||||||
@ -442,6 +445,14 @@ void App::initialize(const AppOptions& options)
|
|||||||
AppScripting engine(&delegate);
|
AppScripting engine(&delegate);
|
||||||
engine.evalFile(script);
|
engine.evalFile(script);
|
||||||
}
|
}
|
||||||
|
// --list-layers
|
||||||
|
else if (opt == &options.listLayers()) {
|
||||||
|
listLayers = true;
|
||||||
|
}
|
||||||
|
// --list-tags
|
||||||
|
else if (opt == &options.listTags()) {
|
||||||
|
listTags = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// File names aren't associated to any option
|
// File names aren't associated to any option
|
||||||
else {
|
else {
|
||||||
@ -461,33 +472,49 @@ void App::initialize(const AppOptions& options)
|
|||||||
if (doc == oldDoc)
|
if (doc == oldDoc)
|
||||||
doc = nullptr;
|
doc = nullptr;
|
||||||
|
|
||||||
if (doc && m_exporter) {
|
// List layers and/or tags
|
||||||
FrameTag* frameTag = nullptr;
|
if (doc) {
|
||||||
if (!frameTagName.empty())
|
if (listLayers) {
|
||||||
frameTag = doc->sprite()->frameTags().getByName(frameTagName);
|
listLayers = false;
|
||||||
|
|
||||||
if (!importLayer.empty()) {
|
|
||||||
std::vector<Layer*> layers;
|
std::vector<Layer*> layers;
|
||||||
doc->sprite()->getLayersList(layers);
|
doc->sprite()->getLayersList(layers);
|
||||||
|
for (Layer* layer : layers)
|
||||||
|
std::cout << layer->name() << "\n";
|
||||||
|
}
|
||||||
|
if (listTags) {
|
||||||
|
listTags = false;
|
||||||
|
for (FrameTag* tag : doc->sprite()->frameTags())
|
||||||
|
std::cout << tag->name() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
Layer* foundLayer = NULL;
|
if (m_exporter) {
|
||||||
for (Layer* layer : layers) {
|
FrameTag* frameTag = nullptr;
|
||||||
if (layer->name() == importLayer) {
|
if (!frameTagName.empty())
|
||||||
foundLayer = layer;
|
frameTag = doc->sprite()->frameTags().getByName(frameTagName);
|
||||||
break;
|
|
||||||
|
if (!importLayer.empty()) {
|
||||||
|
std::vector<Layer*> layers;
|
||||||
|
doc->sprite()->getLayersList(layers);
|
||||||
|
|
||||||
|
Layer* foundLayer = NULL;
|
||||||
|
for (Layer* layer : layers) {
|
||||||
|
if (layer->name() == importLayer) {
|
||||||
|
foundLayer = layer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (foundLayer)
|
||||||
|
m_exporter->addDocument(doc, foundLayer, frameTag);
|
||||||
}
|
}
|
||||||
if (foundLayer)
|
else if (splitLayers) {
|
||||||
m_exporter->addDocument(doc, foundLayer, frameTag);
|
std::vector<Layer*> layers;
|
||||||
|
doc->sprite()->getLayersList(layers);
|
||||||
|
for (auto layer : layers)
|
||||||
|
m_exporter->addDocument(doc, layer, frameTag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_exporter->addDocument(doc, nullptr, frameTag);
|
||||||
}
|
}
|
||||||
else if (splitLayers) {
|
|
||||||
std::vector<Layer*> layers;
|
|
||||||
doc->sprite()->getLayersList(layers);
|
|
||||||
for (auto layer : layers)
|
|
||||||
m_exporter->addDocument(doc, layer, frameTag);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_exporter->addDocument(doc, nullptr, frameTag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!importLayer.empty())
|
if (!importLayer.empty())
|
||||||
@ -495,6 +522,10 @@ void App::initialize(const AppOptions& options)
|
|||||||
|
|
||||||
if (splitLayers)
|
if (splitLayers)
|
||||||
splitLayers = false;
|
splitLayers = false;
|
||||||
|
if (listLayers)
|
||||||
|
listLayers = false;
|
||||||
|
if (listTags)
|
||||||
|
listTags = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ AppOptions::AppOptions(int argc, const char* argv[])
|
|||||||
, m_crop(m_po.add("crop").requiresValue("x,y,width,height").description("Crop all the images to the given rectangle"))
|
, m_crop(m_po.add("crop").requiresValue("x,y,width,height").description("Crop all the images to the given rectangle"))
|
||||||
, m_filenameFormat(m_po.add("filename-format").requiresValue("<fmt>").description("Special format to generate filenames"))
|
, m_filenameFormat(m_po.add("filename-format").requiresValue("<fmt>").description("Special format to generate filenames"))
|
||||||
, m_script(m_po.add("script").requiresValue("<filename>").description("Execute a specific script"))
|
, m_script(m_po.add("script").requiresValue("<filename>").description("Execute a specific script"))
|
||||||
|
, m_listLayers(m_po.add("list-layers").description("List layers of the next given sprite"))
|
||||||
|
, m_listTags(m_po.add("list-tags").description("List tags of the next given sprite"))
|
||||||
, m_verbose(m_po.add("verbose").mnemonic('v').description("Explain what is being done"))
|
, m_verbose(m_po.add("verbose").mnemonic('v').description("Explain what is being done"))
|
||||||
, m_help(m_po.add("help").mnemonic('?').description("Display this help and exits"))
|
, m_help(m_po.add("help").mnemonic('?').description("Display this help and exits"))
|
||||||
, m_version(m_po.add("version").description("Output version information and exit"))
|
, m_version(m_po.add("version").description("Output version information and exit"))
|
||||||
|
@ -55,6 +55,8 @@ public:
|
|||||||
const Option& crop() const { return m_crop; }
|
const Option& crop() const { return m_crop; }
|
||||||
const Option& filenameFormat() const { return m_filenameFormat; }
|
const Option& filenameFormat() const { return m_filenameFormat; }
|
||||||
const Option& script() const { return m_script; }
|
const Option& script() const { return m_script; }
|
||||||
|
const Option& listLayers() const { return m_listLayers; }
|
||||||
|
const Option& listTags() const { return m_listTags; }
|
||||||
|
|
||||||
bool hasExporterParams() const;
|
bool hasExporterParams() const;
|
||||||
|
|
||||||
@ -91,6 +93,8 @@ private:
|
|||||||
Option& m_crop;
|
Option& m_crop;
|
||||||
Option& m_filenameFormat;
|
Option& m_filenameFormat;
|
||||||
Option& m_script;
|
Option& m_script;
|
||||||
|
Option& m_listLayers;
|
||||||
|
Option& m_listTags;
|
||||||
|
|
||||||
Option& m_verbose;
|
Option& m_verbose;
|
||||||
Option& m_help;
|
Option& m_help;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user