One_Eleven_Android/scripts/CustomControls/GalleryMusicPlayer.gd
2024-11-10 03:34:28 +03:00

39 lines
876 B
GDScript

extends Control
onready var playIcon = preload("res://resources/graphics/GUI/Gallery/Play.webp")
onready var stopIcon = preload("res://resources/graphics/GUI/Gallery/Stop.webp")
var musicPath;
var unlocked;
var state = false;
signal PlayerStarted;
func Init(object, index:int):
state = false
var name = object["name"];
unlocked = GallerySingleton.HaveMusic(name)
if unlocked:
$Label.text = str("%02d" % index, " ", name);
musicPath = object["path"];
else :
$Label.text = tr("ui_gallery_locked");
func _on_Button_pressed():
if not unlocked:
return ;
state = not state;
DrawButtonIcon();
emit_signal("PlayerStarted");
func DrawButtonIcon():
if state:
$Button.icon = stopIcon;
else :
$Button.icon = playIcon;
func GetAudioStream()->AudioStream:
if not ResourceLoader.exists(musicPath):
return null
var stream = load(musicPath);
return stream;