Skip to content

Commit 2dabfe4

Browse files
author
StormDelay
committed
Created new view for the stats panel that displays a table of the number of damage bomb required to kill the ship, depending on the type of bomb and the covert op skill level of the bomber.
1 parent b248cde commit 2dabfe4

File tree

6 files changed

+140
-0
lines changed

6 files changed

+140
-0
lines changed

gui/builtinPreferenceViews/pyfaStatViewPreferences.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ def populatePanel(self, panel):
106106
rbSizerRow3.Add(self.rbOutgoing, 1, wx.TOP | wx.RIGHT, 5)
107107
self.rbOutgoing.Bind(wx.EVT_RADIOBOX, self.OnOutgoingChange)
108108

109+
self.rbBombing = wx.RadioBox(panel, -1, _t("Bombing"), wx.DefaultPosition, wx.DefaultSize, [_t('None'), _t('Minimal'), _t('Full')], 1,
110+
wx.RA_SPECIFY_COLS)
111+
# Disable minimal as we don't have a view for this yet
112+
self.rbBombing.EnableItem(1, False)
113+
self.rbBombing.SetSelection(self.settings.get('bombing'))
114+
rbSizerRow3.Add(self.rbBombing, 1, wx.TOP | wx.RIGHT, 5)
115+
self.rbBombing.Bind(wx.EVT_RADIOBOX, self.OnBombingChange)
116+
109117
mainSizer.Add(rbSizerRow3, 1, wx.ALL | wx.EXPAND, 0)
110118

111119
panel.SetSizer(mainSizer)
@@ -144,5 +152,7 @@ def OnDroneChange(self, event):
144152
def getImage(self):
145153
return BitmapLoader.getBitmap("settings_stats", "gui")
146154

155+
def OnBombingChange(self, event):
156+
self.settings.set('bombing', event.GetInt())
147157

148158
PFStatViewPref.register()

gui/builtinStatsViews/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
"targetingMiscViewMinimal",
1010
"priceViewFull",
1111
"priceViewMinimal",
12+
"bombingViewFull",
1213
]
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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()

gui/statsPane.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class StatsPane(wx.Panel):
4444
"capacitor",
4545
"targetingMisc",
4646
"price",
47+
"bombing",
4748
]
4849

4950
# Don't have these....yet....

gui/statsView.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ def refreshPanel(self, fit):
5555
priceViewMinimal,
5656
outgoingViewFull,
5757
outgoingViewMinimal,
58+
bombingViewFull,
5859
)

service/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ def __init__(self):
417417
"miningyield" : 2,
418418
"drones" : 2,
419419
"outgoing" : 2,
420+
"bombing" : 2,
420421
}
421422

422423
self.serviceStatViewDefaultSettings = SettingsProvider.getInstance().getSettings("pyfaServiceStatViewSettings", serviceStatViewDefaultSettings)

0 commit comments

Comments
 (0)