add ai, photo_mode and radio
This commit was merged in pull request #11.
This commit is contained in:
27
core/photo_mode/ui/photo_gallery.gd
Normal file
27
core/photo_mode/ui/photo_gallery.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends Control
|
||||
|
||||
@export var photo_scene: PackedScene
|
||||
|
||||
@onready var grid_container: GridContainer = $%PhotoGrid
|
||||
|
||||
func _ready() -> void:
|
||||
CollectionManager.on_photo_saved.connect(_create_photo_thumbnail)
|
||||
load_gallery()
|
||||
|
||||
func load_gallery() -> void:
|
||||
for child in grid_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
var saved_photos = CollectionManager.saved_photos
|
||||
|
||||
for file_path in saved_photos:
|
||||
if FileAccess.file_exists(file_path):
|
||||
_create_photo_thumbnail(file_path)
|
||||
|
||||
func _create_photo_thumbnail(file_path: String) -> void:
|
||||
var image = Image.load_from_file(file_path)
|
||||
if image:
|
||||
var photo: Photo = photo_scene.instantiate()
|
||||
var texture = ImageTexture.create_from_image(image)
|
||||
photo.setup(texture)
|
||||
grid_container.add_child(photo)
|
||||
Reference in New Issue
Block a user