From c0ac9208ff281c567a22f18d8312915f01337d1d Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 27 Nov 2020 19:27:13 -0300 Subject: [PATCH] Fix layer name for new sprites to match the translation in new layer (fix #2549) --- data/strings/en.ini | 2 ++ src/app/commands/cmd_new_file.cpp | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/data/strings/en.ini b/data/strings/en.ini index 4fe4d0541..2f82ed1a3 100644 --- a/data/strings/en.ini +++ b/data/strings/en.ini @@ -336,6 +336,8 @@ MoveMask_Content = Selection Content NewBrush = New Brush NewFile = New File NewFile_FromClipboard = New File from Clipboard +NewFile_Sprite = Sprite +NewFile_BackgroundLayer = Background NewFrame = New Frame NewFrame_NewEmptyFrame = New Empty Frame NewFrame_DuplicateCels = Duplicate Cels w/Layer Mode diff --git a/src/app/commands/cmd_new_file.cpp b/src/app/commands/cmd_new_file.cpp index 0089157da..ae1d9cfe6 100644 --- a/src/app/commands/cmd_new_file.cpp +++ b/src/app/commands/cmd_new_file.cpp @@ -235,12 +235,11 @@ void NewFileCommand::onExecute(Context* ctx) if (sprite->colorMode() != ColorMode::GRAYSCALE) get_default_palette()->copyColorsTo(sprite->palette(frame_t(0))); - // If the background color isn't transparent, we have to - // convert the `Layer 1' in a `Background' - if (bgColor.getType() != app::Color::MaskType) { - Layer* layer = sprite->root()->firstLayer(); - - if (layer && layer->isImage()) { + Layer* layer = sprite->root()->firstLayer(); + if (layer && layer->isImage()) { + // If the background color isn't transparent, we have to + // convert the `Layer 1' in a `Background' + if (bgColor.getType() != app::Color::MaskType) { LayerImage* layerImage = static_cast(layer); layerImage->configureAsBackground(); @@ -261,11 +260,8 @@ void NewFileCommand::onExecute(Context* ctx) set_current_palette(&oldPal, false); } - } #ifdef ENABLE_UI - else if (clipboardImage) { - Layer* layer = sprite->root()->firstLayer(); - if (layer && layer->isImage()) { + else if (clipboardImage) { LayerImage* layerImage = static_cast(layer); // layerImage->configureAsBackground(); @@ -279,13 +275,19 @@ void NewFileCommand::onExecute(Context* ctx) } sprite->setPalette(&clipboardPalette, false); } - } #endif // ENABLE_UI + if (layer->isBackground()) + layer->setName(Strings::commands_NewFile_BackgroundLayer()); + else + layer->setName(fmt::format("{} {}", Strings::commands_NewLayer_Layer(), 1)); + } + // Show the sprite to the user std::unique_ptr doc(new Doc(sprite.get())); sprite.release(); - doc->setFilename(fmt::format("Sprite-{:04d}", ++g_spriteCounter)); + doc->setFilename(fmt::format("{}-{:04d}", + Strings::commands_NewFile_Sprite(), ++g_spriteCounter)); doc->setContext(ctx); doc.release(); }