Major gauges fix
This commit is contained in:
@@ -87,6 +87,7 @@ class PyGauge(wx.PyWindow):
|
||||
self._timerId = wx.NewId()
|
||||
self._timer = None
|
||||
|
||||
self._overdrive=0
|
||||
self.SetBarGradient((wx.Colour(153,153,153),wx.Colour(204,204,204)))
|
||||
self.SetBackgroundColour(wx.Colour(102,102,102))
|
||||
|
||||
@@ -205,6 +206,12 @@ class PyGauge(wx.PyWindow):
|
||||
|
||||
self.SortForDisplay()
|
||||
self.Refresh()
|
||||
if value > self._range:
|
||||
self._overdrive = value
|
||||
self._value[0] = self._range
|
||||
else:
|
||||
self._overdrive = value
|
||||
|
||||
for v in self._value:
|
||||
if v < 0 or v > self._range:
|
||||
raise Exception("ERROR:\n Gauge value must be between 0 and it's range. ")
|
||||
@@ -249,7 +256,11 @@ class PyGauge(wx.PyWindow):
|
||||
|
||||
if self.GetBarGradient():
|
||||
for i, gradient in enumerate(self._barGradientSorted):
|
||||
c1,c2 = gradient
|
||||
if self._overdrive > self._range:
|
||||
c1 =wx.Colour(255,33,33)
|
||||
c2 =wx.Colour(255,33,33)
|
||||
else:
|
||||
c1,c2 = gradient
|
||||
w = rect.width * (float(self._valueSorted[i]) / self._range)
|
||||
r = copy.copy(rect)
|
||||
r.width = w
|
||||
@@ -266,10 +277,15 @@ class PyGauge(wx.PyWindow):
|
||||
dc.SetTextForeground(wx.Colour(255,255,255))
|
||||
font1 = wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL)
|
||||
dc.SetFont(font1)
|
||||
if self._skipDigits == True:
|
||||
dc.DrawLabel(str(int(self._value[0]*100/self._range)) + "%", rect, wx.ALIGN_CENTER)
|
||||
if self._overdrive > self._range:
|
||||
value = self._overdrive
|
||||
else:
|
||||
dc.DrawLabel(str(round(float(self._value[0]*100/self._range)))+ "%",rect,wx.ALIGN_CENTER)
|
||||
value = self._value[0]
|
||||
|
||||
if self._skipDigits == True:
|
||||
dc.DrawLabel(str(int(value*100/self._range)) + "%", rect, wx.ALIGN_CENTER)
|
||||
else:
|
||||
dc.DrawLabel(str(round(float(value*100/self._range)))+ "%",rect,wx.ALIGN_CENTER)
|
||||
|
||||
def OnTimer(self,event):
|
||||
"""
|
||||
|
||||
@@ -90,6 +90,47 @@ class StatsPane(wx.Panel):
|
||||
label = getattr(self, labelName)
|
||||
label.SetLabel(("%." + str(rounding) + "f") % (value() if fit is not None else 0))
|
||||
|
||||
if fit is not None:
|
||||
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("cpuOutput"),
|
||||
lambda: fit.ship.getModifiedItemAttr("powerOutput"))
|
||||
|
||||
for panel in ("Mini","Full"):
|
||||
i=0
|
||||
for resourceType in ("cpu", "pg", "droneBay", "droneBandwidth"):
|
||||
if fit is not None:
|
||||
if i>1 and panel == "Mini": break
|
||||
|
||||
capitalizedType = resourceType[0].capitalize() + resourceType[1:]
|
||||
|
||||
gauge = getattr(self, "gauge%s%s" % (panel, capitalizedType))
|
||||
resUsed = getattr(fit,"%sUsed" % resourceType)
|
||||
|
||||
if resMax[i]() > 0:
|
||||
gauge.SetRange(resMax[i]())
|
||||
gauge.SetValue(resUsed)
|
||||
else:
|
||||
gauge.SetRange(100)
|
||||
gauge.SetValue(0)
|
||||
i+=1
|
||||
else:
|
||||
if i>1 and panel == "Mini": break
|
||||
|
||||
capitalizedType = resourceType[0].capitalize() + resourceType[1:]
|
||||
|
||||
gauge = getattr(self, "gauge%s%s" % (panel, capitalizedType))
|
||||
|
||||
gauge.SetRange(100)
|
||||
gauge.SetValue(0)
|
||||
i+=1
|
||||
|
||||
for labelName, value, rounding in stats:
|
||||
label = getattr(self, labelName)
|
||||
label.SetLabel(("%." + str(rounding) + "f") % (value() if fit is not None else 0))
|
||||
|
||||
# resMax = (("cpuTotal", lambda: fit.ship.getModifiedItemAttr("cpuOutput")),
|
||||
# ("pgTotal", lambda: fit.ship.getModifiedItemAttr("powerOutput")),
|
||||
# ("droneBayTotal", lambda: fit.ship.getModifiedItemAttr("droneCapacity")),
|
||||
@@ -124,7 +165,7 @@ class StatsPane(wx.Panel):
|
||||
gauge = getattr(self, "gauge%s%s" % (panel, capitalizedType))
|
||||
|
||||
gauge.SetRange(100)
|
||||
gauge.SetValue(0)
|
||||
gauge.SetValue(0)
|
||||
|
||||
for tankType in ("shield", "armor", "hull"):
|
||||
for damageType in ("em", "thermal", "kinetic", "explosive"):
|
||||
@@ -306,7 +347,7 @@ class StatsPane(wx.Panel):
|
||||
setattr(self, "label%sTotal%s" % (panel.capitalize(), capitalizedType), lbl)
|
||||
absolute.Add(lbl, 0, wx.ALIGN_LEFT)
|
||||
|
||||
# Gauges modif. - Darriele
|
||||
# Gauges modif. - Darriele
|
||||
if self._showNormalGauges == True:
|
||||
gauge = wx.Gauge(parent, wx.ID_ANY, 100)
|
||||
gauge.SetMinSize((80, 20))
|
||||
@@ -316,7 +357,9 @@ class StatsPane(wx.Panel):
|
||||
gauge.SetSkipDigitsFlag(True)
|
||||
|
||||
setattr(self, "gauge%s%s" % (panel.capitalize(),capitalizedType), gauge)
|
||||
|
||||
stats.Add(gauge, 0, wx.ALIGN_CENTER)
|
||||
|
||||
if panel == "mini":
|
||||
base.Add(wx.StaticLine(parent, wx.ID_ANY, style=wx.HORIZONTAL), 0, wx.EXPAND)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user