2024-06-04 18:31:04 +02:00
|
|
|
extends Node2D
|
|
|
|
|
2024-12-19 18:52:47 +01:00
|
|
|
@onready var image_viewport = %ImageViewport
|
|
|
|
@onready var ui_control_filesave = %SaveImageDialog
|
|
|
|
|
2024-06-04 18:31:04 +02:00
|
|
|
|
|
|
|
func _ready():
|
2024-12-19 19:14:30 +01:00
|
|
|
DisplayServer.window_set_min_size(Vector2i(900, 500))
|
2024-06-04 21:05:46 +02:00
|
|
|
Globals.target_viewport = image_viewport
|
2024-06-04 18:31:04 +02:00
|
|
|
|
|
|
|
func _on_save_image_button_pressed():
|
2024-06-08 11:23:21 +02:00
|
|
|
if image_viewport.get_result() != null:
|
2024-12-19 18:52:47 +01:00
|
|
|
ui_control_filesave.current_path = Globals.last_image_savepath
|
2024-06-08 11:23:21 +02:00
|
|
|
ui_control_filesave.show()
|
2024-06-04 18:31:04 +02:00
|
|
|
|
2024-06-08 11:23:21 +02:00
|
|
|
func _on_save_image_dialog_file_selected(path):
|
2024-06-21 10:33:34 +02:00
|
|
|
print("Export ", path)
|
2024-06-04 21:05:46 +02:00
|
|
|
var err = image_viewport.get_result().save_png(path)
|
2024-06-04 18:31:04 +02:00
|
|
|
if err != OK:
|
|
|
|
print("An error occured!")
|
2024-06-09 14:48:27 +02:00
|
|
|
else:
|
2024-12-19 18:52:47 +01:00
|
|
|
Globals.last_image_savepath = path
|