Added cargo gauge to resources and ability to toggle

This commit is contained in:
blitzmann
2014-05-08 13:56:22 -04:00
parent 6992537750
commit 40c1bc8ae6
5 changed files with 58 additions and 14 deletions

View File

@@ -1037,6 +1037,14 @@ class Fit(object):
return amount
@property
def cargoBayUsed(self):
amount = 0
for c in self.cargo:
amount += c.getModifiedItemAttr("volume") * c.amount
return amount
@property
def activeDrones(self):
amount = 0

View File

@@ -70,7 +70,9 @@ class AdditionsPane(TogglePanel):
self.notebook.AddPage(self.gangPage, "Fleet", tabImage = gangImg, showClose = False)
self.notebook.SetSelection(0)
PANES = ["Drones", "Cargo", "Implants", "Boosters", "Projected", "Fleet"]
def select(self, name):
self.notebook.SetSelection(self.PANES.index(name))
def getName(self, idx):
return self.PANES[idx]

View File

@@ -22,6 +22,8 @@ from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from gui import pygauge as PG
import gui.mainFrame
import gui.chromeTabs
from eos.types import Hardpoint
@@ -32,6 +34,31 @@ class ResourcesViewFull(StatsView):
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.mainFrame.additionsPane.notebook.Bind(gui.chromeTabs.EVT_NOTEBOOK_PAGE_CHANGED, self.pageChanged)
def pageChanged(self, event):
page = self.mainFrame.additionsPane.getName(event.GetSelection())
if page == "Cargo":
self.toggleCargoGauge(True)
else:
self.toggleCargoGauge(False)
def toggleCargoGauge(self, showCargo = False):
if showCargo:
self.bitmapFullCargoBay.Show()
self.baseFullCargoBay.Show(True)
self.bitmapFullDroneBay.Hide()
self.baseFullDroneBay.Hide(True)
else:
self.bitmapFullDroneBay.Show()
self.baseFullDroneBay.Show(True)
self.bitmapFullCargoBay.Hide()
self.baseFullCargoBay.Hide(True)
self.panel.Layout()
self.headerPanel.Layout()
def getHeaderText(self, fit):
return "Resources"
@@ -85,8 +112,8 @@ class ResourcesViewFull(StatsView):
#PG, Cpu & drone stuff
tooltipText = {"cpu":"CPU", "pg":"PowerGrid", "droneBay":"Drone bay", "droneBandwidth":"Drone bandwidth"}
for i, group in enumerate((("cpu", "pg"), ("droneBay", "droneBandwidth"))):
tooltipText = {"cpu":"CPU", "pg":"PowerGrid", "droneBay":"Drone bay", "droneBandwidth":"Drone bandwidth", "cargoBay":"Cargo bay"}
for i, group in enumerate((("cpu", "pg"), ("cargoBay", "droneBay", "droneBandwidth"))):
main = wx.BoxSizer(wx.VERTICAL)
base.Add(main, 1 , wx.ALIGN_CENTER)
@@ -117,7 +144,7 @@ class ResourcesViewFull(StatsView):
setattr(self, "label%sTotal%s" % (panel.capitalize(), capitalizedType), lbl)
absolute.Add(lbl, 0, wx.ALIGN_LEFT)
units = {"cpu":" tf", "pg":" MW", "droneBandwidth":" mbit/s", "droneBay":u" m\u00B3"}
units = {"cpu":" tf", "pg":" MW", "droneBandwidth":" mbit/s", "droneBay":u" m\u00B3", "cargoBay":u" m\u00B3"}
lbl = wx.StaticText(parent, wx.ID_ANY, "%s" % units[type])
absolute.Add(lbl, 0, wx.ALIGN_LEFT)
@@ -131,6 +158,11 @@ class ResourcesViewFull(StatsView):
setattr(self, "gauge%s%s" % (panel.capitalize(),capitalizedType), gauge)
stats.Add(gauge, 0, wx.ALIGN_CENTER)
setattr(self, "base%s%s" % (panel.capitalize(), capitalizedType), b)
setattr(self, "bitmap%s%s" % (panel.capitalize(), capitalizedType), bitmap)
self.toggleCargoGauge(False)
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
@@ -149,7 +181,9 @@ class ResourcesViewFull(StatsView):
("label%sUsedDroneBay", lambda: fit.droneBayUsed, 3, 0, 9),
("label%sUsedDroneBandwidth", lambda: fit.droneBandwidthUsed, 3, 0, 9),
("label%sTotalDroneBay", lambda: fit.ship.getModifiedItemAttr("droneCapacity"), 3, 0, 9),
("label%sTotalDroneBandwidth", lambda: fit.ship.getModifiedItemAttr("droneBandwidth"), 3, 0, 9))
("label%sTotalDroneBandwidth", lambda: fit.ship.getModifiedItemAttr("droneBandwidth"), 3, 0, 9),
("label%sUsedCargoBay", lambda: fit.cargoBayUsed, 3, 0, 9),
("label%sTotalCargoBay", lambda: fit.ship.getModifiedItemAttr("capacity"), 3, 0, 9))
panel = "Full"
usedTurretHardpoints = 0
totalTurretHardpoints = 0
@@ -232,10 +266,11 @@ class ResourcesViewFull(StatsView):
resMax = (lambda: fit.ship.getModifiedItemAttr("cpuOutput"),
lambda: fit.ship.getModifiedItemAttr("powerOutput"),
lambda: fit.ship.getModifiedItemAttr("droneCapacity"),
lambda: fit.ship.getModifiedItemAttr("droneBandwidth"))
lambda: fit.ship.getModifiedItemAttr("droneBandwidth"),
lambda: fit.ship.getModifiedItemAttr("capacity"))
i = 0
for resourceType in ("cpu", "pg", "droneBay", "droneBandwidth"):
for resourceType in ("cpu", "pg", "droneBay", "droneBandwidth", "cargoBay"):
if fit is not None:
capitalizedType = resourceType[0].capitalize() + resourceType[1:]

View File

@@ -137,6 +137,10 @@ class TargetingMiscViewFull(StatsView):
label.SetToolTip(wx.ToolTip("Max Warp Distance: %.1f AU" % fit.maxWarpDistance))
elif labelName == "labelFullAlignTime":
label.SetToolTip(wx.ToolTip("%.3f" % value))
elif labelName == "labelFullCargo":
tip = u"Capacity: %sm\u00B3\n"% fit.ship.getModifiedItemAttr("capacity")
tip += u"Available: %.1fm\u00B3" % (fit.ship.getModifiedItemAttr("capacity")-fit.cargoBayUsed)
label.SetToolTip(wx.ToolTip(tip))
else:
label.SetToolTip(wx.ToolTip("%.1f" % value))
else:
@@ -151,13 +155,8 @@ class TargetingMiscViewFull(StatsView):
if 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
tip = u"Capacity: %sm\u00B3\n"% fit.ship.getModifiedItemAttr("capacity")
tip += u"Available: %.1fm\u00B3" % (fit.ship.getModifiedItemAttr("capacity")-fit.cargoBayUsed)
label.SetToolTip(wx.ToolTip(tip))
else:
label.SetToolTip(wx.ToolTip(""))

BIN
icons/cargoBay_big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B