From 6ef3b9102c0e132a00f50d998d3b2ab597a1cfe9 Mon Sep 17 00:00:00 2001 From: Justin Brown Date: Fri, 24 May 2024 17:03:17 -0700 Subject: [PATCH] Add create button for the transfer --- .../EntityManagement/CreateTransferWindow.cs | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Pulsar4X/Pulsar4X.Client/EntityManagement/CreateTransferWindow.cs b/Pulsar4X/Pulsar4X.Client/EntityManagement/CreateTransferWindow.cs index 25dc83fff..33b65cabf 100644 --- a/Pulsar4X/Pulsar4X.Client/EntityManagement/CreateTransferWindow.cs +++ b/Pulsar4X/Pulsar4X.Client/EntityManagement/CreateTransferWindow.cs @@ -4,6 +4,7 @@ using ImGuiNET; using Pulsar4X.Datablobs; using Pulsar4X.Engine; +using Pulsar4X.Engine.Orders; using Pulsar4X.Extensions; using Pulsar4X.Interfaces; @@ -72,6 +73,23 @@ internal override void Display() ImGui.Columns(1); + if(TransferLeftGoods.Count > 0 || TransferRightGoods.Count > 0) + { + ImGui.Separator(); + if(ImGui.Button("Create")) + { + if(TransferLeft != null && TransferRight != null && TransferLeftGoods.Count > 0) + { + var itemsToTransfer = new List<(ICargoable, long)>(); + foreach(var item in TransferLeftGoods) + { + itemsToTransfer.Add((item.Key, item.Value.Item1)); + } + CargoUnloadToOrder.CreateCommand(_uiState.Faction.Id, TransferLeft, TransferRight, itemsToTransfer); + } + } + } + ImGui.EndChild(); } ImGui.SameLine(); @@ -139,15 +157,20 @@ private void DisplayStorageList(Entity entity) private void DisplayTradeList(Dictionary list, Entity entity) { var contentSize = ImGui.GetContentRegionAvail(); + var currentX = ImGui.GetCursorPosX(); + var toRemove = new List(); foreach(var (cargoable, value) in list) { var amount = (int)value.Item1; + if(ImGui.SmallButton("-###remove" + cargoable.Name)) + { + toRemove.Add(cargoable); + } + ImGui.SameLine(); ImGui.Text(cargoable.Name); ImGui.SameLine(); - byte[] buffer = new byte[16]; - ImGui.SetNextItemWidth(96); - ImGui.SetCursorPosX(contentSize.X - 96); + ImGui.SetCursorPosX(currentX + contentSize.X - 96); ImGui.InputInt("###input" + cargoable.Name, ref amount); cargoable.ShowTooltip(); @@ -158,6 +181,11 @@ private void DisplayTradeList(Dictionary list, Entity list[cargoable] = ((long)amount, value.Item2); } + + foreach(var item in toRemove) + { + list.Remove(item); + } } private void DisplayTransferSelection()