StreamOverlay/UI/Shoutouts/promote.gd

51 lines
1.5 KiB
GDScript3
Raw Normal View History

extends Alert
var chatter: Chatter
var itch: ItchIOAppData
var steam: SteamAppData
var _updating_size: bool = false
func _ready() -> void:
get_child(0).item_rect_changed.connect(func():
if _updating_size:
return
_updating_size = true
size = get_child(0).size
get_child(0).position = Vector2.ZERO
_updating_size = false
)
var rs := get_tree().root.size
position = Vector2(rs.x + 1000, ((rs.y / 2.0) - (size.y / 2.0)))
if not ((chatter and itch) or (chatter and steam)):
push_error("No chatter or game data set!")
await get_tree().create_timer(1.0).timeout
queue_free()
return
%AvatarImg.texture = await ImageLoader.load_image(chatter.user.profile_image_url)
if %AvatarImg.texture == null:
%AvatarImg.texture = preload("res://assets/twitch_user_profile_pic.png")
if itch:
_populate_itch()
else:
_populate_steam()
await get_tree().process_frame
position = Vector2(rs.x + 20, ((rs.y / 2.0) - (size.y / 2.0)))
var tw := create_tween()
tw.tween_property(self, ^"position:x", rs.x - size.x - 20, 0.6)
tw.tween_interval(8)
tw.tween_property(self, ^"position:x", rs.x + 20, 0.6)
tw.tween_callback(self.queue_free)
func _populate_itch() -> void:
%GameName.text = itch.title
%Description.text = itch.description
%GameBox.texture = await ImageLoader.load_image(itch.screenshots_thumbnails[0])
func _populate_steam() -> void:
%GameName.text = steam.name
%Description.text = steam.short_description
%GameBox.texture = await ImageLoader.load_image(steam.screenshots_thumbs[0])