2019-08-04 09:57:42 +02:00
|
|
|
tool
|
|
|
|
extends FileDialog
|
|
|
|
|
2019-11-23 12:33:43 +01:00
|
|
|
onready var canvas = get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas")
|
2019-08-04 09:57:42 +02:00
|
|
|
|
|
|
|
var file_path = ""
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
get_line_edit().connect("text_entered", self, "_on_LineEdit_text_entered")
|
|
|
|
invalidate()
|
|
|
|
clear_filters()
|
|
|
|
add_filter("*.png ; PNG Images")
|
|
|
|
|
2019-11-23 12:33:43 +01:00
|
|
|
func save_file():
|
|
|
|
canvas.image.unlock()
|
|
|
|
canvas.image.save_png(file_path)
|
|
|
|
canvas.image.lock()
|
2019-08-04 09:57:42 +02:00
|
|
|
|
|
|
|
func _on_LineEdit_text_entered(text):
|
|
|
|
save_file()
|
|
|
|
|
|
|
|
func _on_SaveFileDialog_confirmed():
|
|
|
|
save_file()
|
|
|
|
|
2019-11-23 12:33:43 +01:00
|
|
|
func _on_SaveFileDialog_file_selected(path):
|
|
|
|
file_path = path
|
2019-08-04 09:57:42 +02:00
|
|
|
|
|
|
|
func _on_SaveFileDialog_about_to_show():
|
|
|
|
invalidate()
|
|
|
|
|
|
|
|
func _on_SaveFileDialog_visibility_changed():
|
|
|
|
invalidate()
|