mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-12-18 13:04:42 -05:00
Ability to import an image file as a pattern
Also moved some pattern importing code from Import.gd to Global.create_pattern_button()
This commit is contained in:
parent
a8de56ed68
commit
8e2fe8dac3
4 changed files with 30 additions and 10 deletions
|
|
@ -35,18 +35,24 @@ func _on_PreviewDialog_popup_hide() -> void:
|
|||
func _on_PreviewDialog_confirmed() -> void:
|
||||
if current_import_option == ImageImportOptions.NEW_TAB:
|
||||
OpenSave.open_image_as_new_tab(path, image)
|
||||
|
||||
elif current_import_option == ImageImportOptions.SPRITESHEET:
|
||||
OpenSave.open_image_as_spritesheet(path, image, spritesheet_horizontal, spritesheet_vertical)
|
||||
|
||||
elif current_import_option == ImageImportOptions.NEW_FRAME:
|
||||
var layer_index : int = new_frame_options.get_node("AtLayerSpinbox").value
|
||||
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_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()
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
Global.file_brushes.append(image)
|
||||
Global.create_brush_button(image, Global.Brush_Types.FILE, file_name)
|
||||
|
||||
|
|
@ -55,6 +61,17 @@ func _on_PreviewDialog_confirmed() -> void:
|
|||
var dir = Directory.new()
|
||||
dir.copy(path, Global.directory_module.xdg_data_home.plus_file(location))
|
||||
|
||||
elif current_import_option == ImageImportOptions.PATTERN:
|
||||
var file_name : String = path.get_basename().get_file()
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
Global.patterns.append(image)
|
||||
Global.create_pattern_button(image, file_name)
|
||||
|
||||
# Copy the image file into the "pixelorama/Patterns" directory
|
||||
var location := "Patterns".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:
|
||||
current_import_option = id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue