Updated UserGames

Renamed search and add functions for Steam to _handle_steam_*, Added
ItchIO handlers
Updated Steam Add to check and see if we have already fetched the App
information, and if so, use it, otherwise try to search.  *Note* Need to
clear after adding, so we don't accidently add to the wrong user, and
need to validate if the game has already been added or not.
Added Logic to for ItchIO.
This commit is contained in:
Mario Steele 2026-03-10 10:27:40 -05:00
parent cc01a207fc
commit eb16b80134
2 changed files with 57 additions and 23 deletions

View file

@ -11,10 +11,13 @@ var chatter: Chatter:
populate_games()
func _ready() -> void:
%SteamSearch.pressed.connect(_handle_search)
%AddSteamGame.pressed.connect(_handle_add)
%SteamSearch.pressed.connect(_handle_steam_search)
%AddSteamGame.pressed.connect(_handle_steam_add)
%ItchFetch.pressed.connect(_handle_itch_search)
%ItchAdd.pressed.connect(_handle_itch_add)
func _handle_search() -> void:
#region Steam Search
func _handle_steam_search() -> void:
var info: String = %SteamGameInput.text
var app_id: int = -1
if info.begins_with("https:"):
@ -32,27 +35,58 @@ func _handle_search() -> void:
%SteamAppPanel.display_app_info(data)
%SteamAppPanel.show()
func _handle_add() -> void:
var info: String = %SteamGameInput.text
var app_id: int = -1
if info.begins_with("https:"):
var parts = Array(info.split("/"))
parts.reverse()
for part in parts:
if part.is_valid_int():
app_id = part.to_int()
break
elif info.is_valid_int():
app_id = info.to_int()
func _handle_steam_add() -> void:
if %SteamAppPanel.data:
var app: SteamAppData = %SteamAppPanel.data
chatter.steam_games.append(app.steam_app_id)
else:
var info: String = %SteamGameInput.text
var app_id: int = -1
if info.begins_with("https:"):
var parts = Array(info.split("/"))
parts.reverse()
for part in parts:
if part.is_valid_int():
app_id = part.to_int()
break
elif info.is_valid_int():
app_id = info.to_int()
if app_id == -1: return
if app_id == -1: return
var data: SteamAppData = await %SteamService.get_steam_app_data(app_id)
var data: SteamAppData = await %SteamService.get_steam_app_data(app_id)
if data:
chatter.steam_games.append(app_id)
chatter.save()
clear()
populate_games()
#endregion
#region Itch Search
func _handle_itch_search() -> void:
var info: String = %ItchInput.text
if not (info.begins_with("http://") or info.begins_with("https://")): return
var data: ItchIOAppData = await %ItchIOService.get_itch_app_data(info)
if data:
chatter.steam_games.append(app_id)
chatter.save()
clear()
populate_games()
%ItchAppPanel.display_app_info(data)
%ItchAppPanel.show()
func _handle_itch_add() -> void:
if %ItchAppPanel.data:
var app: ItchIOAppData = %ItchAppPanel.data
chatter.itch_games[app.title] = app.url
else:
var info: String = %ItchInput.text
if not (info.begins_with("http://") or info.begins_with("https://")): return
var data: ItchIOAppData = await %ItchIOService.get_itch_app_data(info)
if data:
chatter.itch_games[data.title] = data.url
chatter.save()
clear()
populate_games()
#endregion
func populate_games() -> void:
for game in chatter.steam_games: