mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-03-12 22:35:18 +00:00
Added import image as a new layer of the current project
Just realized that I forgot to add undo/redo support of importing images as new frame/layer, oops. Will fix next.
This commit is contained in:
parent
f260971056
commit
40a01f1da3
3 changed files with 26 additions and 1 deletions
|
@ -373,6 +373,29 @@ func open_image_as_new_frame(image : Image, layer_index := 0) -> void:
|
|||
project.frames.append(frame)
|
||||
project.frames = project.frames # Just to call frames_changed()
|
||||
project.current_frame = project.frames.size() - 1
|
||||
project.current_layer = layer_index
|
||||
|
||||
|
||||
func open_image_as_new_layer(image : Image, file_name : String, frame_index := 0) -> void:
|
||||
var project = Global.current_project
|
||||
image.crop(project.size.x, project.size.y)
|
||||
|
||||
var layer := Layer.new(file_name)
|
||||
for i in project.frames.size():
|
||||
if i == frame_index:
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
image.lock()
|
||||
project.frames[i].cels.append(Cel.new(image, 1))
|
||||
else:
|
||||
var empty_image := Image.new()
|
||||
empty_image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_image.lock()
|
||||
project.frames[i].cels.append(Cel.new(empty_image, 1))
|
||||
|
||||
project.layers.append(layer)
|
||||
project.layers = project.layers # Just to call layers_changed()
|
||||
project.current_layer = project.layers.size() - 1
|
||||
project.current_frame = frame_index
|
||||
|
||||
|
||||
func set_new_tab(project : Project, path : String) -> void:
|
||||
|
|
|
@ -37,6 +37,8 @@ func _on_PreviewDialog_confirmed() -> void:
|
|||
OpenSave.open_image_as_spritesheet(path, image, spritesheet_horizontal, spritesheet_vertical)
|
||||
elif current_import_option == ImageImportOptions.NEW_FRAME:
|
||||
OpenSave.open_image_as_new_frame(image)
|
||||
elif current_import_option == ImageImportOptions.NEW_LAYER:
|
||||
OpenSave.open_image_as_new_layer(image, path.get_file())
|
||||
elif current_import_option == ImageImportOptions.PALETTE:
|
||||
Global.palette_container.on_palette_import_file_selected(path)
|
||||
|
||||
|
|
|
@ -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, true, 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, true, 5, null, "New pattern", null, true, 6, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="SpritesheetOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
|
|
Loading…
Add table
Reference in a new issue