mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-14 03:47:43 +01:00
Add MarketBoard service and associated interfaces, test and data widget (#1822)
* Add MarketBoard service and associated interfaces, test and data widget * Dispose of events properly * Make listings readonly lists + provide internal list for internal use * Rename CatalogId to ItemId on interfaces, have kept CatalogId internally as it's technically correct * Removed RetainerOwnerId from the public interface * Removed NextCatalogId from the public interface * Updated test text * Null events in scoped service disposal
This commit is contained in:
parent
a35ae5fdf3
commit
e160746d42
12 changed files with 1131 additions and 27 deletions
|
|
@ -43,6 +43,7 @@ internal class DataWindow : Window, IDisposable
|
|||
new IconBrowserWidget(),
|
||||
new ImGuiWidget(),
|
||||
new KeyStateWidget(),
|
||||
new MarketBoardWidget(),
|
||||
new NetworkMonitorWidget(),
|
||||
new ObjectTableWidget(),
|
||||
new PartyListWidget(),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,302 @@
|
|||
using System.Collections.Concurrent;
|
||||
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||
|
||||
using System.Globalization;
|
||||
|
||||
using Game.MarketBoard;
|
||||
using Game.Network.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// Widget to display market board events.
|
||||
/// </summary>
|
||||
internal class MarketBoardWidget : IDataWindowWidget
|
||||
{
|
||||
private readonly ConcurrentQueue<(IMarketBoardHistory MarketBoardHistory, IMarketBoardHistoryListing Listing)> marketBoardHistoryQueue = new();
|
||||
private readonly ConcurrentQueue<(IMarketBoardCurrentOfferings MarketBoardCurrentOfferings, IMarketBoardItemListing Listing)> marketBoardCurrentOfferingsQueue = new();
|
||||
private readonly ConcurrentQueue<IMarketBoardPurchase> marketBoardPurchasesQueue = new();
|
||||
private readonly ConcurrentQueue<IMarketBoardPurchaseHandler> marketBoardPurchaseRequestsQueue = new();
|
||||
private readonly ConcurrentQueue<IMarketTaxRates> marketTaxRatesQueue = new();
|
||||
|
||||
private bool trackMarketBoard;
|
||||
private int trackedEvents;
|
||||
|
||||
/// <summary> Finalizes an instance of the <see cref="MarketBoardWidget"/> class. </summary>
|
||||
~MarketBoardWidget()
|
||||
{
|
||||
if (this.trackMarketBoard)
|
||||
{
|
||||
this.trackMarketBoard = false;
|
||||
var marketBoard = Service<MarketBoard>.GetNullable();
|
||||
if (marketBoard != null)
|
||||
{
|
||||
marketBoard.HistoryReceived -= this.MarketBoardHistoryReceived;
|
||||
marketBoard.OfferingsReceived -= this.MarketBoardOfferingsReceived;
|
||||
marketBoard.ItemPurchased -= this.MarketBoardItemPurchased;
|
||||
marketBoard.PurchaseRequested -= this.MarketBoardPurchaseRequested;
|
||||
marketBoard.TaxRatesReceived -= this.TaxRatesReceived;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string[]? CommandShortcuts { get; init; } = { "marketboard" };
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string DisplayName { get; init; } = "Market Board";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Ready { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Load()
|
||||
{
|
||||
this.trackMarketBoard = false;
|
||||
this.trackedEvents = 0;
|
||||
this.marketBoardHistoryQueue.Clear();
|
||||
this.marketBoardPurchaseRequestsQueue.Clear();
|
||||
this.marketBoardPurchasesQueue.Clear();
|
||||
this.marketTaxRatesQueue.Clear();
|
||||
this.marketBoardCurrentOfferingsQueue.Clear();
|
||||
this.Ready = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Draw()
|
||||
{
|
||||
var marketBoard = Service<MarketBoard>.Get();
|
||||
if (ImGui.Checkbox("Track MarketBoard Events", ref this.trackMarketBoard))
|
||||
{
|
||||
if (this.trackMarketBoard)
|
||||
{
|
||||
marketBoard.HistoryReceived += this.MarketBoardHistoryReceived;
|
||||
marketBoard.OfferingsReceived += this.MarketBoardOfferingsReceived;
|
||||
marketBoard.ItemPurchased += this.MarketBoardItemPurchased;
|
||||
marketBoard.PurchaseRequested += this.MarketBoardPurchaseRequested;
|
||||
marketBoard.TaxRatesReceived += this.TaxRatesReceived;
|
||||
}
|
||||
else
|
||||
{
|
||||
marketBoard.HistoryReceived -= this.MarketBoardHistoryReceived;
|
||||
marketBoard.OfferingsReceived -= this.MarketBoardOfferingsReceived;
|
||||
marketBoard.ItemPurchased -= this.MarketBoardItemPurchased;
|
||||
marketBoard.PurchaseRequested -= this.MarketBoardPurchaseRequested;
|
||||
marketBoard.TaxRatesReceived -= this.TaxRatesReceived;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X / 2);
|
||||
if (ImGui.DragInt("Stored Number of Events", ref this.trackedEvents, 0.1f, 1, 512))
|
||||
{
|
||||
this.trackedEvents = Math.Clamp(this.trackedEvents, 1, 512);
|
||||
}
|
||||
|
||||
if (ImGui.Button("Clear Stored Events"))
|
||||
{
|
||||
this.marketBoardHistoryQueue.Clear();
|
||||
}
|
||||
|
||||
using (var tabBar = ImRaii.TabBar("marketTabs"))
|
||||
{
|
||||
if (tabBar)
|
||||
{
|
||||
using (var tabItem = ImRaii.TabItem("History"))
|
||||
{
|
||||
if (tabItem)
|
||||
{
|
||||
ImGuiTable.DrawTable(string.Empty, this.marketBoardHistoryQueue, this.DrawMarketBoardHistory, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg, "Item ID", "Quantity", "Is HQ?", "Sale Price", "Buyer Name", "Purchase Time");
|
||||
}
|
||||
}
|
||||
|
||||
using (var tabItem = ImRaii.TabItem("Offerings"))
|
||||
{
|
||||
if (tabItem)
|
||||
{
|
||||
ImGuiTable.DrawTable(string.Empty, this.marketBoardCurrentOfferingsQueue, this.DrawMarketBoardCurrentOfferings, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg, "Item ID", "Quantity", "Is HQ?", "Price Per Unit", "Buyer Name", "Retainer Name", "Last Review Time");
|
||||
}
|
||||
}
|
||||
|
||||
using (var tabItem = ImRaii.TabItem("Purchases"))
|
||||
{
|
||||
if (tabItem)
|
||||
{
|
||||
ImGuiTable.DrawTable(string.Empty, this.marketBoardPurchasesQueue, this.DrawMarketBoardPurchases, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg, "Item ID", "Quantity");
|
||||
}
|
||||
}
|
||||
|
||||
using (var tabItem = ImRaii.TabItem("Purchase Requests"))
|
||||
{
|
||||
if (tabItem)
|
||||
{
|
||||
ImGuiTable.DrawTable(string.Empty, this.marketBoardPurchaseRequestsQueue, this.DrawMarketBoardPurchaseRequests, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg, "Item ID", "Quantity", "Price Per Unit", "Listing ID", "Retainer ID");
|
||||
}
|
||||
}
|
||||
|
||||
using (var tabItem = ImRaii.TabItem("Taxes"))
|
||||
{
|
||||
if (tabItem)
|
||||
{
|
||||
ImGuiTable.DrawTable(string.Empty, this.marketTaxRatesQueue, this.DrawMarketTaxRates, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg, "Uldah", "Limsa Lominsa", "Gridania", "Ishgard", "Kugane", "Crystarium", "Sharlayan");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TaxRatesReceived(IMarketTaxRates marketTaxRates)
|
||||
{
|
||||
this.marketTaxRatesQueue.Enqueue(marketTaxRates);
|
||||
|
||||
while (this.marketTaxRatesQueue.Count > this.trackedEvents)
|
||||
{
|
||||
this.marketTaxRatesQueue.TryDequeue(out _);
|
||||
}
|
||||
}
|
||||
|
||||
private void MarketBoardPurchaseRequested(IMarketBoardPurchaseHandler marketBoardPurchaseHandler)
|
||||
{
|
||||
this.marketBoardPurchaseRequestsQueue.Enqueue(marketBoardPurchaseHandler);
|
||||
|
||||
while (this.marketBoardPurchaseRequestsQueue.Count > this.trackedEvents)
|
||||
{
|
||||
this.marketBoardPurchaseRequestsQueue.TryDequeue(out _);
|
||||
}
|
||||
}
|
||||
|
||||
private void MarketBoardItemPurchased(IMarketBoardPurchase marketBoardPurchase)
|
||||
{
|
||||
this.marketBoardPurchasesQueue.Enqueue(marketBoardPurchase);
|
||||
|
||||
while (this.marketBoardPurchasesQueue.Count > this.trackedEvents)
|
||||
{
|
||||
this.marketBoardPurchasesQueue.TryDequeue(out _);
|
||||
}
|
||||
}
|
||||
|
||||
private void MarketBoardOfferingsReceived(IMarketBoardCurrentOfferings marketBoardCurrentOfferings)
|
||||
{
|
||||
foreach (var listing in marketBoardCurrentOfferings.ItemListings)
|
||||
{
|
||||
this.marketBoardCurrentOfferingsQueue.Enqueue((marketBoardCurrentOfferings, listing));
|
||||
}
|
||||
|
||||
while (this.marketBoardCurrentOfferingsQueue.Count > this.trackedEvents)
|
||||
{
|
||||
this.marketBoardCurrentOfferingsQueue.TryDequeue(out _);
|
||||
}
|
||||
}
|
||||
|
||||
private void MarketBoardHistoryReceived(IMarketBoardHistory marketBoardHistory)
|
||||
{
|
||||
foreach (var listing in marketBoardHistory.HistoryListings)
|
||||
{
|
||||
this.marketBoardHistoryQueue.Enqueue((marketBoardHistory, listing));
|
||||
}
|
||||
|
||||
while (this.marketBoardHistoryQueue.Count > this.trackedEvents)
|
||||
{
|
||||
this.marketBoardHistoryQueue.TryDequeue(out _);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMarketBoardHistory((IMarketBoardHistory History, IMarketBoardHistoryListing Listing) data)
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.History.ItemId.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.Quantity.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.IsHq.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.SalePrice.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.BuyerName);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.PurchaseTime.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
private void DrawMarketBoardCurrentOfferings((IMarketBoardCurrentOfferings MarketBoardCurrentOfferings, IMarketBoardItemListing Listing) data)
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.ItemId.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.ItemQuantity.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.IsHq.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.PricePerUnit.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.PlayerName);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.RetainerName);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.Listing.LastReviewTime.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
private void DrawMarketBoardPurchases(IMarketBoardPurchase data)
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.CatalogId.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.ItemQuantity.ToString());
|
||||
}
|
||||
|
||||
private void DrawMarketBoardPurchaseRequests(IMarketBoardPurchaseHandler data)
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.CatalogId.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.ItemQuantity.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.PricePerUnit.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.ListingId.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.RetainerId.ToString());
|
||||
}
|
||||
|
||||
private void DrawMarketTaxRates(IMarketTaxRates data)
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.UldahTax.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.LimsaLominsaTax.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.GridaniaTax.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.IshgardTax.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.KuganeTax.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.CrystariumTax.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(data.SharlayanTax.ToString());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,259 @@
|
|||
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
|
||||
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
using Game.MarketBoard;
|
||||
using Game.Network.Structures;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
/// <summary>
|
||||
/// Tests the various market board events
|
||||
/// </summary>
|
||||
internal class MarketBoardAgingStep : IAgingStep
|
||||
{
|
||||
private SubStep currentSubStep;
|
||||
private bool eventsSubscribed;
|
||||
|
||||
private IMarketBoardHistoryListing? historyListing;
|
||||
private IMarketBoardItemListing? itemListing;
|
||||
private IMarketTaxRates? marketTaxRate;
|
||||
private IMarketBoardPurchaseHandler? marketBoardPurchaseRequest;
|
||||
private IMarketBoardPurchase? marketBoardPurchase;
|
||||
|
||||
private enum SubStep
|
||||
{
|
||||
History,
|
||||
Offerings,
|
||||
PurchaseRequests,
|
||||
Purchases,
|
||||
Taxes,
|
||||
Done,
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Name => "Test MarketBoard";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SelfTestStepResult RunStep()
|
||||
{
|
||||
if (!this.eventsSubscribed)
|
||||
{
|
||||
this.SubscribeToEvents();
|
||||
}
|
||||
|
||||
ImGui.Text($"Testing: {this.currentSubStep.ToString()}");
|
||||
|
||||
switch (this.currentSubStep)
|
||||
{
|
||||
case SubStep.History:
|
||||
|
||||
if (this.historyListing == null)
|
||||
{
|
||||
ImGui.Text("Goto a Market Board. Open any item that has historical sale listings.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text("Does one of the historical sales match this information?");
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Quantity: {this.historyListing.Quantity.ToString()}");
|
||||
ImGui.Text($"Buyer: {this.historyListing.BuyerName}");
|
||||
ImGui.Text($"Sale Price: {this.historyListing.SalePrice.ToString()}");
|
||||
ImGui.Text($"Purchase Time: {this.historyListing.PurchaseTime.ToString(CultureInfo.InvariantCulture)}");
|
||||
ImGui.Separator();
|
||||
if (ImGui.Button("Looks Correct / Skip"))
|
||||
{
|
||||
this.currentSubStep++;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("No"))
|
||||
{
|
||||
return SelfTestStepResult.Fail;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case SubStep.Offerings:
|
||||
|
||||
if (this.itemListing == null)
|
||||
{
|
||||
ImGui.Text("Goto a Market Board. Open any item that has sale listings.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text("Does one of the sales match this information?");
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Quantity: {this.itemListing.ItemQuantity.ToString()}");
|
||||
ImGui.Text($"Price Per Unit: {this.itemListing.PricePerUnit}");
|
||||
ImGui.Text($"Retainer Name: {this.itemListing.RetainerName}");
|
||||
ImGui.Text($"Is HQ?: {(this.itemListing.IsHq ? "Yes" : "No")}");
|
||||
ImGui.Separator();
|
||||
if (ImGui.Button("Looks Correct / Skip"))
|
||||
{
|
||||
this.currentSubStep++;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("No"))
|
||||
{
|
||||
return SelfTestStepResult.Fail;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case SubStep.PurchaseRequests:
|
||||
if (this.marketBoardPurchaseRequest == null)
|
||||
{
|
||||
ImGui.Text("Goto a Market Board. Purchase any item, the cheapest you can find.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text("Does this information match the purchase you made? This is testing the request to the server.");
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Quantity: {this.marketBoardPurchaseRequest.ItemQuantity.ToString()}");
|
||||
ImGui.Text($"Item ID: {this.marketBoardPurchaseRequest.CatalogId}");
|
||||
ImGui.Text($"Price Per Unit: {this.marketBoardPurchaseRequest.PricePerUnit}");
|
||||
ImGui.Separator();
|
||||
if (ImGui.Button("Looks Correct / Skip"))
|
||||
{
|
||||
this.currentSubStep++;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("No"))
|
||||
{
|
||||
return SelfTestStepResult.Fail;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case SubStep.Purchases:
|
||||
if (this.marketBoardPurchase == null)
|
||||
{
|
||||
ImGui.Text("Goto a Market Board. Purchase any item, the cheapest you can find.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text("Does this information match the purchase you made? This is testing the response from the server.");
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Quantity: {this.marketBoardPurchase.ItemQuantity.ToString()}");
|
||||
ImGui.Text($"Item ID: {this.marketBoardPurchase.CatalogId}");
|
||||
ImGui.Separator();
|
||||
if (ImGui.Button("Looks Correct / Skip"))
|
||||
{
|
||||
this.currentSubStep++;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("No"))
|
||||
{
|
||||
return SelfTestStepResult.Fail;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case SubStep.Taxes:
|
||||
if (this.marketTaxRate == null)
|
||||
{
|
||||
ImGui.Text("Goto a Retainer Vocate and talk to then. Click the 'View market tax rates' menu item.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text("Does this market tax rate information look correct?");
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Uldah: {this.marketTaxRate.UldahTax.ToString()}");
|
||||
ImGui.Text($"Gridania: {this.marketTaxRate.GridaniaTax.ToString()}");
|
||||
ImGui.Text($"Limsa Lominsa: {this.marketTaxRate.LimsaLominsaTax.ToString()}");
|
||||
ImGui.Text($"Ishgard: {this.marketTaxRate.IshgardTax.ToString()}");
|
||||
ImGui.Text($"Kugane: {this.marketTaxRate.KuganeTax.ToString()}");
|
||||
ImGui.Text($"Crystarium: {this.marketTaxRate.CrystariumTax.ToString()}");
|
||||
ImGui.Text($"Sharlayan: {this.marketTaxRate.SharlayanTax.ToString()}");
|
||||
ImGui.Separator();
|
||||
if (ImGui.Button("Looks Correct / Skip"))
|
||||
{
|
||||
this.currentSubStep++;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("No"))
|
||||
{
|
||||
return SelfTestStepResult.Fail;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SubStep.Done:
|
||||
return SelfTestStepResult.Pass;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return SelfTestStepResult.Waiting;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void CleanUp()
|
||||
{
|
||||
this.currentSubStep = SubStep.History;
|
||||
this.historyListing = null;
|
||||
this.marketTaxRate = null;
|
||||
this.marketBoardPurchase = null;
|
||||
this.marketBoardPurchaseRequest = null;
|
||||
this.itemListing = null;
|
||||
this.UnsubscribeFromEvents();
|
||||
}
|
||||
|
||||
private void SubscribeToEvents()
|
||||
{
|
||||
var marketBoard = Service<MarketBoard>.Get();
|
||||
marketBoard.HistoryReceived += this.OnHistoryReceived;
|
||||
marketBoard.OfferingsReceived += this.OnOfferingsReceived;
|
||||
marketBoard.ItemPurchased += this.OnItemPurchased;
|
||||
marketBoard.PurchaseRequested += this.OnPurchaseRequested;
|
||||
marketBoard.TaxRatesReceived += this.OnTaxRatesReceived;
|
||||
this.eventsSubscribed = true;
|
||||
}
|
||||
|
||||
private void UnsubscribeFromEvents()
|
||||
{
|
||||
var marketBoard = Service<MarketBoard>.Get();
|
||||
marketBoard.HistoryReceived -= this.OnHistoryReceived;
|
||||
marketBoard.OfferingsReceived -= this.OnOfferingsReceived;
|
||||
marketBoard.ItemPurchased -= this.OnItemPurchased;
|
||||
marketBoard.PurchaseRequested -= this.OnPurchaseRequested;
|
||||
marketBoard.TaxRatesReceived -= this.OnTaxRatesReceived;
|
||||
this.eventsSubscribed = false;
|
||||
}
|
||||
|
||||
private void OnTaxRatesReceived(IMarketTaxRates marketTaxRates)
|
||||
{
|
||||
this.marketTaxRate = marketTaxRates;
|
||||
}
|
||||
|
||||
private void OnPurchaseRequested(IMarketBoardPurchaseHandler marketBoardPurchaseHandler)
|
||||
{
|
||||
this.marketBoardPurchaseRequest = marketBoardPurchaseHandler;
|
||||
}
|
||||
|
||||
private void OnItemPurchased(IMarketBoardPurchase purchase)
|
||||
{
|
||||
this.marketBoardPurchase = purchase;
|
||||
}
|
||||
|
||||
private void OnOfferingsReceived(IMarketBoardCurrentOfferings marketBoardCurrentOfferings)
|
||||
{
|
||||
if (marketBoardCurrentOfferings.ItemListings.Count != 0)
|
||||
{
|
||||
this.itemListing = marketBoardCurrentOfferings.ItemListings.First();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHistoryReceived(IMarketBoardHistory marketBoardHistory)
|
||||
{
|
||||
if (marketBoardHistory.HistoryListings.Count != 0)
|
||||
{
|
||||
this.historyListing = marketBoardHistory.HistoryListings.First();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,6 +44,7 @@ internal class SelfTestWindow : Window
|
|||
new HandledExceptionAgingStep(),
|
||||
new DutyStateAgingStep(),
|
||||
new GameConfigAgingStep(),
|
||||
new MarketBoardAgingStep(),
|
||||
new LogoutEventAgingStep(),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue