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 async Task<SteamItemDef[]> GetItemsWithPricesAsync()
public static string Currency { get; internal set; }
{
var priceRequest = await Internal.RequestPrices();
if ( !priceRequest.HasValue || priceRequest.Value.Result != Result.OK )
return null;
Console.WriteLine( $"Currency: {priceRequest?.Currency}" );
Currency = priceRequest?.Currency;
var num = Internal.GetNumItemsWithPrices();
Console.WriteLine( $"num: {num}" );
if ( num <= 0 )
return null;

View File

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

View File

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