def refreshPanel(self, fit): # If we did anything intresting, we'd update our labels to reflect the new fit's stats here if fit is None and not self.showEffective: self.showEffective = True wx.PostEvent(self.mainFrame, GE.EffectiveHpToggled(effective=True)) return self.stEHPs.SetLabel(_t("EHP") if self.showEffective else _t("HP")) self.activeFit = fit.ID if fit is not None else None for tankType in ("shield", "armor", "hull"): for damageType in ("em", "thermal", "kinetic", "explosive"): if fit is not None: resonanceType = tankType if tankType != "hull" else "" resonance = "%s%sDamageResonance" % (resonanceType, damageType.capitalize()) resonance = resonance[0].lower() + resonance[1:] resonance = (1 - fit.ship.getModifiedItemAttr(resonance)) * 100 else: resonance = 0 lbl = getattr(self, "gaugeResistance%s%s" % (tankType.capitalize(), damageType.capitalize())) lbl.SetValue(resonance) ehp = (fit.ehp if self.showEffective else fit.hp) if fit is not None else None total = 0 for tankType, tooltip in (("shield", _t("Shield: ")), ("armor", _t("Armor: ")), ("hull", _t("Hull: "))): lbl = getattr(self, "labelResistance%sEhp" % tankType.capitalize()) if ehp is not None: total += ehp[tankType] rrFactor = fit.ehp[tankType] / fit.hp[tankType] lbl.SetLabel(formatAmount(ehp[tankType], 3, 0, 9)) lbl.SetToolTip( wx.ToolTip(tooltip + "%d\n" % ehp[tankType] + _t("Resist Multiplier: ") + "%.2fx" % rrFactor)) else: lbl.SetLabel("0") self.labelEhp.SetLabel("%s" % formatAmount(total, 3, 0, 9)) if self.showEffective: self.stEff.SetLabel("(" + _t("Effective HP: ")) self.labelEhp.SetToolTip(wx.ToolTip(_t("Effective: %d HP") % total)) else: self.stEff.SetLabel("(" + _t("Raw HP: ")) self.labelEhp.SetToolTip(wx.ToolTip(_t("Raw: %d HP") % total)) damagePattern = fit.damagePattern if fit is not None and self.showEffective else None total = sum((damagePattern.emAmount, damagePattern.thermalAmount, damagePattern.kineticAmount, damagePattern.explosiveAmount)) if damagePattern is not None else 0 for damageType in ("em", "thermal", "kinetic", "explosive"): lbl = getattr(self, "gaugeResistanceDamagepattern%s" % damageType.capitalize()) if damagePattern is not None: lbl.SetValueRange(getattr(damagePattern, "%sAmount" % damageType), total) else: lbl.SetValue(0) self.panel.Layout() self.headerPanel.Layout()
def toggleEHP(self, event): wx.PostEvent(self.mainFrame, GE.EffectiveHpToggled(effective=self.stEHPs.GetLabel() == _t("HP")))