Merge branch 'akosiaris_miningyeild'
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
__all__ = ["resourcesViewFull", "resistancesViewFull",
|
||||
"rechargeViewFull", "firepowerViewFull", "capacitorViewFull",
|
||||
"targetingMiscViewFull", "priceViewFull"]
|
||||
"targetingMiscViewFull", "priceViewFull", "miningyieldViewFull"]
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
#===============================================================================
|
||||
|
||||
import wx
|
||||
import service
|
||||
import gui.mainFrame
|
||||
from gui.statsView import StatsView
|
||||
from gui import builtinStatsViews
|
||||
from gui import bitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
|
||||
@@ -43,9 +44,9 @@ class FirepowerViewFull(StatsView):
|
||||
|
||||
panel = "full"
|
||||
|
||||
sizerFirepower = wx.FlexGridSizer(1, 3)
|
||||
sizerFirepower = wx.FlexGridSizer(1, 4)
|
||||
sizerFirepower.AddGrowableCol(1)
|
||||
|
||||
|
||||
contentSizer.Add( sizerFirepower, 0, wx.EXPAND, 0)
|
||||
|
||||
counter = 0
|
||||
@@ -97,6 +98,35 @@ class FirepowerViewFull(StatsView):
|
||||
|
||||
gridS.Add(lbl, 0, wx.ALIGN_LEFT)
|
||||
|
||||
image = bitmapLoader.getBitmap("mining_small", "icons")
|
||||
self.miningyield = wx.BitmapButton(contentPanel, -1, image)
|
||||
self.miningyield.SetToolTip(wx.ToolTip("Click to toggle to Mining Yield "))
|
||||
self.miningyield.Bind(wx.EVT_BUTTON, self.switchToMiningYieldView)
|
||||
sizerFirepower.Add(self.miningyield, 0, wx.ALIGN_LEFT)
|
||||
|
||||
self._cachedValues.append(0)
|
||||
|
||||
def switchToMiningYieldView(self, event):
|
||||
# Getting the active fit
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
sFit = service.Fit.getInstance()
|
||||
fit = sFit.getFit(mainFrame.getActiveFit())
|
||||
# Remove ourselves from statsPane's view list
|
||||
self.parent.views.remove(self)
|
||||
self._cachedValues = []
|
||||
# And no longer display us
|
||||
self.panel.GetSizer().Clear(True)
|
||||
self.panel.GetSizer().Layout()
|
||||
# Get the new view
|
||||
view = StatsView.getView("miningyieldViewFull")(self.parent)
|
||||
view.populatePanel(self.panel, self.headerPanel)
|
||||
# Populate us in statsPane's view list
|
||||
self.parent.views.append(view)
|
||||
# Get the TogglePanel
|
||||
tp = self.panel.GetParent()
|
||||
tp.SetLabel(view.getHeaderText(fit))
|
||||
view.refreshPanel(fit)
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
||||
|
||||
@@ -104,6 +134,11 @@ class FirepowerViewFull(StatsView):
|
||||
("labelFullDpsDrone", lambda: fit.droneDPS, 3, 0, 0, "%s DPS", None),
|
||||
("labelFullVolleyTotal", lambda: fit.weaponVolley, 3, 0, 0, "%s", "Volley: %.1f"),
|
||||
("labelFullDpsTotal", lambda: fit.totalDPS, 3, 0, 0, "%s", None))
|
||||
# See GH issue #
|
||||
#if fit is not None and fit.totalYield > 0:
|
||||
# self.miningyield.Show()
|
||||
#else:
|
||||
# self.miningyield.Hide()
|
||||
|
||||
counter = 0
|
||||
for labelName, value, prec, lowest, highest, valueFormat, altFormat in stats:
|
||||
@@ -117,6 +152,7 @@ class FirepowerViewFull(StatsView):
|
||||
label.SetToolTip(wx.ToolTip(tipStr))
|
||||
self._cachedValues[counter] = value
|
||||
counter +=1
|
||||
|
||||
self.panel.Layout()
|
||||
self.headerPanel.Layout()
|
||||
|
||||
|
||||
146
gui/builtinStatsViews/miningyieldViewFull.py
Normal file
146
gui/builtinStatsViews/miningyieldViewFull.py
Normal file
@@ -0,0 +1,146 @@
|
||||
#===============================================================================
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
|
||||
import wx
|
||||
import service
|
||||
import gui.mainFrame
|
||||
from gui.statsView import StatsView
|
||||
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.FlexGridSizer(1, 4)
|
||||
sizerMiningYield.AddGrowableCol(1)
|
||||
|
||||
contentSizer.Add( sizerMiningYield, 0, wx.EXPAND, 0)
|
||||
|
||||
counter = 0
|
||||
|
||||
for miningType, image in (("miner", "mining") , ("drone", "drones")):
|
||||
baseBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
sizerMiningYield.Add(baseBox, 1, wx.ALIGN_LEFT if counter == 0 else wx.ALIGN_CENTER_HORIZONTAL)
|
||||
|
||||
baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, parent, "icons"), 0, wx.ALIGN_CENTER)
|
||||
|
||||
box = wx.BoxSizer(wx.VERTICAL)
|
||||
baseBox.Add(box, 0, wx.ALIGN_CENTER)
|
||||
|
||||
box.Add(wx.StaticText(parent, wx.ID_ANY, miningType.capitalize()), 0, wx.ALIGN_LEFT)
|
||||
|
||||
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
box.Add(hbox, 1, wx.ALIGN_CENTER)
|
||||
|
||||
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_CENTER)
|
||||
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)
|
||||
|
||||
image = bitmapLoader.getBitmap("turret_small", "icons")
|
||||
firepower = wx.BitmapButton(contentPanel, -1, image)
|
||||
firepower.SetToolTip(wx.ToolTip("Click to toggle to Firepower View"))
|
||||
firepower.Bind(wx.EVT_BUTTON, self.switchToFirepowerView)
|
||||
sizerMiningYield.Add(firepower, 0, wx.ALIGN_LEFT)
|
||||
|
||||
self._cachedValues.append(0)
|
||||
|
||||
def switchToFirepowerView(self, event):
|
||||
# Getting the active fit
|
||||
mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
sFit = service.Fit.getInstance()
|
||||
fit = sFit.getFit(mainFrame.getActiveFit())
|
||||
# Remove ourselves from statsPane's view list
|
||||
self.parent.views.remove(self)
|
||||
self._cachedValues = []
|
||||
# And no longer display us
|
||||
self.panel.GetSizer().Clear(True)
|
||||
self.panel.GetSizer().Layout()
|
||||
# Get the new view
|
||||
view = StatsView.getView("firepowerViewFull")(self.parent)
|
||||
view.populatePanel(self.panel, self.headerPanel)
|
||||
# Populate us in statsPane's view list
|
||||
self.parent.views.append(view)
|
||||
# Get the TogglePanel
|
||||
tp = self.panel.GetParent()
|
||||
tp.SetLabel(view.getHeaderText(fit))
|
||||
view.refreshPanel(fit)
|
||||
|
||||
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()
|
||||
@@ -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",]
|
||||
|
||||
def fitChanged(self, event):
|
||||
cFit = service.Fit.getInstance()
|
||||
|
||||
Reference in New Issue
Block a user