mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-26 13:34:42 -04:00
Added a preview dialog that opens every time the user imports an image file
The dialog does not appear on .pxo files. Import options will be added on it soon.
This commit is contained in:
parent
7219a5a274
commit
57d4156341
3 changed files with 72 additions and 10 deletions
19
src/UI/Dialogs/PreviewDialog.gd
Normal file
19
src/UI/Dialogs/PreviewDialog.gd
Normal file
|
@ -0,0 +1,19 @@
|
|||
extends ConfirmationDialog
|
||||
|
||||
|
||||
var path : String
|
||||
var image : Image
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
func _on_PreviewDialog_popup_hide() -> void:
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_PreviewDialog_confirmed() -> void:
|
||||
OpenSave.open_image_file(path, image)
|
38
src/UI/Dialogs/PreviewDialog.tscn
Normal file
38
src/UI/Dialogs/PreviewDialog.tscn
Normal file
|
@ -0,0 +1,38 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/UI/Dialogs/PreviewDialog.gd" type="Script" id=1]
|
||||
|
||||
[node name="PreviewDialog" type="ConfirmationDialog"]
|
||||
margin_right = 200.0
|
||||
margin_bottom = 70.0
|
||||
rect_min_size = Vector2( 400, 70 )
|
||||
popup_exclusive = true
|
||||
resizable = true
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = -8.0
|
||||
margin_bottom = 308.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="CenterContainer"]
|
||||
margin_left = 42.0
|
||||
margin_right = 342.0
|
||||
margin_bottom = 300.0
|
||||
rect_min_size = Vector2( 300, 300 )
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
[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"]
|
Loading…
Add table
Add a link
Reference in a new issue