mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-02 04:20:16 +00:00
Add new CLI param to save animations taking into account subtabs and repeats (fix #4297)
This commit is contained in:
parent
1896483458
commit
88ef46de42
@ -54,6 +54,7 @@ AppOptions::AppOptions(int argc, const char* argv[])
|
|||||||
, m_allLayers(m_po.add("all-layers").description("Make all layers visible\nBy default hidden layers will be ignored"))
|
, m_allLayers(m_po.add("all-layers").description("Make all layers visible\nBy default hidden layers will be ignored"))
|
||||||
, m_ignoreLayer(m_po.add("ignore-layer").requiresValue("<name>").description("Exclude the given layer in the sheet\nor save as operation"))
|
, m_ignoreLayer(m_po.add("ignore-layer").requiresValue("<name>").description("Exclude the given layer in the sheet\nor save as operation"))
|
||||||
, m_tag(m_po.add("tag").alias("frame-tag").requiresValue("<name>").description("Include tagged frames in the sheet"))
|
, m_tag(m_po.add("tag").alias("frame-tag").requiresValue("<name>").description("Include tagged frames in the sheet"))
|
||||||
|
, m_playSubtags(m_po.add("play-subtags").description("Play subtags and repeats when saving the frames of an animated sprite"))
|
||||||
, m_frameRange(m_po.add("frame-range").requiresValue("from,to").description("Only export frames in the [from,to] range"))
|
, m_frameRange(m_po.add("frame-range").requiresValue("from,to").description("Only export frames in the [from,to] range"))
|
||||||
, m_ignoreEmpty(m_po.add("ignore-empty").description("Do not export empty frames/cels"))
|
, m_ignoreEmpty(m_po.add("ignore-empty").description("Do not export empty frames/cels"))
|
||||||
, m_mergeDuplicates(m_po.add("merge-duplicates").description("Merge all duplicate frames into one in the sprite sheet"))
|
, m_mergeDuplicates(m_po.add("merge-duplicates").description("Merge all duplicate frames into one in the sprite sheet"))
|
||||||
|
@ -70,6 +70,7 @@ public:
|
|||||||
const Option& allLayers() const { return m_allLayers; }
|
const Option& allLayers() const { return m_allLayers; }
|
||||||
const Option& ignoreLayer() const { return m_ignoreLayer; }
|
const Option& ignoreLayer() const { return m_ignoreLayer; }
|
||||||
const Option& tag() const { return m_tag; }
|
const Option& tag() const { return m_tag; }
|
||||||
|
const Option& playSubtags() const { return m_playSubtags; }
|
||||||
const Option& frameRange() const { return m_frameRange; }
|
const Option& frameRange() const { return m_frameRange; }
|
||||||
const Option& ignoreEmpty() const { return m_ignoreEmpty; }
|
const Option& ignoreEmpty() const { return m_ignoreEmpty; }
|
||||||
const Option& mergeDuplicates() const { return m_mergeDuplicates; }
|
const Option& mergeDuplicates() const { return m_mergeDuplicates; }
|
||||||
@ -143,6 +144,7 @@ private:
|
|||||||
Option& m_allLayers;
|
Option& m_allLayers;
|
||||||
Option& m_ignoreLayer;
|
Option& m_ignoreLayer;
|
||||||
Option& m_tag;
|
Option& m_tag;
|
||||||
|
Option& m_playSubtags;
|
||||||
Option& m_frameRange;
|
Option& m_frameRange;
|
||||||
Option& m_ignoreEmpty;
|
Option& m_ignoreEmpty;
|
||||||
Option& m_mergeDuplicates;
|
Option& m_mergeDuplicates;
|
||||||
|
@ -44,6 +44,7 @@ namespace app {
|
|||||||
bool trimByGrid = false;
|
bool trimByGrid = false;
|
||||||
bool oneFrame = false;
|
bool oneFrame = false;
|
||||||
bool exportTileset = false;
|
bool exportTileset = false;
|
||||||
|
bool playSubtags = false;
|
||||||
gfx::Rect crop;
|
gfx::Rect crop;
|
||||||
|
|
||||||
bool hasTag() const {
|
bool hasTag() const {
|
||||||
|
@ -303,6 +303,10 @@ int CliProcessor::process(Context* ctx)
|
|||||||
else if (opt == &m_options.tag()) {
|
else if (opt == &m_options.tag()) {
|
||||||
cof.tag = value.value();
|
cof.tag = value.value();
|
||||||
}
|
}
|
||||||
|
// --play-subtags
|
||||||
|
else if (opt == &m_options.playSubtags()) {
|
||||||
|
cof.playSubtags = true;
|
||||||
|
}
|
||||||
// --frame-range from,to
|
// --frame-range from,to
|
||||||
else if (opt == &m_options.frameRange()) {
|
else if (opt == &m_options.frameRange()) {
|
||||||
std::vector<std::string> splitRange;
|
std::vector<std::string> splitRange;
|
||||||
|
@ -88,6 +88,9 @@ void DefaultCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
|
|||||||
if (cof.hasTag()) {
|
if (cof.hasTag()) {
|
||||||
params.set("frame-tag", cof.tag.c_str());
|
params.set("frame-tag", cof.tag.c_str());
|
||||||
}
|
}
|
||||||
|
if (cof.playSubtags) {
|
||||||
|
params.set("playSubtags", "true");
|
||||||
|
}
|
||||||
if (cof.hasFrameRange()) {
|
if (cof.hasFrameRange()) {
|
||||||
params.set("from-frame", base::convert_to<std::string>(cof.fromFrame).c_str());
|
params.set("from-frame", base::convert_to<std::string>(cof.fromFrame).c_str());
|
||||||
params.set("to-frame", base::convert_to<std::string>(cof.toFrame).c_str());
|
params.set("to-frame", base::convert_to<std::string>(cof.toFrame).c_str());
|
||||||
|
@ -121,6 +121,10 @@ void PreviewCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
|
|||||||
std::cout << " - Tag: '" << cof.tag << "'\n";
|
std::cout << " - Tag: '" << cof.tag << "'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cof.playSubtags) {
|
||||||
|
std::cout << " - Play subtags & repeats\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (cof.hasSlice()) {
|
if (cof.hasSlice()) {
|
||||||
std::cout << " - Slice: '" << cof.slice << "'\n";
|
std::cout << " - Slice: '" << cof.slice << "'\n";
|
||||||
}
|
}
|
||||||
|
@ -494,29 +494,28 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
|
|||||||
|
|
||||||
{
|
{
|
||||||
RestoreVisibleLayers layersVisibility;
|
RestoreVisibleLayers layersVisibility;
|
||||||
|
Site site = context->activeSite();
|
||||||
if (context->isUIAvailable()) {
|
if (context->isUIAvailable()) {
|
||||||
Site site = context->activeSite();
|
|
||||||
|
|
||||||
// Selected layers to export
|
// Selected layers to export
|
||||||
calculate_visible_layers(site,
|
calculate_visible_layers(site,
|
||||||
layers,
|
layers,
|
||||||
layersIndex,
|
layersIndex,
|
||||||
layersVisibility);
|
layersVisibility);
|
||||||
|
|
||||||
// m_selFrames is not empty if fromFrame/toFrame parameters are
|
|
||||||
// specified.
|
|
||||||
if (m_framesSeq.empty()) {
|
|
||||||
// Frames sequence to export
|
|
||||||
FramesSequence framesSeq;
|
|
||||||
Tag* tag = calculate_frames_sequence(
|
|
||||||
site, frames, framesSeq, isPlaySubtags, aniDirValue);
|
|
||||||
if (tag)
|
|
||||||
params().tag(tag->name());
|
|
||||||
m_framesSeq = framesSeq;
|
|
||||||
}
|
|
||||||
m_adjustFramesByTag = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// m_selFrames is not empty if fromFrame/toFrame parameters are
|
||||||
|
// specified.
|
||||||
|
if (m_framesSeq.empty()) {
|
||||||
|
// Frames sequence to export
|
||||||
|
FramesSequence framesSeq;
|
||||||
|
Tag* tag = calculate_frames_sequence(
|
||||||
|
site, frames, framesSeq, isPlaySubtags, aniDirValue);
|
||||||
|
if (tag)
|
||||||
|
params().tag(tag->name());
|
||||||
|
m_framesSeq = framesSeq;
|
||||||
|
}
|
||||||
|
m_adjustFramesByTag = false;
|
||||||
|
|
||||||
// Set other parameters
|
// Set other parameters
|
||||||
params().aniDir(aniDirValue);
|
params().aniDir(aniDirValue);
|
||||||
if (!bounds.isEmpty())
|
if (!bounds.isEmpty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user