Fix {duration} file format always gives an incorrect number (fix #2998)

Before this fix, the string '{duration}' in the file format gave an incorrect/random and constant number across all frames. This happened in Save-AS, Export File, CLI, Json on Export Sprite Sheet.
This commit is contained in:
Gaspar Capello 2022-09-26 12:49:14 -03:00 committed by David Capello
parent a85b61e4b1
commit 16362cc511
2 changed files with 4 additions and 2 deletions

View File

@ -676,7 +676,8 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
.outerTagName(outerTag ? outerTag->name(): "")
.frame(outputFrame)
.tagFrame(innerTag ? frame - innerTag->fromFrame():
outputFrame);
outputFrame)
.duration(spr->frameDuration(frame));
fop->m_seq.filename_list.push_back(
filename_formatter(fn_format, fnInfo));

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2022 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -112,12 +113,12 @@ std::string filename_formatter(
base::replace_string(output, "{layer}", info.layerName());
base::replace_string(output, "{group}", info.groupName());
base::replace_string(output, "{slice}", info.sliceName());
base::replace_string(output, "{duration}", std::to_string(info.duration()));
if (replaceFrame) {
base::replace_string(output, "{tag}", info.innerTagName());
base::replace_string(output, "{innertag}", info.innerTagName());
base::replace_string(output, "{outertag}", info.outerTagName());
base::replace_string(output, "{duration}", std::to_string(info.duration()));
replace_frame("{frame", info.frame(), output);
replace_frame("{tagframe", info.tagFrame(), output);
}