74 lines
1.9 KiB
GDScript
74 lines
1.9 KiB
GDScript
extends Control
|
|
|
|
signal galleryPressed;
|
|
|
|
var unlocked;
|
|
var sceneName;
|
|
var path;
|
|
|
|
|
|
func _ready():
|
|
pass
|
|
|
|
func Init(content, type):
|
|
sceneName = content["name"]
|
|
|
|
if content.has("multi"):
|
|
var multi = content["multi"];
|
|
|
|
for i in multi:
|
|
if GallerySingleton.HaveImage(i):
|
|
unlocked = true;
|
|
$TextureRect.texture = load(str("res://resources/graphics/Gallery/Images/", i, ".webp"));
|
|
$TextureRect.material = $TextureRect.material.duplicate()
|
|
return ;
|
|
|
|
unlocked = false;
|
|
$TextureRect.texture = load("res://resources/graphics/Gallery/locked.webp")
|
|
return ;
|
|
|
|
if content.has("multiB"):
|
|
var multi = content["multiB"];
|
|
|
|
for i in multi:
|
|
if GallerySingleton.HaveBackground(i):
|
|
unlocked = true;
|
|
$TextureRect.texture = load(str("res://resources/graphics/Gallery/Backgrounds/", i, ".webp"));
|
|
$TextureRect.material = $TextureRect.material.duplicate()
|
|
return ;
|
|
|
|
unlocked = false;
|
|
$TextureRect.texture = load("res://resources/graphics/Gallery/locked.webp")
|
|
return
|
|
|
|
if type == "background":
|
|
unlocked = GallerySingleton.HaveBackground(sceneName);
|
|
else :
|
|
unlocked = GallerySingleton.HaveImage(sceneName);
|
|
|
|
if unlocked:
|
|
path = content["path"];
|
|
$TextureRect.texture = load(path);
|
|
$TextureRect.material = $TextureRect.material.duplicate()
|
|
else :
|
|
$TextureRect.texture = load("res://resources/graphics/Gallery/locked.webp")
|
|
|
|
func setShaderOn():
|
|
if unlocked:
|
|
$TextureRect.material.set_shader_param("mixing", 0.15);
|
|
|
|
func setShaderOff():
|
|
if unlocked:
|
|
$TextureRect.material.set_shader_param("mixing", 0.0);
|
|
|
|
func _on_ResizeTimer_timeout():
|
|
var scale = 288.0 / $TextureRect.rect_size.x * 1.0;
|
|
$TextureRect.rect_scale = Vector2(scale, scale);
|
|
|
|
func _on_Control_gui_input(event):
|
|
if not unlocked:
|
|
return ;
|
|
|
|
if event is InputEventMouseButton:
|
|
if event.button_index == BUTTON_LEFT and event.pressed:
|
|
emit_signal("galleryPressed")
|