Skip to content

Commit 6e4ca64

Browse files
committed
Allow usage of existing item to fill cargo
1 parent 46c6381 commit 6e4ca64

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

gui/builtinContextMenus/cargoFill.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import gui.mainFrame
55
from gui.contextMenu import ContextMenuSingle
66
from service.fit import Fit
7+
from eos.saveddata.cargo import Cargo
78

89
_t = wx.GetTranslation
910

@@ -13,7 +14,7 @@ def __init__(self):
1314
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
1415

1516
def display(self, callingWindow, srcContext, mainItem):
16-
if srcContext not in ("marketItemGroup", "marketItemMisc"):
17+
if srcContext not in ("marketItemGroup", "marketItemMisc", "cargoItem"):
1718
return False
1819

1920
if mainItem is None:
@@ -22,9 +23,9 @@ def display(self, callingWindow, srcContext, mainItem):
2223
if self.mainFrame.getActiveFit() is None:
2324
return False
2425

25-
# Only allow items that can be stored in cargo
26-
if not (mainItem.isCharge or mainItem.isCommodity):
27-
return False
26+
if srcContext in ("marketItemGroup", "marketItemMisc"):
27+
if not (mainItem.isCharge or mainItem.isCommodity):
28+
return False
2829

2930
return True
3031

@@ -35,8 +36,13 @@ def activate(self, callingWindow, fullContext, mainItem, i):
3536
fitID = self.mainFrame.getActiveFit()
3637
fit = Fit.getInstance().getFit(fitID)
3738

38-
# Get the item's volume
39-
itemVolume = mainItem.attributes['volume'].value
39+
if isinstance(mainItem, Cargo):
40+
itemVolume = mainItem.item.attributes['volume'].value
41+
itemID = mainItem.itemID
42+
else:
43+
itemVolume = mainItem.attributes['volume'].value
44+
itemID = int(mainItem.ID)
45+
4046
if itemVolume is None or itemVolume <= 0:
4147
return
4248

@@ -54,7 +60,7 @@ def activate(self, callingWindow, fullContext, mainItem, i):
5460
return
5561

5662
# Add the items to cargo
57-
command = cmd.GuiAddCargoCommand(fitID=fitID, itemID=int(mainItem.ID), amount=maxAmount)
63+
command = cmd.GuiAddCargoCommand(fitID=fitID, itemID=itemID, amount=maxAmount)
5864
if self.mainFrame.command.Submit(command):
5965
self.mainFrame.additionsPane.select("Cargo", focus=False)
6066

0 commit comments

Comments
 (0)