From 16362cc5112663c11d890684e24e9c1d2e959f1e Mon Sep 17 00:00:00 2001 From: Gaspar Capello Date: Mon, 26 Sep 2022 12:49:14 -0300 Subject: [PATCH] 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. --- src/app/file/file.cpp | 3 ++- src/app/filename_formatter.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/file/file.cpp b/src/app/file/file.cpp index c201ddedd..a0566e672 100644 --- a/src/app/file/file.cpp +++ b/src/app/file/file.cpp @@ -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)); diff --git a/src/app/filename_formatter.cpp b/src/app/filename_formatter.cpp index f2a980228..49ce4c5b5 100644 --- a/src/app/filename_formatter.cpp +++ b/src/app/filename_formatter.cpp @@ -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); }