Skip to content

Commit

Permalink
implement new asset hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Sep 29, 2024
1 parent 5109049 commit 8d37f60
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fluXis.Game/Graphics/Drawables/DrawableAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion fluXis.Game/Graphics/Drawables/DrawableBanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion fluXis.Game/Graphics/Drawables/DrawableClubBanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public DrawableClubBanner(APIClub club)
[BackgroundDependencyLoader]
private void load()
{
Texture = store.GetClubBanner(club.ID);
Texture = store.GetClubBanner(club.BannerHash);
}
}
2 changes: 1 addition & 1 deletion fluXis.Game/Graphics/Drawables/DrawableClubIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public DrawableClubIcon(APIClub club)
[BackgroundDependencyLoader]
private void load()
{
Texture = store.GetClubIcon(club.ID);
Texture = store.GetClubIcon(club.IconHash);
}
}
10 changes: 5 additions & 5 deletions fluXis.Game/Graphics/OnlineTextureStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions fluXis.Shared/Components/Clubs/APIClub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
6 changes: 6 additions & 0 deletions fluXis.Shared/Components/Users/APIUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down

0 comments on commit 8d37f60

Please sign in to comment.