From f81db477fc3867cde43c2860da6c095327c102b8 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Sat, 11 Sep 2010 14:04:49 +0200 Subject: [PATCH] Remove some unused imports --- gui/builtinStatsViews/capacitorViewFull.py | 10 +--- gui/builtinStatsViews/exampleView.py | 43 --------------- gui/builtinStatsViews/firepowerViewFull.py | 14 ++--- gui/builtinStatsViews/priceViewFull.py | 55 +++++++++++-------- gui/builtinStatsViews/rechargeViewFull.py | 12 +--- gui/builtinStatsViews/resistancesViewFull.py | 15 ++--- gui/builtinStatsViews/resourcesViewFull.py | 8 +-- .../targetingmiscViewFull.py | 15 ++--- gui/builtinStatsViews/templateViewFull.py | 12 +--- 9 files changed, 55 insertions(+), 129 deletions(-) delete mode 100644 gui/builtinStatsViews/exampleView.py diff --git a/gui/builtinStatsViews/capacitorViewFull.py b/gui/builtinStatsViews/capacitorViewFull.py index 97941791d..f5df560ba 100644 --- a/gui/builtinStatsViews/capacitorViewFull.py +++ b/gui/builtinStatsViews/capacitorViewFull.py @@ -20,14 +20,8 @@ import wx from gui.statsView import StatsView from gui import builtinStatsViews - -from gui.pyfatogglepanel import TogglePanel from gui import bitmapLoader -from gui import pygauge as PG - -from eos.types import Slot, Hardpoint - -from util import formatAmount +from util import formatAmount class CapacitorViewFull(StatsView): name = "capacitorViewFull" @@ -140,7 +134,7 @@ class CapacitorViewFull(StatsView): s = "" else: t = ("%ds" if not capStable else "%.1f%%") % capState - s = "Stable: " if capStable else "Lasts " + s = "Stable: " if capStable else "Lasts " getattr(self, lblNameTime % panel).SetLabel(t) getattr(self, lblNameState % panel).SetLabel(s) diff --git a/gui/builtinStatsViews/exampleView.py b/gui/builtinStatsViews/exampleView.py deleted file mode 100644 index 4dd34f6b7..000000000 --- a/gui/builtinStatsViews/exampleView.py +++ /dev/null @@ -1,43 +0,0 @@ -#=============================================================================== -# 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 . -#=============================================================================== - -import wx -from gui.statsView import StatsView -from gui import builtinStatsViews - -class ExampleView(StatsView): - name = "exampleView" - def __init__(self): - StatsView.__init__(self) - - def populatePanel(self, panel): - self.panel = panel - self.mainSizer = wx.BoxSizer(wx.HORIZONTAL) - panel.SetSizer(self.mainSizer) - - self.mainSizer.Add(wx.StaticText(panel, wx.ID_ANY, "Hello world!")) - - def getHeaderText(self, fit): - return "MOO" - - def refreshPanel(self, fit): - #If we did anything intresting, we'd update our labels to reflect the new fit's stats here - pass - -builtinStatsViews.registerView(ExampleView) diff --git a/gui/builtinStatsViews/firepowerViewFull.py b/gui/builtinStatsViews/firepowerViewFull.py index ace521b50..6b7047880 100644 --- a/gui/builtinStatsViews/firepowerViewFull.py +++ b/gui/builtinStatsViews/firepowerViewFull.py @@ -20,14 +20,8 @@ import wx from gui.statsView import StatsView from gui import builtinStatsViews - -from gui.pyfatogglepanel import TogglePanel from gui import bitmapLoader -from gui import pygauge as PG - -from eos.types import Slot, Hardpoint - -from util import formatAmount +from util import formatAmount class FirepowerViewFull(StatsView): name = "firepowerViewFull" @@ -56,8 +50,8 @@ class FirepowerViewFull(StatsView): contentSizer.Add( sizerFirepower, 0, wx.EXPAND, 0) - - + + for damageType, image in (("weapon", "turret") , ("drone", "droneBay")): baseBox = wx.BoxSizer(wx.HORIZONTAL) @@ -118,5 +112,5 @@ class FirepowerViewFull(StatsView): label.SetLabel(formatAmount(value, prec, lowest, highest)) label.SetToolTip(wx.ToolTip("%.1f" % value)) - + builtinStatsViews.registerView(FirepowerViewFull) diff --git a/gui/builtinStatsViews/priceViewFull.py b/gui/builtinStatsViews/priceViewFull.py index 731cd00e8..58e3cd105 100644 --- a/gui/builtinStatsViews/priceViewFull.py +++ b/gui/builtinStatsViews/priceViewFull.py @@ -20,20 +20,16 @@ import wx from gui.statsView import StatsView from gui import builtinStatsViews - -from gui.pyfatogglepanel import TogglePanel from gui import bitmapLoader -from gui import pygauge as PG - -from eos.types import Slot, Hardpoint - -from util import formatAmount +from util import formatAmount +import controller class PriceViewFull(StatsView): name = "priceViewFull" def __init__(self, parent): StatsView.__init__(self) self.parent = parent + def getHeaderText(self, fit): return "Price" @@ -42,19 +38,11 @@ class PriceViewFull(StatsView): return width def populatePanel(self, contentPanel, headerPanel): - contentSizer = contentPanel.GetSizer() - - parent = contentPanel panel = "full" - - gridPrice = wx.GridSizer(1, 3) - contentSizer.Add( gridPrice, 0, wx.EXPAND | wx.ALL, 0) - - for type in ("ship", "fittings", "total"): image = "%sPrice_big" % type if type != "ship" else "ship_big" box = wx.BoxSizer(wx.HORIZONTAL) @@ -71,17 +59,38 @@ class PriceViewFull(StatsView): vbox.Add(hbox) lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0.00") - setattr(self, "labelPrice%s" % type, lbl) + setattr(self, "labelPrice%s" % type.capitalize(), lbl) hbox.Add(lbl, 0, wx.ALIGN_LEFT) hbox.Add(wx.StaticText(contentPanel, wx.ID_ANY, " m ISK"), 0, wx.ALIGN_LEFT) - - - def refreshPanel(self, fit): - #If we did anything intresting, we'd update our labels to reflect the new fit's stats here - #No data available yet - pass - + print "r" + if fit is not None: + # Compose a list of all the data we need & request it + typeIDs = [] + typeIDs.append(fit.ship.item.ID) + + for mod in fit.modules: + if not mod.isEmpty: + typeIDs.append(mod.itemID) + + for drone in fit.drones: + for _ in xrange(drone.amount): + typeIDs.append(drone.itemID) + + cMarket = controller.Market.getInstance() + cMarket.getPrices(typeIDs, self.processPrices) + else: + self.labelPriceShip.SetLabel("0.0") + self.labelPriceFittings.SetLabel("0.0") + self.labelPriceTotal.SetLabel("0.0") + + def processPrices(self, prices): + shipPrice = prices[0].price + modPrice = sum(map(lambda p: p.price, prices[1:])) + self.labelPriceShip.SetLabel(formatAmount(shipPrice, 3, 3, 9)) + self.labelPriceFittings.SetLabel(formatAmount(modPrice, 3, 3, 9)) + self.labelPriceTotal.SetLabel(formatAmount(shipPrice + modPrice, 3, 3, 9)) + builtinStatsViews.registerView(PriceViewFull) diff --git a/gui/builtinStatsViews/rechargeViewFull.py b/gui/builtinStatsViews/rechargeViewFull.py index 511f29b6b..97bc8bc27 100644 --- a/gui/builtinStatsViews/rechargeViewFull.py +++ b/gui/builtinStatsViews/rechargeViewFull.py @@ -20,14 +20,8 @@ import wx from gui.statsView import StatsView from gui import builtinStatsViews - -from gui.pyfatogglepanel import TogglePanel from gui import bitmapLoader -from gui import pygauge as PG - -from eos.types import Slot, Hardpoint - -from util import formatAmount +from util import formatAmount class RechargeViewFull(StatsView): name = "rechargeViewFull" @@ -53,7 +47,7 @@ class RechargeViewFull(StatsView): for i in xrange(4): sizerTankStats.AddGrowableCol(i + 1) - + contentSizer.Add(sizerTankStats, 0, wx.EXPAND, 0) #Add an empty label first for correct alignment. @@ -108,7 +102,7 @@ class RechargeViewFull(StatsView): label = getattr(self, "labelTankSustainedShieldPassive") label.SetLabel("0") - label.SetToolTip(wx.ToolTip("%.3f" % value)) + label.SetToolTip(wx.ToolTip("%.3f" % value)) diff --git a/gui/builtinStatsViews/resistancesViewFull.py b/gui/builtinStatsViews/resistancesViewFull.py index ecdfa327d..33d4bb88b 100644 --- a/gui/builtinStatsViews/resistancesViewFull.py +++ b/gui/builtinStatsViews/resistancesViewFull.py @@ -20,14 +20,9 @@ import wx from gui.statsView import StatsView from gui import builtinStatsViews - -from gui.pyfatogglepanel import TogglePanel from gui import bitmapLoader from gui import pygauge as PG - -from eos.types import Slot, Hardpoint - -from util import formatAmount +from util import formatAmount class ResistancesViewFull(StatsView): name = "resistancesViewFull" @@ -60,11 +55,11 @@ class ResistancesViewFull(StatsView): stEff = wx.StaticText(headerPanel, wx.ID_ANY, "( Effective HP: ") headerContentSizer.Add(stEff) headerPanel.GetParent().AddToggleItem(stEff) - + self.labelEhp = wx.StaticText(headerPanel, wx.ID_ANY, "0") headerContentSizer.Add(self.labelEhp, 0) headerPanel.GetParent().AddToggleItem(self.labelEhp) - + stCls = wx.StaticText(headerPanel, wx.ID_ANY, " )") headerPanel.GetParent().AddToggleItem( stCls ) @@ -77,12 +72,12 @@ class ResistancesViewFull(StatsView): row = 0 sizerResistances = wx.GridBagSizer(4, 6) contentSizer.Add( sizerResistances, 0, wx.EXPAND , 0) - + for i in xrange(6): sizerResistances.AddGrowableCol(i + 1) - + # Add an empty label, then the rest. sizerResistances.Add(wx.StaticText(contentPanel, wx.ID_ANY), wx.GBPosition( row, col ), wx.GBSpan( 1, 1 )) col+=1 diff --git a/gui/builtinStatsViews/resourcesViewFull.py b/gui/builtinStatsViews/resourcesViewFull.py index a3cc5cf19..e17c40c02 100644 --- a/gui/builtinStatsViews/resourcesViewFull.py +++ b/gui/builtinStatsViews/resourcesViewFull.py @@ -20,14 +20,12 @@ import wx from gui.statsView import StatsView from gui import builtinStatsViews - -from gui.pyfatogglepanel import TogglePanel from gui import bitmapLoader from gui import pygauge as PG -from eos.types import Slot, Hardpoint +from eos.types import Hardpoint -from util import formatAmount +from util import formatAmount class ResourcesViewFull(StatsView): name = "resourcesViewFull" @@ -78,7 +76,7 @@ class ResourcesViewFull(StatsView): setattr(self, "label%sTotal%s%s" % (panel.capitalize(), type.capitalize(), suffix.capitalize()), lbl) box.Add(lbl, 0, wx.ALIGN_LEFT) - st = wx.VERTICAL + st = wx.VERTICAL base.Add(wx.StaticLine(parent, wx.ID_ANY, style=st), 0, wx.EXPAND | wx.LEFT, 3 if panel == "full" else 0) diff --git a/gui/builtinStatsViews/targetingmiscViewFull.py b/gui/builtinStatsViews/targetingmiscViewFull.py index a16ff60a2..12fdf8c67 100644 --- a/gui/builtinStatsViews/targetingmiscViewFull.py +++ b/gui/builtinStatsViews/targetingmiscViewFull.py @@ -20,14 +20,7 @@ import wx from gui.statsView import StatsView from gui import builtinStatsViews - -from gui.pyfatogglepanel import TogglePanel -from gui import bitmapLoader -from gui import pygauge as PG - -from eos.types import Slot, Hardpoint - -from util import formatAmount +from util import formatAmount class TargetingMiscViewFull(StatsView): name = "targetingmiscViewFull" @@ -51,7 +44,7 @@ class TargetingMiscViewFull(StatsView): gridTargetingMisc = wx.FlexGridSizer(1, 3) contentSizer.Add( gridTargetingMisc, 0, wx.EXPAND | wx.ALL, 0) gridTargetingMisc.AddGrowableCol(0) - gridTargetingMisc.AddGrowableCol(2) + gridTargetingMisc.AddGrowableCol(2) # Targeting gridTargeting = wx.FlexGridSizer(4, 2) @@ -122,6 +115,6 @@ class TargetingMiscViewFull(StatsView): value = value() if fit is not None else 0 value = value if value is not None else 0 label.SetLabel(formatAmount(value, prec, lowest, highest)) - label.SetToolTip(wx.ToolTip("%.1f" % value)) - + label.SetToolTip(wx.ToolTip("%.1f" % value)) + builtinStatsViews.registerView(TargetingMiscViewFull) diff --git a/gui/builtinStatsViews/templateViewFull.py b/gui/builtinStatsViews/templateViewFull.py index 1aa3bcadc..609f1e925 100644 --- a/gui/builtinStatsViews/templateViewFull.py +++ b/gui/builtinStatsViews/templateViewFull.py @@ -21,14 +21,6 @@ import wx from gui.statsView import StatsView from gui import builtinStatsViews -from gui.pyfatogglepanel import TogglePanel -from gui import bitmapLoader -from gui import pygauge as PG - -from eos.types import Slot, Hardpoint - -from util import formatAmount - class FirepowerViewFull(StatsView): name = "firepowerViewFull" def __init__(self, parent): @@ -48,7 +40,7 @@ class FirepowerViewFull(StatsView): parent = contentPanel panel = "full" - contentSizer.Add( sizerResources, 0, wx.EXPAND | wx.ALL, 0) + contentSizer.Add( sizerResources, 0, wx.EXPAND | wx.ALL, 0) @@ -56,5 +48,5 @@ class FirepowerViewFull(StatsView): #If we did anything intresting, we'd update our labels to reflect the new fit's stats here pass - + builtinStatsViews.registerView(FirepowerViewFull)