Make Inventory.OnUpdate an event, FormatPrice can be passed LocalPrice without needing to multiply it

This commit is contained in:
Rohan Singh 2018-12-03 08:17:55 -05:00
parent e69e25a1f1
commit 96511dcc64
3 changed files with 10 additions and 4 deletions

View File

@ -107,7 +107,7 @@ public void InventoryItemList()
bool CallbackCalled = false;
// OnUpdate hsould be called when we receive a list of our items
client.Inventory.OnUpdate = () => { CallbackCalled = true; };
client.Inventory.OnUpdate += () => { CallbackCalled = true; };
// tell steam to download the items
client.Inventory.Refresh();

View File

@ -14,7 +14,7 @@ public partial class Inventory : IDisposable
/// Called when the local client's items are first retrieved, and when they change.
/// Obviously not called on the server.
/// </summary>
public Action OnUpdate;
public event Action OnUpdate;
/// <summary>
/// A list of items owned by this user. You should call Refresh() before trying to access this,
@ -466,6 +466,7 @@ public void UpdatePrices()
Definitions[i].UpdatePrice();
}
OnUpdate?.Invoke();
});
}
}

View File

@ -60,9 +60,14 @@ public static uint FromDateTime( DateTime dt )
}
public static string FormatPrice(string currency, ulong price)
internal static string FormatPrice(string currency, ulong price)
{
var decimaled = (price / 100.0).ToString("0.00");
return FormatPrice(currency, price / 100.0);
}
public static string FormatPrice(string currency, double price)
{
var decimaled = price.ToString("0.00");
switch (currency)
{