Icon loading

This commit is contained in:
Garry Newman 2017-05-09 20:41:16 +01:00
parent 2cff8ccea1
commit 9657f3b32e
2 changed files with 34 additions and 0 deletions

View File

@ -57,6 +57,12 @@ namespace Facepunch.Steamworks.Test
Console.WriteLine( " - - " + ach.State ); Console.WriteLine( " - - " + ach.State );
Console.WriteLine( " - - " + ach.UnlockTime ); Console.WriteLine( " - - " + ach.UnlockTime );
Console.WriteLine( " - - " + ach.Percentage ); Console.WriteLine( " - - " + ach.Percentage );
if ( ach.Icon != null )
{
Console.WriteLine( " - - " + ach.Icon.Width + " x " + ach.Icon.Height );
}
Console.WriteLine( "" ); Console.WriteLine( "" );
} }
} }

View File

@ -87,6 +87,8 @@ namespace Facepunch.Steamworks
/// </summary> /// </summary>
public DateTime UnlockTime { get; private set; } public DateTime UnlockTime { get; private set; }
private int iconId { get; set; } = -1;
/// <summary> /// <summary>
/// If this achievement is linked to a stat this will return the progress. /// If this achievement is linked to a stat this will return the progress.
/// </summary> /// </summary>
@ -106,6 +108,30 @@ namespace Facepunch.Steamworks
} }
} }
private Image _icon;
public Image Icon
{
get
{
if ( iconId <= 0 ) return null;
if ( _icon == null )
{
_icon = new Image();
_icon.Id = iconId;
}
if ( _icon.IsLoaded )
return _icon;
if ( !_icon.TryLoad( client.native.utils ) )
return null;
return _icon;
}
}
public Achievement( Client client, int index ) public Achievement( Client client, int index )
{ {
this.client = client; this.client = client;
@ -114,6 +140,8 @@ namespace Facepunch.Steamworks
Name = client.native.userstats.GetAchievementDisplayAttribute( Id, "name" ); Name = client.native.userstats.GetAchievementDisplayAttribute( Id, "name" );
Description = client.native.userstats.GetAchievementDisplayAttribute( Id, "desc" ); Description = client.native.userstats.GetAchievementDisplayAttribute( Id, "desc" );
iconId = client.native.userstats.GetAchievementIcon( Id );
Refresh(); Refresh();
} }