diff --git a/gui/builtinContextMenus/damagePattern.py b/gui/builtinContextMenus/damagePattern.py
index b43b8f0d9..3f02033b7 100755
--- a/gui/builtinContextMenus/damagePattern.py
+++ b/gui/builtinContextMenus/damagePattern.py
@@ -1,20 +1,20 @@
-from gui.contextMenu import ContextMenu
-from gui.itemStats import ItemStatsDialog
-import gui.mainFrame
-import service
-
-class DamagePattern(ContextMenu):
- def __init__(self):
- self.mainFrame = gui.mainFrame.MainFrame.getInstance()
-
- def display(self, context, selection):
- return context in ("resistancesViewFull",)
-
- def getText(self, context, selection):
- sDP = service.DamagePattern.getInstance()
- return map(lambda p: p.name, sDP.getDamagePatternList())
-
- def activate(self, context, selection, i):
- pass
-
-DamagePattern.register()
+from gui.contextMenu import ContextMenu
+from gui.itemStats import ItemStatsDialog
+import gui.mainFrame
+import service
+
+class DamagePattern(ContextMenu):
+ def __init__(self):
+ self.mainFrame = gui.mainFrame.MainFrame.getInstance()
+
+ def display(self, context, selection):
+ return context in ("resistancesViewFull",)
+
+ def getText(self, context, selection):
+ sDP = service.DamagePattern.getInstance()
+ return map(lambda p: p.name, sDP.getDamagePatternList())
+
+ def activate(self, context, selection, i):
+ pass
+
+DamagePattern.register()
diff --git a/gui/builtinContextMenus/itemStats.py b/gui/builtinContextMenus/itemStats.py
index 0615ec09b..947afd1e1 100755
--- a/gui/builtinContextMenus/itemStats.py
+++ b/gui/builtinContextMenus/itemStats.py
@@ -1,29 +1,29 @@
-from gui.contextMenu import ContextMenu
-from gui.itemStats import ItemStatsDialog
-import gui.mainFrame
-import service
-
-class ItemStats(ContextMenu):
- def __init__(self):
- self.mainFrame = gui.mainFrame.MainFrame.getInstance()
-
- def display(self, context, selection):
- return context in ("item", "ship", "module", "ammo", "skill")
-
- def getText(self, context, selection):
- return "%s stats" % context.capitalize()
-
- def activate(self, context, selection, i):
- if context == "ship":
- fitID = self.mainFrame.getActiveFit()
- cFit = service.Fit.getInstance()
- stuff = cFit.getFit(fitID).ship
- else:
- stuff = selection[0]
-
- if context == "module" and stuff.isEmpty:
- return
-
- dlg=ItemStatsDialog(stuff, context)
-
-ItemStats.register()
+from gui.contextMenu import ContextMenu
+from gui.itemStats import ItemStatsDialog
+import gui.mainFrame
+import service
+
+class ItemStats(ContextMenu):
+ def __init__(self):
+ self.mainFrame = gui.mainFrame.MainFrame.getInstance()
+
+ def display(self, context, selection):
+ return context in ("item", "ship", "module", "ammo", "skill")
+
+ def getText(self, context, selection):
+ return "%s stats" % context.capitalize()
+
+ def activate(self, context, selection, i):
+ if context == "ship":
+ fitID = self.mainFrame.getActiveFit()
+ cFit = service.Fit.getInstance()
+ stuff = cFit.getFit(fitID).ship
+ else:
+ stuff = selection[0]
+
+ if context == "module" and stuff.isEmpty:
+ return
+
+ dlg=ItemStatsDialog(stuff, context)
+
+ItemStats.register()
diff --git a/gui/builtinViewColumns/moduleAmmo.py b/gui/builtinViewColumns/moduleAmmo.py
index 4654a8408..3a252da9f 100755
--- a/gui/builtinViewColumns/moduleAmmo.py
+++ b/gui/builtinViewColumns/moduleAmmo.py
@@ -1,49 +1,49 @@
-#===============================================================================
-# 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
-
-class ModuleAmmo(ViewColumn):
- name = "Module Ammo"
- def __init__(self, fittingView, params):
- ViewColumn.__init__(self, fittingView)
- self.columnText = "Ammo"
-
- def getText(self, mod):
- return mod.charge.name if mod.charge is not None else ""
-
- def getImageId(self, mod):
- if mod.charge is None:
- iconId = -1
- else:
- iconFile = mod.charge.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
-
-ModuleAmmo.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 import builtinViewColumns
+from gui.viewColumn import ViewColumn
+from gui import bitmapLoader
+
+class ModuleAmmo(ViewColumn):
+ name = "Module Ammo"
+ def __init__(self, fittingView, params):
+ ViewColumn.__init__(self, fittingView)
+ self.columnText = "Ammo"
+
+ def getText(self, mod):
+ return mod.charge.name if mod.charge is not None else ""
+
+ def getImageId(self, mod):
+ if mod.charge is None:
+ iconId = -1
+ else:
+ iconFile = mod.charge.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
+
+ModuleAmmo.register()
diff --git a/gui/cachingImageList.py b/gui/cachingImageList.py
index d0549090c..593d24571 100755
--- a/gui/cachingImageList.py
+++ b/gui/cachingImageList.py
@@ -1,39 +1,39 @@
-#===============================================================================
-# Copyright (C) 2010 Diego Duclos
-#
-# This file is part of pyfa.
-#
-# pyfa is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# pyfa is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with pyfa. If not, see .
-#===============================================================================
-
-import wx
-import bitmapLoader
-
-class CachingImageList(wx.ImageList):
- def __init__(self, width, height):
- wx.ImageList.__init__(self, width, height)
- self.map = {}
-
- def Add(self, *loaderArgs):
- key = "".join(loaderArgs)
- if key not in self.map:
- bitmap = bitmapLoader.getBitmap(*loaderArgs)
- if bitmap is None:
- return -1
- id = wx.ImageList.Add(self,bitmap)
- self.map[key] = id
- else:
- id = self.map[key]
-
- return id
+#===============================================================================
+# Copyright (C) 2010 Diego Duclos
+#
+# This file is part of pyfa.
+#
+# pyfa is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# pyfa is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with pyfa. If not, see .
+#===============================================================================
+
+import wx
+import bitmapLoader
+
+class CachingImageList(wx.ImageList):
+ def __init__(self, width, height):
+ wx.ImageList.__init__(self, width, height)
+ self.map = {}
+
+ def Add(self, *loaderArgs):
+ key = "".join(loaderArgs)
+ if key not in self.map:
+ bitmap = bitmapLoader.getBitmap(*loaderArgs)
+ if bitmap is None:
+ return -1
+ id = wx.ImageList.Add(self,bitmap)
+ self.map[key] = id
+ else:
+ id = self.map[key]
+
+ return id
diff --git a/gui/contextMenu.py b/gui/contextMenu.py
index b52f308c4..0d01f053d 100755
--- a/gui/contextMenu.py
+++ b/gui/contextMenu.py
@@ -1,87 +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 .
-#===============================================================================
-
-import wx
-
-class ContextMenu(object):
- menus = []
- @classmethod
- def register(cls):
- ContextMenu.menus.append(cls)
-
- @classmethod
- def getMenu(cls, selection, *contexts):
- menu = wx.Menu()
- menu.info = {}
- menu.selection = selection
- empty = True
- menu.Bind(wx.EVT_MENU, cls.handler)
- for i, context in enumerate(contexts):
- amount = 0
- for menuHandler in cls.menus:
- m = menuHandler()
- if m.display(context, selection):
- amount += 1
- texts = m.getText(context, selection)
- if isinstance(texts, basestring):
- texts = (texts,)
-
- for it, text in enumerate(texts):
- id = wx.NewId()
- item = wx.MenuItem(menu, id, text)
- menu.info[id] = (m, context, it)
-
- bitmap = m.getBitmap(context, selection)
- if bitmap:
- item.SetBitmap(bitmap)
-
- menu.AppendItem(item)
- empty = False
-
- if amount > 0 and i != len(contexts) - 1:
- menu.AppendSeparator()
-
- return menu if not empty else None
-
- @classmethod
- def handler(cls, event):
- menu = event.EventObject
- stuff = menu.info.get(event.Id)
- if stuff is not None:
- m, context, i = stuff
- selection = menu.selection
- if not hasattr(selection, "__iter__"):
- selection = (selection,)
-
- m.activate(context, selection, i)
- event.Skip()
-
- def display(self, context, selection):
- raise NotImplementedError()
-
- def activate(self, context, selection, i):
- raise NotImplementedError()
-
- def getText(self, context, selection):
- raise NotImplementedError()
-
- def getBitmap(self, context, selection):
- return None
-
-from gui.builtinContextMenus import *
+#===============================================================================
+# Copyright (C) 2010 Diego Duclos
+#
+# This file is part of pyfa.
+#
+# pyfa is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# pyfa is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with pyfa. If not, see .
+#===============================================================================
+
+import wx
+
+class ContextMenu(object):
+ menus = []
+ @classmethod
+ def register(cls):
+ ContextMenu.menus.append(cls)
+
+ @classmethod
+ def getMenu(cls, selection, *contexts):
+ menu = wx.Menu()
+ menu.info = {}
+ menu.selection = selection
+ empty = True
+ menu.Bind(wx.EVT_MENU, cls.handler)
+ for i, context in enumerate(contexts):
+ amount = 0
+ for menuHandler in cls.menus:
+ m = menuHandler()
+ if m.display(context, selection):
+ amount += 1
+ texts = m.getText(context, selection)
+ if isinstance(texts, basestring):
+ texts = (texts,)
+
+ for it, text in enumerate(texts):
+ id = wx.NewId()
+ item = wx.MenuItem(menu, id, text)
+ menu.info[id] = (m, context, it)
+
+ bitmap = m.getBitmap(context, selection)
+ if bitmap:
+ item.SetBitmap(bitmap)
+
+ menu.AppendItem(item)
+ empty = False
+
+ if amount > 0 and i != len(contexts) - 1:
+ menu.AppendSeparator()
+
+ return menu if not empty else None
+
+ @classmethod
+ def handler(cls, event):
+ menu = event.EventObject
+ stuff = menu.info.get(event.Id)
+ if stuff is not None:
+ m, context, i = stuff
+ selection = menu.selection
+ if not hasattr(selection, "__iter__"):
+ selection = (selection,)
+
+ m.activate(context, selection, i)
+ event.Skip()
+
+ def display(self, context, selection):
+ raise NotImplementedError()
+
+ def activate(self, context, selection, i):
+ raise NotImplementedError()
+
+ def getText(self, context, selection):
+ raise NotImplementedError()
+
+ def getBitmap(self, context, selection):
+ return None
+
+from gui.builtinContextMenus import *
diff --git a/service/damagePattern.py b/service/damagePattern.py
index ac571288f..2f84d8092 100755
--- a/service/damagePattern.py
+++ b/service/damagePattern.py
@@ -1,46 +1,46 @@
-#===============================================================================
-# Copyright (C) 2010 Diego Duclos
-#
-# This file is part of pyfa.
-#
-# pyfa is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# pyfa is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with pyfa. If not, see .
-#===============================================================================
-
-import eos.db
-import eos.types
-
-class DamagePattern():
- instance = None
- @classmethod
- def getInstance(cls):
- if cls.instance is None:
- cls.instance = DamagePattern()
-
- return cls.instance
-
- def __init__(self):
- self.getDamagePatternList()
-
- def getDamagePatternList(self):
- patterns = eos.db.getDamagePatternList()
- if len(patterns) == 0:
- uniform = eos.types.DamagePattern(25, 25, 25, 25)
- uniform.name = "Uniform"
- eos.db.save(uniform)
- patterns.append(uniform)
-
- return patterns
-
- def getDamagePattern(self, name):
+#===============================================================================
+# Copyright (C) 2010 Diego Duclos
+#
+# This file is part of pyfa.
+#
+# pyfa is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# pyfa is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with pyfa. If not, see .
+#===============================================================================
+
+import eos.db
+import eos.types
+
+class DamagePattern():
+ instance = None
+ @classmethod
+ def getInstance(cls):
+ if cls.instance is None:
+ cls.instance = DamagePattern()
+
+ return cls.instance
+
+ def __init__(self):
+ self.getDamagePatternList()
+
+ def getDamagePatternList(self):
+ patterns = eos.db.getDamagePatternList()
+ if len(patterns) == 0:
+ uniform = eos.types.DamagePattern(25, 25, 25, 25)
+ uniform.name = "Uniform"
+ eos.db.save(uniform)
+ patterns.append(uniform)
+
+ return patterns
+
+ def getDamagePattern(self, name):
return eos.db.getDamagePattern(name)
\ No newline at end of file
diff --git a/service/prefetch.py b/service/prefetch.py
index 87703855f..344976097 100755
--- a/service/prefetch.py
+++ b/service/prefetch.py
@@ -1,39 +1,39 @@
-#===============================================================================
-# Copyright (C) 2010 Diego Duclos
-#
-# This file is part of pyfa.
-#
-# pyfa is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# pyfa is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with pyfa. If not, see .
-#===============================================================================
-
-import threading
-import service
-import eos.db
-
-class PrefetchThread(threading.Thread):
- def run(self):
- # We're a daemon thread, as such, interpreter might get shut down while we do stuff
- # Make sure we don't throw tracebacks to console
- try:
- eos.db.getItemsByCategory("Skill", eager=("effects", "attributes", "icon"))
- cMarket = service.Market.getInstance()
- root = cMarket.getShipRoot()
- for id, _ in root:
- cMarket.getShipList(id)
- except:
- return
-
-prefetch = PrefetchThread()
-prefetch.daemon = True
-prefetch.start()
+#===============================================================================
+# Copyright (C) 2010 Diego Duclos
+#
+# This file is part of pyfa.
+#
+# pyfa is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# pyfa is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with pyfa. If not, see .
+#===============================================================================
+
+import threading
+import service
+import eos.db
+
+class PrefetchThread(threading.Thread):
+ def run(self):
+ # We're a daemon thread, as such, interpreter might get shut down while we do stuff
+ # Make sure we don't throw tracebacks to console
+ try:
+ eos.db.getItemsByCategory("Skill", eager=("effects", "attributes", "icon"))
+ cMarket = service.Market.getInstance()
+ root = cMarket.getShipRoot()
+ for id, _ in root:
+ cMarket.getShipList(id)
+ except:
+ return
+
+prefetch = PrefetchThread()
+prefetch.daemon = True
+prefetch.start()