mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-12-18 13:04:42 -05:00
Importing spritesheets is possible again
This commit is contained in:
parent
181230cb3f
commit
13613703fc
5 changed files with 156 additions and 24 deletions
|
|
@ -1,14 +1,21 @@
|
|||
extends ConfirmationDialog
|
||||
|
||||
|
||||
enum ImageImportOptions {NEW_TAB, SPRITESHEET, NEW_FRAME, NEW_LAYER, PALETTE}
|
||||
|
||||
var path : String
|
||||
var image : Image
|
||||
var current_import_option : int = ImageImportOptions.NEW_TAB
|
||||
var spritesheet_horizontal := 1
|
||||
var spritesheet_vertical := 1
|
||||
|
||||
onready var spritesheet_options = $VBoxContainer/HBoxContainer/SpritesheetOptions
|
||||
|
||||
|
||||
func _on_PreviewDialog_about_to_show() -> void:
|
||||
var img_texture := ImageTexture.new()
|
||||
img_texture.create_from_image(image)
|
||||
get_node("CenterContainer/TextureRect").texture = img_texture
|
||||
get_node("VBoxContainer/CenterContainer/TextureRect").texture = img_texture
|
||||
|
||||
|
||||
func _on_PreviewDialog_popup_hide() -> void:
|
||||
|
|
@ -16,4 +23,23 @@ func _on_PreviewDialog_popup_hide() -> void:
|
|||
|
||||
|
||||
func _on_PreviewDialog_confirmed() -> void:
|
||||
OpenSave.open_image_file(path, image)
|
||||
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)
|
||||
|
||||
|
||||
func _on_ImportOption_item_selected(id : int) -> void:
|
||||
current_import_option = id
|
||||
if id == ImageImportOptions.SPRITESHEET:
|
||||
spritesheet_options.visible = true
|
||||
else:
|
||||
spritesheet_options.visible = false
|
||||
|
||||
|
||||
func _on_HorizontalFrames_value_changed(value) -> void:
|
||||
spritesheet_horizontal = value
|
||||
|
||||
|
||||
func _on_VerticalFrames_value_changed(value) -> void:
|
||||
spritesheet_vertical = value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue