Created UserLive Panel for Live tab
Created panel to show user live information, for when the user is live.
This commit is contained in:
parent
d1f7bccd15
commit
9328ba2356
3 changed files with 154 additions and 0 deletions
57
UI/Controls/internal_user_live.gd
Normal file
57
UI/Controls/internal_user_live.gd
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
extends PanelContainer
|
||||||
|
|
||||||
|
var chatter: Chatter:
|
||||||
|
set(value):
|
||||||
|
chatter = value
|
||||||
|
if not chatter:
|
||||||
|
live = null
|
||||||
|
return
|
||||||
|
live = Globals.live_streamers[chatter.twitch_id] if chatter.twitch_id in Globals.live_streamers.keys() else null
|
||||||
|
_populate_view()
|
||||||
|
|
||||||
|
var live: TwitchStream
|
||||||
|
|
||||||
|
var _ticks: int = 0
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
%StreamTitle.pressed.connect(_open_stream)
|
||||||
|
%RaidCurrentUser.pressed.connect(_raid_stream)
|
||||||
|
if not chatter: return
|
||||||
|
if not live and chatter.twitch_id in Globals.live_streamers.keys():
|
||||||
|
live = Globals.live_streamers[chatter.twitch_id]
|
||||||
|
_populate_view()
|
||||||
|
|
||||||
|
func _populate_view() -> void:
|
||||||
|
if not live:
|
||||||
|
set_process(false)
|
||||||
|
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)
|
||||||
|
|
||||||
|
func _process(_d: float) -> void:
|
||||||
|
if not live:
|
||||||
|
set_process(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
_ticks += 1
|
||||||
|
if _ticks < 30: return
|
||||||
|
_ticks = 0
|
||||||
|
|
||||||
|
var system_unix = Time.get_unix_time_from_system()
|
||||||
|
var stream_start_unix = Time.get_unix_time_from_datetime_string(live.started_at)
|
||||||
|
var elapsed = Time.get_datetime_string_from_unix_time((system_unix - stream_start_unix), true)
|
||||||
|
|
||||||
|
%StreamTime.text = elapsed.split(" ")[1]
|
||||||
|
|
||||||
|
func _open_stream() -> void:
|
||||||
|
if not live: return
|
||||||
|
OS.shell_open("https://twitch.tv/%s" % live.user_login)
|
||||||
|
|
||||||
|
func _raid_stream() -> void:
|
||||||
|
if not live: return
|
||||||
|
pass
|
||||||
1
UI/Controls/internal_user_live.gd.uid
Normal file
1
UI/Controls/internal_user_live.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cdtfvedghei5f
|
||||||
96
UI/Controls/internal_user_live.tscn
Normal file
96
UI/Controls/internal_user_live.tscn
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
[gd_scene format=3 uid="uid://bipoye4ww4ua6"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cdtfvedghei5f" path="res://UI/Controls/internal_user_live.gd" id="1_rl2q8"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b3372gsnwqsyn" path="res://UI/assets/bootstrap/twitch.svg" id="1_sw5jj"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bu2juj2beyws7" path="res://UI/assets/twitch_user_profile_pic.png" id="2_rl2q8"]
|
||||||
|
|
||||||
|
[node name="InternalUserLive" type="PanelContainer" unique_id=17956466]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_rl2q8")
|
||||||
|
metadata/_tab_index = 1
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1170164100]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="StreamTitle" type="Button" parent="VBoxContainer" unique_id=1072998029]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer" unique_id=12650367]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="StreamThumbnail" type="TextureRect" parent="VBoxContainer/HBoxContainer" unique_id=641456832]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
expand_mode = 1
|
||||||
|
stretch_mode = 5
|
||||||
|
|
||||||
|
[node name="UserChat" type="PanelContainer" parent="VBoxContainer/HBoxContainer" unique_id=1609959534]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/HBoxContainer/UserChat" unique_id=471477121]
|
||||||
|
custom_minimum_size = Vector2(300, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Chat" type="PanelContainer" parent="VBoxContainer/HBoxContainer/UserChat/VBoxContainer" unique_id=2018394431]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/HBoxContainer/UserChat/VBoxContainer/Chat" unique_id=1349693918]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ChatHistory" type="VBoxContainer" parent="VBoxContainer/HBoxContainer/UserChat/VBoxContainer/Chat/ScrollContainer" unique_id=1839863005]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Message" type="LineEdit" parent="VBoxContainer/HBoxContainer/UserChat/VBoxContainer" unique_id=1978478528]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
placeholder_text = "chat"
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer" unique_id=1134033714]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer" unique_id=411231899]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="RaidCurrentUser" type="Button" parent="VBoxContainer/PanelContainer/HBoxContainer" unique_id=288716491]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(250, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Raid!"
|
||||||
|
icon = ExtResource("1_sw5jj")
|
||||||
|
expand_icon = true
|
||||||
|
|
||||||
|
[node name="ChatLiveSteramer" type="LineEdit" parent="VBoxContainer/PanelContainer/HBoxContainer" unique_id=789542500]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="StreamTime" type="Label" parent="VBoxContainer/PanelContainer/HBoxContainer" unique_id=969178063]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "00:15:42"
|
||||||
|
|
||||||
|
[node name="Icon" type="TextureRect" parent="VBoxContainer/PanelContainer/HBoxContainer" unique_id=521936560]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(24, 24)
|
||||||
|
layout_mode = 2
|
||||||
|
texture = ExtResource("2_rl2q8")
|
||||||
|
expand_mode = 1
|
||||||
|
stretch_mode = 5
|
||||||
|
|
||||||
|
[node name="StreamViewerCount" type="Label" parent="VBoxContainer/PanelContainer/HBoxContainer" unique_id=20195332]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "15"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue