MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / refreshPanel

Method refreshPanel

gui/builtinStatsViews/capacitorViewFull.py:108–176  ·  view source on GitHub ↗
(self, fit)

Source from the content-addressed store, hash-verified

106 chargeSizer.Add(lbl, 0, wx.ALIGN_CENTER)
107
108 def refreshPanel(self, fit):
109 # If we did anything intresting, we'd update our labels to reflect the new fit's stats here
110 stats = (
111 ("label%sCapacitorCapacity", lambda: fit.ship.getModifiedItemAttr("capacitorCapacity"), 3, 0, 9, False, ''),
112 ("label%sCapacitorDelta", lambda: fit.capDelta, 3, 0, 0, True, ' GJ/s'),
113 ("label%sCapacitorResist", lambda: (1 - fit.ship.getModifiedItemAttr("energyWarfareResistance", 1)) * 100, 3, 0, 0, False, '%'),
114 )
115 if fit is not None:
116 cap_amount = fit.ship.getModifiedItemAttr("capacitorCapacity")
117 cap_recharge = fit.capRecharge
118 cap_use = fit.capUsed
119 neut_res = fit.ship.getModifiedItemAttr("energyWarfareResistance", 1)
120 else:
121 cap_amount = 0
122 cap_recharge = 0
123 cap_use = 0
124 neut_res = 1
125
126 panel = "Full"
127 for labelName, value, prec, lowest, highest, forceSign, unit in stats:
128 label = getattr(self, labelName % panel)
129 value = value() if fit is not None else 0
130 value = value if value is not None else 0
131 if isinstance(value, str):
132 label.SetLabel(value)
133 label.SetToolTip(wx.ToolTip(value))
134 else:
135 label.SetLabel('{}{}'.format(formatAmount(value, prec, lowest, highest, forceSign=forceSign), unit))
136 label.SetToolTip(wx.ToolTip("%.1f" % value))
137
138 if labelName == 'label%sCapacitorDelta' and (cap_recharge or cap_use):
139 lines = [_t('Capacitor delta:'),
140 ' +{} GJ/s'.format(formatAmount(cap_recharge, 3, 0, 3)),
141 ' -{} GJ/s'.format(formatAmount(cap_use, 3, 0, 3))]
142 delta = round(cap_recharge - cap_use, 3)
143 if delta > 0 and 0 < round(neut_res, 4) < 1:
144 lines.append('')
145 lines.append('Effective excessive gain:')
146 lines.append(' +{} GJ/s'.format(formatAmount(delta / neut_res, 3, 0, 3)))
147 label.SetToolTip(wx.ToolTip('\n'.join(lines)))
148 if labelName == 'label%sCapacitorResist':
149 texts = [_t('Neutralizer resistance')]
150 if cap_amount > 0 and 0 < round(neut_res, 4) < 1:
151 texts.append(_t('Effective capacity') + ': {} GJ'.format(formatAmount(cap_amount / neut_res, 3, 0, 9)))
152 label.SetToolTip(wx.ToolTip('\n'.join(texts)))
153
154 capState = fit.capState if fit is not None else 0
155 capStable = fit.capStable if fit is not None else False
156 lblNameTime = "label%sCapacitorTime"
157 lblNameState = "label%sCapacitorState"
158 if isinstance(capState, tuple) and len(capState) >= 2:
159 t = ("{0}%-{1}%", capState[0], capState[1])
160 s = ""
161 else:
162 if capStable:
163 t = "%.1f%%" % capState
164 else:
165 if capState > 60:

Callers

nothing calls this directly

Calls 5

formatAmountFunction · 0.90
SetLabelMethod · 0.80
_tFunction · 0.50
getModifiedItemAttrMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected