Games have icon and logo
This commit is contained in:
parent
89a0dc1bc2
commit
e11390f632
154
API/Migrations/20250526144942_Game-Logo-and-Icon.Designer.cs
generated
Normal file
154
API/Migrations/20250526144942_Game-Logo-and-Icon.Designer.cs
generated
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SQLiteEF;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace API.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Context))]
|
||||||
|
[Migration("20250526144942_Game-Logo-and-Icon")]
|
||||||
|
partial class GameLogoandIcon
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "9.0.5");
|
||||||
|
|
||||||
|
modelBuilder.Entity("GamePlayer", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("GamesAppId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("PlayedBySteamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("GamesAppId", "PlayedBySteamId");
|
||||||
|
|
||||||
|
b.HasIndex("PlayedBySteamId");
|
||||||
|
|
||||||
|
b.ToTable("GamePlayer");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SQLiteEF.Game", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("AppId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("IconUrl")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("LogoUrl")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("AppId");
|
||||||
|
|
||||||
|
b.ToTable("Games");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SQLiteEF.Player", b =>
|
||||||
|
{
|
||||||
|
b.Property<ulong>("SteamId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("AvatarUrl")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ProfileUrl")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("SteamId");
|
||||||
|
|
||||||
|
b.ToTable("Players");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SQLiteEF.TrackedTime", b =>
|
||||||
|
{
|
||||||
|
b.Property<DateTime>("TimeStamp")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<ulong>("GameAppId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("PlayerSteamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong>("TimePlayed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("TimeStamp");
|
||||||
|
|
||||||
|
b.HasIndex("GameAppId");
|
||||||
|
|
||||||
|
b.HasIndex("PlayerSteamId");
|
||||||
|
|
||||||
|
b.ToTable("TrackedTime");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("GamePlayer", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SQLiteEF.Game", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("GamesAppId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SQLiteEF.Player", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("PlayedBySteamId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SQLiteEF.TrackedTime", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SQLiteEF.Game", "Game")
|
||||||
|
.WithMany("TrackedTimes")
|
||||||
|
.HasForeignKey("GameAppId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("SQLiteEF.Player", "Player")
|
||||||
|
.WithMany("TrackedTimes")
|
||||||
|
.HasForeignKey("PlayerSteamId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Game");
|
||||||
|
|
||||||
|
b.Navigation("Player");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SQLiteEF.Game", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("TrackedTimes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SQLiteEF.Player", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("TrackedTimes");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
API/Migrations/20250526144942_Game-Logo-and-Icon.cs
Normal file
38
API/Migrations/20250526144942_Game-Logo-and-Icon.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace API.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class GameLogoandIcon : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "IconUrl",
|
||||||
|
table: "Games",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "LogoUrl",
|
||||||
|
table: "Games",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IconUrl",
|
||||||
|
table: "Games");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "LogoUrl",
|
||||||
|
table: "Games");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,12 @@ namespace API.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("IconUrl")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("LogoUrl")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
@ -86,11 +86,23 @@ public class Tracker : IDisposable
|
|||||||
SteamGame[] ownedGames = Steam.GetOwnedGames(player.SteamId);
|
SteamGame[] ownedGames = Steam.GetOwnedGames(player.SteamId);
|
||||||
foreach (SteamGame ownedGame in ownedGames)
|
foreach (SteamGame ownedGame in ownedGames)
|
||||||
{
|
{
|
||||||
|
string? iconUrlStr = ownedGame.img_icon_url is not null
|
||||||
|
? $"http://media.steampowered.com/steamcommunity/public/images/apps/{ownedGame.appid}/{ownedGame.img_icon_url}.jpg"
|
||||||
|
: null;
|
||||||
|
string? logoUrlStr = ownedGame.img_logo_url is not null
|
||||||
|
? $"http://media.steampowered.com/steamcommunity/public/images/apps/{ownedGame.appid}/{ownedGame.img_logo_url}.jpg"
|
||||||
|
: null;
|
||||||
if (context.Games.Find(ownedGame.appid) is not { } game)
|
if (context.Games.Find(ownedGame.appid) is not { } game)
|
||||||
{
|
{
|
||||||
game = new(ownedGame.appid, ownedGame.name);
|
game = new(ownedGame.appid, ownedGame.name, iconUrlStr, logoUrlStr);
|
||||||
context.Games.Add(game);
|
context.Games.Add(game);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
game.Name = ownedGame.name;
|
||||||
|
game.IconUrl = iconUrlStr;
|
||||||
|
game.LogoUrl = logoUrlStr;
|
||||||
|
}
|
||||||
|
|
||||||
if (!player.Games.Contains(game))
|
if (!player.Games.Contains(game))
|
||||||
{
|
{
|
||||||
@ -129,11 +141,23 @@ public class Tracker : IDisposable
|
|||||||
GetRecentlyPlayedGames recentlyPlayed = Steam.GetRecentlyPlayedGames(player.SteamId);
|
GetRecentlyPlayedGames recentlyPlayed = Steam.GetRecentlyPlayedGames(player.SteamId);
|
||||||
foreach (SteamGame recentlyPlayedGame in recentlyPlayed.games)
|
foreach (SteamGame recentlyPlayedGame in recentlyPlayed.games)
|
||||||
{
|
{
|
||||||
|
string? iconUrlStr = recentlyPlayedGame.img_icon_url is not null
|
||||||
|
? $"http://media.steampowered.com/steamcommunity/public/images/apps/{recentlyPlayedGame.appid}/{recentlyPlayedGame.img_icon_url}.jpg"
|
||||||
|
: null;
|
||||||
|
string? logoUrlStr = recentlyPlayedGame.img_logo_url is not null
|
||||||
|
? $"http://media.steampowered.com/steamcommunity/public/images/apps/{recentlyPlayedGame.appid}/{recentlyPlayedGame.img_logo_url}.jpg"
|
||||||
|
: null;
|
||||||
if (context.Games.Find(recentlyPlayedGame.appid) is not { } game)
|
if (context.Games.Find(recentlyPlayedGame.appid) is not { } game)
|
||||||
{
|
{
|
||||||
game = new(recentlyPlayedGame.appid, recentlyPlayedGame.name);
|
game = new(recentlyPlayedGame.appid, recentlyPlayedGame.name, iconUrlStr, logoUrlStr);
|
||||||
context.Games.Add(game);
|
context.Games.Add(game);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
game.Name = recentlyPlayedGame.name;
|
||||||
|
game.IconUrl = iconUrlStr;
|
||||||
|
game.LogoUrl = logoUrlStr;
|
||||||
|
}
|
||||||
|
|
||||||
if (!player.Games.Contains(game))
|
if (!player.Games.Contains(game))
|
||||||
{
|
{
|
||||||
|
@ -4,10 +4,12 @@ using Newtonsoft.Json;
|
|||||||
namespace SQLiteEF;
|
namespace SQLiteEF;
|
||||||
|
|
||||||
[PrimaryKey("AppId")]
|
[PrimaryKey("AppId")]
|
||||||
public class Game(ulong appId, string name)
|
public class Game(ulong appId, string name, string? iconUrl, string? logoUrl)
|
||||||
{
|
{
|
||||||
public ulong AppId { get; init; } = appId;
|
public ulong AppId { get; init; } = appId;
|
||||||
public string Name { get; init; } = name;
|
public string Name { get; set; } = name;
|
||||||
|
public string? IconUrl { get; set; } = iconUrl;
|
||||||
|
public string? LogoUrl { get; set; } = logoUrl;
|
||||||
[JsonIgnore] public ICollection<Player> PlayedBy { get; init; } = null!;
|
[JsonIgnore] public ICollection<Player> PlayedBy { get; init; } = null!;
|
||||||
[JsonIgnore] public ICollection<TrackedTime> TrackedTimes { get; init; } = null!;
|
[JsonIgnore] public ICollection<TrackedTime> TrackedTimes { get; init; } = null!;
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
namespace SteamApiWrapper.ReturnTypes;
|
namespace SteamApiWrapper.ReturnTypes;
|
||||||
|
|
||||||
public record Game(ulong appid, ulong playtime_forever, string name);
|
public record Game(ulong appid, ulong playtime_forever, string name, string? img_icon_url, string? img_logo_url);
|
Loading…
x
Reference in New Issue
Block a user