StreamOverlay/UI/Shoutouts/shoutout.gd

40 lines
1.3 KiB
GDScript3
Raw Normal View History

extends Alert
var chatter: Chatter
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var rs := get_tree().root.size
position = Vector2(rs.x + 20, ((rs.y / 2.0) - (size.y / 2.0)))
if chatter == null:
return
var game_id: String = ""
if chatter.twitch_id in Globals.live_streamers.keys():
game_id = Globals.live_streamers[chatter.twitch_id].game_id
else:
var resp := await Globals.twitcher.get_channel_information(chatter.twitch_id)
if resp:
var tci: TwitchChannelInformation = resp[chatter.twitch_id]
game_id = tci.game_id
var gresp := await Globals.twitcher.get_games(game_id)
var gd: TwitchGame
if gresp:
gd = gresp[game_id]
%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")
%DisplayName.text = chatter.user.display_name
%Message.text = Globals.settings.shoutout_alert_message.format({"target": chatter.user.display_name})
%GameBox.texture = await ImageLoader.load_image(gd.box_art_url.format({"width": 600, "height": 800}))
%GameName.text = gd.name
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)