Updated InternalUserLive
Added Offline details to Live panel. When user has an Offline Image, we load the image to display in the Stream Preview, otherwise we do a Generic Twitch Logo, with text saying the Stream is Offline.
This commit is contained in:
parent
23fdd1e972
commit
cc01a207fc
2 changed files with 61 additions and 3 deletions
|
|
@ -1,10 +1,14 @@
|
||||||
extends PanelContainer
|
extends PanelContainer
|
||||||
|
|
||||||
|
var _offline_color := Color.html("d36dff4e")
|
||||||
|
var _offline_no_thumbnail := preload("res://assets/bootstrap/twitch_large.svg")
|
||||||
|
|
||||||
var chatter: Chatter:
|
var chatter: Chatter:
|
||||||
set(value):
|
set(value):
|
||||||
chatter = value
|
chatter = value
|
||||||
if not chatter:
|
if not chatter:
|
||||||
live = null
|
live = null
|
||||||
|
clear()
|
||||||
return
|
return
|
||||||
live = Globals.live_streamers[chatter.twitch_id] if chatter.twitch_id in Globals.live_streamers.keys() else null
|
live = Globals.live_streamers[chatter.twitch_id] if chatter.twitch_id in Globals.live_streamers.keys() else null
|
||||||
_populate_view()
|
_populate_view()
|
||||||
|
|
@ -17,21 +21,44 @@ var _ticks: int = 0
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
%StreamTitle.pressed.connect(_open_stream)
|
%StreamTitle.pressed.connect(_open_stream)
|
||||||
%RaidCurrentUser.pressed.connect(_raid_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():
|
if not live and chatter.twitch_id in Globals.live_streamers.keys():
|
||||||
live = Globals.live_streamers[chatter.twitch_id]
|
live = Globals.live_streamers[chatter.twitch_id]
|
||||||
_populate_view()
|
_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:
|
func _populate_view() -> void:
|
||||||
if not live:
|
if not live:
|
||||||
set_process(false)
|
set_process(false)
|
||||||
|
clear()
|
||||||
return
|
return
|
||||||
set_process(true)
|
set_process(true)
|
||||||
%StreamTitle.text = live.title
|
%StreamTitle.text = live.title
|
||||||
%StreamViewerCount.text = str(live.viewer_count)
|
%StreamViewerCount.text = str(live.viewer_count)
|
||||||
var url := live.thumbnail_url.format({"width": 640, "height": 360})
|
var url := live.thumbnail_url.format({"width": 640, "height": 360})
|
||||||
var img = await Globals.twitcher.media.load_image(url)
|
%StreamThumbnail.texture = await ImageLoader.load_image(url)
|
||||||
%StreamThumbnail.texture = ImageTexture.create_from_image(img)
|
%StreamThumbnail.visible = true
|
||||||
|
%OfflineThumbnail.visible = false
|
||||||
|
|
||||||
func _process(_d: float) -> void:
|
func _process(_d: float) -> void:
|
||||||
if not live:
|
if not live:
|
||||||
|
|
|
||||||
|
|
@ -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="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://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"]
|
[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]
|
[node name="InternalUserLive" type="PanelContainer" unique_id=17956466]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
@ -26,11 +30,38 @@ size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="StreamThumbnail" type="TextureRect" parent="VBoxContainer/HBoxContainer" unique_id=641456832]
|
[node name="StreamThumbnail" type="TextureRect" parent="VBoxContainer/HBoxContainer" unique_id=641456832]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
stretch_mode = 5
|
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]
|
[node name="UserChat" type="PanelContainer" parent="VBoxContainer/HBoxContainer" unique_id=1609959534]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
visible = false
|
visible = false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue