Full complete rework of the columnViews, Every column should now work

regardless if the type of view it was put in.
This commit is contained in:
cncfanatics
2010-11-11 15:49:05 +01:00
parent 67058d37e7
commit ea66f6f147
30 changed files with 300 additions and 591 deletions

View File

@@ -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):

View File

@@ -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)

View File

@@ -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"]

View File

@@ -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()

View File

@@ -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()

View File

@@ -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))

View File

@@ -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()

View File

@@ -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()

0
gui/builtinViewColumns/capacitorUse.py Normal file → Executable file
View File

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

2
gui/builtinViewColumns/maxRange.py Normal file → Executable file
View File

@@ -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,

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

View File

@@ -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

View File

@@ -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)

View File

@@ -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):

View File

@@ -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:

View File

@@ -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):

View File

@@ -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)

View File

@@ -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))

View File

@@ -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()