Use a button to toggle between firepower/miningyield
Introduce a button on both firepowerViewFull and miningyieldViewFull views that allows switching between the two. Work by destroying each view and recreating/populating on every button press.
This commit is contained in:
@@ -18,8 +18,9 @@
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
import wx
|
import wx
|
||||||
|
import service
|
||||||
|
import gui.mainFrame
|
||||||
from gui.statsView import StatsView
|
from gui.statsView import StatsView
|
||||||
from gui import builtinStatsViews
|
|
||||||
from gui import bitmapLoader
|
from gui import bitmapLoader
|
||||||
from gui.utils.numberFormatter import formatAmount
|
from gui.utils.numberFormatter import formatAmount
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ class FirepowerViewFull(StatsView):
|
|||||||
|
|
||||||
panel = "full"
|
panel = "full"
|
||||||
|
|
||||||
sizerFirepower = wx.FlexGridSizer(1, 3)
|
sizerFirepower = wx.FlexGridSizer(1, 4)
|
||||||
sizerFirepower.AddGrowableCol(1)
|
sizerFirepower.AddGrowableCol(1)
|
||||||
|
|
||||||
contentSizer.Add( sizerFirepower, 0, wx.EXPAND, 0)
|
contentSizer.Add( sizerFirepower, 0, wx.EXPAND, 0)
|
||||||
@@ -97,6 +98,35 @@ class FirepowerViewFull(StatsView):
|
|||||||
|
|
||||||
gridS.Add(lbl, 0, wx.ALIGN_LEFT)
|
gridS.Add(lbl, 0, wx.ALIGN_LEFT)
|
||||||
|
|
||||||
|
image = bitmapLoader.getBitmap("mining_big", "icons")
|
||||||
|
miningyield = wx.BitmapButton(contentPanel, -1, image)
|
||||||
|
miningyield.SetToolTip(wx.ToolTip("Click to toggle to Mining Yield "))
|
||||||
|
miningyield.Bind(wx.EVT_BUTTON, self.switchToMiningYieldView)
|
||||||
|
sizerFirepower.Add(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):
|
def refreshPanel(self, fit):
|
||||||
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,9 @@
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
import wx
|
import wx
|
||||||
|
import service
|
||||||
|
import gui.mainFrame
|
||||||
from gui.statsView import StatsView
|
from gui.statsView import StatsView
|
||||||
from gui import builtinStatsViews
|
|
||||||
from gui import bitmapLoader
|
from gui import bitmapLoader
|
||||||
from gui.utils.numberFormatter import formatAmount
|
from gui.utils.numberFormatter import formatAmount
|
||||||
|
|
||||||
@@ -43,29 +44,31 @@ class MiningYieldViewFull(StatsView):
|
|||||||
|
|
||||||
panel = "full"
|
panel = "full"
|
||||||
|
|
||||||
sizerMiningYield = wx.GridSizer(1, 3)
|
sizerMiningYield = wx.FlexGridSizer(1, 4)
|
||||||
contentSizer.Add( sizerMiningYield, 0, wx.EXPAND | wx.ALL, 0)
|
sizerMiningYield.AddGrowableCol(1)
|
||||||
|
|
||||||
|
contentSizer.Add( sizerMiningYield, 0, wx.EXPAND, 0)
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
|
|
||||||
for miningType, image in (("miner", "mining") , ("drone", "drones")):
|
for miningType, image in (("miner", "mining") , ("drone", "drones")):
|
||||||
baseBox = wx.BoxSizer(wx.HORIZONTAL)
|
baseBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
sizerMiningYield.Add(baseBox, 1, wx.ALIGN_LEFT)
|
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)
|
baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, parent, "icons"), 0, wx.ALIGN_CENTER)
|
||||||
|
|
||||||
box = wx.BoxSizer(wx.VERTICAL)
|
box = wx.BoxSizer(wx.VERTICAL)
|
||||||
baseBox.Add(box, 0, wx.EXPAND)
|
baseBox.Add(box, 0, wx.ALIGN_CENTER)
|
||||||
|
|
||||||
box.Add(wx.StaticText(parent, wx.ID_ANY, miningType.capitalize()), 0, wx.ALIGN_LEFT)
|
box.Add(wx.StaticText(parent, wx.ID_ANY, miningType.capitalize()), 0, wx.ALIGN_LEFT)
|
||||||
|
|
||||||
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
hbox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box.Add(hbox, 1, wx.EXPAND)
|
box.Add(hbox, 1, wx.ALIGN_CENTER)
|
||||||
|
|
||||||
lbl = wx.StaticText(parent, wx.ID_ANY, u"0.0 m\u00B3/s")
|
lbl = wx.StaticText(parent, wx.ID_ANY, u"0.0 m\u00B3/s")
|
||||||
setattr(self, "label%sminingyield%s" % (panel.capitalize() ,miningType.capitalize()), lbl)
|
setattr(self, "label%sminingyield%s" % (panel.capitalize() ,miningType.capitalize()), lbl)
|
||||||
|
|
||||||
hbox.Add(lbl, 0, wx.ALIGN_LEFT)
|
hbox.Add(lbl, 0, wx.ALIGN_CENTER)
|
||||||
self._cachedValues.append(0)
|
self._cachedValues.append(0)
|
||||||
counter += 1
|
counter += 1
|
||||||
targetSizer = sizerMiningYield
|
targetSizer = sizerMiningYield
|
||||||
@@ -89,6 +92,35 @@ class MiningYieldViewFull(StatsView):
|
|||||||
|
|
||||||
self._cachedValues.append(0)
|
self._cachedValues.append(0)
|
||||||
|
|
||||||
|
image = bitmapLoader.getBitmap("turret_big", "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):
|
def refreshPanel(self, fit):
|
||||||
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import gui.globalEvents as GE
|
|||||||
class StatsPane(wx.Panel):
|
class StatsPane(wx.Panel):
|
||||||
DEFAULT_VIEWS = ["resourcesViewFull", "resistancesViewFull" ,"rechargeViewFull", "firepowerViewFull",
|
DEFAULT_VIEWS = ["resourcesViewFull", "resistancesViewFull" ,"rechargeViewFull", "firepowerViewFull",
|
||||||
"capacitorViewFull", "targetingmiscViewFull",
|
"capacitorViewFull", "targetingmiscViewFull",
|
||||||
"priceViewFull", "miningyieldViewFull"]
|
"priceViewFull",]
|
||||||
|
|
||||||
def fitChanged(self, event):
|
def fitChanged(self, event):
|
||||||
cFit = service.Fit.getInstance()
|
cFit = service.Fit.getInstance()
|
||||||
|
|||||||
Reference in New Issue
Block a user