diff --git a/gui/builtinPreferenceViews/pyfaStatViewPreferences.py b/gui/builtinPreferenceViews/pyfaStatViewPreferences.py index 025394d9e..e16c39655 100644 --- a/gui/builtinPreferenceViews/pyfaStatViewPreferences.py +++ b/gui/builtinPreferenceViews/pyfaStatViewPreferences.py @@ -106,6 +106,14 @@ class PFStatViewPref(PreferenceView): rbSizerRow3.Add(self.rbOutgoing, 1, wx.TOP | wx.RIGHT, 5) self.rbOutgoing.Bind(wx.EVT_RADIOBOX, self.OnOutgoingChange) + self.rbBombing = wx.RadioBox(panel, -1, _t("Bombing"), wx.DefaultPosition, wx.DefaultSize, [_t('None'), _t('Minimal'), _t('Full')], 1, + wx.RA_SPECIFY_COLS) + # Disable minimal as we don't have a view for this yet + self.rbBombing.EnableItem(1, False) + self.rbBombing.SetSelection(self.settings.get('bombing')) + rbSizerRow3.Add(self.rbBombing, 1, wx.TOP | wx.RIGHT, 5) + self.rbBombing.Bind(wx.EVT_RADIOBOX, self.OnBombingChange) + mainSizer.Add(rbSizerRow3, 1, wx.ALL | wx.EXPAND, 0) panel.SetSizer(mainSizer) @@ -144,5 +152,7 @@ class PFStatViewPref(PreferenceView): def getImage(self): return BitmapLoader.getBitmap("settings_stats", "gui") + def OnBombingChange(self, event): + self.settings.set('bombing', event.GetInt()) PFStatViewPref.register() diff --git a/gui/builtinStatsViews/__init__.py b/gui/builtinStatsViews/__init__.py index 8769c7aef..085cef50c 100644 --- a/gui/builtinStatsViews/__init__.py +++ b/gui/builtinStatsViews/__init__.py @@ -9,4 +9,5 @@ __all__ = [ "targetingMiscViewMinimal", "priceViewFull", "priceViewMinimal", + "bombingViewFull", ] diff --git a/gui/builtinStatsViews/bombingViewFull.py b/gui/builtinStatsViews/bombingViewFull.py new file mode 100644 index 000000000..cd3456d85 --- /dev/null +++ b/gui/builtinStatsViews/bombingViewFull.py @@ -0,0 +1,126 @@ +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + +# noinspection PyPackageRequirements +import wx + +import gui.mainFrame +from gui.bitmap_loader import BitmapLoader +from gui.statsView import StatsView + +_t = wx.GetTranslation + + +class BombingViewFull(StatsView): + name = "bombingViewFull" + + def __init__(self, parent): + StatsView.__init__(self) + self.parent = parent + self._cachedValues = [] + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + + def getHeaderText(self, fit): + return _t("Bombing") + + def getTextExtentW(self, text): + width, height = self.parent.GetTextExtent(text) + return width + + def populatePanel(self, contentPanel, headerPanel): + contentSizer = contentPanel.GetSizer() + self.panel = contentPanel + + self.headerPanel = headerPanel + + # Display table + sizerBombing = wx.FlexGridSizer(7, 5, 0, 0) + for i in range(4): + sizerBombing.AddGrowableCol(i + 1) + contentSizer.Add(sizerBombing, 0, wx.EXPAND, 0) + + # Add an empty label, then the rest. + sizerBombing.Add(wx.StaticText(contentPanel, wx.ID_ANY, ""), 0) + toolTipText = { + "em": _t("Electron Bomb"), + "thermal": _t("Scorch Bomb"), + "kinetic": _t("Concussion Bomb"), + "explosive": _t("Shrapnel Bomb") + } + for damageType in ("em", "thermal", "kinetic", "explosive"): + bitmap = BitmapLoader.getStaticBitmap("%s_big" % damageType, contentPanel, "gui") + tooltip = wx.ToolTip(toolTipText[damageType]) + bitmap.SetToolTip(tooltip) + sizerBombing.Add(bitmap, 0, wx.ALIGN_CENTER) + + for covertLevel in ("0", "1", "2", "3", "4", "5"): + label = wx.StaticText(contentPanel, wx.ID_ANY, "%s" % covertLevel) + tooltip = wx.ToolTip(_t("Covert Ops level")) + label.SetToolTip(tooltip) + sizerBombing.Add(label, 0, wx.ALIGN_CENTER) + + for damageType in ("em", "thermal", "kinetic", "explosive"): + label = wx.StaticText(contentPanel, wx.ID_ANY, "0.0") + setattr(self, "labelDamagetypeCovertlevel%s%s" % (damageType.capitalize(), covertLevel), label) + sizerBombing.Add(label, 0, wx.ALIGN_CENTER) + + def refreshPanel(self, fit): + # If we did anything interesting, we'd update our labels to reflect the new fit's stats here + if fit is None: + return + + bombDamage = 5800 + bombSigRadius = 400 + sigRadius = fit.ship.getModifiedItemAttr('signatureRadius') + + # get the raw values for all hp layers + hullHP = fit.ship.getModifiedItemAttr('hp') + armorHP = fit.ship.getModifiedItemAttr('armorHP') + shieldHP = fit.ship.getModifiedItemAttr('shieldCapacity') + + # we calculate the total ehp for pure damage of all types based on raw hp and resonance (resonance= 1-resistance) + emEhp = hullHP / fit.ship.getModifiedItemAttr('emDamageResonance') +\ + armorHP / fit.ship.getModifiedItemAttr('armorEmDamageResonance') +\ + shieldHP / fit.ship.getModifiedItemAttr('shieldEmDamageResonance') + thermalEhp = hullHP / fit.ship.getModifiedItemAttr('thermalDamageResonance') +\ + armorHP / fit.ship.getModifiedItemAttr('armorThermalDamageResonance') +\ + shieldHP / fit.ship.getModifiedItemAttr('shieldThermalDamageResonance') + kineticEhp = hullHP / fit.ship.getModifiedItemAttr('kineticDamageResonance') +\ + armorHP / fit.ship.getModifiedItemAttr('armorKineticDamageResonance') +\ + shieldHP / fit.ship.getModifiedItemAttr('shieldKineticDamageResonance') + explosiveEhp = hullHP / fit.ship.getModifiedItemAttr('explosiveDamageResonance') +\ + armorHP / fit.ship.getModifiedItemAttr('armorExplosiveDamageResonance') +\ + shieldHP / fit.ship.getModifiedItemAttr('shieldExplosiveDamageResonance') + + # updates the labels for each combination of covert op level and damage type + for covertLevel in ("0", "1", "2", "3", "4", "5"): + modBombDamage = bombDamage * (1 + 0.05 * int(covertLevel)) + for damageType, ehp in (("em", emEhp), ("thermal", thermalEhp), + ("kinetic", kineticEhp), ("explosive", explosiveEhp)): + effectiveBombDamage = modBombDamage * min(bombSigRadius, sigRadius) / bombSigRadius + label = getattr(self, "labelDamagetypeCovertlevel%s%s" % (damageType.capitalize(), covertLevel)) + label.SetLabel("{:.1f}".format(ehp / effectiveBombDamage)) + label.SetToolTip("Number of %s bombs to kill a %s using the respective " + "bomber type with Covert Ops level %s" % (damageType, fit.name, covertLevel)) + + self.panel.Layout() + self.headerPanel.Layout() + + +BombingViewFull.register() diff --git a/gui/statsPane.py b/gui/statsPane.py index 35fe2176d..61bfd8030 100644 --- a/gui/statsPane.py +++ b/gui/statsPane.py @@ -44,6 +44,7 @@ class StatsPane(wx.Panel): "capacitor", "targetingMisc", "price", + "bombing", ] # Don't have these....yet.... diff --git a/gui/statsView.py b/gui/statsView.py index 5a98fb92e..8a471f259 100644 --- a/gui/statsView.py +++ b/gui/statsView.py @@ -55,4 +55,5 @@ from gui.builtinStatsViews import ( # noqa: E402, F401 priceViewMinimal, outgoingViewFull, outgoingViewMinimal, + bombingViewFull, ) diff --git a/service/settings.py b/service/settings.py index ed1fecf74..386a47045 100644 --- a/service/settings.py +++ b/service/settings.py @@ -417,6 +417,7 @@ class StatViewSettings: "miningyield" : 2, "drones" : 2, "outgoing" : 2, + "bombing" : 2, } self.serviceStatViewDefaultSettings = SettingsProvider.getInstance().getSettings("pyfaServiceStatViewSettings", serviceStatViewDefaultSettings)