diff --git a/UI/Panels/User/internal_user_live.gd b/UI/Panels/User/internal_user_live.gd index 6fb19b05..60152d9d 100644 --- a/UI/Panels/User/internal_user_live.gd +++ b/UI/Panels/User/internal_user_live.gd @@ -1,10 +1,14 @@ extends PanelContainer +var _offline_color := Color.html("d36dff4e") +var _offline_no_thumbnail := preload("res://assets/bootstrap/twitch_large.svg") + var chatter: Chatter: set(value): chatter = value if not chatter: live = null + clear() return live = Globals.live_streamers[chatter.twitch_id] if chatter.twitch_id in Globals.live_streamers.keys() else null _populate_view() @@ -17,21 +21,44 @@ var _ticks: int = 0 func _ready() -> void: %StreamTitle.pressed.connect(_open_stream) %RaidCurrentUser.pressed.connect(_raid_stream) - if not chatter: return + if not chatter: + clear() + return if not live and chatter.twitch_id in Globals.live_streamers.keys(): live = Globals.live_streamers[chatter.twitch_id] _populate_view() + elif not live: + clear() + return + +func clear() -> void: + %StreamTitle.text = "Not Live" + %StreamViewerCount.text = "0" + %StreamTime.text = "00:00:00" + %StreamThumbnail.visible = false + %OfflineThumbnail.visible = true + %NoThumbText.visible = true + if chatter: + if chatter.user.offline_image_url != "": + %OfflineThumbnail.texture = await ImageLoader.load_image(chatter.user.offline_image_url) + %OfflineThumbnail.self_modulate = Color.WHITE + %NoThumbText.visible = false + return + %OfflineThumbnail.texture = _offline_no_thumbnail + %OfflineThumbnail.self_modulate = _offline_color func _populate_view() -> void: if not live: set_process(false) + clear() return set_process(true) %StreamTitle.text = live.title %StreamViewerCount.text = str(live.viewer_count) var url := live.thumbnail_url.format({"width": 640, "height": 360}) - var img = await Globals.twitcher.media.load_image(url) - %StreamThumbnail.texture = ImageTexture.create_from_image(img) + %StreamThumbnail.texture = await ImageLoader.load_image(url) + %StreamThumbnail.visible = true + %OfflineThumbnail.visible = false func _process(_d: float) -> void: if not live: diff --git a/UI/Panels/User/internal_user_live.tscn b/UI/Panels/User/internal_user_live.tscn index 02702326..fa5e48d6 100644 --- a/UI/Panels/User/internal_user_live.tscn +++ b/UI/Panels/User/internal_user_live.tscn @@ -2,8 +2,12 @@ [ext_resource type="Script" uid="uid://cdtfvedghei5f" path="res://UI/Panels/User/internal_user_live.gd" id="1_rl2q8"] [ext_resource type="Texture2D" uid="uid://b3372gsnwqsyn" path="res://assets/bootstrap/twitch.svg" id="1_sw5jj"] +[ext_resource type="Texture2D" uid="uid://bvmx86tvio46h" path="res://assets/bootstrap/twitch_large.svg" id="2_lcbo3"] [ext_resource type="Texture2D" uid="uid://bu2juj2beyws7" path="res://assets/twitch_user_profile_pic.png" id="2_rl2q8"] +[sub_resource type="LabelSettings" id="LabelSettings_2ohcs"] +font_size = 72 + [node name="InternalUserLive" type="PanelContainer" unique_id=17956466] anchors_preset = 15 anchor_right = 1.0 @@ -26,11 +30,38 @@ size_flags_vertical = 3 [node name="StreamThumbnail" type="TextureRect" parent="VBoxContainer/HBoxContainer" unique_id=641456832] unique_name_in_owner = true +visible = false layout_mode = 2 size_flags_horizontal = 3 expand_mode = 1 stretch_mode = 5 +[node name="OfflineThumbnail" type="TextureRect" parent="VBoxContainer/HBoxContainer" unique_id=924088665] +unique_name_in_owner = true +self_modulate = Color(0.827451, 0.42745098, 1, 0.30588236) +layout_mode = 2 +size_flags_horizontal = 3 +texture = ExtResource("2_lcbo3") +expand_mode = 1 +stretch_mode = 5 + +[node name="NoThumbText" type="Label" parent="VBoxContainer/HBoxContainer/OfflineThumbnail" unique_id=1187072643] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -11.5 +offset_right = 20.0 +offset_bottom = 11.5 +grow_horizontal = 2 +grow_vertical = 2 +text = "Stream Offline" +label_settings = SubResource("LabelSettings_2ohcs") + [node name="UserChat" type="PanelContainer" parent="VBoxContainer/HBoxContainer" unique_id=1609959534] unique_name_in_owner = true visible = false