mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-26 13:44:44 -04: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
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
[node name="PreviewDialog" type="ConfirmationDialog"]
|
||||
margin_right = 200.0
|
||||
margin_bottom = 70.0
|
||||
rect_min_size = Vector2( 400, 70 )
|
||||
rect_min_size = Vector2( 550, 70 )
|
||||
popup_exclusive = true
|
||||
resizable = true
|
||||
script = ExtResource( 1 )
|
||||
|
@ -13,19 +13,27 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = -8.0
|
||||
margin_bottom = 308.0
|
||||
margin_bottom = -36.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="CenterContainer"]
|
||||
margin_left = 42.0
|
||||
margin_right = 342.0
|
||||
[node name="CenterContainer" type="CenterContainer" parent="VBoxContainer"]
|
||||
margin_right = 534.0
|
||||
margin_bottom = 300.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/CenterContainer"]
|
||||
margin_left = 117.0
|
||||
margin_right = 417.0
|
||||
margin_bottom = 300.0
|
||||
rect_min_size = Vector2( 300, 300 )
|
||||
expand = true
|
||||
|
@ -33,6 +41,63 @@ stretch_mode = 6
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 304.0
|
||||
margin_right = 534.0
|
||||
margin_bottom = 324.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_top = 3.0
|
||||
margin_right = 66.0
|
||||
margin_bottom = 17.0
|
||||
text = "Import as:"
|
||||
|
||||
[node name="ImportOption" type="OptionButton" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_left = 70.0
|
||||
margin_right = 151.0
|
||||
margin_bottom = 20.0
|
||||
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, true, 4, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="SpritesheetOptions" type="HBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
visible = false
|
||||
margin_left = 155.0
|
||||
margin_right = 533.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/SpritesheetOptions"]
|
||||
margin_top = 5.0
|
||||
margin_right = 118.0
|
||||
margin_bottom = 19.0
|
||||
text = "Horizontal frames:"
|
||||
|
||||
[node name="HorizontalFrames" type="SpinBox" parent="VBoxContainer/HBoxContainer/SpritesheetOptions"]
|
||||
margin_left = 122.0
|
||||
margin_right = 196.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = 1.0
|
||||
value = 1.0
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/SpritesheetOptions"]
|
||||
margin_left = 200.0
|
||||
margin_top = 5.0
|
||||
margin_right = 300.0
|
||||
margin_bottom = 19.0
|
||||
text = "Vertical frames:"
|
||||
|
||||
[node name="VerticalFrames" type="SpinBox" parent="VBoxContainer/HBoxContainer/SpritesheetOptions"]
|
||||
margin_left = 304.0
|
||||
margin_right = 378.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 2
|
||||
min_value = 1.0
|
||||
value = 1.0
|
||||
[connection signal="about_to_show" from="." to="." method="_on_PreviewDialog_about_to_show"]
|
||||
[connection signal="confirmed" from="." to="." method="_on_PreviewDialog_confirmed"]
|
||||
[connection signal="popup_hide" from="." to="." method="_on_PreviewDialog_popup_hide"]
|
||||
[connection signal="item_selected" from="VBoxContainer/HBoxContainer/ImportOption" to="." method="_on_ImportOption_item_selected"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpritesheetOptions/HorizontalFrames" to="." method="_on_HorizontalFrames_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpritesheetOptions/VerticalFrames" to="." method="_on_VerticalFrames_value_changed"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue