|
| 1 | +# ============================================================================= |
| 2 | +# Copyright (C) 2010 Diego Duclos |
| 3 | +# |
| 4 | +# This file is part of pyfa. |
| 5 | +# |
| 6 | +# pyfa is free software: you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU General Public License as published by |
| 8 | +# the Free Software Foundation, either version 3 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# pyfa is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License |
| 17 | +# along with pyfa. If not, see <http://www.gnu.org/licenses/>. |
| 18 | +# ============================================================================= |
| 19 | + |
| 20 | +# noinspection PyPackageRequirements |
| 21 | +import wx |
| 22 | + |
| 23 | +import gui.mainFrame |
| 24 | +from gui.bitmap_loader import BitmapLoader |
| 25 | +from gui.statsView import StatsView |
| 26 | + |
| 27 | +_t = wx.GetTranslation |
| 28 | + |
| 29 | + |
| 30 | +class BombingViewFull(StatsView): |
| 31 | + name = "bombingViewFull" |
| 32 | + |
| 33 | + def __init__(self, parent): |
| 34 | + StatsView.__init__(self) |
| 35 | + self.parent = parent |
| 36 | + self._cachedValues = [] |
| 37 | + self.mainFrame = gui.mainFrame.MainFrame.getInstance() |
| 38 | + |
| 39 | + def getHeaderText(self, fit): |
| 40 | + return _t("Bombing") |
| 41 | + |
| 42 | + def getTextExtentW(self, text): |
| 43 | + width, height = self.parent.GetTextExtent(text) |
| 44 | + return width |
| 45 | + |
| 46 | + def populatePanel(self, contentPanel, headerPanel): |
| 47 | + contentSizer = contentPanel.GetSizer() |
| 48 | + self.panel = contentPanel |
| 49 | + |
| 50 | + self.headerPanel = headerPanel |
| 51 | + |
| 52 | + # Display table |
| 53 | + sizerBombing = wx.FlexGridSizer(7, 5, 0, 0) |
| 54 | + for i in range(4): |
| 55 | + sizerBombing.AddGrowableCol(i + 1) |
| 56 | + contentSizer.Add(sizerBombing, 0, wx.EXPAND, 0) |
| 57 | + |
| 58 | + # Add an empty label, then the rest. |
| 59 | + sizerBombing.Add(wx.StaticText(contentPanel, wx.ID_ANY, ""), 0) |
| 60 | + toolTipText = { |
| 61 | + "em": _t("Electron Bomb"), |
| 62 | + "thermal": _t("Scorch Bomb"), |
| 63 | + "kinetic": _t("Concussion Bomb"), |
| 64 | + "explosive": _t("Shrapnel Bomb") |
| 65 | + } |
| 66 | + for damageType in ("em", "thermal", "kinetic", "explosive"): |
| 67 | + bitmap = BitmapLoader.getStaticBitmap("%s_big" % damageType, contentPanel, "gui") |
| 68 | + tooltip = wx.ToolTip(toolTipText[damageType]) |
| 69 | + bitmap.SetToolTip(tooltip) |
| 70 | + sizerBombing.Add(bitmap, 0, wx.ALIGN_CENTER) |
| 71 | + |
| 72 | + for covertLevel in ("0", "1", "2", "3", "4", "5"): |
| 73 | + label = wx.StaticText(contentPanel, wx.ID_ANY, "%s" % covertLevel) |
| 74 | + tooltip = wx.ToolTip(_t("Covert Ops level")) |
| 75 | + label.SetToolTip(tooltip) |
| 76 | + sizerBombing.Add(label, 0, wx.ALIGN_CENTER) |
| 77 | + |
| 78 | + for damageType in ("em", "thermal", "kinetic", "explosive"): |
| 79 | + label = wx.StaticText(contentPanel, wx.ID_ANY, "0.0") |
| 80 | + setattr(self, "labelDamagetypeCovertlevel%s%s" % (damageType.capitalize(), covertLevel), label) |
| 81 | + sizerBombing.Add(label, 0, wx.ALIGN_CENTER) |
| 82 | + |
| 83 | + def refreshPanel(self, fit): |
| 84 | + # If we did anything interesting, we'd update our labels to reflect the new fit's stats here |
| 85 | + if fit is None: |
| 86 | + return |
| 87 | + |
| 88 | + bombDamage = 5800 |
| 89 | + bombSigRadius = 400 |
| 90 | + sigRadius = fit.ship.getModifiedItemAttr('signatureRadius') |
| 91 | + |
| 92 | + # get the raw values for all hp layers |
| 93 | + hullHP = fit.ship.getModifiedItemAttr('hp') |
| 94 | + armorHP = fit.ship.getModifiedItemAttr('armorHP') |
| 95 | + shieldHP = fit.ship.getModifiedItemAttr('shieldCapacity') |
| 96 | + |
| 97 | + # we calculate the total ehp for pure damage of all types based on raw hp and resonance (resonance= 1-resistance) |
| 98 | + emEhp = hullHP / fit.ship.getModifiedItemAttr('emDamageResonance') +\ |
| 99 | + armorHP / fit.ship.getModifiedItemAttr('armorEmDamageResonance') +\ |
| 100 | + shieldHP / fit.ship.getModifiedItemAttr('shieldEmDamageResonance') |
| 101 | + thermalEhp = hullHP / fit.ship.getModifiedItemAttr('thermalDamageResonance') +\ |
| 102 | + armorHP / fit.ship.getModifiedItemAttr('armorThermalDamageResonance') +\ |
| 103 | + shieldHP / fit.ship.getModifiedItemAttr('shieldThermalDamageResonance') |
| 104 | + kineticEhp = hullHP / fit.ship.getModifiedItemAttr('kineticDamageResonance') +\ |
| 105 | + armorHP / fit.ship.getModifiedItemAttr('armorKineticDamageResonance') +\ |
| 106 | + shieldHP / fit.ship.getModifiedItemAttr('shieldKineticDamageResonance') |
| 107 | + explosiveEhp = hullHP / fit.ship.getModifiedItemAttr('explosiveDamageResonance') +\ |
| 108 | + armorHP / fit.ship.getModifiedItemAttr('armorExplosiveDamageResonance') +\ |
| 109 | + shieldHP / fit.ship.getModifiedItemAttr('shieldExplosiveDamageResonance') |
| 110 | + |
| 111 | + # updates the labels for each combination of covert op level and damage type |
| 112 | + for covertLevel in ("0", "1", "2", "3", "4", "5"): |
| 113 | + modBombDamage = bombDamage * (1 + 0.05 * int(covertLevel)) |
| 114 | + for damageType, ehp in (("em", emEhp), ("thermal", thermalEhp), |
| 115 | + ("kinetic", kineticEhp), ("explosive", explosiveEhp)): |
| 116 | + effectiveBombDamage = modBombDamage * min(bombSigRadius, sigRadius) / bombSigRadius |
| 117 | + label = getattr(self, "labelDamagetypeCovertlevel%s%s" % (damageType.capitalize(), covertLevel)) |
| 118 | + label.SetLabel("{:.1f}".format(ehp / effectiveBombDamage)) |
| 119 | + label.SetToolTip("Number of %s bombs to kill a %s using the respective " |
| 120 | + "bomber type with Covert Ops level %s" % (damageType, fit.name, covertLevel)) |
| 121 | + |
| 122 | + self.panel.Layout() |
| 123 | + self.headerPanel.Layout() |
| 124 | + |
| 125 | + |
| 126 | +BombingViewFull.register() |
0 commit comments