mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-03 21:46:20 +00:00
Automatic split layers/tags if we use {layer} or {tag} in --save-as (fix #1149)
This commit is contained in:
parent
617afaed78
commit
04f67a1697
@ -198,8 +198,27 @@ void CliProcessor::process()
|
||||
// --save-as <filename>
|
||||
else if (opt == &m_options.saveAs()) {
|
||||
if (lastDoc) {
|
||||
std::string fn = value.value();
|
||||
|
||||
// Automatic --split-layer or --split-tags in case the
|
||||
// output filename already contains {layer} or {tag}
|
||||
// template elements.
|
||||
bool hasLayerTemplate = (fn.find("{layer}") != std::string::npos);
|
||||
bool hasTagTemplate = (fn.find("{tag}") != std::string::npos);
|
||||
if (hasLayerTemplate || hasTagTemplate) {
|
||||
cof.splitLayers = (cof.splitLayers || hasLayerTemplate);
|
||||
cof.splitTags = (cof.splitTags || hasTagTemplate);
|
||||
cof.filenameFormat =
|
||||
get_default_filename_format(
|
||||
fn,
|
||||
true, // With path
|
||||
(lastDoc->sprite()->totalFrames() > 1), // Has frames
|
||||
false, // Has layer
|
||||
false); // Has frame tag
|
||||
}
|
||||
|
||||
cof.document = lastDoc;
|
||||
cof.filename = value.value();
|
||||
cof.filename = fn;
|
||||
saveFile(cof);
|
||||
}
|
||||
else
|
||||
|
@ -123,12 +123,16 @@ std::string get_default_filename_format(
|
||||
if (hasFrameTag)
|
||||
format += " #{tag}";
|
||||
|
||||
if (hasFrames && is_static_image_format(filename)) {
|
||||
const bool autoFrameFromLastDigit = (!hasLayer && !hasFrameTag);
|
||||
int frameBase = -1, frameWidth = 0;
|
||||
if (hasFrames && is_static_image_format(filename) &&
|
||||
filename.find("{frame") == std::string::npos &&
|
||||
filename.find("{tagframe") == std::string::npos) {
|
||||
const bool autoFrameFromLastDigit =
|
||||
(!hasLayer &&
|
||||
!hasFrameTag);
|
||||
|
||||
// Check if we already have a frame number at the end of the
|
||||
// filename (e.g. output01.png)
|
||||
int frameBase = -1, frameWidth = 0;
|
||||
std::string left, right;
|
||||
if (autoFrameFromLastDigit)
|
||||
frameBase = split_filename(filename.c_str(), left, right, frameWidth);
|
||||
|
Loading…
Reference in New Issue
Block a user