LocalPriceFormatted

This commit is contained in:
Garry Newman 2019-04-27 21:52:30 +01:00
parent aa666a3149
commit 37f6192213
3 changed files with 11 additions and 10 deletions

View File

@ -37,16 +37,16 @@ namespace Steamworks
public static event Action OnDefinitionsUpdated; public static event Action OnDefinitionsUpdated;
public static async Task<SteamItemDef[]> GetItemsWithPricesAsync() public static async Task<SteamItemDef[]> GetItemsWithPricesAsync()
public static string Currency { get; internal set; }
{ {
var priceRequest = await Internal.RequestPrices(); var priceRequest = await Internal.RequestPrices();
if ( !priceRequest.HasValue || priceRequest.Value.Result != Result.OK ) if ( !priceRequest.HasValue || priceRequest.Value.Result != Result.OK )
return null; return null;
Console.WriteLine( $"Currency: {priceRequest?.Currency}" ); Currency = priceRequest?.Currency;
var num = Internal.GetNumItemsWithPrices(); var num = Internal.GetNumItemsWithPrices();
Console.WriteLine( $"num: {num}" );
if ( num <= 0 ) if ( num <= 0 )
return null; return null;

View File

@ -8,6 +8,11 @@ namespace Steamworks
{ {
internal SteamItemDef_t _id; internal SteamItemDef_t _id;
public SteamItemDef( int defId )
{
_id = defId;
}
public int Id => _id.Value; public int Id => _id.Value;
/// <summary> /// <summary>
@ -146,6 +151,8 @@ namespace Steamworks
} }
} }
public string LocalPriceFormatted => Utility.FormatPrice( SteamInventory.Currency, LocalPrice / 100.0 );
/// <summary> /// <summary>
/// If the price has been discounted, LocalPrice will differ from LocalBasePrice /// If the price has been discounted, LocalPrice will differ from LocalBasePrice
/// (assumed, this isn't documented) /// (assumed, this isn't documented)
@ -164,7 +171,6 @@ namespace Steamworks
} }
} }
public int CurrentPrice; public string LocalBasePriceFormatted => Utility.FormatPrice( SteamInventory.Currency, LocalPrice / 100.0 );
public int BasePrice;
} }
} }

View File

@ -27,12 +27,7 @@ namespace Steamworks
return new IPAddress( Swap( ipAddress ) ); return new IPAddress( Swap( ipAddress ) );
} }
internal static string FormatPrice(string currency, ulong price) public static string FormatPrice(string currency, double price)
{
return FormatPrice(currency, price / 100.0);
}
public static string FormatPrice(string currency, double price)
{ {
var decimaled = price.ToString("0.00"); var decimaled = price.ToString("0.00");