[aseprite] 154/250: Add --list-tags and --list-layers options
Tobias Hansen
thansen at moszumanska.debian.org
Sun Dec 20 15:27:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 9ef3e1e1347a4ae58998d7b6ec9a6c124f99ed89
Author: David Capello <davidcapello at gmail.com>
Date: Tue Oct 13 13:23:45 2015 -0300
Add --list-tags and --list-layers options
Related to #807
---
src/app/app.cpp | 73 +++++++++++++++++++++++++++++++++++--------------
src/app/app_options.cpp | 2 ++
src/app/app_options.h | 4 +++
3 files changed, 58 insertions(+), 21 deletions(-)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index a8a9bca..c703434 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -58,6 +58,7 @@
#include "base/split_string.h"
#include "base/unique_ptr.h"
#include "doc/document_observer.h"
+#include "doc/frame_tag.h"
#include "doc/image.h"
#include "doc/layer.h"
#include "doc/palette.h"
@@ -222,6 +223,8 @@ void App::initialize(const AppOptions& options)
Console console;
bool splitLayers = false;
bool splitLayersSaveAs = false;
+ bool listLayers = false;
+ bool listTags = false;
std::string importLayer;
std::string importLayerSaveAs;
std::string filenameFormat;
@@ -442,6 +445,14 @@ void App::initialize(const AppOptions& options)
AppScripting engine(&delegate);
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
else {
@@ -461,33 +472,49 @@ void App::initialize(const AppOptions& options)
if (doc == oldDoc)
doc = nullptr;
- if (doc && m_exporter) {
- FrameTag* frameTag = nullptr;
- if (!frameTagName.empty())
- frameTag = doc->sprite()->frameTags().getByName(frameTagName);
-
- if (!importLayer.empty()) {
+ // List layers and/or tags
+ if (doc) {
+ if (listLayers) {
+ listLayers = false;
std::vector<Layer*> 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;
- for (Layer* layer : layers) {
- if (layer->name() == importLayer) {
- foundLayer = layer;
- break;
+ if (m_exporter) {
+ FrameTag* frameTag = nullptr;
+ if (!frameTagName.empty())
+ frameTag = doc->sprite()->frameTags().getByName(frameTagName);
+
+ 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)
- m_exporter->addDocument(doc, foundLayer, frameTag);
- }
- else if (splitLayers) {
- std::vector<Layer*> layers;
- doc->sprite()->getLayersList(layers);
- for (auto layer : layers)
- m_exporter->addDocument(doc, layer, 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);
}
- else
- m_exporter->addDocument(doc, nullptr, frameTag);
}
if (!importLayer.empty())
@@ -495,6 +522,10 @@ void App::initialize(const AppOptions& options)
if (splitLayers)
splitLayers = false;
+ if (listLayers)
+ listLayers = false;
+ if (listTags)
+ listTags = false;
}
}
diff --git a/src/app/app_options.cpp b/src/app/app_options.cpp
index c5f3261..6e376b9 100644
--- a/src/app/app_options.cpp
+++ b/src/app/app_options.cpp
@@ -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_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_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_help(m_po.add("help").mnemonic('?').description("Display this help and exits"))
, m_version(m_po.add("version").description("Output version information and exit"))
diff --git a/src/app/app_options.h b/src/app/app_options.h
index 0d67294..10b1d5b 100644
--- a/src/app/app_options.h
+++ b/src/app/app_options.h
@@ -55,6 +55,8 @@ public:
const Option& crop() const { return m_crop; }
const Option& filenameFormat() const { return m_filenameFormat; }
const Option& script() const { return m_script; }
+ const Option& listLayers() const { return m_listLayers; }
+ const Option& listTags() const { return m_listTags; }
bool hasExporterParams() const;
@@ -91,6 +93,8 @@ private:
Option& m_crop;
Option& m_filenameFormat;
Option& m_script;
+ Option& m_listLayers;
+ Option& m_listTags;
Option& m_verbose;
Option& m_help;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list