Major statspane rework -- (ministats panel isnt available for now)

This commit is contained in:
HomeWorld
2010-09-10 18:09:41 +03:00
parent 10b57cbd79
commit 99d6a6b2c2
12 changed files with 1163 additions and 1633 deletions

View File

@@ -0,0 +1,10 @@
__all__ = ["resourcesViewFull", "resistancesViewFull",
"rechargeViewFull", "firepowerViewFull", "capacitorViewFull",
"targetingmiscViewFull", "priceViewFull"]
columns = {}
def registerView(column):
columns[column.name] = column
def getView(name):
return columns[name]

View File

@@ -0,0 +1,149 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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 CapacitorViewFull(StatsView):
name = "capacitorViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Capacitor"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
return width
def populatePanel(self, contentPanel, headerPanel):
contentSizer = contentPanel.GetSizer()
parent = contentPanel
panel = "full"
sizerCapacitor = wx.GridSizer(1, 2)
contentSizer.Add(sizerCapacitor, 0, wx.EXPAND, 0)
# Capacitor capacity and time
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerCapacitor.Add(baseBox, 0, wx.ALIGN_LEFT)
baseBox.Add(bitmapLoader.getStaticBitmap("capacitorInfo_big", parent, "icons"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 0, wx.ALIGN_LEFT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
box.Add(hbox, 0, wx.ALIGN_LEFT)
hbox.Add(wx.StaticText(parent, wx.ID_ANY, "Total: "), 0, wx.ALIGN_LEFT | wx.LEFT, 3)
lbl = wx.StaticText(parent, wx.ID_ANY, "0.0")
setattr(self, "label%sCapacitorCapacity" % panel.capitalize(), lbl)
hbox.Add(lbl, 0, wx.ALIGN_LEFT)
hbox.Add(wx.StaticText(parent, wx.ID_ANY, " GJ"), 0, wx.ALIGN_LEFT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
box.Add(hbox, 0, wx.ALIGN_LEFT)
lbl = wx.StaticText(parent, wx.ID_ANY, "Lasts ")
hbox.Add(lbl, 0, wx.ALIGN_LEFT | wx.LEFT, 3)
setattr(self, "label%sCapacitorState" % panel.capitalize(), lbl)
lbl = wx.StaticText(parent, wx.ID_ANY, "0s")
setattr(self, "label%sCapacitorTime" % panel.capitalize(), lbl)
hbox.Add(lbl, 0, wx.ALIGN_LEFT)
# Capacitor balance
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerCapacitor.Add(baseBox, 0, wx.ALIGN_CENTER_HORIZONTAL)
baseBox.Add(bitmapLoader.getStaticBitmap("capacitorRecharge_big", parent, "icons"), 0, wx.ALIGN_CENTER)
# Recharge
chargeSizer = wx.FlexGridSizer(2, 3)
baseBox.Add(chargeSizer, 0, wx.ALIGN_CENTER)
chargeSizer.Add(wx.StaticText(parent, wx.ID_ANY, "+ "), 0, wx.ALIGN_CENTER)
lbl = wx.StaticText(parent, wx.ID_ANY, "0.0")
setattr(self, "label%sCapacitorRecharge" % panel.capitalize(), lbl)
chargeSizer.Add(lbl, 0, wx.ALIGN_CENTER)
chargeSizer.Add(wx.StaticText(parent, wx.ID_ANY, " GJ/s"), 0, wx.ALIGN_CENTER)
# Discharge
chargeSizer.Add(wx.StaticText(parent, wx.ID_ANY, "- "), 0, wx.ALIGN_CENTER)
lbl = wx.StaticText(parent, wx.ID_ANY, "0.0")
setattr(self, "label%sCapacitorDischarge" % panel.capitalize(), lbl)
chargeSizer.Add(lbl, 0, wx.ALIGN_CENTER)
chargeSizer.Add(wx.StaticText(parent, wx.ID_ANY, " GJ/s"), 0, wx.ALIGN_CENTER)
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
stats= (("label%sCapacitorCapacity", lambda: fit.ship.getModifiedItemAttr("capacitorCapacity"), 3, 0, 9),
("label%sCapacitorRecharge", lambda: fit.capRecharge, 3, 0, 0),
("label%sCapacitorDischarge", lambda: fit.capUsed, 3, 0, 0))
panel = "Full"
for labelName, value, prec, lowest, highest in stats:
label = getattr(self, labelName % panel)
value = value() if fit is not None else 0
value = value if value is not None else 0
if isinstance(value, basestring):
label.SetLabel(value)
label.SetToolTip(wx.ToolTip(value))
else:
label.SetLabel(formatAmount(value, prec, lowest, highest))
label.SetToolTip(wx.ToolTip("%.1f" % value))
capState = fit.capState if fit is not None else 0
capStable = fit.capStable if fit is not None else False
lblNameTime = "label%sCapacitorTime"
lblNameState = "label%sCapacitorState"
if isinstance(capState, tuple):
t = "%.1f%%-%.1f%%" % capState
s = ""
else:
t = ("%ds" if not capStable else "%.1f%%") % capState
s = "Stable: " if capStable else "Lasts "
getattr(self, lblNameTime % panel).SetLabel(t)
getattr(self, lblNameState % panel).SetLabel(s)
builtinStatsViews.registerView(CapacitorViewFull)

View File

@@ -0,0 +1,43 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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)

View File

@@ -0,0 +1,122 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Firepower"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
return width
def populatePanel(self, contentPanel, headerPanel):
contentSizer = contentPanel.GetSizer()
parent = contentPanel
panel = "full"
sizerFirepower = wx.FlexGridSizer(1, 3)
for i in xrange(3):
sizerFirepower.AddGrowableCol(i)
contentSizer.Add( sizerFirepower, 0, wx.EXPAND, 0)
for damageType, image in (("weapon", "turret") , ("drone", "droneBay")):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerFirepower.Add(baseBox, 0, 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.ALIGN_CENTER)
box.Add(wx.StaticText(parent, wx.ID_ANY, damageType.capitalize()), 0, wx.ALIGN_LEFT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
box.Add(hbox, 1, wx.ALIGN_CENTER)
lbl = wx.StaticText(parent, wx.ID_ANY, "0.0")
setattr(self, "label%sDps%s" % (panel.capitalize() ,damageType.capitalize()), lbl)
hbox.Add(lbl, 0, wx.ALIGN_CENTER)
hbox.Add(wx.StaticText(parent, wx.ID_ANY, " DPS"), 0, wx.ALIGN_CENTER)
targetSizer = sizerFirepower
baseBox = wx.BoxSizer(wx.HORIZONTAL)
targetSizer.Add(baseBox, 0, wx.ALIGN_LEFT)
baseBox.Add(bitmapLoader.getStaticBitmap("volley_big", parent, "icons"), 0, wx.ALIGN_CENTER)
gridS = wx.GridSizer(2,2,0,0)
baseBox.Add(gridS, 0, wx.ALIGN_LEFT)
lbl = wx.StaticText(parent, wx.ID_ANY, "0.0")
setattr(self, "label%sVolleyTotal" % panel.capitalize(), lbl)
gridS.Add(wx.StaticText(parent, wx.ID_ANY, " Volley: "), 0, wx.ALL | wx.ALIGN_RIGHT)
gridS.Add(lbl, 0, wx.ALIGN_LEFT)
lbl = wx.StaticText(parent, wx.ID_ANY, "0.0")
setattr(self, "label%sDpsTotal" % panel.capitalize(), lbl)
gridS.Add(wx.StaticText(parent, wx.ID_ANY, " DPS: "), 0, wx.ALL | wx.ALIGN_RIGHT)
gridS.Add(lbl, 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
stats = (("labelFullDpsWeapon", lambda: fit.weaponDPS, 3, 0, 9),
("labelFullDpsDrone", lambda: fit.droneDPS, 3, 0, 9),
("labelFullVolleyTotal", lambda: fit.weaponVolley, 3, 0, 9),
("labelFullDpsTotal", lambda: fit.totalDPS, 3, 0, 9))
for labelName, value, prec, lowest, highest in stats:
label = getattr(self, labelName)
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))
builtinStatsViews.registerView(FirepowerViewFull)

View File

@@ -0,0 +1,87 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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 PriceViewFull(StatsView):
name = "priceViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Price"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
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)
gridPrice.Add(box, 0, wx.ALIGN_CENTER)
box.Add(bitmapLoader.getStaticBitmap(image, contentPanel, "icons"), 0, wx.ALIGN_CENTER)
vbox = wx.BoxSizer(wx.VERTICAL)
box.Add(vbox, 1, wx.EXPAND)
vbox.Add(wx.StaticText(contentPanel, wx.ID_ANY, type.capitalize()), 0, wx.ALIGN_LEFT)
hbox = wx.BoxSizer(wx.HORIZONTAL)
vbox.Add(hbox)
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0.00")
setattr(self, "labelPrice%s" % type, 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
builtinStatsViews.registerView(PriceViewFull)

View File

@@ -0,0 +1,115 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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 RechargeViewFull(StatsView):
name = "rechargeViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Recharge rates"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
return width
def populatePanel(self, contentPanel, headerPanel):
contentSizer = contentPanel.GetSizer()
parent = contentPanel
panel = "full"
sizerTankStats = wx.FlexGridSizer(3, 5)
for i in xrange(4):
sizerTankStats.AddGrowableCol(i + 1)
contentSizer.Add(sizerTankStats, 0, wx.EXPAND, 0)
#Add an empty label first for correct alignment.
sizerTankStats.Add(wx.StaticText(contentPanel, wx.ID_ANY, ""), 0)
for tankType in ("shieldPassive", "shieldActive", "armorActive", "hullActive"):
sizerTankStats.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, contentPanel, "icons"), 0, wx.ALIGN_CENTER)
for stability in ("reinforced", "sustained"):
sizerTankStats.Add(bitmapLoader.getStaticBitmap("regen%s_big" % stability.capitalize(), contentPanel, "icons"), 0, wx.ALIGN_CENTER)
for tankType in ("shieldPassive", "shieldActive", "armorActive", "hullActive"):
if stability == "reinforced" and tankType == "shieldPassive":
sizerTankStats.Add(wx.StaticText(contentPanel, wx.ID_ANY, ""))
continue
tankTypeCap = tankType[0].capitalize() + tankType[1:]
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0.0", style = wx.ALIGN_RIGHT)
setattr(self, "labelTank%s%s" % (stability.capitalize(), tankTypeCap), lbl)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl, 1, wx.EXPAND)
box.Add(wx.StaticText(contentPanel, wx.ID_ANY, " HP/s"), 1, wx.EXPAND)
sizerTankStats.Add(box, 0, wx.ALIGN_CENTRE)
contentPanel.Layout()
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
for stability in ("reinforced", "sustained"):
if stability == "reinforced" and fit != None:
tank = fit.effectiveTank
elif stability == "sustained" and fit != None:
tank = fit.effectiveSustainableTank
else:
tank = None
for name in ("shield", "armor", "hull"):
lbl = getattr(self, "labelTank%s%sActive" % (stability.capitalize(), name.capitalize()))
if tank is not None:
lbl.SetLabel("%.1f" % tank["%sRepair" % name])
else:
lbl.SetLabel("0.0")
if fit is not None:
label = getattr(self, "labelTankSustainedShieldPassive")
value = fit.calculateShieldRecharge()
label.SetLabel(formatAmount(value, 3, 0, 9))
else:
value = 0
label = getattr(self, "labelTankSustainedShieldPassive")
label.SetLabel("0")
label.SetToolTip(wx.ToolTip("%.3f" % value))
builtinStatsViews.registerView(RechargeViewFull)

View File

@@ -0,0 +1,189 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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 ResistancesViewFull(StatsView):
name = "resistancesViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Resistances"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
return width
def populatePanel(self, contentPanel, headerPanel):
contentSizer = contentPanel.GetSizer()
parent = contentPanel
panel = "full"
# Resistances
# Custom header EHP
headerContentSizer = wx.BoxSizer(wx.HORIZONTAL)
hsizer = headerPanel.GetSizer()
hsizer.Add(headerContentSizer,0,0,0)
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 )
headerContentSizer.Add( stCls )
# headerContentSizer.Add(wx.StaticLine(headerPanel, wx.ID_ANY), 1, wx.ALIGN_CENTER)
# Display table
col = 0
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
for damageType in ("em", "thermal", "kinetic", "explosive"):
sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % damageType, contentPanel, "icons"), wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ), wx.ALIGN_CENTER)
col+=1
sizerResistances.Add(wx.StaticText(contentPanel, wx.ID_ANY, "EHP"), wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ), wx.ALIGN_CENTER)
col=0
row+=1
gaugeColours=( ((38,133,198),(52,86,98)), ((198,38,38),(83,65,67)), ((163,163,163),(74,90,93)), ((198,133,38),(81,83,67)) )
for tankType in ("shield", "armor", "hull", "separator", "damagePattern"):
if tankType != "separator":
sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, contentPanel, "icons"), wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ), wx.ALIGN_CENTER)
col+=1
else:
sizerResistances.Add(wx.StaticLine(contentPanel, wx.ID_ANY), wx.GBPosition( row, col ), wx.GBSpan( 1, 6 ), wx.EXPAND|wx.ALIGN_CENTER)
row+=1
col=0
continue
currGColour=0
for damageType in ("em", "thermal", "kinetic", "explosive"):
box = wx.BoxSizer(wx.HORIZONTAL)
sizerResistances.Add(box, wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ), wx.ALIGN_CENTER)
#Fancy gauges addon
pgColour= gaugeColours[currGColour]
fc = pgColour[0]
bc = pgColour[1]
currGColour+=1
lbl = PG.PyGauge(contentPanel, wx.ID_ANY, 100)
lbl.SetMinSize((48, 16))
lbl.SetBackgroundColour(wx.Colour(bc[0],bc[1],bc[2]))
lbl.SetBarColour(wx.Colour(fc[0],fc[1],fc[2]))
lbl.SetBarGradient()
lbl.SetFractionDigits(1)
setattr(self, "labelResistance%s%s" % (tankType.capitalize(), damageType.capitalize()), lbl)
box.Add(lbl, 0, wx.ALIGN_CENTER)
col+=1
box = wx.BoxSizer(wx.VERTICAL)
box.SetMinSize(wx.Size(self.getTextExtentW("WWWWk"), -1))
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0" if tankType != "damagePattern" else "")
box.Add(lbl, 0, wx.ALIGN_CENTER)
setattr(self, "labelResistance%sEhp" % tankType.capitalize(), lbl)
sizerResistances.Add(box, wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ), wx.ALIGN_CENTER)
row+=1
col=0
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
for tankType in ("shield", "armor", "hull"):
for damageType in ("em", "thermal", "kinetic", "explosive"):
if fit is not None:
resonanceType = tankType if tankType != "hull" else ""
resonance = "%s%sDamageResonance" % (resonanceType, damageType.capitalize())
resonance = resonance[0].lower() + resonance[1:]
resonance = (1 - fit.ship.getModifiedItemAttr(resonance)) * 100
else:
resonance = 0
lbl = getattr(self, "labelResistance%s%s" % (tankType.capitalize(), damageType.capitalize()))
lbl.SetValue(resonance)
ehp = fit.ehp if fit is not None else None
total = 0
for tankType in ("shield", "armor", "hull"):
lbl = getattr(self, "labelResistance%sEhp" % tankType.capitalize())
if ehp is not None:
total += ehp[tankType]
lbl.SetLabel(formatAmount(ehp[tankType], 3, 0, 9))
lbl.SetToolTip(wx.ToolTip("%s: %d" % (tankType.capitalize(), ehp[tankType])))
else:
lbl.SetLabel("0")
self.labelEhp.SetLabel("%s" % formatAmount(total, 3, 0, 9))
self.labelEhp.SetToolTip(wx.ToolTip("Effective: %d" % total))
damagePattern = fit.damagePattern if fit is not None else None
for damageType in ("em", "thermal", "kinetic", "explosive"):
lbl = getattr(self, "labelResistanceDamagepattern%s" % damageType.capitalize())
if damagePattern:
lbl.SetLabel("%.2f" % getattr(damagePattern, "%sAmount" % damageType))
else:
lbl.SetLabel("0.00")
builtinStatsViews.registerView(ResistancesViewFull)

View File

@@ -0,0 +1,185 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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 ResourcesViewFull(StatsView):
name = "resourcesViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Resources"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
return width
def populatePanel(self, contentPanel, headerPanel):
contentSizer = contentPanel.GetSizer()
sizerResources = wx.BoxSizer(wx.HORIZONTAL)
contentSizer.Add( sizerResources, 0, wx.EXPAND, 0)
parent = contentPanel
panel = "full"
sizer = wx.FlexGridSizer(3, 2)
sizer.SetMinSize(wx.Size(27 + self.getTextExtentW("400/400"), 0))
for i in xrange(3):
sizer.AddGrowableCol(i + 1)
base = sizerResources
base.Add(sizer, 0, wx.ALIGN_CENTER)
#Turrets & launcher hardslots display
for type in ("turret", "launcher", "calibration"):
bitmap = bitmapLoader.getStaticBitmap("%s_big" % type, parent, "icons")
box = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(bitmap, 0, wx.ALIGN_CENTER)
sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL)
suffix = "Points" if type == "calibration" else "Hardpoints"
lbl = wx.StaticText(parent, wx.ID_ANY, "0")
setattr(self, "label%sUsed%s%s" % (panel.capitalize(), type.capitalize(), suffix.capitalize()), lbl)
box.Add(lbl, 0, wx.ALIGN_LEFT)
box.Add(wx.StaticText(parent, wx.ID_ANY, "/"), 0, wx.ALIGN_LEFT)
lbl = wx.StaticText(parent, wx.ID_ANY, "0")
setattr(self, "label%sTotal%s%s" % (panel.capitalize(), type.capitalize(), suffix.capitalize()), lbl)
box.Add(lbl, 0, wx.ALIGN_LEFT)
st = wx.VERTICAL
base.Add(wx.StaticLine(parent, wx.ID_ANY, style=st), 0, wx.EXPAND | wx.LEFT, 3 if panel == "full" else 0)
#PG, Cpu & drone stuff
for i, group in enumerate((("cpu", "pg"), ("droneBay", "droneBandwidth"))):
main = wx.BoxSizer(wx.VERTICAL)
base.Add(main, 1 , wx.ALIGN_CENTER)
for type in group:
capitalizedType = type[0].capitalize() + type[1:]
bitmap = bitmapLoader.getStaticBitmap(type + "_big", parent, "icons")
stats = wx.BoxSizer(wx.VERTICAL)
absolute = wx.BoxSizer(wx.HORIZONTAL)
stats.Add(absolute, 0, wx.EXPAND)
b = wx.BoxSizer(wx.HORIZONTAL)
main.Add(b, 1, wx.ALIGN_CENTER)
b.Add(bitmap, 0, wx.ALIGN_BOTTOM)
b.Add(stats, 1, wx.EXPAND)
lbl = wx.StaticText(parent, wx.ID_ANY, "0")
setattr(self, "label%sUsed%s" % (panel.capitalize(), capitalizedType), lbl)
absolute.Add(lbl, 0, wx.ALIGN_LEFT)
absolute.Add(wx.StaticText(parent, wx.ID_ANY, "/"), 0, wx.ALIGN_LEFT)
lbl = wx.StaticText(parent, wx.ID_ANY, "0")
setattr(self, "label%sTotal%s" % (panel.capitalize(), capitalizedType), lbl)
absolute.Add(lbl, 0, wx.ALIGN_LEFT)
units = {"cpu":" tf", "pg":" MW", "droneBandwidth":" mbit/s", "droneBay":u" m\u00B3"}
lbl = wx.StaticText(parent, wx.ID_ANY, "%s" % units[type])
absolute.Add(lbl, 0, wx.ALIGN_LEFT)
# Gauges modif. - Darriele
gauge = PG.PyGauge(parent, wx.ID_ANY, 100)
gauge.SetMinSize((self.getTextExtentW("999.9k/1.3M GJ"), 23))
gauge.SetFractionDigits(2)
setattr(self, "gauge%s%s" % (panel.capitalize(),capitalizedType), gauge)
stats.Add(gauge, 0, wx.ALIGN_CENTER)
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
stats = (("label%sUsedTurretHardpoints", lambda: fit.getHardpointsUsed(Hardpoint.TURRET), 0, 0, 0),
("label%sTotalTurretHardpoints", lambda: fit.ship.getModifiedItemAttr('turretSlotsLeft'), 0, 0, 0),
("label%sUsedLauncherHardpoints", lambda: fit.getHardpointsUsed(Hardpoint.MISSILE), 0, 0, 0),
("label%sTotalLauncherHardpoints", lambda: fit.ship.getModifiedItemAttr('launcherSlotsLeft'), 0, 0, 0),
("label%sUsedCalibrationPoints", lambda: fit.calibrationUsed, 0, 0, 0),
("label%sTotalCalibrationPoints", lambda: fit.ship.getModifiedItemAttr('upgradeCapacity'), 0, 0, 0),
("label%sUsedPg", lambda: fit.pgUsed, 4, 0, 9),
("label%sUsedCpu", lambda: fit.cpuUsed, 4, 0, 9),
("label%sTotalPg", lambda: fit.ship.getModifiedItemAttr("powerOutput"), 4, 0, 9),
("label%sTotalCpu", lambda: fit.ship.getModifiedItemAttr("cpuOutput"), 4, 0, 9))
panel = "Full"
for labelName, value, prec, lowest, highest in stats:
label = getattr(self, labelName % panel)
value = value() if fit is not None else 0
value = value if value is not None else 0
if isinstance(value, basestring):
label.SetLabel(value)
label.SetToolTip(wx.ToolTip(value))
else:
label.SetLabel(formatAmount(value, prec, lowest, highest))
label.SetToolTip(wx.ToolTip("%.1f" % value))
if fit is not None:
resMax = (lambda: fit.ship.getModifiedItemAttr("cpuOutput"),
lambda: fit.ship.getModifiedItemAttr("powerOutput"),
lambda: fit.ship.getModifiedItemAttr("droneCapacity"),
lambda: fit.ship.getModifiedItemAttr("droneBandwidth"))
i = 0
for resourceType in ("cpu", "pg", "droneBay", "droneBandwidth"):
if fit is not None:
capitalizedType = resourceType[0].capitalize() + resourceType[1:]
gauge = getattr(self, "gauge%s%s" % (panel, capitalizedType))
resUsed = getattr(fit,"%sUsed" % resourceType)
if resMax[i]() > 0:
gauge.SetRange(resMax[i]())
gauge.SetValue(resUsed)
i+=1
else:
capitalizedType = resourceType[0].capitalize() + resourceType[1:]
gauge = getattr(self, "gauge%s%s" % (panel, capitalizedType))
gauge.SetRange(100)
gauge.SetValue(0)
i+=1
builtinStatsViews.registerView(ResourcesViewFull)

View File

@@ -0,0 +1,127 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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 TargetingMiscViewFull(StatsView):
name = "targetingmiscViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Targeting && Misc"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
return width
def populatePanel(self, contentPanel, headerPanel):
contentSizer = contentPanel.GetSizer()
parent = contentPanel
panel = "full"
gridTargetingMisc = wx.FlexGridSizer(1, 3)
contentSizer.Add( gridTargetingMisc, 0, wx.EXPAND | wx.ALL, 0)
gridTargetingMisc.AddGrowableCol(0)
gridTargetingMisc.AddGrowableCol(2)
# Targeting
gridTargeting = wx.FlexGridSizer(4, 2)
gridTargeting.AddGrowableCol(1)
gridTargetingMisc.Add(gridTargeting, 0, wx.ALIGN_LEFT | wx.ALL, 5)
labels = (("Targets", "Targets", ""),
("Range", "Range", "km"),
("Scan res.", "ScanRes", "mm"),
("Sensor str.", "SensorStr", ""))
for header, labelShort, unit in labels:
gridTargeting.Add(wx.StaticText(contentPanel, wx.ID_ANY, "%s: " % header), 0, wx.ALIGN_LEFT)
box = wx.BoxSizer(wx.HORIZONTAL)
gridTargeting.Add(box, 0, wx.ALIGN_LEFT)
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0")
setattr(self, "label%s" % labelShort, lbl)
box.Add(lbl, 0, wx.ALIGN_LEFT)
lblUnit = wx.StaticText(contentPanel, wx.ID_ANY, " %s" % unit)
setattr(self, "labelUnit%s" % labelShort, lblUnit)
box.Add(lblUnit, 0, wx.ALIGN_LEFT)
# Misc
gridTargetingMisc.Add( wx.StaticLine( contentPanel, wx.ID_ANY, style = wx.VERTICAL),0, wx.EXPAND, 3 )
gridMisc = wx.FlexGridSizer(4, 2)
gridMisc.AddGrowableCol(1)
gridTargetingMisc.Add(gridMisc,0 , wx.ALIGN_LEFT | wx.ALL, 5)
labels = (("Speed", "Speed", "m/s"),
("Align time", "AlignTime", "s"),
("Cargo", "Cargo", u"m\u00B3"),
("Signature", "SigRadius", "m"))
for header, labelShort, unit in labels:
gridMisc.Add(wx.StaticText(contentPanel, wx.ID_ANY, "%s: " % header), 0, wx.ALIGN_LEFT)
box = wx.BoxSizer(wx.HORIZONTAL)
gridMisc.Add(box, 0, wx.ALIGN_LEFT)
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0")
setattr(self, "labelFull%s" % labelShort, lbl)
box.Add(lbl, 0, wx.ALIGN_LEFT)
lblUnit = wx.StaticText(contentPanel, wx.ID_ANY, " %s" % unit)
setattr(self, "labelFullUnit%s" % labelShort, lblUnit)
box.Add(lblUnit, 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
stats = (("labelTargets", lambda: fit.maxTargets, 3, 0, 0),
("labelRange", lambda: fit.ship.getModifiedItemAttr('maxTargetRange') / 1000, 3, 0, 0),
("labelScanRes", lambda: fit.ship.getModifiedItemAttr('scanResolution'), 3, 0, 0),
("labelSensorStr", lambda: fit.scanStrength, 3, 0, 0),
("labelFullCargo", lambda: fit.extraAttributes["capacity"], 3, 0, 9),
("labelFullSigRadius", lambda: fit.ship.getModifiedItemAttr("signatureRadius"), 3, 0, 9),
("labelFullSpeed", lambda: fit.ship.getModifiedItemAttr("maxVelocity"), 3, 0, 0),
("labelFullAlignTime", lambda: fit.alignTime, 3, 0, 0))
for labelName, value, prec, lowest, highest in stats:
label = getattr(self, labelName)
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))
builtinStatsViews.registerView(TargetingMiscViewFull)

View File

@@ -0,0 +1,60 @@
#===============================================================================
# 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 <http://www.gnu.org/licenses/>.
#===============================================================================
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):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Firepower"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
return width
def populatePanel(self, contentPanel):
contentSizer = contentPanel.GetSizer()
parent = contentPanel
panel = "full"
contentSizer.Add( sizerResources, 0, wx.EXPAND | wx.ALL, 0)
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(FirepowerViewFull)

View File

@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
###########################################################################
## pyfatogllepanel.py
@@ -6,7 +6,7 @@
## Author: Darriele - HomeWorld
## Serial: 2010090702 (YYYYMMDDII)
## Project home: http://www.evefit.org - pyfa project
## http://www.evefit.org is the home for pyfa / eos / aurora
## http://www.evefit.org is the home for pyfa / eos / aurora
## Some portions of code are based on
## AGW:pycollapsiblepane generic implementation of wx.CollapsiblePane
## AGW:pycollapsiblepane credits ( from the original source file used ):
@@ -30,7 +30,7 @@ from gui import bitmapLoader
###########################################################################
class TogglePanel ( wx.Panel ):
def __init__( self, parent ):
wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL )
@@ -47,16 +47,16 @@ class TogglePanel ( wx.Panel ):
self.mainSizer = wx.BoxSizer( wx.VERTICAL )
self.SetSizer( self.mainSizer )
parentSize = parent.GetMinSize()
# Create the header panel
self.headerPanel = wx.Panel(self)
self.headerPanel = wx.Panel(self, style = wx.STATIC_BORDER)
self.headerPanel.SetBackgroundColour( self.bkColour)
self.mainSizer.Add(self.headerPanel,0,wx.EXPAND,5)
self.mainSizer.Add(self.headerPanel,0,wx.EXPAND | wx.TOP|wx.BOTTOM|wx.RIGHT, 1)
# Attempt to use native treeitembitmaps - fails on some linux distros / w.mangers
# Attempt to use native treeitembitmaps - fails on some linux distros / w.mangers
# self.bmpExpanded = self.GetNativeTreeItemBitmap("expanded")
# self.bmpCollapsed = self.GetNativeTreeItemBitmap("")
#
@@ -73,27 +73,27 @@ class TogglePanel ( wx.Panel ):
img = self.bmpExpanded.ConvertToImage()
img.Replace(0, 0, 0, sysTextColour[0], sysTextColour[1], sysTextColour[2])
self.bmpExpanded = wx.BitmapFromImage(img)
img = self.bmpCollapsed.ConvertToImage()
img.Replace(0, 0, 0, sysTextColour[0], sysTextColour[1], sysTextColour[2])
self.bmpCollapsed = wx.BitmapFromImage(img)
# Assign the bitmaps to the header static bitmap control
self.headerBmp = wx.StaticBitmap(self.headerPanel )
self.headerBmp.SetBitmap( self.bmpExpanded)
# Create the header sizer and append the static bitmap and static text controls
# Create the header sizer and append the static bitmap and static text controls
headerSizer = wx.BoxSizer( wx.HORIZONTAL )
self.headerPanel.SetSizer( headerSizer)
hbmpSizer = wx.BoxSizer( wx.HORIZONTAL )
hlblSizer = wx.BoxSizer( wx.HORIZONTAL )
self.hcntSizer = wx.BoxSizer( wx.HORIZONTAL)
hbmpSizer.Add( self.headerBmp, 0,0, 5 )
self.headerLabel = wx.StaticText( self.headerPanel, wx.ID_ANY, u"PYFA", wx.DefaultPosition, wx.DefaultSize, 0 )
hlblSizer.Add( self.headerLabel, 0, wx.EXPAND , 5 )
@@ -107,18 +107,19 @@ class TogglePanel ( wx.Panel ):
headerFont.SetWeight(wx.BOLD)
self.headerLabel.SetFont(headerFont)
# Create the content panel and its main sizer
# Create the content panel and its main sizer
self.contentSizer = wx.BoxSizer( wx.VERTICAL )
self.contentPanel = wx.Panel(self)
self.contentPanel.SetSizer(self.contentSizer)
self.mainSizer.Add( self.contentPanel, 1, wx.EXPAND, 5)
self.mainSizer.Add( self.contentPanel, 1, wx.EXPAND | wx.RIGHT , 1)
self.Layout()
# Connect Events
self.headerLabel.Bind( wx.EVT_LEFT_UP, self.toggleContent )
@@ -127,15 +128,18 @@ class TogglePanel ( wx.Panel ):
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.headerPanel.Bind(wx.EVT_PAINT, self.OnPaint)
self.contentPanel.Bind(wx.EVT_PAINT, self.OnPaint)
def __del__( self ):
pass
def OnPaint(self, event):
self.contentPanel.Layout()
self.headerPanel.Layout()
event.Skip()
event.Skip()
def AddToggleItem(self, hitem):
hitem.Bind( wx.EVT_LEFT_UP, self.toggleContent )
def GetHeaderContentSizer(self):
return self.hcntSizer
@@ -148,15 +152,15 @@ class TogglePanel ( wx.Panel ):
def AddSizer(self, sizer):
self.contentSizer.Add(sizer, 0, wx.EXPAND | wx.ALL, 0)
self.Layout()
def GetContentPane(self):
return self.contentPanel
def SetLabel(self, label):
self.headerLabel.SetLabel(label)
def GetNativeTreeItemBitmap(self, mode):
bitmap = wx.EmptyBitmap(24, 24)
dc = wx.MemoryDC()
dc.SelectObject(bitmap)
@@ -166,9 +170,9 @@ class TogglePanel ( wx.Panel ):
wx.RendererNative.Get().DrawTreeItemButton(self, dc, wx.Rect(0, 0, 24, 24), wx.CONTROL_EXPANDED if mode == "expanded" else 0)
dc.Destroy()
return bitmap
return bitmap
# Virtual event handlers, overide them in your derived class
def IsCollapsed(self):
@@ -200,7 +204,7 @@ class TogglePanel ( wx.Panel ):
self.parent.GetSizer().SetSizeHints(self.parent)
if self.IsCollapsed():
# expanded . collapsed transition
if self.parent.GetSizer():
@@ -210,26 +214,26 @@ class TogglePanel ( wx.Panel ):
# use SetClientSize() and not SetSize() otherwise the size for
# e.g. a wxFrame with a menubar wouldn't be correctly set
self.parent.SetClientSize(sz)
else:
self.parent.Layout()
else:
# collapsed . expanded transition
# force our parent to "fit", i.e. expand so that it can honour
# our minimal size
self.parent.Fit()
# Toggle the content panel (hide/show)
def toggleContent( self, event ):
self.Freeze()
self.Freeze()
if self._toggle == 1:
# self.contentPanel.Hide()
self.contentMinSize = self.contentPanel.GetSize()
@@ -243,7 +247,7 @@ class TogglePanel ( wx.Panel ):
self.headerBmp.SetBitmap( self.bmpExpanded)
self._toggle *=-1
self.Thaw()
@@ -260,11 +264,11 @@ class TogglePanel ( wx.Panel ):
self.headerPanel.Refresh()
event.Skip()
def leaveWindow( self, event ):
self.headerPanel.SetBackgroundColour( self.bkColour )
self.headerPanel.Refresh()
self.headerPanel.Refresh()
event.Skip()

File diff suppressed because it is too large Load Diff