public void Reset() { Result = TradeDialogResult.Pending; Transaction = null; EnvoyColumns.Reconstruct(Helper.AggregateResourcesIntoTradeableItems(Envoy.Resources), new List <TradeableItem>(), (int)Envoy.Money); PlayerColumns.Reconstruct(Helper.AggregateResourcesIntoTradeableItems(Player.Resources), new List <TradeableItem>(), (int)Player.Money); UpdateBottomDisplays(); if (Balance != null) { Balance.TradeBalance = 0.0f; } Layout(); }
public override void Construct() { Border = "border-one"; Text = "Select Resources to Trade"; Font = "font16"; InteriorMargin = new Margin(32, 5, 5, 5); var existingResources = Faction.ListResources(); StayingResources = new List <ResourceAmount>(); foreach (var resource in existingResources) { StayingResources.Add(resource.Value); } var TradeEntity = new ExpeditionTradeEntity() { Faction = this.Faction, AvailableMoney = this.Faction.Economy.CurrentMoney, AvailableResources = StayingResources, Space = 9999 }; var container = AddChild(new Widget() { Rect = GetDrawableInterior().Interior(new Margin(64, 64, 32, 32)) }); ResourceColumns columns = container.AddChild(new ResourceColumns() { AutoLayout = AutoLayout.DockFill, TradeEntity = TradeEntity, ValueSourceEntity = TradeEntity, LeftHeader = "In Stockpiles", RightHeader = "With Expedition", MoneyLabel = "Trade Money" }) as ResourceColumns; columns.Reconstruct(StayingResources, new List <ResourceAmount>(), (int)Faction.Economy.CurrentMoney); AddChild(new Button() { Text = "Cancel", Tooltip = "Go back to the factions view.", AutoLayout = AutoLayout.FloatBottomLeft, OnClick = (sender, args) => { if (OnCanceled != null) { OnCanceled.Invoke(); } Close(); } }); AddChild(new Button() { Text = "Send Expedition", Tooltip = "The expedition will begin immediately!", AutoLayout = AutoLayout.FloatBottomRight, OnClick = (sender, args) => { SelectedResources = columns.SelectedResources; SelectedMoney = columns.TradeMoney; if (OnProceed != null) { OnProceed.Invoke(this); } Close(); } }); Layout(); base.Construct(); }