From 8d37f6091fc1735d35f4b0bd93d11ec092b2e94d Mon Sep 17 00:00:00 2001 From: flustix Date: Sun, 29 Sep 2024 21:04:53 +0200 Subject: [PATCH] implement new asset hashes --- fluXis.Game/Graphics/Drawables/DrawableAvatar.cs | 2 +- fluXis.Game/Graphics/Drawables/DrawableBanner.cs | 2 +- fluXis.Game/Graphics/Drawables/DrawableClubBanner.cs | 2 +- fluXis.Game/Graphics/Drawables/DrawableClubIcon.cs | 2 +- fluXis.Game/Graphics/OnlineTextureStore.cs | 10 +++++----- fluXis.Shared/Components/Clubs/APIClub.cs | 6 ++++++ fluXis.Shared/Components/Users/APIUser.cs | 6 ++++++ 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/fluXis.Game/Graphics/Drawables/DrawableAvatar.cs b/fluXis.Game/Graphics/Drawables/DrawableAvatar.cs index e5b499e2..062b36d8 100644 --- a/fluXis.Game/Graphics/Drawables/DrawableAvatar.cs +++ b/fluXis.Game/Graphics/Drawables/DrawableAvatar.cs @@ -41,7 +41,7 @@ private void load() private void setTexture() { if (user is { ID: >= 0 }) // the texture from the online store could still be null - Texture = store.GetAvatar(user.ID) ?? textures.Get("Online/default-avatar"); + Texture = store.GetAvatar(user.AvatarHash) ?? textures.Get("Online/default-avatar"); else Texture = textures.Get("Online/default-avatar"); diff --git a/fluXis.Game/Graphics/Drawables/DrawableBanner.cs b/fluXis.Game/Graphics/Drawables/DrawableBanner.cs index 0dd29fe5..eeb46b54 100644 --- a/fluXis.Game/Graphics/Drawables/DrawableBanner.cs +++ b/fluXis.Game/Graphics/Drawables/DrawableBanner.cs @@ -37,7 +37,7 @@ private void load() private void setTexture() { if (user is { ID: >= 0 }) // the texture from the online store could still be null - Texture = store.GetBanner(user.ID) ?? textures.Get("Online/default-banner"); + Texture = store.GetBanner(user.BannerHash) ?? textures.Get("Online/default-banner"); else Texture = textures.Get("Online/default-banner"); diff --git a/fluXis.Game/Graphics/Drawables/DrawableClubBanner.cs b/fluXis.Game/Graphics/Drawables/DrawableClubBanner.cs index 176d7e3d..b43fe24f 100644 --- a/fluXis.Game/Graphics/Drawables/DrawableClubBanner.cs +++ b/fluXis.Game/Graphics/Drawables/DrawableClubBanner.cs @@ -21,6 +21,6 @@ public DrawableClubBanner(APIClub club) [BackgroundDependencyLoader] private void load() { - Texture = store.GetClubBanner(club.ID); + Texture = store.GetClubBanner(club.BannerHash); } } diff --git a/fluXis.Game/Graphics/Drawables/DrawableClubIcon.cs b/fluXis.Game/Graphics/Drawables/DrawableClubIcon.cs index fed4c3f3..54161cef 100644 --- a/fluXis.Game/Graphics/Drawables/DrawableClubIcon.cs +++ b/fluXis.Game/Graphics/Drawables/DrawableClubIcon.cs @@ -21,6 +21,6 @@ public DrawableClubIcon(APIClub club) [BackgroundDependencyLoader] private void load() { - Texture = store.GetClubIcon(club.ID); + Texture = store.GetClubIcon(club.IconHash); } } diff --git a/fluXis.Game/Graphics/OnlineTextureStore.cs b/fluXis.Game/Graphics/OnlineTextureStore.cs index e199e7d0..9a475102 100644 --- a/fluXis.Game/Graphics/OnlineTextureStore.cs +++ b/fluXis.Game/Graphics/OnlineTextureStore.cs @@ -23,15 +23,15 @@ public OnlineTextureStore(GameHost host, APIEndpointConfig endpointConfig, UserC } public Texture GetAchievement(string id) => get(AssetType.Achievement, id, AssetSize.Small, true); - public Texture GetAvatar(long id) => get(AssetType.Avatar, id); - public Texture GetBanner(long id) => get(AssetType.Banner, id); + public Texture GetAvatar(string hash) => get(AssetType.Avatar, hash); + public Texture GetBanner(string hash) => get(AssetType.Banner, hash); public Texture GetBackground(long id, AssetSize size = AssetSize.Small) => get(AssetType.Background, id, size); public Texture GetCover(long id, AssetSize size = AssetSize.Small) => get(AssetType.Cover, id, size); - public Texture GetClubIcon(long id) => get(AssetType.ClubIcon, id); - public Texture GetClubBanner(long id) => get(AssetType.ClubBanner, id); + public Texture GetClubIcon(string id) => get(AssetType.ClubIcon, id); + public Texture GetClubBanner(string id) => get(AssetType.ClubBanner, id); private Texture get(AssetType type, long id, AssetSize size = AssetSize.Small, bool addExtension = false) => get(type, id.ToString(), size, addExtension); - private Texture get(AssetType type, string id, AssetSize size = AssetSize.Small, bool addExtension = false) => Get(getUrl(type, id, size, addExtension)); + private Texture get(AssetType type, string id, AssetSize size = AssetSize.Small, bool addExtension = false) => string.IsNullOrEmpty(id) ? null : Get(getUrl(type, id, size, addExtension)); private string getUrl(AssetType type, string id, AssetSize size, bool addExtension) { diff --git a/fluXis.Shared/Components/Clubs/APIClub.cs b/fluXis.Shared/Components/Clubs/APIClub.cs index 0d1c20a9..65ed1e10 100644 --- a/fluXis.Shared/Components/Clubs/APIClub.cs +++ b/fluXis.Shared/Components/Clubs/APIClub.cs @@ -15,6 +15,12 @@ public class APIClub [JsonProperty("tag")] public string Tag { get; set; } = ""; + [JsonProperty("icon")] + public string? IconHash { get; set; } + + [JsonProperty("banner")] + public string? BannerHash { get; set; } + [JsonProperty("count")] public long MemberCount { get; set; } diff --git a/fluXis.Shared/Components/Users/APIUser.cs b/fluXis.Shared/Components/Users/APIUser.cs index bd3e2049..d1818e54 100644 --- a/fluXis.Shared/Components/Users/APIUser.cs +++ b/fluXis.Shared/Components/Users/APIUser.cs @@ -16,6 +16,12 @@ public class APIUser [JsonProperty("displayname")] public string? DisplayName { get; set; } + [JsonProperty("avatar")] + public string? AvatarHash { get; set; } + + [JsonProperty("banner")] + public string? BannerHash { get; set; } + [JsonProperty("aboutme")] public string? AboutMe { get; set; }