Created GameEntry
Created GameEntry item for Game lists in User Panel
This commit is contained in:
parent
7aa064fe24
commit
f5aeb44cfd
3 changed files with 182 additions and 0 deletions
93
UI/Controls/game_entry.gd
Normal file
93
UI/Controls/game_entry.gd
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
extends PanelContainer
|
||||
class_name GameEntry
|
||||
|
||||
enum Type {STEAM, ITCHIO}
|
||||
var type: Type
|
||||
|
||||
var steam_app_id: int
|
||||
var itchio_app_url: String
|
||||
|
||||
var steam_data: SteamAppData
|
||||
var itchio_data: ItchIOAppData
|
||||
|
||||
signal game_info_steam_pressed(steam_data: SteamAppData)
|
||||
signal game_info_itchio_pressesd(itchio_data: ItchIOAppData)
|
||||
signal entry_deleted(entry: GameEntry)
|
||||
|
||||
func _ready() -> void:
|
||||
populate()
|
||||
%Refresh.pressed.connect(_reload_data)
|
||||
%GameName.pressed.connect(_select_game)
|
||||
%Promote.pressed.connect(_promote_game)
|
||||
%SteamLink.pressed.connect(_launch_game_site)
|
||||
%ItchLink.pressed.connect(_launch_game_site)
|
||||
%Delete.pressed.connect(entry_deleted.emit.bind(self))
|
||||
|
||||
func populate() -> void:
|
||||
%SteamLink.visible = type == Type.STEAM
|
||||
%ItchLink.visible = type == Type.ITCHIO
|
||||
|
||||
match type:
|
||||
Type.STEAM:
|
||||
if not steam_data:
|
||||
steam_data = await %SteamService.get_steam_app_data(steam_app_id)
|
||||
%GameName.text = steam_data.name
|
||||
%GameName.tooltip_text = steam_data.name
|
||||
var url_no_query: String = steam_data.header_image.split("?")[0]
|
||||
%Background.texture = ImageTexture.create_from_image(await Globals.twitcher.media.load_image(url_no_query))
|
||||
Type.ITCHIO:
|
||||
if not itchio_data:
|
||||
itchio_data = await %ItchIOService.get_itch_app_data(itchio_app_url)
|
||||
%GameName.text = itchio_data.title
|
||||
var url: String = itchio_data.cover_image
|
||||
%Background.texture = ImageTexture.create_from_image(await Globals.twitcher.media.load_image(url))
|
||||
|
||||
func _reload_data() -> void:
|
||||
match type:
|
||||
Type.STEAM:
|
||||
steam_data = await %SteamService.get_steam_app_data(steam_app_id)
|
||||
populate()
|
||||
game_info_steam_pressed.emit(steam_data)
|
||||
Type.ITCHIO:
|
||||
itchio_data = await %ItchIOService.get_itch_app_data(itchio_app_url)
|
||||
populate()
|
||||
game_info_itchio_pressesd.emit(itchio_data)
|
||||
|
||||
func _select_game() -> void:
|
||||
if type == Type.STEAM: game_info_steam_pressed.emit(steam_data)
|
||||
elif type == Type.ITCHIO: game_info_itchio_pressesd.emit(itchio_data)
|
||||
|
||||
func _promote_game() -> void:
|
||||
var msg: String = "Check out {title} by {developer}! {description} {link}"
|
||||
var title: String
|
||||
var developer: String
|
||||
var description: String
|
||||
var link: String
|
||||
match type:
|
||||
Type.STEAM:
|
||||
title = steam_data.name
|
||||
developer = steam_data.developers.front()
|
||||
description = steam_data.short_description
|
||||
link = steam_data.s_team_url
|
||||
pass
|
||||
Type.ITCHIO:
|
||||
title = itchio_data.title
|
||||
developer = itchio_data.developer
|
||||
description = itchio_data.description.left(200) + "..."
|
||||
link = itchio_data.url
|
||||
msg = msg.format({
|
||||
"title": title,
|
||||
"developer": developer,
|
||||
"description": description,
|
||||
"link": link
|
||||
})
|
||||
Globals.twitcher.send_message(msg)
|
||||
|
||||
func _launch_game_site() -> void:
|
||||
var link: String
|
||||
match type:
|
||||
Type.STEAM: link = "https://s.team/a/%d" % steam_app_id
|
||||
Type.ITCHIO: link = itchio_app_url
|
||||
_:
|
||||
link = "https://google.com"
|
||||
OS.shell_open(link)
|
||||
1
UI/Controls/game_entry.gd.uid
Normal file
1
UI/Controls/game_entry.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c0gqgv8ixdudx
|
||||
88
UI/Controls/game_entry.tscn
Normal file
88
UI/Controls/game_entry.tscn
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
[gd_scene format=3 uid="uid://qu7opwfv2ejy"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bb2asei1pibev" path="res://UI/assets/bootstrap/arrow-repeat.png" id="1_b8obq"]
|
||||
[ext_resource type="Script" uid="uid://c0gqgv8ixdudx" path="res://UI/Controls/game_entry.gd" id="1_eo48f"]
|
||||
[ext_resource type="Script" uid="uid://chgufd1youdel" path="res://lib/games_info/steam_service.gd" id="1_lcnnc"]
|
||||
[ext_resource type="Texture2D" uid="uid://eybcntflwjpx" path="res://UI/assets/bootstrap/megaphone.svg" id="2_7t4x7"]
|
||||
[ext_resource type="Script" uid="uid://cyef5m8x5f7k6" path="res://lib/games_info/itch_io_service.gd" id="2_eo48f"]
|
||||
[ext_resource type="Texture2D" uid="uid://pur2a3t6vlfb" path="res://UI/assets/simple/steam.svg" id="3_lcnnc"]
|
||||
[ext_resource type="Texture2D" uid="uid://bw7yr2aonagxc" path="res://UI/assets/font_awesome/itch-io.svg" id="4_eo48f"]
|
||||
[ext_resource type="Texture2D" uid="uid://i8rcx5bhkd5x" path="res://UI/assets/bootstrap/trash.svg" id="5_b1mm0"]
|
||||
|
||||
[node name="GameEntry" type="PanelContainer" unique_id=2093938454]
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("1_eo48f")
|
||||
|
||||
[node name="SteamService" type="Node" parent="." unique_id=1960802515]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("1_lcnnc")
|
||||
metadata/_custom_type_script = "uid://chgufd1youdel"
|
||||
|
||||
[node name="ItchIOService" type="Node" parent="." unique_id=641518539]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("2_eo48f")
|
||||
metadata/_custom_type_script = "uid://cyef5m8x5f7k6"
|
||||
|
||||
[node name="Background" type="TextureRect" parent="." unique_id=593212671]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
expand_mode = 1
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=1820948686]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Refresh" type="Button" parent="HBoxContainer" unique_id=827162280]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(32, 32)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Refresh"
|
||||
icon = ExtResource("1_b8obq")
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[node name="GameName" type="Button" parent="HBoxContainer" unique_id=1669812435]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Name of the game very very long name so that we check if the ellipsis work"
|
||||
text_overrun_behavior = 3
|
||||
|
||||
[node name="Promote" type="Button" parent="HBoxContainer" unique_id=710639076]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(32, 32)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Promote"
|
||||
icon = ExtResource("2_7t4x7")
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[node name="SteamLink" type="Button" parent="HBoxContainer" unique_id=1282286487]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(32, 32)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Steam Page"
|
||||
icon = ExtResource("3_lcnnc")
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[node name="ItchLink" type="Button" parent="HBoxContainer" unique_id=414407013]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(32, 32)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Itch Page"
|
||||
icon = ExtResource("4_eo48f")
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
|
||||
[node name="Delete" type="Button" parent="HBoxContainer" unique_id=1920032998]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(32, 32)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Delete"
|
||||
icon = ExtResource("5_b1mm0")
|
||||
icon_alignment = 1
|
||||
expand_icon = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue