Created TwitchUserInfo control
Created user control to handle showing TwitchUser information.
This commit is contained in:
parent
59bb3d323d
commit
c803f31e6c
3 changed files with 258 additions and 0 deletions
98
UI/Controls/twitch_user_info.gd
Normal file
98
UI/Controls/twitch_user_info.gd
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
extends PanelContainer
|
||||
|
||||
const CHEVRONS = [
|
||||
preload("res://UI/assets/font_awesome/chevron-left.svg"),
|
||||
preload("res://UI/assets/font_awesome/chevron-right.svg")
|
||||
]
|
||||
@export var expanded: bool = false
|
||||
|
||||
signal extra_expanded(is_expanded: bool)
|
||||
|
||||
var is_extra_panel_expanded: bool
|
||||
var tw_expand: Tween
|
||||
|
||||
var t_user: TwitchUser
|
||||
var chatter: Chatter
|
||||
|
||||
func _ready() -> void:
|
||||
toggle_extra_panel(expanded)
|
||||
%ExpandExtraInfo.pressed.connect(func(): toggle_extra_panel(!is_extra_panel_expanded))
|
||||
%LoadingSimple.hide()
|
||||
|
||||
func show_busy() -> void:
|
||||
%LoadingSimple.show()
|
||||
|
||||
func show_normal() -> void:
|
||||
%LoadingSimple.hide()
|
||||
|
||||
func populate_from_twitch_user(_t_user: TwitchUser) -> void:
|
||||
%LoadingSimple.show()
|
||||
clear()
|
||||
t_user = _t_user
|
||||
if not t_user: return
|
||||
%Username.text = t_user.login
|
||||
%DisplayName.text = t_user.display_name
|
||||
%UserId.text = t_user.id
|
||||
%ProfilePictureURL.text = t_user.profile_image_url
|
||||
if t_user.profile_image_url:
|
||||
%AvatarImg.texture = await Globals.twitcher.media.load_profile_image(t_user)
|
||||
else:
|
||||
%AvatarImg.texture = preload("res://UI/assets/twitch_user_profile_pic.png")
|
||||
|
||||
%Type.text = t_user.type
|
||||
%ChannelDescription.text = t_user.description
|
||||
%BroadcasterType.text = t_user.broadcaster_type
|
||||
%OfflineImageURL.text = t_user.offline_image_url
|
||||
%ViewCount.text = str(t_user.view_count)
|
||||
%LoadingSimple.hide()
|
||||
|
||||
func populate_from_chatter(_chatter: Chatter) -> void:
|
||||
%LoadingSimple.show()
|
||||
clear()
|
||||
chatter = _chatter
|
||||
if not chatter: return
|
||||
t_user = await Globals.twitcher.get_user_by_id(chatter.twitch_id)
|
||||
%Username.text = t_user.login
|
||||
%DisplayName.text = t_user.display_name
|
||||
%UserId.text = t_user.id
|
||||
%ProfilePictureURL.text = t_user.profile_image_url
|
||||
if t_user.profile_image_url:
|
||||
%AvatarImg.texture = await Globals.twitcher.media.load_profile_image(t_user)
|
||||
else:
|
||||
%AvatarImg.texture = preload("res://UI/assets/twitch_user_profile_pic.png")
|
||||
|
||||
%Type.text = t_user.type
|
||||
%ChannelDescription.text = t_user.description
|
||||
%BroadcasterType.text = t_user.broadcaster_type
|
||||
%OfflineImageURL.text = t_user.offline_image_url
|
||||
%ViewCount.text = str(t_user.view_count)
|
||||
%LoadingSimple.hide()
|
||||
|
||||
func clear() -> void:
|
||||
%AvatarImg.texture = preload("res://UI/assets/twitch_user_profile_pic.png")
|
||||
%Username.text = ""
|
||||
%DisplayName.text = ""
|
||||
%UserId.text = ""
|
||||
%ProfilePictureURL.text = ""
|
||||
%ChatColor.color = Color.TRANSPARENT
|
||||
|
||||
%Type.text = ""
|
||||
%ChannelDescription.text = ""
|
||||
%BroadcasterType.text = ""
|
||||
%OfflineImageURL.text = ""
|
||||
%ViewCount.text = ""
|
||||
|
||||
func toggle_extra_panel(val: bool) -> void:
|
||||
is_extra_panel_expanded = val
|
||||
%ExpandExtraInfo.icon = CHEVRONS[0] if is_extra_panel_expanded else CHEVRONS[1]
|
||||
var min_size_x: float = 400 if is_extra_panel_expanded else 0
|
||||
if tw_expand:
|
||||
tw_expand.kill()
|
||||
%ExtraInfo.show()
|
||||
tw_expand = create_tween()
|
||||
tw_expand.set_ease(Tween.EASE_OUT)
|
||||
tw_expand.set_trans(Tween.TRANS_CUBIC)
|
||||
tw_expand.tween_property(%ExtraInfo, ^"custom_minimum_size:x", min_size_x, 0.3)
|
||||
if !is_extra_panel_expanded:
|
||||
tw_expand.tween_property(%ExtraInfo, ^"visible", false, 0.0)
|
||||
tw_expand.tween_callback(extra_expanded.emit.bind(is_extra_panel_expanded))
|
||||
Loading…
Add table
Add a link
Reference in a new issue