Merge branch 'master' of evefit.org:pyfa
This commit is contained in:
@@ -45,7 +45,7 @@ class PyGauge(wx.PyWindow):
|
|||||||
self._range = range
|
self._range = range
|
||||||
self._value = 0
|
self._value = 0
|
||||||
|
|
||||||
self._skipDigits = True
|
self._fractionDigits = 0
|
||||||
self._timerId = wx.NewId()
|
self._timerId = wx.NewId()
|
||||||
self._timer = None
|
self._timer = None
|
||||||
self._timerOver = None
|
self._timerOver = None
|
||||||
@@ -100,8 +100,8 @@ class PyGauge(wx.PyWindow):
|
|||||||
SetBarColor = SetBarColour
|
SetBarColor = SetBarColour
|
||||||
GetBarColor = GetBarColour
|
GetBarColor = GetBarColour
|
||||||
|
|
||||||
def SetSkipDigitsFlag(self,flag):
|
def SetFractionDigits(self, digits):
|
||||||
self._skipDigits=flag
|
self._fractionDigits=digits
|
||||||
|
|
||||||
def GetBarGradient(self):
|
def GetBarGradient(self):
|
||||||
""" Returns a tuple containing the gradient start and end colours. """
|
""" Returns a tuple containing the gradient start and end colours. """
|
||||||
@@ -189,12 +189,12 @@ class PyGauge(wx.PyWindow):
|
|||||||
if value < 0:
|
if value < 0:
|
||||||
self._value = 0
|
self._value = 0
|
||||||
self._overdrive = 0
|
self._overdrive = 0
|
||||||
|
|
||||||
if not self._timer:
|
if not self._timer:
|
||||||
self._timer = wx.Timer(self, self._timerId)
|
self._timer = wx.Timer(self, self._timerId)
|
||||||
self._animStep = 0
|
self._animStep = 0
|
||||||
self._timer.Start(self._period)
|
self._timer.Start(self._period)
|
||||||
|
|
||||||
def OnEraseBackground(self, event):
|
def OnEraseBackground(self, event):
|
||||||
"""
|
"""
|
||||||
Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{PyGauge}.
|
Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{PyGauge}.
|
||||||
@@ -228,7 +228,7 @@ class PyGauge(wx.PyWindow):
|
|||||||
if self._timer:
|
if self._timer:
|
||||||
if self._timer.IsRunning():
|
if self._timer.IsRunning():
|
||||||
value = self._animValue
|
value = self._animValue
|
||||||
|
|
||||||
if self._border_colour:
|
if self._border_colour:
|
||||||
dc.SetPen(wx.Pen(self.GetBorderColour()))
|
dc.SetPen(wx.Pen(self.GetBorderColour()))
|
||||||
dc.DrawRectangleRect(rect)
|
dc.DrawRectangleRect(rect)
|
||||||
@@ -244,7 +244,7 @@ class PyGauge(wx.PyWindow):
|
|||||||
else:
|
else:
|
||||||
c1 =wx.Colour(255,0,0)
|
c1 =wx.Colour(255,0,0)
|
||||||
c2 =wx.Colour(255,0,0)
|
c2 =wx.Colour(255,0,0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
c1,c2 = self.GetBarGradient()
|
c1,c2 = self.GetBarGradient()
|
||||||
|
|
||||||
@@ -268,10 +268,8 @@ class PyGauge(wx.PyWindow):
|
|||||||
if self._overdrive > self._range:
|
if self._overdrive > self._range:
|
||||||
value = self._overdrive
|
value = self._overdrive
|
||||||
self._tooltip.SetTip("%.2f/%.2f" % (value, self._range))
|
self._tooltip.SetTip("%.2f/%.2f" % (value, self._range))
|
||||||
if self._skipDigits == True:
|
formatStr = "{0:." + str(self._fractionDigits) + "f}%"
|
||||||
dc.DrawLabel("%d%%" % (value*100/self._range), rect, wx.ALIGN_CENTER)
|
dc.DrawLabel(formatStr.format((value*100/self._range)), rect, wx.ALIGN_CENTER)
|
||||||
else:
|
|
||||||
dc.DrawLabel("%.1f%%" % (value * 100 / self._range) , rect, wx.ALIGN_CENTER)
|
|
||||||
|
|
||||||
def OUT_QUAD (self, t, b, c, d):
|
def OUT_QUAD (self, t, b, c, d):
|
||||||
t=float(t)
|
t=float(t)
|
||||||
@@ -282,7 +280,7 @@ class PyGauge(wx.PyWindow):
|
|||||||
t/=d
|
t/=d
|
||||||
|
|
||||||
return -c *(t)*(t-2) + b
|
return -c *(t)*(t-2) + b
|
||||||
|
|
||||||
def OUT_BOUNCE (self, t, b, c, d):
|
def OUT_BOUNCE (self, t, b, c, d):
|
||||||
t=float(t)
|
t=float(t)
|
||||||
b=float(b)
|
b=float(b)
|
||||||
@@ -304,7 +302,7 @@ class PyGauge(wx.PyWindow):
|
|||||||
else:
|
else:
|
||||||
t-=(2.625/2.75)
|
t-=(2.625/2.75)
|
||||||
return c*(7.5625*(t)*t + .984375) + b
|
return c*(7.5625*(t)*t + .984375) + b
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def OnTimer(self,event):
|
def OnTimer(self,event):
|
||||||
@@ -331,7 +329,7 @@ class PyGauge(wx.PyWindow):
|
|||||||
if self._timerId == event.GetId():
|
if self._timerId == event.GetId():
|
||||||
# and self._overdriveTimerId != event.GetId():
|
# and self._overdriveTimerId != event.GetId():
|
||||||
stop_timer = False
|
stop_timer = False
|
||||||
|
|
||||||
if self._animStep > self._animDuration:
|
if self._animStep > self._animDuration:
|
||||||
stop_timer = True
|
stop_timer = True
|
||||||
|
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ class StatsPane(wx.Panel):
|
|||||||
else:
|
else:
|
||||||
gauge = PG.PyGauge(parent, wx.ID_ANY, 100)
|
gauge = PG.PyGauge(parent, wx.ID_ANY, 100)
|
||||||
gauge.SetMinSize((self.getTextExtentW("999.9k/1.3M GJ"), 23))
|
gauge.SetMinSize((self.getTextExtentW("999.9k/1.3M GJ"), 23))
|
||||||
gauge.SetSkipDigitsFlag(True)
|
gauge.SetFractionDigits(2)
|
||||||
|
|
||||||
setattr(self, "gauge%s%s" % (panel.capitalize(),capitalizedType), gauge)
|
setattr(self, "gauge%s%s" % (panel.capitalize(),capitalizedType), gauge)
|
||||||
stats.Add(gauge, 0, wx.ALIGN_CENTER)
|
stats.Add(gauge, 0, wx.ALIGN_CENTER)
|
||||||
@@ -460,7 +460,7 @@ class StatsPane(wx.Panel):
|
|||||||
lbl.SetBackgroundColour(wx.Colour(bc[0],bc[1],bc[2]))
|
lbl.SetBackgroundColour(wx.Colour(bc[0],bc[1],bc[2]))
|
||||||
lbl.SetBarColour(wx.Colour(fc[0],fc[1],fc[2]))
|
lbl.SetBarColour(wx.Colour(fc[0],fc[1],fc[2]))
|
||||||
lbl.SetBarGradient()
|
lbl.SetBarGradient()
|
||||||
lbl.SetSkipDigitsFlag(False)
|
lbl.SetFractionDigits(1)
|
||||||
|
|
||||||
setattr(self, "labelResistance%s%s" % (tankType.capitalize(), damageType.capitalize()), lbl)
|
setattr(self, "labelResistance%s%s" % (tankType.capitalize(), damageType.capitalize()), lbl)
|
||||||
box.Add(lbl, 0, wx.ALIGN_CENTER)
|
box.Add(lbl, 0, wx.ALIGN_CENTER)
|
||||||
|
|||||||
6
util.py
6
util.py
@@ -1,4 +1,4 @@
|
|||||||
def formatAmount(val, prec=4, lowest=0, highest=0):
|
def formatAmount(val, prec=3, lowest=0, highest=0):
|
||||||
"""
|
"""
|
||||||
Add suffix to value, transform value to match new suffix and round it.
|
Add suffix to value, transform value to match new suffix and round it.
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ def formatAmount(val, prec=4, lowest=0, highest=0):
|
|||||||
result = u"{0}{1}".format(newMantissa, suffix)
|
result = u"{0}{1}".format(newMantissa, suffix)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def suffixizeAmount(val, lowest, highest):
|
def suffixizeAmount(val, lowest=-6, highest=9):
|
||||||
"""
|
"""
|
||||||
Add suffix to value and transform value to match new suffix.
|
Add suffix to value and transform value to match new suffix.
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ def suffixizeAmount(val, lowest, highest):
|
|||||||
else:
|
else:
|
||||||
return val, ""
|
return val, ""
|
||||||
|
|
||||||
def processAmount(val, prec):
|
def processAmount(val, prec=3):
|
||||||
"""
|
"""
|
||||||
Round number and return as string.
|
Round number and return as string.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user