From 4278b602c3196b5b251f3a91b3a69bd5742932de Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Sun, 10 Oct 2010 22:31:19 +0300 Subject: [PATCH] Added more anim equations in pygauge class, changed gauge anim equation from OUT_QUAD to OUT_QUART --- gui/builtinStatsViews/resistancesViewFull.py | 8 +-- gui/pygauge.py | 53 +++++++++++++++++++- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/gui/builtinStatsViews/resistancesViewFull.py b/gui/builtinStatsViews/resistancesViewFull.py index 7f2497346..2453c0704 100644 --- a/gui/builtinStatsViews/resistancesViewFull.py +++ b/gui/builtinStatsViews/resistancesViewFull.py @@ -29,6 +29,8 @@ class ResistancesViewFull(StatsView): def __init__(self, parent): StatsView.__init__(self) self.parent = parent + self._cachedValues = [] + def getHeaderText(self, fit): return "Resistances" @@ -114,7 +116,7 @@ class ResistancesViewFull(StatsView): lbl.SetBarGradient() lbl.SetFractionDigits(1) - setattr(self, "labelResistance%s%s" % (tankType.capitalize(), damageType.capitalize()), lbl) + setattr(self, "gaugeResistance%s%s" % (tankType.capitalize(), damageType.capitalize()), lbl) box.Add(lbl, 0, wx.ALIGN_CENTER) col+=1 @@ -144,7 +146,7 @@ class ResistancesViewFull(StatsView): else: resonance = 0 - lbl = getattr(self, "labelResistance%s%s" % (tankType.capitalize(), damageType.capitalize())) + lbl = getattr(self, "gaugeResistance%s%s" % (tankType.capitalize(), damageType.capitalize())) lbl.SetValue(resonance) @@ -165,7 +167,7 @@ class ResistancesViewFull(StatsView): damagePattern = fit.damagePattern if fit is not None else None for damageType in ("em", "thermal", "kinetic", "explosive"): - lbl = getattr(self, "labelResistanceDamagepattern%s" % damageType.capitalize()) + lbl = getattr(self, "gaugeResistanceDamagepattern%s" % damageType.capitalize()) if damagePattern is not None: lbl.SetValue(getattr(damagePattern, "%sAmount" % damageType)) else: diff --git a/gui/pygauge.py b/gui/pygauge.py index df4e8752c..b9f4011fd 100644 --- a/gui/pygauge.py +++ b/gui/pygauge.py @@ -13,6 +13,7 @@ It uses the easeOutQuad equation from caurina.transitions.Tweener to do the anim import wx import copy +import math class PyGauge(wx.PyWindow): """ @@ -54,7 +55,7 @@ class PyGauge(wx.PyWindow): self._animDuration = 600 self._animStep = 0 - self._period = 25 + self._period = 10 self._animValue = 0 @@ -341,6 +342,41 @@ class PyGauge(wx.PyWindow): formatStr = "{0:." + str(self._fractionDigits) + "f}%" dc.DrawLabel(formatStr.format(value), rect, wx.ALIGN_CENTER) + def OUT_CIRC (self, t, b, c, d): + t=float(t) + b=float(b) + c=float(c) + d=float(d) + t = t/d -1 + return c * math.sqrt(1 - t*t) + b; + + def OUT_QUART(self, t, b, c, d): + t=float(t) + b=float(b) + c=float(c) + d=float(d) + t = t/d -1 + return -c * ((t)*t*t*t - 1) + b; + + def INOUT_CIRC(self, t, b, c, d): + t=float(t) + b=float(b) + c=float(c) + d=float(d) + t1 = t / (d / 2) + + if ((t / (d/2)) < 1): + return -c/2 * (math.sqrt(1 - (t/(d/2))**2) - 1) + b + return c/2 * (math.sqrt(1 - (t1-2)**2) + 1) + b; + + def IN_CUBIC (self, t, b, c, d): + t=float(t) + b=float(b) + c=float(c) + d=float(d) + t = t/d + return c*t*t*t + b + def OUT_QUAD (self, t, b, c, d): t=float(t) b=float(b) @@ -373,6 +409,19 @@ class PyGauge(wx.PyWindow): t-=(2.625/2.75) return c*(7.5625*(t)*t + .984375) + b + def INOUT_EXP(self, t, b, c, d): + t=float(t) + b=float(b) + c=float(c) + d=float(d) + t1 = t / (d/2) + if t==0: + return b + if t==d: + return b+c + if (t1) < 1: + return c/2 * math.pow(2, 10 * (t1 - 1)) + b - c * 0.0005 + return c/2 * 1.0005 * (-math.pow(2, -10 * (t1-1)) + 2) + b def OnTimer(self,event): @@ -393,7 +442,7 @@ class PyGauge(wx.PyWindow): start = 0 end = oldValue - value - step=self.OUT_QUAD(self._animStep, start, end, self._animDuration) + step=self.OUT_QUART(self._animStep, start, end, self._animDuration) self._animStep += self._period if self._timerId == event.GetId():