mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Added import image as a new frame of the current project
Will also add a way to let the user choose which layer the new cel of the imported image will be.
This commit is contained in:
parent
597fdbc0c0
commit
f260971056
|
@ -354,6 +354,27 @@ func open_image_as_spritesheet(path : String, image : Image, horizontal : int, v
|
|||
set_new_tab(project, path)
|
||||
|
||||
|
||||
func open_image_as_new_frame(image : Image, layer_index := 0) -> void:
|
||||
var project = Global.current_project
|
||||
image.crop(project.size.x, project.size.y)
|
||||
|
||||
var frame := Frame.new()
|
||||
for i in project.layers.size():
|
||||
if i == layer_index:
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
image.lock()
|
||||
frame.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()
|
||||
frame.cels.append(Cel.new(empty_image, 1))
|
||||
|
||||
project.frames.append(frame)
|
||||
project.frames = project.frames # Just to call frames_changed()
|
||||
project.current_frame = project.frames.size() - 1
|
||||
|
||||
|
||||
func set_new_tab(project : Project, path : String) -> void:
|
||||
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
|
||||
Global.canvas.camera_zoom()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extends ConfirmationDialog
|
||||
|
||||
|
||||
enum ImageImportOptions {NEW_TAB, SPRITESHEET, NEW_FRAME, NEW_LAYER, PALETTE}
|
||||
enum ImageImportOptions {NEW_TAB, SPRITESHEET, NEW_FRAME, NEW_LAYER, PALETTE, BRUSH, PATTERN}
|
||||
|
||||
var path : String
|
||||
var image : Image
|
||||
|
@ -35,6 +35,8 @@ func _on_PreviewDialog_confirmed() -> void:
|
|||
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:
|
||||
OpenSave.open_image_as_new_frame(image)
|
||||
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, true, 2, null, "New layer", null, true, 3, null, "New palette", null, false, 4, null ]
|
||||
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 ]
|
||||
selected = 0
|
||||
|
||||
[node name="SpritesheetOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
|
|
Loading…
Reference in a new issue