Added available cargo to capacity tooltip and cargo volume column
This commit is contained in:
@@ -24,11 +24,8 @@ class Cargo(ContextMenu):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
cargo = eos.types.Cargo(selection[0])
|
||||
|
||||
dlg = CargoChanger(self.mainFrame, cargo, fullContext)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
sFit.addChangeCargo(fitID,cargo, 1)
|
||||
self.mainFrame.additionsPane.notebook.SetSelection(1)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
Cargo.register()
|
||||
@@ -60,11 +57,12 @@ class CargoChanger(wx.Dialog):
|
||||
|
||||
bSizer1 = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
self.input = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
self.input = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_PROCESS_ENTER)
|
||||
|
||||
bSizer1.Add(self.input, 0, wx.ALL, 5)
|
||||
bSizer1.Add(self.input, 1, wx.ALL, 5)
|
||||
self.input.Bind(wx.EVT_CHAR, self.onChar)
|
||||
self.button = wx.Button(self, wx.ID_OK, u"Change")
|
||||
self.input.Bind(wx.EVT_TEXT_ENTER, self.change)
|
||||
self.button = wx.Button(self, wx.ID_OK, u"Done")
|
||||
bSizer1.Add(self.button, 0, wx.ALL, 5)
|
||||
|
||||
self.SetSizer(bSizer1)
|
||||
@@ -80,15 +78,15 @@ class CargoChanger(wx.Dialog):
|
||||
sFit.addChangeCargo(fitID, self.cargo, int(self.input.GetLineText(0)))
|
||||
|
||||
wx.PostEvent(mainFrame, GE.FitChanged(fitID=fitID))
|
||||
event.Skip()
|
||||
|
||||
event.Skip()
|
||||
self.Destroy()
|
||||
## checks to make sure it's valid number
|
||||
def onChar(self, event):
|
||||
key = event.GetKeyCode()
|
||||
|
||||
acceptable_characters = "1234567890"
|
||||
acceptable_keycode = [3, 22, 13, 8, 127] # modifiers like delete, copy, paste
|
||||
|
||||
if key in acceptable_keycode or key >= 255 or (key < 255 and chr(key) in acceptable_characters):
|
||||
event.Skip()
|
||||
return
|
||||
|
||||
@@ -95,7 +95,7 @@ class TargetingMiscViewFull(StatsView):
|
||||
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
||||
#If we did anything interesting, we'd update our labels to reflect the new fit's stats here
|
||||
|
||||
stats = (("labelTargets", lambda: fit.maxTargets, 3, 0, 0, ""),
|
||||
("labelRange", lambda: fit.maxTargetRange / 1000, 3, 0, 0, "km"),
|
||||
@@ -142,11 +142,21 @@ class TargetingMiscViewFull(StatsView):
|
||||
else:
|
||||
label.SetToolTip(wx.ToolTip(""))
|
||||
self._cachedValues[counter] = value
|
||||
elif labelName == "labelFullWarpSpeed":
|
||||
if fit:
|
||||
elif labelName == "labelFullWarpSpeed" and fit:
|
||||
label.SetToolTip(wx.ToolTip("Max Warp Distance: %.1f AU" % fit.maxWarpDistance))
|
||||
else:
|
||||
label.SetToolTip(wx.ToolTip(""))
|
||||
elif labelName == "labelFullCargo" and fit:
|
||||
# if you add stuff to cargo, the capacity doesn't change and thus it is still cached
|
||||
# This assures us that we force refresh of cargo tooltip
|
||||
capacity = fit.ship.getModifiedItemAttr("capacity")
|
||||
cargoSize = 0
|
||||
for mod in fit.cargo:
|
||||
cargoSize += mod.getModifiedItemAttr("volume") * mod.amount
|
||||
a = capacity-cargoSize
|
||||
tip = u"Capacity: %sm\u00B3\n"% capacity
|
||||
tip += u"Available: %.1fm\u00B3" %a
|
||||
label.SetToolTip(wx.ToolTip(tip))
|
||||
else:
|
||||
label.SetToolTip(wx.ToolTip(""))
|
||||
|
||||
counter += 1
|
||||
|
||||
|
||||
@@ -75,10 +75,16 @@ class AttributeDisplay(ViewColumn):
|
||||
else:
|
||||
attr = mod.getAttribute(self.info.name)
|
||||
|
||||
if self.info.name == "volume":
|
||||
str = (formatAmount(attr, 3, 0, 3))
|
||||
if hasattr(mod, "amount"):
|
||||
str = str + u"m\u00B3 (%s m\u00B3)"%(formatAmount(attr*mod.amount, 3, 0, 3))
|
||||
attr = str
|
||||
|
||||
if isinstance(attr, (float, int)):
|
||||
return (formatAmount(attr, 3, 0, 3))
|
||||
else:
|
||||
return attr if attr is not None else ""
|
||||
attr = (formatAmount(attr, 3, 0, 3))
|
||||
|
||||
return attr if attr is not None else ""
|
||||
|
||||
def getImageId(self, mod):
|
||||
return -1
|
||||
|
||||
@@ -27,7 +27,9 @@ import globalEvents as GE
|
||||
|
||||
# @todo: Was copied form another class and modified. Look through entire file, refine
|
||||
class CargoView(d.Display):
|
||||
DEFAULT_COLS = ["Base Name"]
|
||||
DEFAULT_COLS = ["Base Icon",
|
||||
"Base Name",
|
||||
"attr:volume"]
|
||||
|
||||
def __init__(self, parent):
|
||||
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL | wx.BORDER_NONE)
|
||||
|
||||
Reference in New Issue
Block a user