forked from pyfa-org/Pyfa
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcargoAddAmmo.py
More file actions
54 lines (39 loc) · 1.77 KB
/
cargoAddAmmo.py
File metadata and controls
54 lines (39 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import wx
import gui.fitCommands as cmd
import gui.mainFrame
from gui.contextMenu import ContextMenuSingle
_t = wx.GetTranslation
class AddToCargoAmmo(ContextMenuSingle):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, callingWindow, srcContext, mainItem):
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
return False
if mainItem is None:
return False
if mainItem.category.ID != 8:
return False
return True
def getText(self, callingWindow, itmContext, mainItem):
if mainItem.marketGroup.name == "Scan Probes":
return _t("Add {0} to Cargo (x8)").format(itmContext)
return _t("Add a variable amount of {0} to cargo").format(itmContext)
def activate(self, callingWindow, fullContext, mainItem, i):
fitID = self.mainFrame.getActiveFit()
typeID = int(mainItem.ID)
if mainItem.marketGroup.name == "Scan Probes":
command = cmd.GuiAddCargoCommand(fitID=fitID, itemID=typeID, amount=8)
else:
quantity_to_add = wx.TextEntryDialog(None, "How many would you like to add to cargo",
'Quantity', 'number')
if quantity_to_add.ShowModal() == wx.ID_OK:
try:
quantity = int(quantity_to_add.GetValue())
except:
quantity = 0
else:
quantity = 0
command = cmd.GuiAddCargoCommand(fitID=fitID, itemID=typeID, amount=quantity)
if self.mainFrame.command.Submit(command):
self.mainFrame.additionsPane.select("Cargo", focus=False)
AddToCargoAmmo.register()