mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-27 03:16:58 +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_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_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_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"))
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
const Option& allLayers() const { return m_allLayers; }
|
||||
const Option& ignoreLayer() const { return m_ignoreLayer; }
|
||||
const Option& tag() const { return m_tag; }
|
||||
const Option& playSubtags() const { return m_playSubtags; }
|
||||
const Option& frameRange() const { return m_frameRange; }
|
||||
const Option& ignoreEmpty() const { return m_ignoreEmpty; }
|
||||
const Option& mergeDuplicates() const { return m_mergeDuplicates; }
|
||||
@ -143,6 +144,7 @@ private:
|
||||
Option& m_allLayers;
|
||||
Option& m_ignoreLayer;
|
||||
Option& m_tag;
|
||||
Option& m_playSubtags;
|
||||
Option& m_frameRange;
|
||||
Option& m_ignoreEmpty;
|
||||
Option& m_mergeDuplicates;
|
||||
|
@ -44,6 +44,7 @@ namespace app {
|
||||
bool trimByGrid = false;
|
||||
bool oneFrame = false;
|
||||
bool exportTileset = false;
|
||||
bool playSubtags = false;
|
||||
gfx::Rect crop;
|
||||
|
||||
bool hasTag() const {
|
||||
|
@ -303,6 +303,10 @@ int CliProcessor::process(Context* ctx)
|
||||
else if (opt == &m_options.tag()) {
|
||||
cof.tag = value.value();
|
||||
}
|
||||
// --play-subtags
|
||||
else if (opt == &m_options.playSubtags()) {
|
||||
cof.playSubtags = true;
|
||||
}
|
||||
// --frame-range from,to
|
||||
else if (opt == &m_options.frameRange()) {
|
||||
std::vector<std::string> splitRange;
|
||||
|
@ -88,6 +88,9 @@ void DefaultCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
|
||||
if (cof.hasTag()) {
|
||||
params.set("frame-tag", cof.tag.c_str());
|
||||
}
|
||||
if (cof.playSubtags) {
|
||||
params.set("playSubtags", "true");
|
||||
}
|
||||
if (cof.hasFrameRange()) {
|
||||
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());
|
||||
|
@ -121,6 +121,10 @@ void PreviewCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
|
||||
std::cout << " - Tag: '" << cof.tag << "'\n";
|
||||
}
|
||||
|
||||
if (cof.playSubtags) {
|
||||
std::cout << " - Play subtags & repeats\n";
|
||||
}
|
||||
|
||||
if (cof.hasSlice()) {
|
||||
std::cout << " - Slice: '" << cof.slice << "'\n";
|
||||
}
|
||||
|
@ -494,29 +494,28 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
|
||||
|
||||
{
|
||||
RestoreVisibleLayers layersVisibility;
|
||||
Site site = context->activeSite();
|
||||
if (context->isUIAvailable()) {
|
||||
Site site = context->activeSite();
|
||||
|
||||
// Selected layers to export
|
||||
calculate_visible_layers(site,
|
||||
layers,
|
||||
layersIndex,
|
||||
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
|
||||
params().aniDir(aniDirValue);
|
||||
if (!bounds.isEmpty())
|
||||
|
Loading…
Reference in New Issue
Block a user