From a8de56ed6889aa09dadf93dc47b88bbd967da8ef Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Tue, 23 Jun 2020 21:59:47 +0300 Subject: [PATCH] Ability to import an image file as a brush Works only for file brushes at the moment. The image files gets copied into the "pixelorama/Brushes" directory. --- Translations/Translations.pot | 12 ++++++++++++ src/UI/Dialogs/PreviewDialog.gd | 11 ++++++++++- src/UI/Dialogs/PreviewDialog.tscn | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Translations/Translations.pot b/Translations/Translations.pot index e924d8929..a07244cdd 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -160,6 +160,12 @@ msgstr "" msgid "New palette" msgstr "" +msgid "New brush" +msgstr "" + +msgid "New pattern" +msgstr "" + msgid "Horizontal frames:" msgstr "" @@ -473,6 +479,12 @@ msgstr "" msgid "Turkish" msgstr "" +msgid "Norwegian" +msgstr "" + +msgid "Korean" +msgstr "" + msgid "Development Team" msgstr "" diff --git a/src/UI/Dialogs/PreviewDialog.gd b/src/UI/Dialogs/PreviewDialog.gd index f5601f140..a53275e34 100644 --- a/src/UI/Dialogs/PreviewDialog.gd +++ b/src/UI/Dialogs/PreviewDialog.gd @@ -42,9 +42,18 @@ func _on_PreviewDialog_confirmed() -> void: OpenSave.open_image_as_new_frame(image, layer_index) elif current_import_option == ImageImportOptions.NEW_LAYER: var frame_index : int = new_layer_options.get_node("AtFrameSpinbox").value - 1 - OpenSave.open_image_as_new_layer(image, path.get_file(), frame_index) + OpenSave.open_image_as_new_layer(image, path.get_basename().get_file(), frame_index) elif current_import_option == ImageImportOptions.PALETTE: Global.palette_container.on_palette_import_file_selected(path) + elif current_import_option == ImageImportOptions.BRUSH: + var file_name : String = path.get_basename().get_file() + Global.file_brushes.append(image) + Global.create_brush_button(image, Global.Brush_Types.FILE, file_name) + + # Copy the image file into the "pixelorama/Brushes" directory + var location := "Brushes".plus_file(path.get_file()) + var dir = Directory.new() + dir.copy(path, Global.directory_module.xdg_data_home.plus_file(location)) func _on_ImportOption_item_selected(id : int) -> void: diff --git a/src/UI/Dialogs/PreviewDialog.tscn b/src/UI/Dialogs/PreviewDialog.tscn index 596a186a3..a1834c979 100644 --- a/src/UI/Dialogs/PreviewDialog.tscn +++ b/src/UI/Dialogs/PreviewDialog.tscn @@ -64,7 +64,7 @@ margin_right = 151.0 margin_bottom = 20.0 mouse_default_cursor_shape = 2 text = "New tab" -items = [ "New tab", null, false, 0, null, "Spritesheet (new tab)", null, false, 1, null, "New frame", null, false, 2, null, "New layer", null, false, 3, null, "New palette", null, false, 4, null, "New brush", null, true, 5, null, "New pattern", null, true, 6, null ] +items = [ "New tab", null, false, 0, null, "Spritesheet (new tab)", null, false, 1, null, "New frame", null, false, 2, null, "New layer", null, false, 3, null, "New palette", null, false, 4, null, "New brush", null, false, 5, null, "New pattern", null, true, 6, null ] selected = 0 [node name="SpritesheetOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]