From 28cfaf1702a8f14116110b6452df887d1f02fcde Mon Sep 17 00:00:00 2001 From: Alexandros Kosiaris Date: Tue, 27 May 2014 17:00:31 +0300 Subject: [PATCH] Add mining yield view Add a panel for displaying the mining yield. Display miner and drone yield. Only create the frontend in this commit. --- eos/saveddata/fit.py | 35 ++++++ gui/builtinStatsViews/__init__.py | 2 +- gui/builtinStatsViews/miningyieldViewFull.py | 114 +++++++++++++++++++ gui/statsPane.py | 3 +- 4 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 gui/builtinStatsViews/miningyieldViewFull.py diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index 8bb7a4ac1..30991b4e6 100755 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -734,8 +734,10 @@ class Fit(object): self.__extraDrains = [] self.__ehp = None self.__weaponDPS = None + self.__minerYield = None self.__weaponVolley = None self.__droneDPS = None + self.__droneYield = None self.__sustainableTank = None self.__effectiveSustainableTank = None self.__effectiveTank = None @@ -837,6 +839,24 @@ class Fit(object): def totalDPS(self): return self.droneDPS + self.weaponDPS + @property + def minerYield(self): + if self.__minerYield is None: + self.calculateMiningStats() + + return self.__minerYield + + @property + def droneYield(self): + if self.__droneYield is None: + self.calculateMiningStats() + + return self.__droneYield + + @property + def totalYield(self): + return self.droneYield + self.minerYield + @property def maxTargets(self): return min(self.extraAttributes["maxTargetsLockedFromSkills"], self.ship.getModifiedItemAttr("maxLockedTargets")) @@ -895,10 +915,12 @@ class Fit(object): def clear(self): self.__effectiveTank = None self.__weaponDPS = None + self.__minerYield = None self.__weaponVolley = None self.__effectiveSustainableTank = None self.__sustainableTank = None self.__droneDPS = None + self.__droneYield = None self.__ehp = None self.__calculated = False self.__capStable = None @@ -1418,6 +1440,19 @@ class Fit(object): else: return self.ship.getModifiedItemAttr("scanSpeed") / 1000.0 + def calculateMiningStats(self): + minerYield = 0 + droneYield = 0 + + for mod in self.modules: + minerYield += mod.miningStats + + for drone in self.drones: + droneYield += drone.miningStats + + self.__minerYield = minerYield + self.__droneYield = droneYield + def calculateWeaponStats(self): weaponDPS = 0 droneDPS = 0 diff --git a/gui/builtinStatsViews/__init__.py b/gui/builtinStatsViews/__init__.py index e4e7b9369..5f2ca646e 100644 --- a/gui/builtinStatsViews/__init__.py +++ b/gui/builtinStatsViews/__init__.py @@ -1,3 +1,3 @@ __all__ = ["resourcesViewFull", "resistancesViewFull", "rechargeViewFull", "firepowerViewFull", "capacitorViewFull", - "targetingMiscViewFull", "priceViewFull"] + "targetingMiscViewFull", "priceViewFull", "miningyieldViewFull"] diff --git a/gui/builtinStatsViews/miningyieldViewFull.py b/gui/builtinStatsViews/miningyieldViewFull.py new file mode 100644 index 000000000..f8d6fb097 --- /dev/null +++ b/gui/builtinStatsViews/miningyieldViewFull.py @@ -0,0 +1,114 @@ +#=============================================================================== +# Copyright (C) 2014 Alexandros Kosiaris +# +# 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 . +#=============================================================================== + +import wx +from gui.statsView import StatsView +from gui import builtinStatsViews +from gui import bitmapLoader +from gui.utils.numberFormatter import formatAmount + +class MiningYieldViewFull(StatsView): + name = "miningyieldViewFull" + def __init__(self, parent): + StatsView.__init__(self) + self.parent = parent + self._cachedValues = [] + def getHeaderText(self, fit): + return "Mining Yield" + + def getTextExtentW(self, text): + width, height = self.parent.GetTextExtent( text ) + return width + + def populatePanel(self, contentPanel, headerPanel): + contentSizer = contentPanel.GetSizer() + parent = self.panel = contentPanel + self.headerPanel = headerPanel + + panel = "full" + + sizerMiningYield = wx.GridSizer(1, 3) + contentSizer.Add( sizerMiningYield, 0, wx.EXPAND | wx.ALL, 0) + + counter = 0 + + for miningType, image in (("miner", "mining") , ("drone", "drones")): + baseBox = wx.BoxSizer(wx.HORIZONTAL) + sizerMiningYield.Add(baseBox, 1, wx.ALIGN_LEFT) + + baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, parent, "icons"), 0, wx.ALIGN_CENTER) + + box = wx.BoxSizer(wx.VERTICAL) + baseBox.Add(box, 0, wx.EXPAND) + + box.Add(wx.StaticText(parent, wx.ID_ANY, miningType.capitalize()), 0, wx.ALIGN_LEFT) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + box.Add(hbox, 1, wx.EXPAND) + + lbl = wx.StaticText(parent, wx.ID_ANY, u"0.0 m\u00B3/s") + setattr(self, "label%sminingyield%s" % (panel.capitalize() ,miningType.capitalize()), lbl) + + hbox.Add(lbl, 0, wx.ALIGN_LEFT) + self._cachedValues.append(0) + counter += 1 + targetSizer = sizerMiningYield + + baseBox = wx.BoxSizer(wx.HORIZONTAL) + targetSizer.Add(baseBox, 0, wx.ALIGN_LEFT) + + baseBox.Add(bitmapLoader.getStaticBitmap("cargoBay_big", parent, "icons"), 0, wx.ALIGN_CENTER) + + box = wx.BoxSizer(wx.VERTICAL) + baseBox.Add(box, 0, wx.EXPAND) + + box.Add(wx.StaticText(parent, wx.ID_ANY, "Total"), 0, wx.ALIGN_LEFT) + + hbox = wx.BoxSizer(wx.HORIZONTAL) + box.Add(hbox, 1, wx.EXPAND) + + lbl = wx.StaticText(parent, wx.ID_ANY, u"0.0 m\u00B3/s") + setattr(self, "label%sminingyieldTotal" % panel.capitalize(), lbl) + hbox.Add(lbl, 0, wx.ALIGN_LEFT) + + self._cachedValues.append(0) + + def refreshPanel(self, fit): + #If we did anything intresting, we'd update our labels to reflect the new fit's stats here + + stats = (("labelFullminingyieldMiner", lambda: fit.minerYield, 3, 0, 0, u"%s m\u00B3/s",None), + ("labelFullminingyieldDrone", lambda: fit.droneYield, 3, 0, 0, u"%s m\u00B3/s", None), + ("labelFullminingyieldTotal", lambda: fit.totalYield, 3, 0, 0, u"%s m\u00B3/s", None)) + + counter = 0 + for labelName, value, prec, lowest, highest, valueFormat, altFormat in stats: + label = getattr(self, labelName) + value = value() if fit is not None else 0 + value = value if value is not None else 0 + if self._cachedValues[counter] != value: + valueStr = formatAmount(value, prec, lowest, highest) + label.SetLabel(valueFormat % valueStr) + tipStr = valueFormat % valueStr if altFormat is None else altFormat % value + label.SetToolTip(wx.ToolTip(tipStr)) + self._cachedValues[counter] = value + counter +=1 + self.panel.Layout() + self.headerPanel.Layout() + +MiningYieldViewFull.register() diff --git a/gui/statsPane.py b/gui/statsPane.py index 37331e875..5af8a0ac4 100644 --- a/gui/statsPane.py +++ b/gui/statsPane.py @@ -29,7 +29,8 @@ import gui.globalEvents as GE class StatsPane(wx.Panel): DEFAULT_VIEWS = ["resourcesViewFull", "resistancesViewFull" ,"rechargeViewFull", "firepowerViewFull", - "capacitorViewFull", "targetingmiscViewFull", "priceViewFull"] + "capacitorViewFull", "targetingmiscViewFull", + "priceViewFull", "miningyieldViewFull"] def fitChanged(self, event): cFit = service.Fit.getInstance()