Fix layer name for new sprites to match the translation in new layer (fix #2549)

This commit is contained in:
David Capello 2020-11-27 19:27:13 -03:00
parent 85e51abcaa
commit c0ac9208ff
2 changed files with 16 additions and 12 deletions

View File

@ -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

View File

@ -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<LayerImage*>(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<LayerImage*>(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> 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();
}