diff --git a/gui/boosterView.py b/gui/boosterView.py index f3be99407..2fa80a713 100644 --- a/gui/boosterView.py +++ b/gui/boosterView.py @@ -22,14 +22,13 @@ import service import gui.display as d import gui.fittingView as fv import gui.marketBrowser as mb -from gui.builtinViewColumns.activityCheckbox import ActivityCheckbox +from gui.builtinViewColumns.state import State from gui.contextMenu import ContextMenu class BoosterView(d.Display): - DEFAULT_COLS = ["Activity Checkbox", + DEFAULT_COLS = ["State", "attr:boosterness", - "Name", - ] + "Base Name"] def __init__(self, parent): d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL) @@ -74,7 +73,7 @@ class BoosterView(d.Display): row, _ = self.HitTest(event.Position) if row != -1: col = self.getColumn(event.Position) - if col == self.getColIndex(ActivityCheckbox): + if col == self.getColIndex(State): fitID = self.mainFrame.getActiveFit() cFit = service.Fit.getInstance() cFit.toggleBooster(fitID, row) @@ -83,7 +82,7 @@ class BoosterView(d.Display): def scheduleMenu(self, event): event.Skip() - if self.getColumn(event.Position) != self.getColIndex(ActivityCheckbox): + if self.getColumn(event.Position) != self.getColIndex(State): wx.CallAfter(self.spawnMenu) def spawnMenu(self): diff --git a/gui/builtinStatsViews/targetingMiscViewFull.py b/gui/builtinStatsViews/targetingMiscViewFull.py index 1fde123cf..0ebd4059d 100644 --- a/gui/builtinStatsViews/targetingMiscViewFull.py +++ b/gui/builtinStatsViews/targetingMiscViewFull.py @@ -107,6 +107,7 @@ class TargetingMiscViewFull(StatsView): ("labelFullSigRadius", lambda: fit.ship.getModifiedItemAttr("signatureRadius"), 3, 0, 9, ""), ("labelFullWarpSpeed", lambda: fit.warpSpeed, 3, 0, 0, "AU/s"), ("labelFullCargo", lambda: fit.ship.getModifiedItemAttr("capacity"), 3, 0, 9, u"m\u00B3")) + counter = 0 for labelName, value, prec, lowest, highest, unit in stats: label = getattr(self, labelName) @@ -115,8 +116,8 @@ class TargetingMiscViewFull(StatsView): if self._cachedValues[counter] != value: label.SetLabel("%s %s" %(formatAmount(value, prec, lowest, highest), unit)) # Tooltip stuff - RADII = [("Pod",25), ("Interceptor",33), ("Frigate",38), - ("Destroyer", 83), ("Cruiser", 130), + RADII = [("Pod",25), ("Interceptor",33), ("Frigate",38), + ("Destroyer", 83), ("Cruiser", 130), ("Battlecruiser", 265), ("Battleship",420)] if labelName is "labelScanRes": lockTime = "%s\n" % "Lock Times".center(28) diff --git a/gui/builtinViewColumns/__init__.py b/gui/builtinViewColumns/__init__.py index f85f4bd13..61185cd74 100644 --- a/gui/builtinViewColumns/__init__.py +++ b/gui/builtinViewColumns/__init__.py @@ -1,5 +1,2 @@ -__all__ = ["moduleState", "moduleName", "attributeDisplay", "maxRange", - "name", "droneDps", "droneNameAmount", "droneCheckbox", "moduleAmmo", - "capacitorUse", "activityCheckbox", "moduleAmmoIcon", "modulePrice", - "projectedName", "projectedState", "projectedAmmoIcon", - "projectedAmmo", "moduleTracking"] +__all__ = ["ammo", "ammoIcon", "attributeDisplay", "baseIcon", "baseName", + "capacitorUse", "maxRange", "price", "propertyDisplay", "state", "tracking"] diff --git a/gui/builtinViewColumns/moduleAmmo.py b/gui/builtinViewColumns/ammo.py similarity index 83% rename from gui/builtinViewColumns/moduleAmmo.py rename to gui/builtinViewColumns/ammo.py index bebf65da5..b3694fa95 100644 --- a/gui/builtinViewColumns/moduleAmmo.py +++ b/gui/builtinViewColumns/ammo.py @@ -21,19 +21,19 @@ from gui import builtinViewColumns from gui.viewColumn import ViewColumn from gui import bitmapLoader import wx -class ModuleAmmo(ViewColumn): - name = "Module Ammo" + +class Ammo(ViewColumn): + name = "Ammo" def __init__(self, fittingView, params): ViewColumn.__init__(self, fittingView) - self.mask = wx.LIST_MASK_IMAGE - self.imageId = fittingView.imageList.Add(bitmapLoader.getBitmap("damagePattern_small", "icons")) - def getText(self, mod): - return "%s (%s)" % (mod.charge.name, mod.numCharges) if mod.charge is not None else "" + def getText(self, stuff): + return "%s (%s)" % (stuff.charge.name, stuff.numCharges) if getattr(stuff, "charge", None) is not None else "" + def getImageId(self, mod): return -1 -ModuleAmmo.register() +Ammo.register() diff --git a/gui/builtinViewColumns/moduleAmmoIcon.py b/gui/builtinViewColumns/ammoIcon.py similarity index 73% rename from gui/builtinViewColumns/moduleAmmoIcon.py rename to gui/builtinViewColumns/ammoIcon.py index 18ec5431d..f48d5ef69 100644 --- a/gui/builtinViewColumns/moduleAmmoIcon.py +++ b/gui/builtinViewColumns/ammoIcon.py @@ -21,9 +21,10 @@ from gui import builtinViewColumns from gui.viewColumn import ViewColumn from gui import bitmapLoader import wx +from eos.types import Module -class ModuleAmmoIcon(ViewColumn): - name = "Module Ammo Icon" +class AmmoIcon(ViewColumn): + name = "Ammo Icon" def __init__(self, fittingView, params): ViewColumn.__init__(self, fittingView) self.size = 16 @@ -34,20 +35,21 @@ class ModuleAmmoIcon(ViewColumn): def getText(self, mod): return "" - def getImageId(self, mod): - if mod.charge is None: - iconId = -1 + def getImageId(self, stuff): + if not isinstance(stuff, Module): + return -1 + + if stuff.charge is None: + return -1 else: - iconFile = mod.charge.icon.iconFile if mod.item.icon else "" + iconFile = stuff.charge.icon.iconFile if stuff.item.icon else "" if iconFile: bitmap = bitmapLoader.getBitmap(iconFile, "pack") if bitmap is None: - iconId = -1 + return -1 else: - iconId = self.fittingView.imageList.Add(bitmap) + return self.fittingView.imageList.Add(bitmap) else: - iconId = -1 + return -1 - return iconId - -ModuleAmmoIcon.register() +AmmoIcon.register() diff --git a/gui/builtinViewColumns/attributeDisplay.py b/gui/builtinViewColumns/attributeDisplay.py index 5c5a7e4d9..6e16c266d 100644 --- a/gui/builtinViewColumns/attributeDisplay.py +++ b/gui/builtinViewColumns/attributeDisplay.py @@ -25,7 +25,7 @@ from util import formatAmount import wx class AttributeDisplay(ViewColumn): - name = "Attribute Display" + name = "attr" def __init__(self, fittingView, params): ViewColumn.__init__(self, fittingView) cAttribute = service.Attribute.getInstance() @@ -67,7 +67,8 @@ class AttributeDisplay(ViewColumn): def getImageId(self, mod): return -1 - def getParameters(self): + @staticmethod + def getParameters(): return (("attribute", str, None), ("displayName", bool, False), ("showIcon", bool, True)) diff --git a/gui/builtinViewColumns/baseIcon.py b/gui/builtinViewColumns/baseIcon.py new file mode 100755 index 000000000..e2525f0aa --- /dev/null +++ b/gui/builtinViewColumns/baseIcon.py @@ -0,0 +1,42 @@ +from gui import builtinViewColumns +from gui.viewColumn import ViewColumn +from gui import bitmapLoader +import wx +from eos.types import Drone, Fit, Module, Slot + +class BaseIcon(ViewColumn): + name = "Base Icon" + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + self.size = 16 + self.maxsize = self.size + self.mask = wx.LIST_MASK_TEXT + self.columnText = "" + self.shipImage = fittingView.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons")) + + def getImageId(self, stuff): + if isinstance(stuff, Drone): + return -1 + if isinstance(stuff, Fit): + return self.shipImage + if isinstance(stuff, Module): + if stuff.isEmpty: + bitmap = bitmapLoader.getBitmap("slot_%s_small" % Slot.getName(stuff.slot).lower(), "icons") + return self.fittingView.imageList.Add(bitmap) + else: + return self.loadIconFile(stuff.item.icon.iconFile if stuff.item.icon else "") + + item = getattr(stuff, "item", stuff) + return self.loadIconFile(item.icon.iconFile if item.icon else "") + + def loadIconFile(self, iconFile): + if iconFile: + bitmap = bitmapLoader.getBitmap(iconFile, "pack") + if bitmap is None: + return -1 + else: + return self.fittingView.imageList.Add(bitmap) + else: + return -1 + +BaseIcon.register() diff --git a/gui/builtinViewColumns/name.py b/gui/builtinViewColumns/baseName.py similarity index 63% rename from gui/builtinViewColumns/name.py rename to gui/builtinViewColumns/baseName.py index 529ea4cd1..f6664fdea 100644 --- a/gui/builtinViewColumns/name.py +++ b/gui/builtinViewColumns/baseName.py @@ -21,30 +21,28 @@ from gui import builtinViewColumns from gui.viewColumn import ViewColumn from gui import bitmapLoader import wx +from eos.types import Drone, Fit, Module, Slot -class StuffName(ViewColumn): - name = "Name" +class BaseName(ViewColumn): + name = "Base Name" def __init__(self, fittingView, params): ViewColumn.__init__(self, fittingView) self.columnText = "Name" + self.shipImage = fittingView.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons")) self.mask = wx.LIST_MASK_TEXT def getText(self, stuff): - item = getattr(stuff, "item", stuff) - return item.name - - def getImageId(self, mod): - item = getattr(mod, "item", mod) - iconFile = item.icon.iconFile if item.icon else "" - if iconFile: - bitmap = bitmapLoader.getBitmap(iconFile, "pack") - if bitmap is None: - iconId = -1 + if isinstance(stuff, Drone): + return "%dx %s" % (stuff.amount, stuff.item.name) + elif isinstance(stuff, Fit): + return "%s (%s)" % (stuff.name, stuff.ship.item.name) + elif isinstance(stuff, Module): + if stuff.isEmpty: + return "%s Slot" % Slot.getName(stuff.slot).capitalize() else: - iconId = self.fittingView.imageList.Add(bitmap) + return stuff.item.name else: - iconId = -1 + item = getattr(stuff, "item", stuff) + return item.name - return iconId - -StuffName.register() +BaseName.register() diff --git a/gui/builtinViewColumns/capacitorUse.py b/gui/builtinViewColumns/capacitorUse.py old mode 100644 new mode 100755 diff --git a/gui/builtinViewColumns/droneCheckbox.py b/gui/builtinViewColumns/droneCheckbox.py deleted file mode 100644 index 7820b5df3..000000000 --- a/gui/builtinViewColumns/droneCheckbox.py +++ /dev/null @@ -1,50 +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 . -#=============================================================================== - -from gui import builtinViewColumns -from gui.viewColumn import ViewColumn -import gui.mainFrame -import wx - -class DroneCheckbox(ViewColumn): - name = "Drone Checkbox" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.resizable = False - self.size = 24 - for name, state in (("checked", wx.CONTROL_CHECKED), ("unchecked", 0)): - bitmap = wx.EmptyBitmap(16, 16) - dc = wx.MemoryDC() - dc.SelectObject(bitmap) - dc.SetBackground(wx.TheBrushList.FindOrCreateBrush(fittingView.GetBackgroundColour(), wx.SOLID)) - dc.Clear() - wx.RendererNative.Get().DrawCheckBox(fittingView, dc, wx.Rect(0, 0, 16, 16), state) - dc.Destroy() - setattr(self, "%sId" % name, fittingView.imageList.Add(bitmap)) - - def getText(self, mod): - return "" - - def getImageId(self, drone): - if drone.amountActive > 0: - return self.checkedId - else: - return self.uncheckedId - -DroneCheckbox.register() diff --git a/gui/builtinViewColumns/droneDps.py b/gui/builtinViewColumns/droneDps.py deleted file mode 100644 index 5f7be203c..000000000 --- a/gui/builtinViewColumns/droneDps.py +++ /dev/null @@ -1,40 +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 . -#=============================================================================== - -from gui import builtinViewColumns -from gui.viewColumn import ViewColumn -from gui import bitmapLoader -from eos.types import Slot -import wx -class DroneDps(ViewColumn): - name = "Drone DPS" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.columnText = "" - self.mask = wx.LIST_MASK_IMAGE - bitmap = bitmapLoader.getBitmap("droneBandwidth_small", "icons") - self.imageId = fittingView.imageList.Add(bitmap) - - def getText(self, stuff): - return "%.1f" % stuff.dps - - def getImageId(self, mod): - return -1 - -DroneDps.register() \ No newline at end of file diff --git a/gui/builtinViewColumns/droneNameAmount.py b/gui/builtinViewColumns/droneNameAmount.py deleted file mode 100644 index 1c80c6a5e..000000000 --- a/gui/builtinViewColumns/droneNameAmount.py +++ /dev/null @@ -1,39 +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 . -#=============================================================================== - -from gui import builtinViewColumns -from gui.viewColumn import ViewColumn -from gui import bitmapLoader -from eos.types import Slot -import wx - -class DroneNameAmount(ViewColumn): - name = "Drone Name/Amount" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.columnText = "Name" - self.mask = wx.LIST_MASK_TEXT - - def getText(self, drone): - return "%dx %s" % (drone.amount, drone.item.name) - - def getImageId(self, mod): - return -1 - -DroneNameAmount.register() diff --git a/gui/builtinViewColumns/maxRange.py b/gui/builtinViewColumns/maxRange.py old mode 100644 new mode 100755 index ca08f45b8..189111869 --- a/gui/builtinViewColumns/maxRange.py +++ b/gui/builtinViewColumns/maxRange.py @@ -25,7 +25,7 @@ from util import formatAmount import wx class MaxRange(ViewColumn): - name = "Max range" + name = "Max Range" def __init__(self, fittingView, params = None): if params == None: params = {"showIcon": True, diff --git a/gui/builtinViewColumns/moduleName.py b/gui/builtinViewColumns/moduleName.py deleted file mode 100644 index 58a80b9ae..000000000 --- a/gui/builtinViewColumns/moduleName.py +++ /dev/null @@ -1,56 +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 . -#=============================================================================== - -from gui import builtinViewColumns -from gui.viewColumn import ViewColumn -from gui import bitmapLoader -from eos.types import Slot -import wx - -class ModuleName(ViewColumn): - name = "Module Name" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.columnText = "Name" - self.mask = wx.LIST_MASK_TEXT - - def getText(self, mod): - if mod.isEmpty: - return "%s Slot" % Slot.getName(mod.slot).capitalize() - else: - return mod.item.name - - def getImageId(self, mod): - if mod.isEmpty: - bitmap = bitmapLoader.getBitmap("slot_%s_small" % Slot.getName(mod.slot).lower(), "icons") - iconId = self.fittingView.imageList.Add(bitmap) - else: - iconFile = mod.item.icon.iconFile if mod.item.icon else "" - if iconFile: - bitmap = bitmapLoader.getBitmap(iconFile, "pack") - if bitmap is None: - iconId = -1 - else: - iconId = self.fittingView.imageList.Add(bitmap) - else: - iconId = -1 - - return iconId - -ModuleName.register() diff --git a/gui/builtinViewColumns/moduleState.py b/gui/builtinViewColumns/moduleState.py deleted file mode 100644 index 8e0437f2c..000000000 --- a/gui/builtinViewColumns/moduleState.py +++ /dev/null @@ -1,45 +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 . -#=============================================================================== - -from gui import builtinViewColumns -from gui.viewColumn import ViewColumn -from gui import bitmapLoader -from eos.types import State -import wx - -class ModuleState(ViewColumn): - name = "Module State" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.resizable = False - self.size = 20 - self.mask = wx.LIST_MASK_IMAGE - self.stateNameMap = {} - - def getText(self, mod): - return "" - - def getImageId(self, mod): - if mod.isEmpty: - return -1 - else: - bitmap = bitmapLoader.getBitmap("state_%s_small" % State.getName(mod.state).lower(), "icons") - return self.fittingView.imageList.Add(bitmap) - -ModuleState.register() diff --git a/gui/builtinViewColumns/modulePrice.py b/gui/builtinViewColumns/price.py similarity index 90% rename from gui/builtinViewColumns/modulePrice.py rename to gui/builtinViewColumns/price.py index 146c817f6..e03bb2dc0 100644 --- a/gui/builtinViewColumns/modulePrice.py +++ b/gui/builtinViewColumns/price.py @@ -23,8 +23,8 @@ import service from util import formatAmount import wx -class ModulePrice(ViewColumn): - name = "Module Price" +class Price(ViewColumn): + name = "Price" def __init__(self, fittingView, params): ViewColumn.__init__(self, fittingView) self.mask = wx.LIST_MASK_IMAGE @@ -35,12 +35,12 @@ class ModulePrice(ViewColumn): self.imageId = -1 - def getText(self, mod): - if mod.item is None: + def getText(self, stuff): + if stuff.item is None: return "" sMarket = service.Market.getInstance() - price = sMarket.getPriceNow(mod.item.ID).price + price = sMarket.getPriceNow(stuff.item.ID).price return formatAmount(price, 3, 3, 9) if price else False def delayedText(self, mod, display, colItem): @@ -49,10 +49,9 @@ class ModulePrice(ViewColumn): colItem.SetText(formatAmount(price, 3, 3, 9) if price else "") display.SetItem(colItem) - service.Market.getInstance().getPrices([mod.item.ID], callback) def getImageId(self, mod): return -1 -ModulePrice.register() +Price.register() diff --git a/gui/builtinViewColumns/projectedAmmo.py b/gui/builtinViewColumns/projectedAmmo.py deleted file mode 100644 index 78aafc6ab..000000000 --- a/gui/builtinViewColumns/projectedAmmo.py +++ /dev/null @@ -1,46 +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 . -#=============================================================================== - -from gui.viewColumn import ViewColumn -import gui.builtinViewColumns.moduleAmmo -from eos.types import Module -import wx - -class ProjectedAmmo(ViewColumn): - name = "Projected Ammo" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.columnText = "" - self.mask = wx.LIST_MASK_IMAGE - - self.slave = gui.builtinViewColumns.moduleAmmo.ModuleAmmo(fittingView, params) - self.imageId = self.slave.imageId - def getText(self, stuff): - if isinstance(stuff, Module): - return self.slave.getText(stuff) - else: - return "" - - def getImageId(self, thing): - if isinstance(thing, Module): - return self.slave.getImageId(thing) - else: - return -1 - -ProjectedAmmo.register() diff --git a/gui/builtinViewColumns/projectedAmmoIcon.py b/gui/builtinViewColumns/projectedAmmoIcon.py deleted file mode 100644 index 8a0689702..000000000 --- a/gui/builtinViewColumns/projectedAmmoIcon.py +++ /dev/null @@ -1,46 +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 . -#=============================================================================== - -from gui.viewColumn import ViewColumn -import gui.builtinViewColumns.moduleAmmoIcon -from eos.types import Module -import wx -class ProjectedAmmoIcon(ViewColumn): - name = "Projected Ammo Icon" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.columnText = "" - self.size = 20 - self.mask = wx.LIST_MASK_IMAGE - - self.slave = gui.builtinViewColumns.moduleAmmoIcon.ModuleAmmoIcon(fittingView, params) - - def getText(self, stuff): - if isinstance(stuff, Module): - return self.slave.getText(stuff) - else: - return "" - - def getImageId(self, thing): - if isinstance(thing, Module): - return self.slave.getImageId(thing) - else: - return -1 - -ProjectedAmmoIcon.register() diff --git a/gui/builtinViewColumns/projectedName.py b/gui/builtinViewColumns/projectedName.py deleted file mode 100644 index 2aef1ce8d..000000000 --- a/gui/builtinViewColumns/projectedName.py +++ /dev/null @@ -1,53 +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 . -#=============================================================================== - -from gui.viewColumn import ViewColumn -import gui.builtinViewColumns.name -import gui.builtinViewColumns.droneNameAmount -from eos.types import Drone, Fit -import wx -from gui import bitmapLoader - -class ProjectedName(ViewColumn): - name = "Projected Name" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.columnText = "Name" - self.mask = wx.LIST_MASK_TEXT - self.shipImage = fittingView.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons")) - self.slave = gui.builtinViewColumns.name.StuffName(fittingView, params) - self.droneSlave = gui.builtinViewColumns.droneNameAmount.DroneNameAmount(fittingView, params) - - def getText(self, stuff): - if isinstance(stuff, Drone): - return self.droneSlave.getText(stuff) - elif isinstance(stuff, Fit): - return "%s (%s)" % (stuff.name, stuff.ship.item.name) - else: - return self.slave.getText(stuff) - - def getImageId(self, thing): - if isinstance(thing, Drone): - return self.droneSlave.getImageId(thing) - elif isinstance(thing, Fit): - return self.shipImage - else: - return self.slave.getImageId(thing) - -ProjectedName.register() diff --git a/gui/builtinViewColumns/projectedState.py b/gui/builtinViewColumns/projectedState.py deleted file mode 100644 index b3a4bdd00..000000000 --- a/gui/builtinViewColumns/projectedState.py +++ /dev/null @@ -1,57 +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 . -#=============================================================================== - -from gui import builtinViewColumns -from gui.viewColumn import ViewColumn -from gui import bitmapLoader -from eos.types import Slot -import gui.builtinViewColumns.moduleState -import gui.builtinViewColumns.droneCheckbox -from eos.types import Module, Drone, Fit -import gui.bitmapLoader -import wx - -class ProjectedState(ViewColumn): - name = "Projected State" - def __init__(self, view, params): - ViewColumn.__init__(self, view) - self.columnText = "" - self.size = 20 - self.mask = wx.LIST_MASK_IMAGE - self.fitImageId = view.imageList.Add(gui.bitmapLoader.getBitmap("fit_small", "icons")) - self.moduleSlave = gui.builtinViewColumns.moduleState.ModuleState(view, params) - self.droneSlave = gui.builtinViewColumns.droneCheckbox.DroneCheckbox(view, params) - - def getText(self, stuff): - if isinstance(stuff, Module): - return self.moduleSlave.getText(stuff) - elif isinstance(stuff, Drone): - return self.droneSlave.getText(stuff) - else: - return "" - - def getImageId(self, stuff): - if isinstance(stuff, Module): - return self.moduleSlave.getImageId(stuff) - elif isinstance(stuff, Drone): - return self.droneSlave.getImageId(stuff) - else: - return self.fitImageId - -ProjectedState.register() diff --git a/gui/builtinViewColumns/propertyDisplay.py b/gui/builtinViewColumns/propertyDisplay.py new file mode 100755 index 000000000..79485d4f7 --- /dev/null +++ b/gui/builtinViewColumns/propertyDisplay.py @@ -0,0 +1,75 @@ +#=============================================================================== +# 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 . +#=============================================================================== + +from gui.viewColumn import ViewColumn +from gui import bitmapLoader +import service +from util import formatAmount +import wx + +class PropertyDisplay(ViewColumn): + name = "prop" + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + cAttribute = service.Attribute.getInstance() + attributeSlave = params["attributeSlave"] or params["property"] + try: + info = cAttribute.getAttributeInfo(attributeSlave) + except: + info = None + + self.mask = 0 + self.propertyName = params["property"] + self.info = info + if params["showIcon"]: + if info.name == "power": + iconFile = "pg_small" + iconType = "icons" + else: + iconFile = info.icon.iconFile if info.icon else None + iconType = "pack" + if iconFile: + bitmap = bitmapLoader.getBitmap(iconFile, iconType) + if bitmap: + self.imageId = fittingView.imageList.Add(bitmap) + else: + self.imageId = -1 + else: + self.imageId = -1 + else: + self.imageId = -1 + + if params["displayName"] or self.imageId == -1: + self.columnText = info.displayName if info.displayName != "" else info.name + + def getText(self, stuff): + attr = getattr(stuff, self.propertyName, None) + if attr: + return (formatAmount(attr, 3, 0, 3)) + else: + return "" + + @staticmethod + def getParameters(): + return (("property", str, None), + ("attributeSlave", str, None), + ("displayName", bool, False), + ("showIcon", bool, True)) + +PropertyDisplay.register() diff --git a/gui/builtinViewColumns/activityCheckbox.py b/gui/builtinViewColumns/state.py similarity index 67% rename from gui/builtinViewColumns/activityCheckbox.py rename to gui/builtinViewColumns/state.py index 4a790b7e7..4feaf8cec 100644 --- a/gui/builtinViewColumns/activityCheckbox.py +++ b/gui/builtinViewColumns/state.py @@ -1,49 +1,63 @@ -#=============================================================================== -# 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 . -#=============================================================================== - -from gui import builtinViewColumns -from gui.viewColumn import ViewColumn -import gui.mainFrame -import wx - -class ActivityCheckbox(ViewColumn): - name = "Activity Checkbox" - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.resizable = False - self.size = 24 - self.maxsize = self.size - self.mask = wx.LIST_MASK_WIDTH - for name, state in (("checked", wx.CONTROL_CHECKED), ("unchecked", 0)): - bitmap = wx.EmptyBitmap(16, 16) - dc = wx.MemoryDC() - dc.SelectObject(bitmap) - dc.SetBackground(wx.TheBrushList.FindOrCreateBrush(fittingView.GetBackgroundColour(), wx.SOLID)) - dc.Clear() - wx.RendererNative.Get().DrawCheckBox(fittingView, dc, wx.Rect(0, 0, 16, 16), state) - dc.Destroy() - setattr(self, "%sId" % name, fittingView.imageList.Add(bitmap)) - - def getText(self, mod): - return "" - - def getImageId(self, implant): - return self.checkedId if implant.active else self.uncheckedId - -ActivityCheckbox.register() +#=============================================================================== +# 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 . +#=============================================================================== + +from gui.viewColumn import ViewColumn +from gui import bitmapLoader +import wx +from eos.types import Drone, Module +from eos.types import State as State_ + +class State(ViewColumn): + name = "State" + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + self.resizable = False + self.size = 24 + self.maxsize = self.size + self.mask = wx.LIST_MASK_WIDTH + for name, state in (("checked", wx.CONTROL_CHECKED), ("unchecked", 0)): + bitmap = wx.EmptyBitmap(16, 16) + dc = wx.MemoryDC() + dc.SelectObject(bitmap) + dc.SetBackground(wx.TheBrushList.FindOrCreateBrush(fittingView.GetBackgroundColour(), wx.SOLID)) + dc.Clear() + wx.RendererNative.Get().DrawCheckBox(fittingView, dc, wx.Rect(0, 0, 16, 16), state) + dc.Destroy() + setattr(self, "%sId" % name, fittingView.imageList.Add(bitmap)) + + def getText(self, mod): + return "" + + def getImageId(self, stuff): + if isinstance(stuff, Drone): + return self.checkedId if stuff.amountActive > 0 else self.uncheckedId + elif isinstance(stuff, Module): + if stuff.isEmpty: + return -1 + else: + bitmap = bitmapLoader.getBitmap("state_%s_small" % State_.getName(stuff.state).lower(), "icons") + return self.fittingView.imageList.Add(bitmap) + else: + active = getattr(stuff, "active", None) + if active is None: + return -1 + else: + return self.checkedId if active else self.uncheckedId + +State.register() diff --git a/gui/builtinViewColumns/moduleTracking.py b/gui/builtinViewColumns/tracking.py old mode 100644 new mode 100755 similarity index 85% rename from gui/builtinViewColumns/moduleTracking.py rename to gui/builtinViewColumns/tracking.py index ffda80c2d..97f730cb8 --- a/gui/builtinViewColumns/moduleTracking.py +++ b/gui/builtinViewColumns/tracking.py @@ -26,7 +26,7 @@ from eos.types import Hardpoint import wx class MaxRange(ViewColumn): - name = "Module Tracking" + name = "Tracking" def __init__(self, fittingView, params = None): if params == None: params = {"showIcon": True, @@ -56,15 +56,18 @@ class MaxRange(ViewColumn): self.mask |= wx.LIST_MASK_TEXT def getText(self, stuff): - if stuff.hardpoint == Hardpoint.TURRET: - return (formatAmount(stuff.getModifiedItemAttr("trackingSpeed"), 3, 0, 3)) - elif stuff.hardpoint == Hardpoint.MISSILE: + trackingSpeed = stuff.getModifiedItemAttr("trackingSpeed") + if trackingSpeed is not None: + return (formatAmount(trackingSpeed, 3, 0, 3)) + else: if stuff.charge is None: return "" cloudSize = stuff.getModifiedChargeAttr("aoeCloudSize") - text = "%s%s" % (formatAmount(cloudSize, 3, 0, 3), - stuff.charge.attributes["aoeCloudSize"].unit.displayName) + text = "" + if cloudSize: + text += "%s%s" % (formatAmount(cloudSize, 3, 0, 3), + stuff.charge.attributes["aoeCloudSize"].unit.displayName) aoeVelocity = stuff.getModifiedChargeAttr("aoeVelocity") if aoeVelocity: @@ -73,8 +76,6 @@ class MaxRange(ViewColumn): "m/s") #Hardcoded unit here, m/sec is too long return text - else: - return "" def getImageId(self, mod): return -1 diff --git a/gui/display.py b/gui/display.py index 8040ffbad..e4e9277eb 100644 --- a/gui/display.py +++ b/gui/display.py @@ -37,12 +37,19 @@ class Display(wx.ListCtrl): i = 0 for colName in self.DEFAULT_COLS: - if colName[0:5] == "attr:": - attrName = colName[5:] - params = {"showIcon": True, - "displayName": False, - "attribute": attrName} - col = ViewColumn.getColumn("Attribute Display")(self, params) + if ":" in colName: + colName, params = colName.split(":", 1) + params = params.split(",") + colClass = ViewColumn.getColumn(colName) + paramList = colClass.getParameters() + paramDict = {} + for x, param in enumerate(paramList): + name, type, defaultValue = param + value = params[x] if len(params) > x else defaultValue + if type == bool: + value = bool(value) if value != "False" else False + paramDict[name] = value + col = colClass(self, paramDict) else: col = ViewColumn.getColumn(colName)(self, None) diff --git a/gui/droneView.py b/gui/droneView.py index 3bf099d10..020e3d288 100644 --- a/gui/droneView.py +++ b/gui/droneView.py @@ -23,7 +23,7 @@ import service import gui.fittingView as fv import gui.marketBrowser as mb import gui.display as d -from gui.builtinViewColumns.droneCheckbox import DroneCheckbox +from gui.builtinViewColumns.state import State from gui.contextMenu import ContextMenu class DroneViewDrop(wx.PyDropTarget): @@ -40,11 +40,12 @@ class DroneViewDrop(wx.PyDropTarget): return t class DroneView(d.Display): - DEFAULT_COLS = ["Drone Checkbox", - "Drone Name/Amount", - "Drone DPS", - "Max range", - "attr:trackingSpeed", + DEFAULT_COLS = ["State", + "Base Icon", + "Base Name", + "prop:droneDps,droneBandwidth", + "Max Range", + "Tracking", "attr:maxVelocity",] def __init__(self, parent): @@ -123,7 +124,7 @@ class DroneView(d.Display): row, _ = self.HitTest(event.Position) if row != -1: col = self.getColumn(event.Position) - if col != self.getColIndex(DroneCheckbox): + if col != self.getColIndex(State): fitID = self.mainFrame.getActiveFit() cFit = service.Fit.getInstance() drone = self.drones[self.GetItemData(row)] @@ -135,7 +136,7 @@ class DroneView(d.Display): row, _ = self.HitTest(event.Position) if row != -1: col = self.getColumn(event.Position) - if col == self.getColIndex(DroneCheckbox): + if col == self.getColIndex(State): fitID = self.mainFrame.getActiveFit() cFit = service.Fit.getInstance() drone = self.drones[row] @@ -144,7 +145,7 @@ class DroneView(d.Display): def scheduleMenu(self, event): event.Skip() - if self.getColumn(event.Position) != self.getColIndex(DroneCheckbox): + if self.getColumn(event.Position) != self.getColIndex(State): wx.CallAfter(self.spawnMenu) def spawnMenu(self): diff --git a/gui/fittingView.py b/gui/fittingView.py index 7d84b9b6d..c0bae34ae 100644 --- a/gui/fittingView.py +++ b/gui/fittingView.py @@ -25,7 +25,7 @@ import gui.display as d from gui.contextMenu import ContextMenu import sys from eos.types import Slot -from gui.builtinViewColumns.moduleState import ModuleState +from gui.builtinViewColumns.state import State FitChanged, FIT_CHANGED = wx.lib.newevent.NewEvent() @@ -43,16 +43,17 @@ class FittingViewDrop(wx.PyDropTarget): return t class FittingView(d.Display): - DEFAULT_COLS = ["Module State", - "Module Ammo Icon", - "Module Name", + DEFAULT_COLS = ["State", + "Ammo Icon", + "Base Icon", + "Base Name", "attr:power", "attr:cpu", - "Max range", - "Module Tracking", + "Max Range", + "Tracking", "Capacitor Usage", - "Module Price", - "Module Ammo", + "Price", + "Ammo", ] def __init__(self, parent): @@ -140,7 +141,7 @@ class FittingView(d.Display): row, _ = self.HitTest(event.Position) if row != -1: col = self.getColumn(event.Position) - if col != self.getColIndex(ModuleState): + if col != self.getColIndex(State): cFit = service.Fit.getInstance() populate = cFit.removeModule(self.activeFitID, self.mods[self.GetItemData(row)].position) @@ -206,7 +207,7 @@ class FittingView(d.Display): def scheduleMenu(self, event): event.Skip() - if self.getColumn(event.Position) != self.getColIndex(ModuleState): + if self.getColumn(event.Position) != self.getColIndex(State): wx.CallAfter(self.spawnMenu) def spawnMenu(self): @@ -233,7 +234,7 @@ class FittingView(d.Display): def click(self, event): row, _ = self.HitTest(event.Position) col = self.getColumn(event.Position) - if row != -1 and col == self.getColIndex(ModuleState): + if row != -1 and col == self.getColIndex(State): sel = [] curr = self.GetFirstSelected() while curr != -1: diff --git a/gui/implantView.py b/gui/implantView.py index 530b5a76e..b4637570c 100644 --- a/gui/implantView.py +++ b/gui/implantView.py @@ -22,13 +22,13 @@ import service import gui.display as d import gui.fittingView as fv import gui.marketBrowser as mb -from gui.builtinViewColumns.activityCheckbox import ActivityCheckbox +from gui.builtinViewColumns.state import State from gui.contextMenu import ContextMenu class ImplantView(d.Display): - DEFAULT_COLS = ["Activity Checkbox", + DEFAULT_COLS = ["State", "attr:implantness", - "Name"] + "Base Name"] def __init__(self, parent): d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL) @@ -88,7 +88,7 @@ class ImplantView(d.Display): row, _ = self.HitTest(event.Position) if row != -1: col = self.getColumn(event.Position) - if col == self.getColIndex(ActivityCheckbox): + if col == self.getColIndex(State): fitID = self.mainFrame.getActiveFit() cFit = service.Fit.getInstance() cFit.toggleImplant(fitID, row) @@ -96,7 +96,7 @@ class ImplantView(d.Display): def scheduleMenu(self, event): event.Skip() - if self.getColumn(event.Position) != self.getColIndex(ActivityCheckbox): + if self.getColumn(event.Position) != self.getColIndex(State): wx.CallAfter(self.spawnMenu) def spawnMenu(self): diff --git a/gui/marketBrowser.py b/gui/marketBrowser.py index 1e6d620ce..6ecd417fd 100644 --- a/gui/marketBrowser.py +++ b/gui/marketBrowser.py @@ -198,7 +198,8 @@ class MarketTree(wx.TreeCtrl): self.marketBrowser.itemView.searching = False class ItemView(d.Display): - DEFAULT_COLS = ["Name"] + DEFAULT_COLS = ["Base Icon", + "Base Name"] def __init__(self, parent, marketBrowser): d.Display.__init__(self, parent) diff --git a/gui/projectedView.py b/gui/projectedView.py index 2677a31cd..9ba314ac3 100644 --- a/gui/projectedView.py +++ b/gui/projectedView.py @@ -22,7 +22,7 @@ import gui.display as d import gui.fittingView as fv import service import gui.droneView -from gui.builtinViewColumns.projectedState import ProjectedState +from gui.builtinViewColumns.state import State from gui.contextMenu import ContextMenu import eos.types @@ -41,10 +41,11 @@ class ProjectedViewDrop(wx.PyDropTarget): return t class ProjectedView(d.Display): - DEFAULT_COLS = ["Projected State", - "Projected Ammo Icon", - "Projected Name", - "Projected Ammo"] + DEFAULT_COLS = ["State", + "Ammo Icon", + "Base Icon", + "Base Name", + "Ammo"] def __init__(self, parent): d.Display.__init__(self, parent, style = wx.LC_SINGLE_SEL) @@ -133,7 +134,7 @@ class ProjectedView(d.Display): if row != -1: item = self.get(row) col = self.getColumn(event.Position) - if col == self.getColIndex(ProjectedState): + if col == self.getColIndex(State): fitID = self.mainFrame.getActiveFit() cFit = service.Fit.getInstance() cFit.toggleProjected(fitID, item, "right" if event.Button == 3 else "left") @@ -156,7 +157,7 @@ class ProjectedView(d.Display): row, _ = self.HitTest(event.Position) if row != -1: col = self.getColumn(event.Position) - if col != self.getColIndex(ProjectedState): + if col != self.getColIndex(State): fitID = self.mainFrame.getActiveFit() cFit = service.Fit.getInstance() cFit.removeProjected(fitID, self.get(row)) diff --git a/gui/viewColumn.py b/gui/viewColumn.py index 5f704c448..fec1f9293 100644 --- a/gui/viewColumn.py +++ b/gui/viewColumn.py @@ -47,13 +47,14 @@ class ViewColumn(object): raise NotImplementedError() def getText(self, mod): - raise NotImplementedError() + return "" def getImageId(self, mod): - raise NotImplementedError() + return -1 - def getParameters(self): - raise NotImplementedError() + @staticmethod + def getParameters(): + return tuple() def delayedText(self, display, colItem): raise NotImplementedError()