From 1f5e4cfc4f03c835010100c6011b220270b53dbe Mon Sep 17 00:00:00 2001 From: Gaspar Capello Date: Thu, 23 Jun 2022 15:52:51 -0300 Subject: [PATCH] Add '{title}' and '{layer}' functionality to the Export dialog (fix aseprite/aseprite#3363) Also Add '{title}' functionality to CLI dialog on sprite-sheet file name --- src/app/commands/cmd_save_file.cpp | 7 ++++++- src/app/doc_exporter.cpp | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/commands/cmd_save_file.cpp b/src/app/commands/cmd_save_file.cpp index 92bf030bb..ef5d18498 100644 --- a/src/app/commands/cmd_save_file.cpp +++ b/src/app/commands/cmd_save_file.cpp @@ -23,6 +23,7 @@ #include "app/file/gif_format.h" #include "app/file/png_format.h" #include "app/file_selector.h" +#include "app/filename_formatter.h" #include "app/i18n/strings.h" #include "app/job.h" #include "app/modules/gui.h" @@ -390,7 +391,11 @@ void SaveFileCopyAsCommand::onExecute(Context* context) if (!result) return; - outputFilename = win.outputFilenameValue(); + FilenameInfo fnInfo; + fnInfo + .filename(context->activeDocument()->name()) + .layerName(win.layersValue()); + outputFilename = filename_formatter(win.outputFilenameValue(), fnInfo); if (askOverwrite && base::is_file(outputFilename)) { diff --git a/src/app/doc_exporter.cpp b/src/app/doc_exporter.cpp index 5385394ef..fe3120025 100644 --- a/src/app/doc_exporter.cpp +++ b/src/app/doc_exporter.cpp @@ -689,6 +689,11 @@ Doc* DocExporter::exportSheet(Context* ctx, base::task_token& token) // Save the image files. if (!m_textureFilename.empty()) { DX_TRACE("DocExporter::exportSheet", m_textureFilename); + // filename_formatter usage to include {title} key word on CLI. + FilenameInfo fnInfo; + fnInfo.filename(ctx->activeDocument()->name()); + m_textureFilename = filename_formatter(m_textureFilename.c_str(), fnInfo); + textureDocument->setFilename(m_textureFilename.c_str()); int ret = save_document(ctx, textureDocument.get()); if (ret == 0)