so many pep8 fixes

(cherry picked from commit bee125d)
This commit is contained in:
a-tal
2016-12-03 17:04:12 -08:00
committed by Ebag333
parent 510492e5e9
commit d3b6bc1c93
133 changed files with 3371 additions and 3319 deletions

View File

@@ -31,18 +31,19 @@ gameDB = None
class StreamToLogger(object):
"""
Fake file-like stream object that redirects writes to a logger instance.
From: http://www.electricmonk.nl/log/2011/08/14/redirect-stdout-and-stderr-to-a-logger-in-python/
"""
def __init__(self, logger, log_level=logging.INFO):
self.logger = logger
self.log_level = log_level
self.linebuf = ''
"""
Fake file-like stream object that redirects writes to a logger instance.
From: http://www.electricmonk.nl/log/2011/08/14/redirect-stdout-and-stderr-to-a-logger-in-python/
"""
def __init__(self, logger, log_level=logging.INFO):
self.logger = logger
self.log_level = log_level
self.linebuf = ''
def write(self, buf):
for line in buf.rstrip().splitlines():
self.logger.log(self.log_level, line.rstrip())
def write(self, buf):
for line in buf.rstrip().splitlines():
self.logger.log(self.log_level, line.rstrip())
def isFrozen():
if hasattr(sys, 'frozen'):
@@ -50,16 +51,19 @@ def isFrozen():
else:
return False
def getPyfaRoot():
base = getattr(sys.modules['__main__'], "__file__", sys.executable) if isFrozen() else sys.argv[0]
root = os.path.dirname(os.path.realpath(os.path.abspath(base)))
root = unicode(root, sys.getfilesystemencoding())
return root
def __createDirs(path):
if not os.path.exists(path):
os.makedirs(path)
def defPaths(customSavePath):
global debug
global pyfaPath
@@ -87,9 +91,9 @@ def defPaths(customSavePath):
else:
savePath = getattr(configforced, "savePath", None)
if savePath is None:
if customSavePath is None: # customSavePath is not overriden
if customSavePath is None: # customSavePath is not overriden
savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")),
sys.getfilesystemencoding())
sys.getfilesystemencoding())
else:
savePath = customSavePath
@@ -114,9 +118,9 @@ def defPaths(customSavePath):
sys.stdout = sl
# This interferes with cx_Freeze's own handling of exceptions. Find a way to fix this.
#stderr_logger = logging.getLogger('STDERR')
#sl = StreamToLogger(stderr_logger, logging.ERROR)
#sys.stderr = sl
# stderr_logger = logging.getLogger('STDERR')
# sl = StreamToLogger(stderr_logger, logging.ERROR)
# sys.stderr = sl
# The database where we store all the fits etc
saveDB = os.path.join(savePath, "saveddata.db")
@@ -126,10 +130,10 @@ def defPaths(customSavePath):
# maintenance script
gameDB = os.path.join(pyfaPath, "eve.db")
## DON'T MODIFY ANYTHING BELOW ##
# DON'T MODIFY ANYTHING BELOW!
import eos.config
#Caching modifiers, disable all gamedata caching, its unneeded.
# Caching modifiers, disable all gamedata caching, its unneeded.
eos.config.gamedataCache = False
# saveddata db location modifier, shouldn't ever need to touch this
eos.config.saveddata_connectionstring = "sqlite:///" + saveDB + "?check_same_thread=False"

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,13 +15,14 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
class PFListPane(wx.ScrolledWindow):
def __init__(self, parent):
wx.ScrolledWindow.__init__ (self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(1, 1), style=wx.TAB_TRAVERSAL)
wx.ScrolledWindow.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(1, 1), style=wx.TAB_TRAVERSAL)
self._wList = []
self._wCount = 0
@@ -29,19 +30,18 @@ class PFListPane(wx.ScrolledWindow):
self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
self.SetVirtualSize((1, 1))
self.SetScrollRate(0, 1)
self.Bind(wx.EVT_SCROLLWIN_LINEUP, self.MScrollUp)
self.Bind(wx.EVT_SCROLLWIN_LINEDOWN, self.MScrollDown)
# self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
# self.Bind(wx.EVT_LEFT_DOWN, self.ForceFocus)
# self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
# self.Bind(wx.EVT_LEFT_DOWN, self.ForceFocus)
self.SetFocus()
# self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self.ForceFocus)
# self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self.ForceFocus)
self.Bind(wx.EVT_SCROLLWIN_THUMBRELEASE, self.ForceFocus)
def ForceFocus(self,event):
def ForceFocus(self, event):
if self.FindFocus() and self.FindFocus().Parent != self:
self.SetFocus()
event.Skip()
@@ -67,13 +67,12 @@ class PFListPane(wx.ScrolledWindow):
event.Skip()
def ScrollChildIntoView(self, child):
"""
Scrolls the panel such that the specified child window is in view.
"""
sppu_x, sppu_y = self.GetScrollPixelsPerUnit()
vs_x, vs_y = self.GetViewStart()
vs_x, vs_y = self.GetViewStart()
cr = child.GetRect()
clntsz = self.GetSize()
new_vs_x, new_vs_y = -1, -1
@@ -110,8 +109,6 @@ class PFListPane(wx.ScrolledWindow):
if new_vs_x != -1 or new_vs_y != -1:
self.Scroll(new_vs_x, new_vs_y)
def AddWidget(self, widget):
widget.Reparent(self)
self._wList.append(widget)
@@ -124,13 +121,11 @@ class PFListPane(wx.ScrolledWindow):
def IsWidgetSelectedByContext(self, widget):
return False
def RefreshList(self, doRefresh = False, doFocus = False):
ypos = 0
def RefreshList(self, doRefresh=False, doFocus=False):
maxy = 0
scrollTo = 0
selected = None
for i in xrange( len(self._wList) ):
for i in xrange(len(self._wList)):
iwidth, iheight = self._wList[i].GetSize()
xa, ya = self.CalcScrolledPosition((0, maxy))
self._wList[i].SetPosition((xa, ya))
@@ -143,16 +138,16 @@ class PFListPane(wx.ScrolledWindow):
if selected:
self.ScrollChildIntoView(selected)
#selected.SetFocus()
# selected.SetFocus()
elif doFocus:
self.SetFocus()
clientW,clientH = self.GetSize()
for i in xrange( len(self._wList) ):
clientW, clientH = self.GetSize()
for i in xrange(len(self._wList)):
iwidth, iheight = self._wList[i].GetSize()
itemX,itemY = self._wList[i].GetPosition()
itemX, itemY = self._wList[i].GetPosition()
self._wList[i].SetSize((cwidth, iheight))
if doRefresh == True:
if doRefresh is True:
self._wList[i].Refresh()
self.itemsHeight = max(self.itemsHeight, iheight - 1)
@@ -160,7 +155,6 @@ class PFListPane(wx.ScrolledWindow):
child.Destroy()
self._wList.remove(child)
def RemoveAllChildren(self):
for widget in self._wList:
widget.Destroy()

View File

@@ -1,7 +1,6 @@
import wx
import gui.utils.colorUtils as colorUtils
import gui.utils.drawUtils as drawUtils
from gui.bitmapLoader import BitmapLoader
SearchButton, EVT_SEARCH_BTN = wx.lib.newevent.NewEvent()
@@ -9,9 +8,10 @@ CancelButton, EVT_CANCEL_BTN = wx.lib.newevent.NewEvent()
TextEnter, EVT_TEXT_ENTER = wx.lib.newevent.NewEvent()
TextTyped, EVT_TEXT = wx.lib.newevent.NewEvent()
class PFSearchBox(wx.Window):
def __init__(self, parent, id = wx.ID_ANY, value = "", pos = wx.DefaultPosition, size = wx.Size(-1,24), style = 0):
wx.Window.__init__(self, parent, id, pos, size, style = style)
def __init__(self, parent, id=wx.ID_ANY, value="", pos=wx.DefaultPosition, size=wx.Size(-1, 24), style=0):
wx.Window.__init__(self, parent, id, pos, size, style=style)
self.isSearchButtonVisible = False
self.isCancelButtonVisible = False
@@ -35,13 +35,12 @@ class PFSearchBox(wx.Window):
self.editX = 0
self.editY = 0
self.padding = 4
self._hl = False
w,h = size
self.EditBox = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, (-1, h - 2 if 'wxGTK' in wx.PlatformInfo else -1 ), wx.TE_PROCESS_ENTER | (wx.BORDER_NONE if 'wxGTK' in wx.PlatformInfo else 0))
w, h = size
self.EditBox = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, (-1, h - 2 if 'wxGTK' in wx.PlatformInfo else -1), wx.TE_PROCESS_ENTER | (wx.BORDER_NONE if 'wxGTK' in wx.PlatformInfo else 0))
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBk)
@@ -50,7 +49,7 @@ class PFSearchBox(wx.Window):
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
# self.EditBox.ChangeValue(self.descriptiveText)
# self.EditBox.ChangeValue(self.descriptiveText)
self.EditBox.Bind(wx.EVT_SET_FOCUS, self.OnEditSetFocus)
self.EditBox.Bind(wx.EVT_KILL_FOCUS, self.OnEditKillFocus)
@@ -68,11 +67,10 @@ class PFSearchBox(wx.Window):
wx.PostEvent(self, TextEnter())
event.Skip()
def OnEditSetFocus(self, event):
# value = self.EditBox.GetValue()
# if value == self.descriptiveText:
# self.EditBox.ChangeValue("")
# value = self.EditBox.GetValue()
# if value == self.descriptiveText:
# self.EditBox.ChangeValue("")
event.Skip()
def OnEditKillFocus(self, event):
@@ -80,10 +78,9 @@ class PFSearchBox(wx.Window):
self.Clear()
event.Skip()
def Clear(self):
self.EditBox.Clear()
# self.EditBox.ChangeValue(self.descriptiveText)
# self.EditBox.ChangeValue(self.descriptiveText)
def Focus(self):
self.EditBox.SetFocus()
@@ -110,8 +107,8 @@ class PFSearchBox(wx.Window):
def GetButtonsPos(self):
btnpos = []
btnpos.append( (self.searchButtonX, self.searchButtonY) )
btnpos.append( (self.cancelButtonX, self.cancelButtonY) )
btnpos.append((self.searchButtonX, self.searchButtonY))
btnpos.append((self.cancelButtonX, self.cancelButtonY))
return btnpos
def GetButtonsSize(self):
@@ -131,8 +128,8 @@ class PFSearchBox(wx.Window):
cw = 0
ch = 0
btnsize.append( (sw,sh))
btnsize.append( (cw,ch))
btnsize.append((sw, sh))
btnsize.append((cw, ch))
return btnsize
def OnLeftDown(self, event):
@@ -140,7 +137,7 @@ class PFSearchBox(wx.Window):
btnsize = self.GetButtonsSize()
self.CaptureMouse()
for btn in xrange(2):
for btn in range(2):
if self.HitTest(btnpos[btn], event.GetPosition(), btnsize[btn]):
if btn == 0:
if not self.searchButtonPressed:
@@ -158,7 +155,7 @@ class PFSearchBox(wx.Window):
if self.HasCapture():
self.ReleaseMouse()
for btn in xrange(2):
for btn in range(2):
if self.HitTest(btnpos[btn], event.GetPosition(), btnsize[btn]):
if btn == 0:
if self.searchButtonPressed:
@@ -218,9 +215,9 @@ class PFSearchBox(wx.Window):
editWidth, editHeight = self.EditBox.GetSize()
self.editY = (cheight - editHeight)/2
self.editY = (cheight - editHeight) / 2
self.EditBox.SetPosition((self.editX, self.editY))
self.EditBox.SetSize( (self.cancelButtonX - self.padding - self.editX, -1))
self.EditBox.SetSize((self.cancelButtonX - self.padding - self.editX, -1))
def OnPaint(self, event):
dc = wx.BufferedPaintDC(self)
@@ -246,7 +243,6 @@ class PFSearchBox(wx.Window):
dc.DrawBitmap(self.searchBitmapShadow, self.searchButtonX + 1, self.searchButtonY + 1)
dc.DrawBitmap(self.searchBitmap, self.searchButtonX + spad, self.searchButtonY + spad)
if self.isCancelButtonVisible:
if self.cancelBitmap:
if self.cancelButtonPressed:
@@ -256,8 +252,8 @@ class PFSearchBox(wx.Window):
dc.DrawBitmap(self.cancelBitmapShadow, self.cancelButtonX + 1, self.cancelButtonY + 1)
dc.DrawBitmap(self.cancelBitmap, self.cancelButtonX + cpad, self.cancelButtonY + cpad)
dc.SetPen(wx.Pen(sepColor,1))
dc.DrawLine(0,rect.height - 1, rect.width, rect.height - 1)
dc.SetPen(wx.Pen(sepColor, 1))
dc.DrawLine(0, rect.height - 1, rect.width, rect.height - 1)
def SetSearchBitmap(self, bitmap):
self.searchBitmap = bitmap
@@ -273,10 +269,10 @@ class PFSearchBox(wx.Window):
def IsCancelButtonVisible(self):
return self.isCancelButtonVisible
def ShowSearchButton(self, show = True):
def ShowSearchButton(self, show=True):
self.isSearchButtonVisible = show
def ShowCancelButton(self, show = True):
def ShowCancelButton(self, show=True):
self.isCancelButtonVisible = show
def SetDescriptiveText(self, text):
@@ -284,4 +280,3 @@ class PFSearchBox(wx.Window):
def GetDescriptiveText(self):
return self.descriptiveText

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,9 +15,11 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import config
versionString = "{0} {1} - {2} {3}".format(config.version, config.tag, config.expansionName, config.expansionVersion)
licenses = (
"pyfa is released under GNU GPLv3 - see included LICENSE file",
@@ -27,7 +29,7 @@ licenses = (
)
developers = (
"blitzmann \tSable Blitzmann (maintainer)",
"cncfanatics \tSakari Orisi (retired)" ,
"cncfanatics \tSakari Orisi (retired)",
"DarkPhoenix \tKadesh Priestess (retired)",
"Darriele \t\tDarriele (retired)",
"Ebag333 \t\tEbag Trescientas"

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.mainFrame
@@ -29,16 +29,16 @@ from gui.projectedView import ProjectedView
from gui.commandView import CommandView
from gui.notesView import NotesView
from gui.pyfatogglepanel import TogglePanel
from gui.gangView import GangView
from gui.bitmapLoader import BitmapLoader
import gui.chromeTabs
class AdditionsPane(TogglePanel):
def __init__(self, parent):
TogglePanel.__init__(self, parent, forceLayout = 1)
TogglePanel.__init__(self, parent, forceLayout=1)
self.SetLabel("Additions")
pane = self.GetContentPane()
@@ -63,28 +63,28 @@ class AdditionsPane(TogglePanel):
notesImg = BitmapLoader.getImage("skill_small", "gui")
self.drone = DroneView(self.notebook)
self.notebook.AddPage(self.drone, "Drones", tabImage = droneImg, showClose = False)
self.notebook.AddPage(self.drone, "Drones", tabImage=droneImg, showClose=False)
self.fighter = FighterView(self.notebook)
self.notebook.AddPage(self.fighter, "Fighters", tabImage = fighterImg, showClose = False)
self.notebook.AddPage(self.fighter, "Fighters", tabImage=fighterImg, showClose=False)
self.cargo = CargoView(self.notebook)
self.notebook.AddPage(self.cargo, "Cargo", tabImage = cargoImg, showClose = False)
self.notebook.AddPage(self.cargo, "Cargo", tabImage=cargoImg, showClose=False)
self.implant = ImplantView(self.notebook)
self.notebook.AddPage(self.implant, "Implants", tabImage = implantImg, showClose = False)
self.notebook.AddPage(self.implant, "Implants", tabImage=implantImg, showClose=False)
self.booster = BoosterView(self.notebook)
self.notebook.AddPage(self.booster, "Boosters", tabImage = boosterImg, showClose = False)
self.notebook.AddPage(self.booster, "Boosters", tabImage=boosterImg, showClose=False)
self.projectedPage = ProjectedView(self.notebook)
self.notebook.AddPage(self.projectedPage, "Projected", tabImage = projectedImg, showClose = False)
self.notebook.AddPage(self.projectedPage, "Projected", tabImage=projectedImg, showClose=False)
self.gangPage = CommandView(self.notebook)
self.notebook.AddPage(self.gangPage, "Command", tabImage = gangImg, showClose = False)
self.notebook.AddPage(self.gangPage, "Command", tabImage=gangImg, showClose=False)
self.notes = NotesView(self.notebook)
self.notebook.AddPage(self.notes, "Notes", tabImage = notesImg, showClose = False)
self.notebook.AddPage(self.notes, "Notes", tabImage=notesImg, showClose=False)
self.notebook.SetSelection(0)
@@ -101,12 +101,12 @@ class AdditionsPane(TogglePanel):
def toggleContent(self, event):
TogglePanel.toggleContent(self, event)
h = self.headerPanel.GetSize()[1]+4
h = self.headerPanel.GetSize()[1] + 4
if self.IsCollapsed():
self.old_pos = self.parent.GetSashPosition()
self.parent.SetMinimumPaneSize(h)
self.parent.SetSashPosition(h*-1, True)
self.parent.SetSashPosition(h * -1, True)
# only available in >= wx2.9
if getattr(self.parent, "SetSashInvisible", None):
self.parent.SetSashInvisible(True)
@@ -115,4 +115,3 @@ class AdditionsPane(TogglePanel):
self.parent.SetSashInvisible(False)
self.parent.SetMinimumPaneSize(200)
self.parent.SetSashPosition(self.old_pos, True)

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import os.path
import config
@@ -28,7 +28,8 @@ try:
except ImportError:
from utils.compat import OrderedDict
class BitmapLoader():
class BitmapLoader(object):
try:
archive = zipfile.ZipFile(os.path.join(config.pyfaPath, 'imgs.zip'), 'r')
@@ -42,7 +43,7 @@ class BitmapLoader():
@classmethod
def getStaticBitmap(cls, name, parent, location):
static = wx.StaticBitmap(parent)
static.SetBitmap(cls.getBitmap(name,location))
static.SetBitmap(cls.getBitmap(name, location))
return static
@classmethod
@@ -83,11 +84,11 @@ class BitmapLoader():
sbuf = cStringIO.StringIO(img_data)
return wx.ImageFromStream(sbuf)
except KeyError:
print "Missing icon file from zip: {0}".format(path)
print("Missing icon file from zip: {0}".format(path))
else:
path = os.path.join(config.pyfaPath, 'imgs', location, filename)
if os.path.exists(path):
return wx.Image(path)
else:
print "Missing icon file: {0}".format(path)
print("Missing icon file: {0}".format(path))

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.display as d
@@ -25,19 +25,21 @@ from gui.builtinViewColumns.state import State
from gui.contextMenu import ContextMenu
from service.fit import Fit
class BoosterViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID
self.dropData = wx.PyTextDataObject()
self.SetDataObject(self.dropData)
def OnData(self, x, y, t):
if self.GetData():
data = self.dropData.GetText().split(':')
self.dropFn(x, y, data)
return t
class BoosterViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID
self.dropData = wx.PyTextDataObject()
self.SetDataObject(self.dropData)
def OnData(self, x, y, t):
if self.GetData():
data = self.dropData.GetText().split(':')
self.dropFn(x, y, data)
return t
class BoosterView(d.Display):
DEFAULT_COLS = ["State",
@@ -58,7 +60,7 @@ class BoosterView(d.Display):
self.SetDropTarget(BoosterViewDrop(self.handleListDrag))
if "__WXGTK__" in wx.PlatformInfo:
if "__WXGTK__" in wx.PlatformInfo:
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
else:
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
@@ -75,7 +77,7 @@ class BoosterView(d.Display):
if data[0] == "market":
wx.PostEvent(self.mainFrame, mb.ItemSelected(itemID=int(data[1])))
def kbEvent(self,event):
def kbEvent(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_DELETE or keycode == wx.WXK_NUMPAD_DELETE:
row = self.GetFirstSelected()
@@ -90,7 +92,7 @@ class BoosterView(d.Display):
self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)
#Clear list and get out if current fitId is None
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
@@ -154,7 +156,6 @@ class BoosterView(d.Display):
sFit.toggleBooster(fitID, row)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
def scheduleMenu(self, event):
event.Skip()
if self.getColumn(event.Position) != self.getColIndex(State):

View File

@@ -1,34 +1,37 @@
from gui.contextMenu import ContextMenu
import gui.mainFrame
import wx
import gui.globalEvents as GE
class AmmoPattern(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
return False
item = selection[0]
for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"):
if item.getAttribute(attr) is not None:
return True
return False
def getText(self, itmContext, selection):
return "Set {0} as Damage Pattern".format(itmContext if itmContext is not None else "Item")
def activate(self, fullContext, selection, i):
item = selection[0]
fit = self.mainFrame.getActiveFit()
sFit = Fit.getInstance()
sFit.setAsPattern(fit, item)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fit))
def getBitmap(self, context, selection):
return None
AmmoPattern.register()
from gui.contextMenu import ContextMenu
import gui.mainFrame
import wx
import gui.globalEvents as GE
from service.fit import Fit
class AmmoPattern(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
return False
item = selection[0]
for attr in ("emDamage", "thermalDamage", "explosiveDamage", "kineticDamage"):
if item.getAttribute(attr) is not None:
return True
return False
def getText(self, itmContext, selection):
return "Set {0} as Damage Pattern".format(itmContext if itmContext is not None else "Item")
def activate(self, fullContext, selection, i):
item = selection[0]
fit = self.mainFrame.getActiveFit()
sFit = Fit.getInstance()
sFit.setAsPattern(fit, item)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fit))
def getBitmap(self, context, selection):
return None
AmmoPattern.register()

View File

@@ -23,6 +23,7 @@ class ChangeAmount(ContextMenu):
dlg = AmountChanger(self.mainFrame, selection[0], srcContext)
dlg.ShowModal()
ChangeAmount.register()
class AmountChanger(wx.Dialog):

View File

@@ -32,4 +32,5 @@ class Cargo(ContextMenu):
self.mainFrame.additionsPane.select("Cargo")
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
Cargo.register()

View File

@@ -100,4 +100,5 @@ class ChangeAffectingSkills(ContextMenu):
wx.PostEvent(self.mainFrame, GE.CharListUpdated())
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
ChangeAffectingSkills.register()

View File

@@ -105,4 +105,5 @@ class DamagePattern(ContextMenu):
setattr(self.mainFrame,"_activeDmgPattern", pattern)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
DamagePattern.register()

View File

@@ -23,4 +23,5 @@ class ItemRemove(ContextMenu):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
ItemRemove.register()

View File

@@ -1,58 +1,61 @@
from gui.contextMenu import ContextMenu
from gui.itemStats import ItemStatsDialog
import gui.mainFrame
import gui.globalEvents as GE
import wx
class DroneSplit(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
return srcContext in ("droneItem", "projectedDrone") and selection[0].amount > 1
def getText(self, itmContext, selection):
return "Split {0} Stack".format(itmContext)
def activate(self, fullContext, selection, i):
srcContext = fullContext[0]
dlg = DroneSpinner(self.mainFrame, selection[0], srcContext)
dlg.ShowModal()
dlg.Destroy()
DroneSplit.register()
class DroneSpinner(wx.Dialog):
def __init__(self, parent, drone, context):
wx.Dialog.__init__(self, parent, title="Select Amount", size=wx.Size(220, 60))
self.drone = drone
self.context = context
bSizer1 = wx.BoxSizer(wx.HORIZONTAL)
self.spinner = wx.SpinCtrl(self)
self.spinner.SetRange(1, drone.amount - 1)
self.spinner.SetValue(1)
bSizer1.Add(self.spinner, 0, wx.ALL, 5)
self.button = wx.Button(self, wx.ID_OK, u"Split")
bSizer1.Add(self.button, 0, wx.ALL, 5)
self.SetSizer(bSizer1)
self.Layout()
self.Centre(wx.BOTH)
self.button.Bind(wx.EVT_BUTTON, self.split)
def split(self, event):
sFit = Fit.getInstance()
mainFrame = gui.mainFrame.MainFrame.getInstance()
fitID = mainFrame.getActiveFit()
if self.context == "droneItem":
sFit.splitDroneStack(fitID, self.drone, self.spinner.GetValue())
else:
sFit.splitProjectedDroneStack(fitID, self.drone, self.spinner.GetValue())
wx.PostEvent(mainFrame, GE.FitChanged(fitID=fitID))
event.Skip()
from gui.contextMenu import ContextMenu
from gui.itemStats import ItemStatsDialog
import gui.mainFrame
import gui.globalEvents as GE
from service.fit import Fit
import wx
class DroneSplit(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
return srcContext in ("droneItem", "projectedDrone") and selection[0].amount > 1
def getText(self, itmContext, selection):
return "Split {0} Stack".format(itmContext)
def activate(self, fullContext, selection, i):
srcContext = fullContext[0]
dlg = DroneSpinner(self.mainFrame, selection[0], srcContext)
dlg.ShowModal()
dlg.Destroy()
DroneSplit.register()
class DroneSpinner(wx.Dialog):
def __init__(self, parent, drone, context):
wx.Dialog.__init__(self, parent, title="Select Amount", size=wx.Size(220, 60))
self.drone = drone
self.context = context
bSizer1 = wx.BoxSizer(wx.HORIZONTAL)
self.spinner = wx.SpinCtrl(self)
self.spinner.SetRange(1, drone.amount - 1)
self.spinner.SetValue(1)
bSizer1.Add(self.spinner, 0, wx.ALL, 5)
self.button = wx.Button(self, wx.ID_OK, u"Split")
bSizer1.Add(self.button, 0, wx.ALL, 5)
self.SetSizer(bSizer1)
self.Layout()
self.Centre(wx.BOTH)
self.button.Bind(wx.EVT_BUTTON, self.split)
def split(self, event):
sFit = Fit.getInstance()
mainFrame = gui.mainFrame.MainFrame.getInstance()
fitID = mainFrame.getActiveFit()
if self.context == "droneItem":
sFit.splitDroneStack(fitID, self.drone, self.spinner.GetValue())
else:
sFit.splitProjectedDroneStack(fitID, self.drone, self.spinner.GetValue())
wx.PostEvent(mainFrame, GE.FitChanged(fitID=fitID))
event.Skip()

View File

@@ -52,4 +52,5 @@ class FighterAbility(ContextMenu):
sFit.toggleFighterAbility(fitID, ability)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
FighterAbility.register()

View File

@@ -1,62 +1,64 @@
from gui.contextMenu import ContextMenu
from gui.itemStats import ItemStatsDialog
import gui.mainFrame
import wx
from service.fit import Fit
class ItemStats(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
return srcContext in ("marketItemGroup", "marketItemMisc",
"fittingModule", "fittingCharge",
"fittingShip", "baseShip",
"cargoItem", "droneItem",
"implantItem", "boosterItem",
"skillItem", "projectedModule",
"projectedDrone", "projectedCharge",
"itemStats", "fighterItem",
"implantItemChar", "projectedFighter")
def getText(self, itmContext, selection):
return "{0} Stats".format(itmContext if itmContext is not None else "Item")
def activate(self, fullContext, selection, i):
srcContext = fullContext[0]
if srcContext == "fittingShip":
fitID = self.mainFrame.getActiveFit()
sFit = Fit.getInstance()
stuff = sFit.getFit(fitID).ship
else:
stuff = selection[0]
if srcContext == "fittingModule" and stuff.isEmpty:
return
mstate = wx.GetMouseState()
reuse = False
if mstate.CmdDown():
reuse = True
if self.mainFrame.GetActiveStatsWindow() is None and reuse:
ItemStatsDialog(stuff, fullContext)
elif reuse:
lastWnd = self.mainFrame.GetActiveStatsWindow()
pos = lastWnd.GetPosition()
maximized = lastWnd.IsMaximized()
if not maximized:
size = lastWnd.GetSize()
else:
size = wx.DefaultSize
pos = wx.DefaultPosition
ItemStatsDialog(stuff, fullContext, pos, size, maximized)
lastWnd.closeEvent(None)
else:
ItemStatsDialog(stuff, fullContext)
ItemStats.register()
from gui.contextMenu import ContextMenu
from gui.itemStats import ItemStatsDialog
import gui.mainFrame
import wx
from service.fit import Fit
class ItemStats(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
return srcContext in ("marketItemGroup", "marketItemMisc",
"fittingModule", "fittingCharge",
"fittingShip", "baseShip",
"cargoItem", "droneItem",
"implantItem", "boosterItem",
"skillItem", "projectedModule",
"projectedDrone", "projectedCharge",
"itemStats", "fighterItem",
"implantItemChar", "projectedFighter")
def getText(self, itmContext, selection):
return "{0} Stats".format(itmContext if itmContext is not None else "Item")
def activate(self, fullContext, selection, i):
srcContext = fullContext[0]
if srcContext == "fittingShip":
fitID = self.mainFrame.getActiveFit()
sFit = Fit.getInstance()
stuff = sFit.getFit(fitID).ship
else:
stuff = selection[0]
if srcContext == "fittingModule" and stuff.isEmpty:
return
mstate = wx.GetMouseState()
reuse = False
if mstate.CmdDown():
reuse = True
if self.mainFrame.GetActiveStatsWindow() is None and reuse:
ItemStatsDialog(stuff, fullContext)
elif reuse:
lastWnd = self.mainFrame.GetActiveStatsWindow()
pos = lastWnd.GetPosition()
maximized = lastWnd.IsMaximized()
if not maximized:
size = lastWnd.GetSize()
else:
size = wx.DefaultSize
pos = wx.DefaultPosition
ItemStatsDialog(stuff, fullContext, pos, size, maximized)
lastWnd.closeEvent(None)
else:
ItemStatsDialog(stuff, fullContext)
ItemStats.register()

View File

@@ -1,48 +1,49 @@
from gui.contextMenu import ContextMenu
from gui.itemStats import ItemStatsDialog
import gui.mainFrame
from service.market import Market
class MarketJump(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
validContexts = ("marketItemMisc", "fittingModule",
"fittingCharge", "droneItem",
"implantItem", "boosterItem",
"projectedModule", "projectedDrone",
"projectedCharge", "cargoItem",
"implantItemChar", "fighterItem",
"projectedDrone")
if not srcContext in validContexts or selection is None or len(selection) < 1:
return False
sMkt = Market.getInstance()
item = getattr(selection[0], "item", selection[0])
mktGrp = sMkt.getMarketGroupByItem(item)
# 1663 is Special Edition Festival Assets, we don't have root group for it
if mktGrp is None or mktGrp.ID == 1663:
return False
doit = not selection[0].isEmpty if srcContext == "fittingModule" else True
return doit
def getText(self, itmContext, selection):
return "{0} Market Group".format(itmContext if itmContext is not None else "Item")
def activate(self, fullContext, selection, i):
srcContext = fullContext[0]
if srcContext in ("fittingCharge", "projectedCharge"):
item = selection[0].charge
elif hasattr(selection[0], "item"):
item = selection[0].item
else:
item = selection[0]
self.mainFrame.notebookBrowsers.SetSelection(0)
self.mainFrame.marketBrowser.jump(item)
MarketJump.register()
from gui.contextMenu import ContextMenu
from gui.itemStats import ItemStatsDialog
import gui.mainFrame
from service.market import Market
class MarketJump(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
validContexts = ("marketItemMisc", "fittingModule",
"fittingCharge", "droneItem",
"implantItem", "boosterItem",
"projectedModule", "projectedDrone",
"projectedCharge", "cargoItem",
"implantItemChar", "fighterItem",
"projectedDrone")
if srcContext not in validContexts or selection is None or len(selection) < 1:
return False
sMkt = Market.getInstance()
item = getattr(selection[0], "item", selection[0])
mktGrp = sMkt.getMarketGroupByItem(item)
# 1663 is Special Edition Festival Assets, we don't have root group for it
if mktGrp is None or mktGrp.ID == 1663:
return False
doit = not selection[0].isEmpty if srcContext == "fittingModule" else True
return doit
def getText(self, itmContext, selection):
return "{0} Market Group".format(itmContext if itmContext is not None else "Item")
def activate(self, fullContext, selection, i):
srcContext = fullContext[0]
if srcContext in ("fittingCharge", "projectedCharge"):
item = selection[0].charge
elif hasattr(selection[0], "item"):
item = selection[0].item
else:
item = selection[0]
self.mainFrame.notebookBrowsers.SetSelection(0)
self.mainFrame.marketBrowser.jump(item)
MarketJump.register()

View File

@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from gui.contextMenu import ContextMenu
from gui.itemStats import ItemStatsDialog
import gui.mainFrame
import wx
import gui.globalEvents as GE
from service.market import Market
from service.fit import Fit
from service.market import Market
import gui.mainFrame
import gui.globalEvents as GE
from gui.contextMenu import ContextMenu
class MetaSwap(ContextMenu):
def __init__(self):
@@ -42,7 +41,8 @@ class MetaSwap(ContextMenu):
self.moduleLookup = {}
def get_metalevel(x):
if "metaLevel" not in x.attributes: return 0
if "metaLevel" not in x.attributes:
return 0
return x.attributes["metaLevel"].value
def get_metagroup(x):
@@ -99,4 +99,5 @@ class MetaSwap(ContextMenu):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
MetaSwap.register()

View File

@@ -1,224 +1,226 @@
# -*- coding: utf-8 -*-
from gui.contextMenu import ContextMenu
import gui.mainFrame
import wx
from gui.bitmapLoader import BitmapLoader
from eos.types import Hardpoint
import gui.globalEvents as GE
from service.market import Market
from service.fit import Fit
class ModuleAmmoPicker(ContextMenu):
DAMAGE_TYPES = ("em", "explosive", "kinetic", "thermal")
MISSILE_ORDER = ("em", "thermal", "kinetic", "explosive", "mixed")
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
if self.mainFrame.getActiveFit() is None or srcContext not in ("fittingModule", "projectedModule"):
return False
modules = selection if srcContext == "fittingModule" else (selection[0],)
validCharges = None
checkedTypes = set()
for mod in modules:
# loop through modules and gather list of valid charges
if mod.item.ID in checkedTypes:
continue
checkedTypes.add(mod.item.ID)
currCharges = mod.getValidCharges()
if len(currCharges) > 0:
if validCharges is not None and validCharges != currCharges:
return False
validCharges = currCharges
self.module = mod
if validCharges is None:
return False
self.modules = modules
self.charges = list(filter(lambda charge: Market.getInstance().getPublicityByItem(charge), validCharges))
return len(self.charges) > 0
def getText(self, itmContext, selection):
return "Charge"
def turretSorter(self, charge):
damage = 0
range = (self.module.getModifiedItemAttr("maxRange") or 0) * (charge.getAttribute("weaponRangeMultiplier") or 1)
falloff = (self.module.getModifiedItemAttr("falloff") or 0) * (charge.getAttribute("fallofMultiplier") or 1)
for type in self.DAMAGE_TYPES:
d = charge.getAttribute("%sDamage" % type)
if d > 0:
damage += d
# Take optimal and half falloff as range factor
rangeFactor = range + falloff / 2
return - rangeFactor, charge.name.rsplit()[-2:], damage, charge.name
def missileSorter(self, charge):
# Get charge damage type and total damage
chargeDamageType, totalDamage = self.damageInfo(charge)
# Find its position in sort list
position = self.MISSILE_ORDER.index(chargeDamageType)
return position, totalDamage, charge.name
def damageInfo(self, charge):
# Set up data storage for missile damage stuff
damageMap = {}
totalDamage = 0
# Fill them with the data about charge
for damageType in self.DAMAGE_TYPES:
currentDamage = charge.getAttribute("{0}Damage".format(damageType)) or 0
damageMap[damageType] = currentDamage
totalDamage += currentDamage
# Detect type of ammo
chargeDamageType = None
for damageType in damageMap:
# If all damage belongs to certain type purely, set appropriate
# ammoType
if damageMap[damageType] == totalDamage:
chargeDamageType = damageType
break
# Else consider ammo as mixed damage
if chargeDamageType is None:
chargeDamageType = "mixed"
return chargeDamageType, totalDamage
def numericConverter(self, string):
return int(string) if string.isdigit() else string
def nameSorter(self, charge):
parts = charge.name.split(" ")
return map(self.numericConverter, parts)
def addCharge(self, menu, charge):
id = ContextMenu.nextID()
name = charge.name if charge is not None else "Empty"
self.chargeIds[id] = charge
item = wx.MenuItem(menu, id, name)
menu.Bind(wx.EVT_MENU, self.handleAmmoSwitch, item)
item.charge = charge
if charge is not None and charge.icon is not None:
bitmap = BitmapLoader.getBitmap(charge.icon.iconFile, "icons")
if bitmap is not None:
item.SetBitmap(bitmap)
return item
def addSeperator(self, m, text):
id = ContextMenu.nextID()
m.Append(id, u'%s' % text)
m.Enable(id, False)
def getSubMenu(self, context, selection, rootMenu, i, pitem):
msw = True if "wxMSW" in wx.PlatformInfo else False
m = wx.Menu()
self.chargeIds = {}
hardpoint = self.module.hardpoint
moduleName = self.module.item.name
# Make sure we do not consider mining turrets as combat turrets
if hardpoint == Hardpoint.TURRET and self.module.getModifiedItemAttr("miningAmount") is None:
self.addSeperator(m, "Long Range")
items = []
range = None
nameBase = None
sub = None
self.charges.sort(key=self.turretSorter)
for charge in self.charges:
# fix issue 71 - will probably have to change if CCP adds more Orbital ammo
if "Orbital" in charge.name:
# uncomment if we ever want to include Oribital ammo in ammo picker - see issue #71
# This allows us to hide the ammo, but it's still loadable from the market
#item = self.addCharge(m, charge)
#items.append(item)
continue
currBase = charge.name.rsplit()[-2:]
currRange = charge.getAttribute("weaponRangeMultiplier")
if nameBase is None or range != currRange or nameBase != currBase:
if sub is not None:
self.addSeperator(sub, "More Damage")
sub = None
base = charge
nameBase = currBase
range = currRange
item = self.addCharge(rootMenu if msw else m, charge)
items.append(item)
else:
if sub is None:
sub = wx.Menu()
sub.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
self.addSeperator(sub, "Less Damage")
item.SetSubMenu(sub)
sub.AppendItem(self.addCharge(rootMenu if msw else sub, base))
sub.AppendItem(self.addCharge(rootMenu if msw else sub, charge))
if sub is not None:
self.addSeperator(sub, "More Damage")
for item in items:
m.AppendItem(item)
self.addSeperator(m, "Short Range")
elif hardpoint == Hardpoint.MISSILE and moduleName != 'Festival Launcher':
self.charges.sort(key=self.missileSorter)
type = None
sub = None
defender = None
for charge in self.charges:
currType = self.damageInfo(charge)[0]
if currType != type or type is None:
if sub is not None:
self.addSeperator(sub, "More Damage")
type = currType
item = wx.MenuItem(m, wx.ID_ANY, type.capitalize())
bitmap = BitmapLoader.getBitmap("%s_small" % type, "gui")
if bitmap is not None:
item.SetBitmap(bitmap)
sub = wx.Menu()
sub.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
self.addSeperator(sub, "Less Damage")
item.SetSubMenu(sub)
m.AppendItem(item)
if charge.name not in ("Light Defender Missile I", "Heavy Defender Missile I"):
sub.AppendItem(self.addCharge(rootMenu if msw else sub, charge))
else:
defender = charge
if defender is not None:
m.AppendItem(self.addCharge(rootMenu if msw else m, defender))
if sub is not None:
self.addSeperator(sub, "More Damage")
else:
self.charges.sort(key=self.nameSorter)
for charge in self.charges:
m.AppendItem(self.addCharge(rootMenu if msw else m, charge))
m.AppendItem(self.addCharge(rootMenu if msw else m, None))
return m
def handleAmmoSwitch(self, event):
charge = self.chargeIds.get(event.Id, False)
if charge is False:
event.Skip()
return
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
sFit.setAmmo(fitID, charge.ID if charge is not None else None, self.modules)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
ModuleAmmoPicker.register()
# -*- coding: utf-8 -*-
from gui.contextMenu import ContextMenu
import gui.mainFrame
import wx
from gui.bitmapLoader import BitmapLoader
from eos.types import Hardpoint
import gui.globalEvents as GE
from service.market import Market
from service.fit import Fit
class ModuleAmmoPicker(ContextMenu):
DAMAGE_TYPES = ("em", "explosive", "kinetic", "thermal")
MISSILE_ORDER = ("em", "thermal", "kinetic", "explosive", "mixed")
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
if self.mainFrame.getActiveFit() is None or srcContext not in ("fittingModule", "projectedModule"):
return False
modules = selection if srcContext == "fittingModule" else (selection[0],)
validCharges = None
checkedTypes = set()
for mod in modules:
# loop through modules and gather list of valid charges
if mod.item.ID in checkedTypes:
continue
checkedTypes.add(mod.item.ID)
currCharges = mod.getValidCharges()
if len(currCharges) > 0:
if validCharges is not None and validCharges != currCharges:
return False
validCharges = currCharges
self.module = mod
if validCharges is None:
return False
self.modules = modules
self.charges = list(filter(lambda charge: Market.getInstance().getPublicityByItem(charge), validCharges))
return len(self.charges) > 0
def getText(self, itmContext, selection):
return "Charge"
def turretSorter(self, charge):
damage = 0
range_ = (self.module.getModifiedItemAttr("maxRange") or 0) * (charge.getAttribute("weaponRangeMultiplier") or 1)
falloff = (self.module.getModifiedItemAttr("falloff") or 0) * (charge.getAttribute("fallofMultiplier") or 1)
for type_ in self.DAMAGE_TYPES:
d = charge.getAttribute("%sDamage" % type_)
if d > 0:
damage += d
# Take optimal and half falloff as range factor
rangeFactor = range_ + falloff / 2
return - rangeFactor, charge.name.rsplit()[-2:], damage, charge.name
def missileSorter(self, charge):
# Get charge damage type and total damage
chargeDamageType, totalDamage = self.damageInfo(charge)
# Find its position in sort list
position = self.MISSILE_ORDER.index(chargeDamageType)
return position, totalDamage, charge.name
def damageInfo(self, charge):
# Set up data storage for missile damage stuff
damageMap = {}
totalDamage = 0
# Fill them with the data about charge
for damageType in self.DAMAGE_TYPES:
currentDamage = charge.getAttribute("{0}Damage".format(damageType)) or 0
damageMap[damageType] = currentDamage
totalDamage += currentDamage
# Detect type of ammo
chargeDamageType = None
for damageType in damageMap:
# If all damage belongs to certain type purely, set appropriate
# ammoType
if damageMap[damageType] == totalDamage:
chargeDamageType = damageType
break
# Else consider ammo as mixed damage
if chargeDamageType is None:
chargeDamageType = "mixed"
return chargeDamageType, totalDamage
def numericConverter(self, string):
return int(string) if string.isdigit() else string
def nameSorter(self, charge):
parts = charge.name.split(" ")
return map(self.numericConverter, parts)
def addCharge(self, menu, charge):
id_ = ContextMenu.nextID()
name = charge.name if charge is not None else "Empty"
self.chargeIds[id_] = charge
item = wx.MenuItem(menu, id_, name)
menu.Bind(wx.EVT_MENU, self.handleAmmoSwitch, item)
item.charge = charge
if charge is not None and charge.icon is not None:
bitmap = BitmapLoader.getBitmap(charge.icon.iconFile, "icons")
if bitmap is not None:
item.SetBitmap(bitmap)
return item
def addSeperator(self, m, text):
id_ = ContextMenu.nextID()
m.Append(id_, u'%s' % text)
m.Enable(id_, False)
def getSubMenu(self, context, selection, rootMenu, i, pitem):
msw = True if "wxMSW" in wx.PlatformInfo else False
m = wx.Menu()
self.chargeIds = {}
hardpoint = self.module.hardpoint
moduleName = self.module.item.name
# Make sure we do not consider mining turrets as combat turrets
if hardpoint == Hardpoint.TURRET and self.module.getModifiedItemAttr("miningAmount") is None:
self.addSeperator(m, "Long Range")
items = []
range_ = None
nameBase = None
sub = None
self.charges.sort(key=self.turretSorter)
for charge in self.charges:
# fix issue 71 - will probably have to change if CCP adds more Orbital ammo
if "Orbital" in charge.name:
# uncomment if we ever want to include Oribital ammo in ammo picker - see issue #71
# This allows us to hide the ammo, but it's still loadable from the market
# item = self.addCharge(m, charge)
# items.append(item)
continue
currBase = charge.name.rsplit()[-2:]
currRange = charge.getAttribute("weaponRangeMultiplier")
if nameBase is None or range_ != currRange or nameBase != currBase:
if sub is not None:
self.addSeperator(sub, "More Damage")
sub = None
base = charge
nameBase = currBase
range_ = currRange
item = self.addCharge(rootMenu if msw else m, charge)
items.append(item)
else:
if sub is None:
sub = wx.Menu()
sub.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
self.addSeperator(sub, "Less Damage")
item.SetSubMenu(sub)
sub.AppendItem(self.addCharge(rootMenu if msw else sub, base))
sub.AppendItem(self.addCharge(rootMenu if msw else sub, charge))
if sub is not None:
self.addSeperator(sub, "More Damage")
for item in items:
m.AppendItem(item)
self.addSeperator(m, "Short Range")
elif hardpoint == Hardpoint.MISSILE and moduleName != 'Festival Launcher':
self.charges.sort(key=self.missileSorter)
type_ = None
sub = None
defender = None
for charge in self.charges:
currType = self.damageInfo(charge)[0]
if currType != type_ or type_ is None:
if sub is not None:
self.addSeperator(sub, "More Damage")
type_ = currType
item = wx.MenuItem(m, wx.ID_ANY, type_.capitalize())
bitmap = BitmapLoader.getBitmap("%s_small" % type, "gui")
if bitmap is not None:
item.SetBitmap(bitmap)
sub = wx.Menu()
sub.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
self.addSeperator(sub, "Less Damage")
item.SetSubMenu(sub)
m.AppendItem(item)
if charge.name not in ("Light Defender Missile I", "Heavy Defender Missile I"):
sub.AppendItem(self.addCharge(rootMenu if msw else sub, charge))
else:
defender = charge
if defender is not None:
m.AppendItem(self.addCharge(rootMenu if msw else m, defender))
if sub is not None:
self.addSeperator(sub, "More Damage")
else:
self.charges.sort(key=self.nameSorter)
for charge in self.charges:
m.AppendItem(self.addCharge(rootMenu if msw else m, charge))
m.AppendItem(self.addCharge(rootMenu if msw else m, None))
return m
def handleAmmoSwitch(self, event):
charge = self.chargeIds.get(event.Id, False)
if charge is False:
event.Skip()
return
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
sFit.setAmmo(fitID, charge.ID if charge is not None else None, self.modules)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
ModuleAmmoPicker.register()

View File

@@ -17,4 +17,5 @@ class OpenFit(ContextMenu):
fit = selection[0]
wx.PostEvent(self.mainFrame, FitSelected(fitID=fit.ID, startup=2))
OpenFit.register()

View File

@@ -19,4 +19,5 @@ class PriceClear(ContextMenu):
sMkt.clearPriceCache()
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
PriceClear.register()

View File

@@ -1,37 +1,38 @@
from gui.contextMenu import ContextMenu
import gui.mainFrame
import gui.globalEvents as GE
import wx
import eos.db
from service.fit import Fit
class Project(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
return False
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
fit = sFit.getFit(fitID)
if fit.isStructure:
return False
item = selection[0]
return item.isType("projected")
def getText(self, itmContext, selection):
return "Project {0} onto Fit".format(itmContext)
def activate(self, fullContext, selection, i):
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
trigger = sFit.project(fitID, selection[0])
if trigger:
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
self.mainFrame.additionsPane.select("Projected")
Project.register()
from gui.contextMenu import ContextMenu
import gui.mainFrame
import gui.globalEvents as GE
import wx
from service.fit import Fit
class Project(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, srcContext, selection):
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
return False
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
fit = sFit.getFit(fitID)
if fit.isStructure:
return False
item = selection[0]
return item.isType("projected")
def getText(self, itmContext, selection):
return "Project {0} onto Fit".format(itmContext)
def activate(self, fullContext, selection, i):
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
trigger = sFit.project(fitID, selection[0])
if trigger:
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
self.mainFrame.additionsPane.select("Projected")
Project.register()

View File

@@ -23,4 +23,5 @@ class ShipJump(ContextMenu):
self.mainFrame.notebookBrowsers.SetSelection(1)
wx.PostEvent(self.mainFrame.shipBrowser,Stage3Selected(shipID=stuff.item.ID, back=groupID))
ShipJump.register()

View File

@@ -58,4 +58,5 @@ class TacticalMode(ContextMenu):
sFit.setMode(fitID, self.modeIds[event.Id])
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
TacticalMode.register()

View File

@@ -106,4 +106,5 @@ class TargetResists(ContextMenu):
return sub
TargetResists.register()

View File

@@ -54,4 +54,5 @@ class WhProjector(ContextMenu):
sFit.project(fitID, swObj)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
WhProjector.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# 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.graph import Graph
from gui.bitmapLoader import BitmapLoader
@@ -24,6 +24,7 @@ from eos.graph import Data
import gui.mainFrame
from service.attribute import Attribute
class FitDpsGraph(Graph):
propertyAttributeMap = {"angle": "maxVelocity",
"distance": "maxRange",
@@ -74,7 +75,7 @@ class FitDpsGraph(Graph):
if variable is None:
variable = fieldName
else:
#We can't handle more then one variable atm, OOPS FUCK OUT
# We can't handle more then one variable atm, OOPS FUCK OUT
return False, "Can only handle 1 variable"
fitDps.setData(d)
@@ -90,4 +91,5 @@ class FitDpsGraph(Graph):
return x, y
FitDpsGraph.register()

View File

@@ -1,6 +1,6 @@
__all__ = ["pyfaGeneralPreferences","pyfaHTMLExportPreferences","pyfaUpdatePreferences","pyfaNetworkPreferences"]
import wx
if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)):
__all__ = ["pyfaGeneralPreferences", "pyfaHTMLExportPreferences", "pyfaUpdatePreferences", "pyfaNetworkPreferences"] # noqa
if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)):
__all__.append("pyfaCrestPreferences")

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,80 +15,81 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
class DummyView(PreferenceView):
title = "Dummy"
def populatePanel(self, panel):
mainSizer = wx.BoxSizer( wx.VERTICAL )
mainSizer = wx.BoxSizer(wx.VERTICAL)
headerSizer = self.initHeader(panel)
mainSizer.Add( headerSizer, 0, wx.EXPAND, 5 )
mainSizer.Add(headerSizer, 0, wx.EXPAND, 5)
self.stline1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.stline1, 0, wx.EXPAND, 5 )
self.stline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.stline1, 0, wx.EXPAND, 5)
contentSizer = self.initContent(panel)
mainSizer.Add( contentSizer, 1, wx.EXPAND|wx.TOP|wx.BOTTOM|wx.LEFT, 10 )
self.stline2 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.stline2, 0, wx.EXPAND, 5 )
mainSizer.Add(contentSizer, 1, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.LEFT, 10)
self.stline2 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.stline2, 0, wx.EXPAND, 5)
footerSizer = self.initFooter(panel)
mainSizer.Add( footerSizer, 0, wx.EXPAND, 5 )
panel.SetSizer( mainSizer )
mainSizer.Add(footerSizer, 0, wx.EXPAND, 5)
panel.SetSizer(mainSizer)
panel.Layout()
def refreshPanel(self, fit):
pass
def initHeader(self, panel):
headerSizer = wx.BoxSizer( wx.VERTICAL )
self.stTitle = wx.StaticText( panel, wx.ID_ANY, u"Dummy", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stTitle.Wrap( -1 )
self.stTitle.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
headerSizer.Add( self.stTitle, 0, wx.ALL, 5)
headerSizer = wx.BoxSizer(wx.VERTICAL)
self.stTitle = wx.StaticText(panel, wx.ID_ANY, u"Dummy", wx.DefaultPosition, wx.DefaultSize, 0)
self.stTitle.Wrap(-1)
self.stTitle.SetFont(wx.Font(14, 70, 90, 90, False, wx.EmptyString))
headerSizer.Add(self.stTitle, 0, wx.ALL, 5)
return headerSizer
def initContent(self, panel):
contentSizer = wx.BoxSizer( wx.VERTICAL )
contentSizer = wx.BoxSizer(wx.VERTICAL)
self.m_checkBox2 = wx.CheckBox( panel, wx.ID_ANY, u"Check Me!", wx.DefaultPosition, wx.DefaultSize, 0 )
contentSizer.Add( self.m_checkBox2, 0, wx.ALL, 5 )
self.m_checkBox2 = wx.CheckBox(panel, wx.ID_ANY, u"Check Me!", wx.DefaultPosition, wx.DefaultSize, 0)
contentSizer.Add(self.m_checkBox2, 0, wx.ALL, 5)
self.m_radioBtn2 = wx.RadioButton( panel, wx.ID_ANY, u"RadioBtn", wx.DefaultPosition, wx.DefaultSize, 0 )
contentSizer.Add( self.m_radioBtn2, 0, wx.ALL, 5 )
self.m_radioBtn2 = wx.RadioButton(panel, wx.ID_ANY, u"RadioBtn", wx.DefaultPosition, wx.DefaultSize, 0)
contentSizer.Add(self.m_radioBtn2, 0, wx.ALL, 5)
self.m_slider2 = wx.Slider( panel, wx.ID_ANY, 50, 0, 100, wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL )
contentSizer.Add( self.m_slider2, 0, wx.ALL, 5 )
self.m_slider2 = wx.Slider(panel, wx.ID_ANY, 50, 0, 100, wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL)
contentSizer.Add(self.m_slider2, 0, wx.ALL, 5)
self.m_gauge1 = wx.Gauge( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL )
contentSizer.Add( self.m_gauge1, 0, wx.ALL, 5 )
self.m_gauge1 = wx.Gauge(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL)
contentSizer.Add(self.m_gauge1, 0, wx.ALL, 5)
self.m_textCtrl2 = wx.TextCtrl( panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
contentSizer.Add( self.m_textCtrl2, 0, wx.ALL, 5 )
self.m_textCtrl2 = wx.TextCtrl(panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
contentSizer.Add(self.m_textCtrl2, 0, wx.ALL, 5)
return contentSizer
def initFooter(self, panel):
footerSizer = wx.BoxSizer( wx.HORIZONTAL )
footerSizer = wx.BoxSizer(wx.HORIZONTAL)
footerSizer.AddSpacer((0, 0), 1, wx.EXPAND, 5)
footerSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
self.btnRestore = wx.Button(panel, wx.ID_ANY, u"Restore", wx.DefaultPosition, wx.DefaultSize, 0)
self.btnRestore.Enable(False)
self.btnRestore = wx.Button( panel, wx.ID_ANY, u"Restore", wx.DefaultPosition, wx.DefaultSize, 0 )
self.btnRestore.Enable( False )
footerSizer.Add(self.btnRestore, 0, wx.ALL, 5)
footerSizer.Add( self.btnRestore, 0, wx.ALL, 5 )
self.btnApply = wx.Button( panel, wx.ID_ANY, u"Apply", wx.DefaultPosition, wx.DefaultSize, 0 )
footerSizer.Add( self.btnApply, 0, wx.ALL, 5 )
self.btnApply = wx.Button(panel, wx.ID_ANY, u"Apply", wx.DefaultPosition, wx.DefaultSize, 0)
footerSizer.Add(self.btnApply, 0, wx.ALL, 5)
return footerSizer
DummyView.register()

View File

@@ -4,35 +4,35 @@ from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
from service.crest import CrestModes
from service.crest import Crest
from service.settings import CRESTSettings
from wx.lib.intctrl import IntCtrl
class PFCrestPref ( PreferenceView):
class PFCrestPref(PreferenceView):
title = "CREST"
def populatePanel( self, panel ):
def populatePanel(self, panel):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.settings = CRESTSettings.getInstance()
self.dirtySettings = False
dlgWidth = panel.GetParent().GetParent().ClientSize.width
mainSizer = wx.BoxSizer( wx.VERTICAL )
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.stTitle = wx.StaticText( panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stTitle.Wrap( -1 )
self.stTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0)
self.stTitle.Wrap(-1)
self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
mainSizer.Add( self.stTitle, 0, wx.ALL, 5 )
mainSizer.Add(self.stTitle, 0, wx.ALL, 5)
self.m_staticline1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline1, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )
self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
self.stInfo = wx.StaticText( panel, wx.ID_ANY, u"Please see the pyfa wiki on GitHub for information regarding these options.", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stInfo = wx.StaticText(panel, wx.ID_ANY, u"Please see the pyfa wiki on GitHub for information regarding these options.", wx.DefaultPosition, wx.DefaultSize, 0)
self.stInfo.Wrap(dlgWidth - 50)
mainSizer.Add( self.stInfo, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )
mainSizer.Add(self.stInfo, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
rbSizer = wx.BoxSizer(wx.HORIZONTAL)
self.rbMode = wx.RadioBox(panel, -1, "Mode", wx.DefaultPosition, wx.DefaultSize, ['Implicit', 'User-supplied details'], 1, wx.RA_SPECIFY_COLS)
@@ -41,65 +41,65 @@ class PFCrestPref ( PreferenceView):
self.rbMode.SetSelection(self.settings.get('mode'))
self.rbServer.SetSelection(self.settings.get('server'))
rbSizer.Add(self.rbMode, 1, wx.TOP | wx.RIGHT, 5 )
rbSizer.Add(self.rbServer, 1, wx.ALL, 5 )
rbSizer.Add(self.rbMode, 1, wx.TOP | wx.RIGHT, 5)
rbSizer.Add(self.rbServer, 1, wx.ALL, 5)
self.rbMode.Bind(wx.EVT_RADIOBOX, self.OnModeChange)
self.rbServer.Bind(wx.EVT_RADIOBOX, self.OnServerChange)
mainSizer.Add(rbSizer, 1, wx.ALL|wx.EXPAND, 0)
mainSizer.Add(rbSizer, 1, wx.ALL | wx.EXPAND, 0)
timeoutSizer = wx.BoxSizer(wx.HORIZONTAL)
self.stTimout = wx.StaticText( panel, wx.ID_ANY, u"Timeout (seconds):", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stTimout.Wrap( -1 )
self.stTimout = wx.StaticText(panel, wx.ID_ANY, u"Timeout (seconds):", wx.DefaultPosition, wx.DefaultSize, 0)
self.stTimout.Wrap(-1)
timeoutSizer.Add( self.stTimout, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5 )
timeoutSizer.Add(self.stTimout, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.intTimeout = IntCtrl(panel, max=300000, limited=True, value=self.settings.get('timeout'))
timeoutSizer.Add(self.intTimeout, 0, wx.ALL, 5 )
timeoutSizer.Add(self.intTimeout, 0, wx.ALL, 5)
self.intTimeout.Bind(wx.lib.intctrl.EVT_INT, self.OnTimeoutChange)
mainSizer.Add(timeoutSizer, 0, wx.ALL|wx.EXPAND, 0)
mainSizer.Add(timeoutSizer, 0, wx.ALL | wx.EXPAND, 0)
detailsTitle = wx.StaticText( panel, wx.ID_ANY, "CREST client details", wx.DefaultPosition, wx.DefaultSize, 0 )
detailsTitle.Wrap( -1 )
detailsTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
detailsTitle = wx.StaticText(panel, wx.ID_ANY, "CREST client details", wx.DefaultPosition, wx.DefaultSize, 0)
detailsTitle.Wrap(-1)
detailsTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
mainSizer.Add( detailsTitle, 0, wx.ALL, 5 )
mainSizer.Add( wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0, wx.EXPAND, 5 )
mainSizer.Add(detailsTitle, 0, wx.ALL, 5)
mainSizer.Add(wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND, 5)
fgAddrSizer = wx.FlexGridSizer( 2, 2, 0, 0 )
fgAddrSizer.AddGrowableCol( 1 )
fgAddrSizer.SetFlexibleDirection( wx.BOTH )
fgAddrSizer.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
fgAddrSizer = wx.FlexGridSizer(2, 2, 0, 0)
fgAddrSizer.AddGrowableCol(1)
fgAddrSizer.SetFlexibleDirection(wx.BOTH)
fgAddrSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
self.stSetID = wx.StaticText( panel, wx.ID_ANY, u"Client ID:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stSetID.Wrap( -1 )
fgAddrSizer.Add( self.stSetID, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.stSetID = wx.StaticText(panel, wx.ID_ANY, u"Client ID:", wx.DefaultPosition, wx.DefaultSize, 0)
self.stSetID.Wrap(-1)
fgAddrSizer.Add(self.stSetID, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.inputClientID = wx.TextCtrl( panel, wx.ID_ANY, self.settings.get('clientID'), wx.DefaultPosition, wx.DefaultSize, 0 )
self.inputClientID = wx.TextCtrl(panel, wx.ID_ANY, self.settings.get('clientID'), wx.DefaultPosition, wx.DefaultSize, 0)
fgAddrSizer.Add( self.inputClientID, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5 )
fgAddrSizer.Add(self.inputClientID, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
self.stSetSecret = wx.StaticText( panel, wx.ID_ANY, u"Client Secret:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stSetSecret.Wrap( -1 )
self.stSetSecret = wx.StaticText(panel, wx.ID_ANY, u"Client Secret:", wx.DefaultPosition, wx.DefaultSize, 0)
self.stSetSecret.Wrap(-1)
fgAddrSizer.Add( self.stSetSecret, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
fgAddrSizer.Add(self.stSetSecret, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.inputClientSecret = wx.TextCtrl( panel, wx.ID_ANY, self.settings.get('clientSecret'), wx.DefaultPosition, wx.DefaultSize, 0 )
self.inputClientSecret = wx.TextCtrl(panel, wx.ID_ANY, self.settings.get('clientSecret'), wx.DefaultPosition, wx.DefaultSize, 0)
fgAddrSizer.Add( self.inputClientSecret, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5 )
fgAddrSizer.Add(self.inputClientSecret, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
self.btnApply = wx.Button( panel, wx.ID_ANY, u"Save Client Settings", wx.DefaultPosition, wx.DefaultSize, 0 )
self.btnApply = wx.Button(panel, wx.ID_ANY, u"Save Client Settings", wx.DefaultPosition, wx.DefaultSize, 0)
self.btnApply.Bind(wx.EVT_BUTTON, self.OnBtnApply)
mainSizer.Add( fgAddrSizer, 0, wx.EXPAND, 5)
mainSizer.Add( self.btnApply, 0, wx.ALIGN_RIGHT, 5)
mainSizer.Add(fgAddrSizer, 0, wx.EXPAND, 5)
mainSizer.Add(self.btnApply, 0, wx.ALIGN_RIGHT, 5)
self.ToggleProxySettings(self.settings.get('mode'))
panel.SetSizer( mainSizer )
panel.SetSizer(mainSizer)
panel.Layout()
def OnTimeoutChange(self, event):
@@ -135,4 +135,5 @@ class PFCrestPref ( PreferenceView):
def getImage(self):
return BitmapLoader.getBitmap("eve", "gui")
PFCrestPref.register()

View File

@@ -11,12 +11,13 @@ from gui.utils import colorUtils
import gui.utils.drawUtils as drawUtils
###########################################################################
## Class PFGaugePref
# Class PFGaugePref
###########################################################################
class PFGaugePreview(wx.Window):
def __init__ (self, parent, id = wx.ID_ANY, value = 0, pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0):
wx.Window.__init__(self, parent, id, pos = pos, size = size, style = style)
def __init__(self, parent, id=wx.ID_ANY, value=0, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.Window.__init__(self, parent, id, pos=pos, size=size, style=style)
self.value = float(value)
self.oldValue = self.value
@@ -28,14 +29,14 @@ class PFGaugePreview(wx.Window):
self.animDir = 1
self._fractionDigits = 2
self.colorS = wx.Colour(0,0,0,255)
self.colorE = wx.Colour(0,0,0,255)
self.colorS = wx.Colour(0, 0, 0, 255)
self.colorE = wx.Colour(0, 0, 0, 255)
self.gradientStart = 0
self.bkColor = wx.Colour(0,0,0,255)
self.SetMinSize((100,-1))
self.bkColor = wx.Colour(0, 0, 0, 255)
self.SetMinSize((100, -1))
self.font = wx.FontFromPixelSize((0,13),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.font = wx.FontFromPixelSize((0, 13), wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.timerID = wx.NewId()
self.timer = wx.Timer(self, self.timerID)
@@ -56,7 +57,7 @@ class PFGaugePreview(wx.Window):
if self.value > 100:
self.value = 100
self.animDir = -1
if self.value <0:
if self.value < 0:
self.value = 0
self.animDir = 1
self.Refresh()
@@ -79,7 +80,7 @@ class PFGaugePreview(wx.Window):
self.Refresh()
event.Skip()
def CanAnimate(self, anim = True):
def CanAnimate(self, anim=True):
self.animate = anim
if self.timer.IsRunning():
self.timer.Stop()
@@ -97,7 +98,7 @@ class PFGaugePreview(wx.Window):
self.Refresh()
def SetValue(self, value):
self.value = min(max(value,0),100)
self.value = min(max(value, 0), 100)
self.Refresh()
def SetPercentages(self, start, end):
@@ -119,198 +120,198 @@ class PFGaugePreview(wx.Window):
r = copy.copy(rect)
r.width = w
color = colorUtils.CalculateTransitionColor(self.colorS, self.colorE, float(value)/100)
color = colorUtils.CalculateTransitionColor(self.colorS, self.colorE, float(value) / 100)
if self.gradientStart > 0:
gcolor = colorUtils.BrightenColor(color, float(self.gradientStart) / 100)
gMid = colorUtils.BrightenColor(color, float(self.gradientStart/2) / 100)
gcolor = colorUtils.BrightenColor(color, float(self.gradientStart) / 100)
gMid = colorUtils.BrightenColor(color, float(self.gradientStart / 2) / 100)
else:
gcolor = colorUtils.DarkenColor(color, float(-self.gradientStart) / 100)
gMid = colorUtils.DarkenColor(color, float(-self.gradientStart/2) / 100)
gcolor = colorUtils.DarkenColor(color, float(-self.gradientStart) / 100)
gMid = colorUtils.DarkenColor(color, float(-self.gradientStart / 2) / 100)
gBmp = drawUtils.DrawGradientBar(r.width, r.height, gMid, color, gcolor)
dc.DrawBitmap(gBmp,0,0)
dc.DrawBitmap(gBmp, 0, 0)
dc.SetFont(self.font)
r = copy.copy(rect)
r.left +=1
r.top +=1
r.left += 1
r.top += 1
formatStr = "{0:." + str(self._fractionDigits) + "f}%"
value = (self.percE - self.percS) * value / (self.percE - self.percS)
value = self.percS + (self.percE - self.percS) * value / 100
dc.SetTextForeground(wx.Colour(80,80,80))
dc.SetTextForeground(wx.Colour(80, 80, 80))
dc.DrawLabel(formatStr.format(value), r, wx.ALIGN_CENTER)
dc.SetTextForeground(wx.Colour(255,255,255))
dc.SetTextForeground(wx.Colour(255, 255, 255))
dc.DrawLabel(formatStr.format(value), rect, wx.ALIGN_CENTER)
class PFGaugePref ( PreferenceView):
class PFGaugePref(PreferenceView):
title = "Pyfa Gauge Theme"
def populatePanel( self, panel ):
def populatePanel(self, panel):
self.InitDefaultColours()
mainSizer = wx.BoxSizer( wx.VERTICAL )
mainSizer = wx.BoxSizer(wx.VERTICAL)
gSizer1 = wx.BoxSizer( wx.HORIZONTAL )
gSizer1 = wx.BoxSizer(wx.HORIZONTAL)
self.st0100 = wx.StaticText( panel, wx.ID_ANY, u"0 - 100", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT )
self.st0100.Wrap( -1 )
gSizer1.Add( self.st0100, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.st0100 = wx.StaticText(panel, wx.ID_ANY, u"0 - 100", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT)
self.st0100.Wrap(-1)
gSizer1.Add(self.st0100, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.cp0100S = wx.ColourPickerCtrl( panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL )
gSizer1.Add( self.cp0100S, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.cp0100S = wx.ColourPickerCtrl(panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
gSizer1.Add(self.cp0100S, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.cp0100E = wx.ColourPickerCtrl( panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL )
gSizer1.Add( self.cp0100E, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.cp0100E = wx.ColourPickerCtrl(panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
gSizer1.Add(self.cp0100E, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.gauge0100S = PFGaugePreview( panel, wx.ID_ANY, 33, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer1.Add( self.gauge0100S, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5 )
self.gauge0100S = PFGaugePreview(panel, wx.ID_ANY, 33, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer1.Add(self.gauge0100S, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.gauge0100M = PFGaugePreview( panel, wx.ID_ANY, 66, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer1.Add( self.gauge0100M, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5 )
self.gauge0100M = PFGaugePreview(panel, wx.ID_ANY, 66, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer1.Add(self.gauge0100M, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.gauge0100E = PFGaugePreview( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer1.Add( self.gauge0100E, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.LEFT, 5 )
self.gauge0100E = PFGaugePreview(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer1.Add(self.gauge0100E, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 5)
mainSizer.Add( gSizer1, 0, wx.EXPAND, 5 )
mainSizer.Add(gSizer1, 0, wx.EXPAND, 5)
gSizer2 = wx.BoxSizer( wx.HORIZONTAL )
gSizer2 = wx.BoxSizer(wx.HORIZONTAL)
self.st100101 = wx.StaticText( panel, wx.ID_ANY, u"100 - 101", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT )
self.st100101.Wrap( -1 )
gSizer2.Add( self.st100101, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.st100101 = wx.StaticText(panel, wx.ID_ANY, u"100 - 101", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT)
self.st100101.Wrap(-1)
gSizer2.Add(self.st100101, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.cp100101S = wx.ColourPickerCtrl( panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL )
gSizer2.Add( self.cp100101S, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.cp100101S = wx.ColourPickerCtrl(panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
gSizer2.Add(self.cp100101S, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.cp100101E = wx.ColourPickerCtrl( panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL )
gSizer2.Add( self.cp100101E, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.cp100101E = wx.ColourPickerCtrl(panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
gSizer2.Add(self.cp100101E, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.gauge100101S = PFGaugePreview( panel, wx.ID_ANY, 33, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer2.Add( self.gauge100101S, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5 )
self.gauge100101S = PFGaugePreview(panel, wx.ID_ANY, 33, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer2.Add(self.gauge100101S, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.gauge100101M = PFGaugePreview( panel, wx.ID_ANY, 66, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer2.Add( self.gauge100101M, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5 )
self.gauge100101M = PFGaugePreview(panel, wx.ID_ANY, 66, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer2.Add(self.gauge100101M, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.gauge100101E = PFGaugePreview( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer2.Add( self.gauge100101E, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.LEFT, 5 )
self.gauge100101E = PFGaugePreview(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer2.Add(self.gauge100101E, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 5)
mainSizer.Add( gSizer2, 0, wx.EXPAND, 5 )
mainSizer.Add(gSizer2, 0, wx.EXPAND, 5)
gSizer3 = wx.BoxSizer( wx.HORIZONTAL )
gSizer3 = wx.BoxSizer(wx.HORIZONTAL)
self.st101103 = wx.StaticText( panel, wx.ID_ANY, u"101 - 103", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT )
self.st101103.Wrap( -1 )
gSizer3.Add( self.st101103, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.st101103 = wx.StaticText(panel, wx.ID_ANY, u"101 - 103", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT)
self.st101103.Wrap(-1)
gSizer3.Add(self.st101103, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.cp101103S = wx.ColourPickerCtrl( panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL )
gSizer3.Add( self.cp101103S, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.cp101103S = wx.ColourPickerCtrl(panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
gSizer3.Add(self.cp101103S, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.cp101103E = wx.ColourPickerCtrl( panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL )
gSizer3.Add( self.cp101103E, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.cp101103E = wx.ColourPickerCtrl(panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
gSizer3.Add(self.cp101103E, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.gauge101103S = PFGaugePreview( panel, wx.ID_ANY, 33, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer3.Add( self.gauge101103S, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5 )
self.gauge101103S = PFGaugePreview(panel, wx.ID_ANY, 33, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer3.Add(self.gauge101103S, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.gauge101103M = PFGaugePreview( panel, wx.ID_ANY, 66, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer3.Add( self.gauge101103M, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5 )
self.gauge101103M = PFGaugePreview(panel, wx.ID_ANY, 66, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer3.Add(self.gauge101103M, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.gauge101103E = PFGaugePreview( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer3.Add( self.gauge101103E, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.LEFT, 5 )
self.gauge101103E = PFGaugePreview(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer3.Add(self.gauge101103E, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 5)
mainSizer.Add( gSizer3, 0, wx.EXPAND, 5 )
mainSizer.Add(gSizer3, 0, wx.EXPAND, 5)
gSizer4 = wx.BoxSizer( wx.HORIZONTAL )
gSizer4 = wx.BoxSizer(wx.HORIZONTAL)
self.st103105 = wx.StaticText( panel, wx.ID_ANY, u"103 - 105", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT )
self.st103105.Wrap( -1 )
gSizer4.Add( self.st103105, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.st103105 = wx.StaticText(panel, wx.ID_ANY, u"103 - 105", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_RIGHT)
self.st103105.Wrap(-1)
gSizer4.Add(self.st103105, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.cp103105S = wx.ColourPickerCtrl( panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL )
gSizer4.Add( self.cp103105S, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.cp103105S = wx.ColourPickerCtrl(panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
gSizer4.Add(self.cp103105S, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.cp103105E = wx.ColourPickerCtrl( panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL )
gSizer4.Add( self.cp103105E, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.cp103105E = wx.ColourPickerCtrl(panel, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE | wx.CLRP_SHOW_LABEL)
gSizer4.Add(self.cp103105E, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.gauge103105S = PFGaugePreview( panel, wx.ID_ANY, 33, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer4.Add( self.gauge103105S, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5 )
self.gauge103105S = PFGaugePreview(panel, wx.ID_ANY, 33, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer4.Add(self.gauge103105S, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.gauge103105M = PFGaugePreview( panel, wx.ID_ANY, 66, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer4.Add( self.gauge103105M, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5 )
self.gauge103105M = PFGaugePreview(panel, wx.ID_ANY, 66, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer4.Add(self.gauge103105M, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
self.gauge103105E = PFGaugePreview( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER )
gSizer4.Add( self.gauge103105E, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.LEFT, 5 )
self.gauge103105E = PFGaugePreview(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER)
gSizer4.Add(self.gauge103105E, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 5)
mainSizer.Add( gSizer4, 0, wx.EXPAND, 5 )
mainSizer.Add(gSizer4, 0, wx.EXPAND, 5)
footerSizer = wx.BoxSizer( wx.VERTICAL )
footerSizer = wx.BoxSizer(wx.VERTICAL)
self.sl1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
footerSizer.Add( self.sl1, 0, wx.EXPAND |wx.ALL, 5 )
self.sl1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
footerSizer.Add(self.sl1, 0, wx.EXPAND | wx.ALL, 5)
previewSizer = wx.BoxSizer( wx.HORIZONTAL )
previewSizer = wx.BoxSizer(wx.HORIZONTAL)
self.wndPreview0100 = PFGaugePreview( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, 0)
previewSizer.Add( self.wndPreview0100, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
self.wndPreview0100 = PFGaugePreview(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, 0)
previewSizer.Add(self.wndPreview0100, 1, wx.ALIGN_CENTER_VERTICAL, 5)
self.wndPreview100101 = PFGaugePreview( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, 0)
previewSizer.Add( self.wndPreview100101, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
self.wndPreview100101 = PFGaugePreview(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, 0)
previewSizer.Add(self.wndPreview100101, 1, wx.ALIGN_CENTER_VERTICAL, 5)
self.wndPreview101103 = PFGaugePreview( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, 0)
previewSizer.Add( self.wndPreview101103, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
self.wndPreview101103 = PFGaugePreview(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, 0)
previewSizer.Add(self.wndPreview101103, 1, wx.ALIGN_CENTER_VERTICAL, 5)
self.wndPreview103105 = PFGaugePreview( panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, 0)
previewSizer.Add( self.wndPreview103105, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
self.wndPreview103105 = PFGaugePreview(panel, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, 0)
previewSizer.Add(self.wndPreview103105, 1, wx.ALIGN_CENTER_VERTICAL, 5)
footerSizer.Add( previewSizer, 1, wx.EXPAND | wx.ALL, 5 )
footerSizer.Add(previewSizer, 1, wx.EXPAND | wx.ALL, 5)
buttonsSizer = wx.BoxSizer( wx.HORIZONTAL )
buttonsSizer = wx.BoxSizer(wx.HORIZONTAL)
self.cbLink = wx.CheckBox( panel, wx.ID_ANY, u"Link Colors", wx.DefaultPosition, wx.DefaultSize, 0 )
buttonsSizer.Add( self.cbLink, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 5 )
self.cbLink = wx.CheckBox(panel, wx.ID_ANY, u"Link Colors", wx.DefaultPosition, wx.DefaultSize, 0)
buttonsSizer.Add(self.cbLink, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 5)
self.sliderGradientStart = wx.Slider( panel, wx.ID_ANY, self.gradientStart, -100, 100, wx.DefaultPosition, (127,-1), wx.SL_HORIZONTAL|wx.SL_LABELS )
buttonsSizer.Add( self.sliderGradientStart, 1, wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5 )
self.sliderGradientStart = wx.Slider(panel, wx.ID_ANY, self.gradientStart, -100, 100, wx.DefaultPosition, (127, -1), wx.SL_HORIZONTAL | wx.SL_LABELS)
buttonsSizer.Add(self.sliderGradientStart, 1, wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.btnRestore = wx.Button( panel, wx.ID_ANY, u"Restore Defaults", wx.DefaultPosition, wx.DefaultSize, 0 )
buttonsSizer.Add( self.btnRestore, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5 )
self.btnRestore = wx.Button(panel, wx.ID_ANY, u"Restore Defaults", wx.DefaultPosition, wx.DefaultSize, 0)
buttonsSizer.Add(self.btnRestore, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.btnDump = wx.Button( panel, wx.ID_ANY, u"Dump Colors", wx.DefaultPosition, wx.DefaultSize, 0 )
buttonsSizer.Add( self.btnDump, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5 )
self.btnDump = wx.Button(panel, wx.ID_ANY, u"Dump Colors", wx.DefaultPosition, wx.DefaultSize, 0)
buttonsSizer.Add(self.btnDump, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.btnOk = wx.Button( panel, wx.ID_ANY, u"Apply", wx.DefaultPosition, wx.DefaultSize, 0 )
buttonsSizer.Add( self.btnOk, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5 )
self.btnOk = wx.Button(panel, wx.ID_ANY, u"Apply", wx.DefaultPosition, wx.DefaultSize, 0)
buttonsSizer.Add(self.btnOk, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
footerSizer.Add( buttonsSizer, 1, wx.ALIGN_RIGHT, 5 )
mainSizer.Add( footerSizer, 0, wx.EXPAND, 5 )
footerSizer.Add(buttonsSizer, 1, wx.ALIGN_RIGHT, 5)
mainSizer.Add(footerSizer, 0, wx.EXPAND, 5)
panel.SetSizer( mainSizer )
panel.SetSizer(mainSizer)
self.SetColours()
# self.Fit()
# self.Layout()
# self.Fit()
# self.Layout()
self.sliderGradientStart.Bind(wx.EVT_SCROLL, self.OnGradientStartScroll)
self.btnRestore.Bind(wx.EVT_BUTTON, self.RestoreDefaults)
self.btnDump.Bind(wx.EVT_BUTTON, self.DumpColours)
self.btnOk.Bind(wx.EVT_BUTTON, self.OnOk)
self.cp0100S.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
self.cp0100E.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
self.cp0100S.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)
self.cp0100E.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)
self.cp100101S.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
self.cp100101E.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
self.cp100101S.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)
self.cp100101E.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)
self.cp101103S.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
self.cp101103E.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
self.cp101103S.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)
self.cp101103E.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)
self.cp103105S.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
self.cp103105E.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
self.cp103105S.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)
self.cp103105E.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged)
def getImage(self):
return BitmapLoader.getBitmap("pref-gauges_big", "gui")
@@ -344,7 +345,6 @@ class PFGaugePref ( PreferenceView):
self.gauge0100M.SetGradientStart(self.sliderGradientStart.GetValue())
self.gauge0100E.SetGradientStart(self.sliderGradientStart.GetValue())
self.cp100101S.SetColour(self.c100101S)
self.cp100101E.SetColour(self.c100101E)
self.gauge100101S.SetColour(self.c100101S, self.c100101E)
@@ -363,7 +363,6 @@ class PFGaugePref ( PreferenceView):
self.gauge100101M.SetGradientStart(self.sliderGradientStart.GetValue())
self.gauge100101E.SetGradientStart(self.sliderGradientStart.GetValue())
self.cp101103S.SetColour(self.c101103S)
self.cp101103E.SetColour(self.c101103E)
self.gauge101103S.SetColour(self.c101103S, self.c101103E)
@@ -378,7 +377,6 @@ class PFGaugePref ( PreferenceView):
self.gauge101103M.SetGradientStart(self.sliderGradientStart.GetValue())
self.gauge101103E.SetGradientStart(self.sliderGradientStart.GetValue())
self.cp103105S.SetColour(self.c103105S)
self.cp103105E.SetColour(self.c103105E)
self.gauge103105S.SetColour(self.c103105S, self.c103105E)
@@ -406,7 +404,7 @@ class PFGaugePref ( PreferenceView):
self.wndPreview101103.SetGradientStart(self.sliderGradientStart.GetValue())
self.wndPreview103105.SetColour(self.c103105S, self.c103105E)
self.wndPreview103105.SetPercentages(103,104.99)
self.wndPreview103105.SetPercentages(103, 104.99)
self.wndPreview103105.SetGradientStart(self.sliderGradientStart.GetValue())
def OnGradientStartScroll(self, event):
@@ -415,15 +413,15 @@ class PFGaugePref ( PreferenceView):
event.Skip()
def OnOk(self, event):
#Apply New Settings
# Apply New Settings
event.Skip()
def DumpColours(self, event):
print "Gradient start: %d" % self.sliderGradientStart.GetValue()
print " 0 <-> 100 Start: ", self.c0100S, " End: ", self.c0100E
print "100 <-> 101 Start: ", self.c100101S, " End: ", self.c100101E
print "101 <-> 103 Start: ", self.c101103S, " End: ", self.c101103E
print "103 <-> 105 Start: ", self.c103105S, " End: ", self.c103105E
print("Gradient start: %d" % self.sliderGradientStart.GetValue())
print(" 0 <-> 100 Start: ", self.c0100S, " End: ", self.c0100E)
print("100 <-> 101 Start: ", self.c100101S, " End: ", self.c100101E)
print("101 <-> 103 Start: ", self.c101103S, " End: ", self.c101103E)
print("103 <-> 105 Start: ", self.c103105S, " End: ", self.c103105E)
event.Skip()
@@ -478,7 +476,8 @@ class PFGaugePref ( PreferenceView):
self.SetColours()
event.Skip()
def __del__( self ):
def __del__(self):
pass
PFGaugePref.register()

View File

@@ -8,67 +8,68 @@ import gui.globalEvents as GE
from service.settings import SettingsProvider
from service.fit import Fit
class PFGeneralPref ( PreferenceView):
class PFGeneralPref(PreferenceView):
title = "General"
def populatePanel( self, panel ):
def populatePanel(self, panel):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.dirtySettings = False
self.openFitsSettings = SettingsProvider.getInstance().getSettings("pyfaPrevOpenFits", {"enabled": False, "pyfaOpenFits": []})
mainSizer = wx.BoxSizer( wx.VERTICAL )
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.stTitle = wx.StaticText( panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stTitle.Wrap( -1 )
self.stTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0)
self.stTitle.Wrap(-1)
self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
mainSizer.Add( self.stTitle, 0, wx.ALL, 5 )
mainSizer.Add(self.stTitle, 0, wx.ALL, 5)
self.m_staticline1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline1, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )
self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
self.cbGlobalChar = wx.CheckBox( panel, wx.ID_ANY, u"Use global character", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbGlobalChar, 0, wx.ALL|wx.EXPAND, 5 )
self.cbGlobalChar = wx.CheckBox(panel, wx.ID_ANY, u"Use global character", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbGlobalChar, 0, wx.ALL | wx.EXPAND, 5)
self.cbGlobalDmgPattern = wx.CheckBox( panel, wx.ID_ANY, u"Use global damage pattern", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbGlobalDmgPattern, 0, wx.ALL|wx.EXPAND, 5 )
self.cbGlobalDmgPattern = wx.CheckBox(panel, wx.ID_ANY, u"Use global damage pattern", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbGlobalDmgPattern, 0, wx.ALL | wx.EXPAND, 5)
self.cbGlobalForceReload = wx.CheckBox( panel, wx.ID_ANY, u"Factor in reload time", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbGlobalForceReload, 0, wx.ALL|wx.EXPAND, 5 )
self.cbGlobalForceReload = wx.CheckBox(panel, wx.ID_ANY, u"Factor in reload time", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbGlobalForceReload, 0, wx.ALL | wx.EXPAND, 5)
self.cbCompactSkills = wx.CheckBox( panel, wx.ID_ANY, u"Compact skills needed tooltip", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbCompactSkills, 0, wx.ALL|wx.EXPAND, 5 )
self.cbCompactSkills = wx.CheckBox(panel, wx.ID_ANY, u"Compact skills needed tooltip", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbCompactSkills, 0, wx.ALL | wx.EXPAND, 5)
self.cbFitColorSlots = wx.CheckBox( panel, wx.ID_ANY, u"Color fitting view by slot", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbFitColorSlots, 0, wx.ALL|wx.EXPAND, 5 )
self.cbFitColorSlots = wx.CheckBox(panel, wx.ID_ANY, u"Color fitting view by slot", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbFitColorSlots, 0, wx.ALL | wx.EXPAND, 5)
self.cbReopenFits = wx.CheckBox( panel, wx.ID_ANY, u"Reopen previous fits on startup", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbReopenFits, 0, wx.ALL|wx.EXPAND, 5 )
self.cbReopenFits = wx.CheckBox(panel, wx.ID_ANY, u"Reopen previous fits on startup", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbReopenFits, 0, wx.ALL | wx.EXPAND, 5)
self.cbRackSlots = wx.CheckBox( panel, wx.ID_ANY, u"Separate Racks", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbRackSlots, 0, wx.ALL|wx.EXPAND, 5 )
self.cbRackSlots = wx.CheckBox(panel, wx.ID_ANY, u"Separate Racks", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbRackSlots, 0, wx.ALL | wx.EXPAND, 5)
labelSizer = wx.BoxSizer( wx.VERTICAL )
self.cbRackLabels = wx.CheckBox( panel, wx.ID_ANY, u"Show Rack Labels", wx.DefaultPosition, wx.DefaultSize, 0 )
labelSizer.Add( self.cbRackLabels, 0, wx.ALL|wx.EXPAND, 5 )
mainSizer.Add( labelSizer, 0, wx.LEFT|wx.EXPAND, 30 )
labelSizer = wx.BoxSizer(wx.VERTICAL)
self.cbRackLabels = wx.CheckBox(panel, wx.ID_ANY, u"Show Rack Labels", wx.DefaultPosition, wx.DefaultSize, 0)
labelSizer.Add(self.cbRackLabels, 0, wx.ALL | wx.EXPAND, 5)
mainSizer.Add(labelSizer, 0, wx.LEFT | wx.EXPAND, 30)
self.cbShowTooltip = wx.CheckBox( panel, wx.ID_ANY, u"Show tab tooltips", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbShowTooltip, 0, wx.ALL|wx.EXPAND, 5 )
self.cbShowTooltip = wx.CheckBox(panel, wx.ID_ANY, u"Show tab tooltips", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbShowTooltip, 0, wx.ALL | wx.EXPAND, 5)
self.cbMarketShortcuts = wx.CheckBox( panel, wx.ID_ANY, u"Show market shortcuts", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbMarketShortcuts, 0, wx.ALL|wx.EXPAND, 5 )
self.cbMarketShortcuts = wx.CheckBox(panel, wx.ID_ANY, u"Show market shortcuts", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbMarketShortcuts, 0, wx.ALL | wx.EXPAND, 5)
self.cbGaugeAnimation = wx.CheckBox( panel, wx.ID_ANY, u"Animate gauges", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbGaugeAnimation, 0, wx.ALL|wx.EXPAND, 5 )
self.cbGaugeAnimation = wx.CheckBox(panel, wx.ID_ANY, u"Animate gauges", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbGaugeAnimation, 0, wx.ALL | wx.EXPAND, 5)
self.cbExportCharges = wx.CheckBox( panel, wx.ID_ANY, u"Export loaded charges", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbExportCharges, 0, wx.ALL|wx.EXPAND, 5 )
self.cbOpenFitInNew = wx.CheckBox( panel, wx.ID_ANY, u"Open fittings in a new page by default", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbOpenFitInNew, 0, wx.ALL|wx.EXPAND, 5 )
self.cbExportCharges = wx.CheckBox(panel, wx.ID_ANY, u"Export loaded charges", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbExportCharges, 0, wx.ALL | wx.EXPAND, 5)
defCharSizer = wx.BoxSizer( wx.HORIZONTAL )
self.cbOpenFitInNew = wx.CheckBox(panel, wx.ID_ANY, u"Open fittings in a new page by default", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbOpenFitInNew, 0, wx.ALL | wx.EXPAND, 5)
wx.BoxSizer(wx.HORIZONTAL)
self.sFit = Fit.getInstance()
@@ -102,7 +103,7 @@ class PFGeneralPref ( PreferenceView):
self.cbRackLabels.Enable(self.sFit.serviceFittingOptions["rackSlots"] or False)
panel.SetSizer( mainSizer )
panel.SetSizer(mainSizer)
panel.Layout()
def onCBGlobalColorBySlot(self, event):
@@ -163,11 +164,12 @@ class PFGeneralPref ( PreferenceView):
def onCBExportCharges(self, event):
self.sFit.serviceFittingOptions["exportCharges"] = self.cbExportCharges.GetValue()
def onCBOpenFitInNew(self, event):
self.sFit.serviceFittingOptions["openFitInNew"] = self.cbOpenFitInNew.GetValue()
def getImage(self):
return BitmapLoader.getBitmap("prefs_settings", "gui")
PFGeneralPref.register()
PFGeneralPref.register()

View File

@@ -5,79 +5,76 @@ from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import gui.globalEvents as GE
from service.settings import HTMLExportSettings
class PFHTMLExportPref ( PreferenceView):
class PFHTMLExportPref(PreferenceView):
title = "HTML Export"
desc = "HTML Export (File > Export HTML) allows you to export your entire fitting "+\
"database into an HTML file at the specified location. This file can be "+\
"used in the in-game browser to easily open and import your fits, or used "+\
"in a regular web browser to open them at NULL-SEC.com or Osmium."
desc2 = "Enabling automatic exporting will update the HTML file after any change "+\
"to a fit is made. Under certain circumstance, this may cause performance issues."
desc4 = "Export Fittings in a minmal HTML Version, just containing the Fittingslinks " +\
"without any visual styling or javscript features"
desc = ("HTML Export (File > Export HTML) allows you to export your entire fitting "
"database into an HTML file at the specified location. This file can be "
"used in the in-game browser to easily open and import your fits, or used "
"in a regular web browser to open them at NULL-SEC.com or Osmium.")
desc2 = ("Enabling automatic exporting will update the HTML file after any change "
"to a fit is made. Under certain circumstance, this may cause performance issues.")
desc4 = ("Export Fittings in a minmal HTML Version, just containing the Fittingslinks "
"without any visual styling or javscript features")
def populatePanel( self, panel ):
def populatePanel(self, panel):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.HTMLExportSettings = HTMLExportSettings.getInstance()
self.dirtySettings = False
dlgWidth = panel.GetParent().GetParent().ClientSize.width
mainSizer = wx.BoxSizer( wx.VERTICAL )
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.stTitle = wx.StaticText( panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stTitle.Wrap( -1 )
self.stTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
mainSizer.Add( self.stTitle, 0, wx.ALL, 5 )
self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0)
self.stTitle.Wrap(-1)
self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
mainSizer.Add(self.stTitle, 0, wx.ALL, 5)
self.m_staticline1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline1, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )
self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
self.stDesc = wx.StaticText( panel, wx.ID_ANY, self.desc, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stDesc = wx.StaticText(panel, wx.ID_ANY, self.desc, wx.DefaultPosition, wx.DefaultSize, 0)
self.stDesc.Wrap(dlgWidth - 50)
mainSizer.Add( self.stDesc, 0, wx.ALL, 5 )
mainSizer.Add(self.stDesc, 0, wx.ALL, 5)
self.PathLinkCtrl = wx.HyperlinkCtrl( panel, wx.ID_ANY, self.HTMLExportSettings.getPath(), u'file:///{}'.format(self.HTMLExportSettings.getPath()), wx.DefaultPosition, wx.DefaultSize, wx.HL_ALIGN_LEFT|wx.NO_BORDER|wx.HL_CONTEXTMENU )
mainSizer.Add( self.PathLinkCtrl, 0, wx.ALL|wx.EXPAND, 5)
self.PathLinkCtrl = wx.HyperlinkCtrl(panel, wx.ID_ANY, self.HTMLExportSettings.getPath(), u'file:///{}'.format(self.HTMLExportSettings.getPath()), wx.DefaultPosition, wx.DefaultSize, wx.HL_ALIGN_LEFT | wx.NO_BORDER | wx.HL_CONTEXTMENU)
mainSizer.Add(self.PathLinkCtrl, 0, wx.ALL | wx.EXPAND, 5)
self.fileSelectDialog = wx.FileDialog(None, "Save Fitting As...", wildcard = "EVE IGB HTML fitting file (*.html)|*.html", style = wx.FD_SAVE)
self.fileSelectDialog = wx.FileDialog(None, "Save Fitting As...", wildcard="EVE IGB HTML fitting file (*.html)|*.html", style=wx.FD_SAVE)
self.fileSelectDialog.SetPath(self.HTMLExportSettings.getPath())
self.fileSelectDialog.SetFilename(os.path.basename(self.HTMLExportSettings.getPath()));
self.fileSelectDialog.SetFilename(os.path.basename(self.HTMLExportSettings.getPath()))
self.fileSelectButton = wx.Button(panel, -1, "Set export destination", pos=(0,0))
self.fileSelectButton = wx.Button(panel, -1, "Set export destination", pos=(0, 0))
self.fileSelectButton.Bind(wx.EVT_BUTTON, self.selectHTMLExportFilePath)
mainSizer.Add( self.fileSelectButton, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
mainSizer.Add(self.fileSelectButton, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.stDesc2 = wx.StaticText( panel, wx.ID_ANY, self.desc2, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stDesc2 = wx.StaticText(panel, wx.ID_ANY, self.desc2, wx.DefaultPosition, wx.DefaultSize, 0)
self.stDesc2.Wrap(dlgWidth - 50)
mainSizer.Add( self.stDesc2, 0, wx.ALL, 5 )
mainSizer.Add(self.stDesc2, 0, wx.ALL, 5)
self.exportEnabled = wx.CheckBox( panel, wx.ID_ANY, u"Enable automatic HTML export", wx.DefaultPosition, wx.DefaultSize, 0 )
self.exportEnabled = wx.CheckBox(panel, wx.ID_ANY, u"Enable automatic HTML export", wx.DefaultPosition, wx.DefaultSize, 0)
self.exportEnabled.SetValue(self.HTMLExportSettings.getEnabled())
self.exportEnabled.Bind(wx.EVT_CHECKBOX, self.OnExportEnabledChange)
mainSizer.Add( self.exportEnabled, 0, wx.ALL|wx.EXPAND, 5 )
mainSizer.Add(self.exportEnabled, 0, wx.ALL | wx.EXPAND, 5)
self.stDesc4 = wx.StaticText( panel, wx.ID_ANY, self.desc4, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stDesc4 = wx.StaticText(panel, wx.ID_ANY, self.desc4, wx.DefaultPosition, wx.DefaultSize, 0)
self.stDesc4.Wrap(dlgWidth - 50)
mainSizer.Add( self.stDesc4, 0, wx.ALL, 5 )
mainSizer.Add(self.stDesc4, 0, wx.ALL, 5)
self.exportMinimal = wx.CheckBox( panel, wx.ID_ANY, u"Enable minimal export Format", wx.DefaultPosition, wx.DefaultSize, 0 )
self.exportMinimal = wx.CheckBox(panel, wx.ID_ANY, u"Enable minimal export Format", wx.DefaultPosition, wx.DefaultSize, 0)
self.exportMinimal.SetValue(self.HTMLExportSettings.getMinimalEnabled())
self.exportMinimal.Bind(wx.EVT_CHECKBOX, self.OnMinimalEnabledChange)
mainSizer.Add( self.exportMinimal, 0, wx.ALL|wx.EXPAND, 5 )
mainSizer.Add(self.exportMinimal, 0, wx.ALL | wx.EXPAND, 5)
panel.SetSizer( mainSizer )
panel.SetSizer(mainSizer)
panel.Layout()
def setPathLinkCtrlValues(self, path):
self.PathLinkCtrl.SetLabel(self.HTMLExportSettings.getPath())
self.PathLinkCtrl.SetURL(u'file:///{}'.format(self.HTMLExportSettings.getPath()))
self.PathLinkCtrl.SetSize(wx.DefaultSize);
self.PathLinkCtrl.SetSize(wx.DefaultSize)
self.PathLinkCtrl.Refresh()
def selectHTMLExportFilePath(self, event):
@@ -95,4 +92,5 @@ class PFHTMLExportPref ( PreferenceView):
def getImage(self):
return BitmapLoader.getBitmap("prefs_html", "gui")
PFHTMLExportPref.register()

View File

@@ -7,48 +7,49 @@ import gui.mainFrame
from service.settings import NetworkSettings
from service.network import Network
class PFNetworkPref ( PreferenceView):
class PFNetworkPref(PreferenceView):
title = "Network"
def populatePanel( self, panel ):
def populatePanel(self, panel):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.settings = NetworkSettings.getInstance()
self.network = Network.getInstance()
self.dirtySettings = False
mainSizer = wx.BoxSizer( wx.VERTICAL )
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.stTitle = wx.StaticText( panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stTitle.Wrap( -1 )
self.stTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0)
self.stTitle.Wrap(-1)
self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
mainSizer.Add( self.stTitle, 0, wx.ALL, 5 )
mainSizer.Add(self.stTitle, 0, wx.ALL, 5)
self.m_staticline1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline1, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )
self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
self.cbEnableNetwork = wx.CheckBox( panel, wx.ID_ANY, u"Enable Network", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbEnableNetwork, 0, wx.ALL|wx.EXPAND, 5 )
self.cbEnableNetwork = wx.CheckBox(panel, wx.ID_ANY, u"Enable Network", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbEnableNetwork, 0, wx.ALL | wx.EXPAND, 5)
subSizer = wx.BoxSizer( wx.VERTICAL )
self.cbEve = wx.CheckBox( panel, wx.ID_ANY, u"EVE Servers (API && CREST import)", wx.DefaultPosition, wx.DefaultSize, 0 )
subSizer.Add( self.cbEve, 0, wx.ALL|wx.EXPAND, 5 )
subSizer = wx.BoxSizer(wx.VERTICAL)
self.cbEve = wx.CheckBox(panel, wx.ID_ANY, u"EVE Servers (API && CREST import)", wx.DefaultPosition, wx.DefaultSize, 0)
subSizer.Add(self.cbEve, 0, wx.ALL | wx.EXPAND, 5)
self.cbPricing = wx.CheckBox( panel, wx.ID_ANY, u"Pricing updates", wx.DefaultPosition, wx.DefaultSize, 0 )
subSizer.Add( self.cbPricing, 0, wx.ALL|wx.EXPAND, 5 )
self.cbPricing = wx.CheckBox(panel, wx.ID_ANY, u"Pricing updates", wx.DefaultPosition, wx.DefaultSize, 0)
subSizer.Add(self.cbPricing, 0, wx.ALL | wx.EXPAND, 5)
self.cbPyfaUpdate = wx.CheckBox( panel, wx.ID_ANY, u"Pyfa Update checks", wx.DefaultPosition, wx.DefaultSize, 0 )
subSizer.Add( self.cbPyfaUpdate, 0, wx.ALL|wx.EXPAND, 5 )
self.cbPyfaUpdate = wx.CheckBox(panel, wx.ID_ANY, u"Pyfa Update checks", wx.DefaultPosition, wx.DefaultSize, 0)
subSizer.Add(self.cbPyfaUpdate, 0, wx.ALL | wx.EXPAND, 5)
mainSizer.Add( subSizer, 0, wx.LEFT|wx.EXPAND, 30 )
mainSizer.Add(subSizer, 0, wx.LEFT | wx.EXPAND, 30)
proxyTitle = wx.StaticText( panel, wx.ID_ANY, "Proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 )
proxyTitle.Wrap( -1 )
proxyTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
proxyTitle = wx.StaticText(panel, wx.ID_ANY, "Proxy settings", wx.DefaultPosition, wx.DefaultSize, 0)
proxyTitle.Wrap(-1)
proxyTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
mainSizer.Add( proxyTitle, 0, wx.ALL, 5 )
mainSizer.Add( wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0, wx.EXPAND, 5 )
mainSizer.Add(proxyTitle, 0, wx.ALL, 5)
mainSizer.Add(wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND, 5)
self.cbEnableNetwork.SetValue(self.settings.isEnabled(self.network.ENABLED))
self.cbEve.SetValue(self.settings.isEnabled(self.network.EVE))
@@ -62,9 +63,9 @@ class PFNetworkPref ( PreferenceView):
self.toggleNetworks(self.cbEnableNetwork.GetValue())
#---------------
# ---------------
# Proxy
#---------------
# ---------------
self.nMode = self.settings.getMode()
self.nAddr = self.settings.getAddress()
@@ -74,46 +75,44 @@ class PFNetworkPref ( PreferenceView):
if self.nAuth is None:
self.nAuth = ("", "") # we don't want None here, it should be a tuple
ptypeSizer = wx.BoxSizer( wx.HORIZONTAL )
ptypeSizer = wx.BoxSizer(wx.HORIZONTAL)
self.stPType = wx.StaticText( panel, wx.ID_ANY, u"Mode:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPType.Wrap( -1 )
ptypeSizer.Add( self.stPType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.stPType = wx.StaticText(panel, wx.ID_ANY, u"Mode:", wx.DefaultPosition, wx.DefaultSize, 0)
self.stPType.Wrap(-1)
ptypeSizer.Add(self.stPType, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.chProxyTypeChoices = [ u"No proxy", u"Auto-detected proxy settings", u"Manual proxy settings" ]
self.chProxyType = wx.Choice( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.chProxyTypeChoices, 0 )
self.chProxyTypeChoices = [u"No proxy", u"Auto-detected proxy settings", u"Manual proxy settings"]
self.chProxyType = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.chProxyTypeChoices, 0)
self.chProxyType.SetSelection(self.nMode)
self.chProxyType.SetSelection( self.nMode )
ptypeSizer.Add(self.chProxyType, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
ptypeSizer.Add( self.chProxyType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
mainSizer.Add(ptypeSizer, 0, wx.EXPAND, 5)
mainSizer.Add( ptypeSizer, 0, wx.EXPAND, 5 )
fgAddrSizer = wx.FlexGridSizer(2, 2, 0, 0)
fgAddrSizer.AddGrowableCol(1)
fgAddrSizer.SetFlexibleDirection(wx.BOTH)
fgAddrSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
fgAddrSizer = wx.FlexGridSizer( 2, 2, 0, 0 )
fgAddrSizer.AddGrowableCol( 1 )
fgAddrSizer.SetFlexibleDirection( wx.BOTH )
fgAddrSizer.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
self.stPSetAddr = wx.StaticText(panel, wx.ID_ANY, u"Addr:", wx.DefaultPosition, wx.DefaultSize, 0)
self.stPSetAddr.Wrap(-1)
fgAddrSizer.Add(self.stPSetAddr, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.editProxySettingsAddr = wx.TextCtrl(panel, wx.ID_ANY, self.nAddr, wx.DefaultPosition, wx.DefaultSize, 0)
self.stPSetAddr = wx.StaticText( panel, wx.ID_ANY, u"Addr:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPSetAddr.Wrap( -1 )
fgAddrSizer.Add( self.stPSetAddr, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
fgAddrSizer.Add(self.editProxySettingsAddr, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
self.editProxySettingsAddr = wx.TextCtrl( panel, wx.ID_ANY, self.nAddr, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPSetPort = wx.StaticText(panel, wx.ID_ANY, u"Port:", wx.DefaultPosition, wx.DefaultSize, 0)
self.stPSetPort.Wrap(-1)
fgAddrSizer.Add( self.editProxySettingsAddr, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5 )
fgAddrSizer.Add(self.stPSetPort, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.stPSetPort = wx.StaticText( panel, wx.ID_ANY, u"Port:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPSetPort.Wrap( -1 )
self.editProxySettingsPort = wx.TextCtrl(panel, wx.ID_ANY, self.nPort, wx.DefaultPosition, wx.DefaultSize, 0)
fgAddrSizer.Add( self.stPSetPort, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
fgAddrSizer.Add(self.editProxySettingsPort, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
self.editProxySettingsPort = wx.TextCtrl( panel, wx.ID_ANY, self.nPort, wx.DefaultPosition, wx.DefaultSize, 0 )
fgAddrSizer.Add( self.editProxySettingsPort, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5 )
mainSizer.Add( fgAddrSizer, 0, wx.EXPAND, 5)
mainSizer.Add(fgAddrSizer, 0, wx.EXPAND, 5)
# proxy auth information: login and pass
self.stPSetLogin = wx.StaticText(panel, wx.ID_ANY, u"Username:", wx.DefaultPosition, wx.DefaultSize, 0)
@@ -130,23 +129,23 @@ class PFNetworkPref ( PreferenceView):
pAuthSizer.Add(self.editProxySettingsPassword, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
mainSizer.Add(pAuthSizer, 0, wx.EXPAND, 5)
self.stPSAutoDetected = wx.StaticText( panel, wx.ID_ANY, u"Auto-detected: ", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPSAutoDetected.Wrap( -1 )
mainSizer.Add( self.stPSAutoDetected, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.stPSAutoDetected = wx.StaticText(panel, wx.ID_ANY, u"Auto-detected: ", wx.DefaultPosition, wx.DefaultSize, 0)
self.stPSAutoDetected.Wrap(-1)
mainSizer.Add(self.stPSAutoDetected, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
btnSizer = wx.BoxSizer( wx.HORIZONTAL )
btnSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.AddSpacer((0, 0), 1, wx.EXPAND, 5)
self.btnApply = wx.Button( panel, wx.ID_ANY, u"Apply Proxy Settings", wx.DefaultPosition, wx.DefaultSize, 0 )
self.btnApply = wx.Button(panel, wx.ID_ANY, u"Apply Proxy Settings", wx.DefaultPosition, wx.DefaultSize, 0)
btnSizer.Add( self.btnApply, 0, wx.ALL, 5 )
btnSizer.Add(self.btnApply, 0, wx.ALL, 5)
mainSizer.Add(btnSizer, 0, wx.EXPAND,5)
mainSizer.Add(btnSizer, 0, wx.EXPAND, 5)
proxy = self.settings.autodetect()
if proxy is not None:
addr,port = proxy
addr, port = proxy
txt = addr + ":" + str(port)
else:
txt = "None"
@@ -160,7 +159,6 @@ class PFNetworkPref ( PreferenceView):
self.editProxySettingsLogin.Bind(wx.EVT_TEXT, self.OnEditPSLoginText)
self.editProxySettingsPassword.Bind(wx.EVT_TEXT, self.OnEditPSPasswordText)
self.btnApply.Bind(wx.EVT_BUTTON, self.OnBtnApply)
self.UpdateApplyButtonState()
@@ -170,7 +168,7 @@ class PFNetworkPref ( PreferenceView):
else:
self.ToggleProxySettings(True)
panel.SetSizer( mainSizer )
panel.SetSizer(mainSizer)
panel.Layout()
def toggleNetworks(self, toggle):
@@ -265,4 +263,5 @@ class PFNetworkPref ( PreferenceView):
def getImage(self):
return BitmapLoader.getBitmap("prefs_proxy", "gui")
PFNetworkPref.register()

View File

@@ -1,83 +1,79 @@
import wx
import os
from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
from service.settings import UpdateSettings
import gui.globalEvents as GE
class PFUpdatePref (PreferenceView):
class PFUpdatePref(PreferenceView):
title = "Updates"
desc = "Pyfa can automatically check and notify you of new releases. "+\
"This feature is toggled in the Network settings. "+\
"Here, you may allow pre-release notifications and view "+\
"suppressed release notifications, if any."
desc = ("Pyfa can automatically check and notify you of new releases. "
"This feature is toggled in the Network settings. "
"Here, you may allow pre-release notifications and view "
"suppressed release notifications, if any.")
def populatePanel( self, panel ):
def populatePanel(self, panel):
self.UpdateSettings = UpdateSettings.getInstance()
self.dirtySettings = False
dlgWidth = panel.GetParent().GetParent().ClientSize.width
mainSizer = wx.BoxSizer( wx.VERTICAL )
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.stTitle = wx.StaticText( panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stTitle.Wrap( -1 )
self.stTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
mainSizer.Add( self.stTitle, 0, wx.ALL, 5 )
self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0)
self.stTitle.Wrap(-1)
self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
mainSizer.Add(self.stTitle, 0, wx.ALL, 5)
self.m_staticline1 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline1, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )
self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
self.stDesc = wx.StaticText( panel, wx.ID_ANY, self.desc, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stDesc = wx.StaticText(panel, wx.ID_ANY, self.desc, wx.DefaultPosition, wx.DefaultSize, 0)
self.stDesc.Wrap(dlgWidth - 50)
mainSizer.Add( self.stDesc, 0, wx.ALL, 5 )
mainSizer.Add(self.stDesc, 0, wx.ALL, 5)
self.suppressPrerelease = wx.CheckBox( panel, wx.ID_ANY, u"Allow pre-release notifications", wx.DefaultPosition, wx.DefaultSize, 0 )
self.suppressPrerelease = wx.CheckBox(panel, wx.ID_ANY, u"Allow pre-release notifications", wx.DefaultPosition, wx.DefaultSize, 0)
self.suppressPrerelease.Bind(wx.EVT_CHECKBOX, self.OnPrereleaseStateChange)
self.suppressPrerelease.SetValue(not self.UpdateSettings.get('prerelease'))
mainSizer.Add( self.suppressPrerelease, 0, wx.ALL|wx.EXPAND, 5 )
mainSizer.Add(self.suppressPrerelease, 0, wx.ALL | wx.EXPAND, 5)
if (self.UpdateSettings.get('version')):
self.versionSizer = wx.BoxSizer( wx.VERTICAL )
self.versionSizer = wx.BoxSizer(wx.VERTICAL)
self.versionTitle = wx.StaticText(panel, wx.ID_ANY, "Suppressing {0} Notifications".format(self.UpdateSettings.get('version')), wx.DefaultPosition, wx.DefaultSize, 0)
self.versionTitle.Wrap(-1)
self.versionTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
self.versionTitle = wx.StaticText( panel, wx.ID_ANY, "Suppressing "+self.UpdateSettings.get('version')+" Notifications", wx.DefaultPosition, wx.DefaultSize, 0 )
self.versionTitle.Wrap( -1 )
self.versionTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
self.versionInfo = ("There is a release available which you have chosen to suppress. "
"You can choose to reset notification suppression for this release, "
"or download the new release from GitHub.")
self.versionInfo = "There is a release available which you have chosen to suppress. "+\
"You can choose to reset notification suppression for this release, "+\
"or download the new release from GitHub."
self.versionSizer.AddSpacer((5, 5), 0, wx.EXPAND, 5)
self.versionSizer.AddSpacer( ( 5, 5), 0, wx.EXPAND, 5 )
self.versionSizer.Add(wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND, 5)
self.versionSizer.AddSpacer((5, 5), 0, wx.EXPAND, 5)
self.versionSizer.Add( wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0, wx.EXPAND, 5 )
self.versionSizer.AddSpacer( ( 5, 5), 0, wx.EXPAND, 5 )
self.versionSizer.Add( self.versionTitle, 0, wx.EXPAND, 5 )
self.versionDesc = wx.StaticText( panel, wx.ID_ANY, self.versionInfo, wx.DefaultPosition, wx.DefaultSize, 0 )
self.versionSizer.Add(self.versionTitle, 0, wx.EXPAND, 5)
self.versionDesc = wx.StaticText(panel, wx.ID_ANY, self.versionInfo, wx.DefaultPosition, wx.DefaultSize, 0)
self.versionDesc.Wrap(dlgWidth - 50)
self.versionSizer.Add( self.versionDesc, 0, wx.ALL, 5 )
self.versionSizer.Add(self.versionDesc, 0, wx.ALL, 5)
actionSizer = wx.BoxSizer( wx.HORIZONTAL )
resetSizer = wx.BoxSizer( wx.VERTICAL )
actionSizer = wx.BoxSizer(wx.HORIZONTAL)
resetSizer = wx.BoxSizer(wx.VERTICAL)
self.downloadButton = wx.Button( panel, wx.ID_ANY, "Download", wx.DefaultPosition, wx.DefaultSize, 0 )
self.downloadButton = wx.Button(panel, wx.ID_ANY, "Download", wx.DefaultPosition, wx.DefaultSize, 0)
self.downloadButton.Bind(wx.EVT_BUTTON, self.OnDownload)
resetSizer.Add( self.downloadButton, 0, wx.ALL, 5 )
actionSizer.Add( resetSizer, 1, wx.EXPAND, 5 )
resetSizer.Add(self.downloadButton, 0, wx.ALL, 5)
actionSizer.Add(resetSizer, 1, wx.EXPAND, 5)
self.resetButton = wx.Button( panel, wx.ID_ANY, "Reset Suppression", wx.DefaultPosition, wx.DefaultSize, 0 )
self.resetButton = wx.Button(panel, wx.ID_ANY, "Reset Suppression", wx.DefaultPosition, wx.DefaultSize, 0)
self.resetButton.Bind(wx.EVT_BUTTON, self.ResetSuppression)
actionSizer.Add( self.resetButton, 0, wx.ALL, 5 )
self.versionSizer.Add( actionSizer, 0, wx.EXPAND, 5 )
mainSizer.Add( self.versionSizer, 0, wx.EXPAND, 5 )
actionSizer.Add(self.resetButton, 0, wx.ALL, 5)
self.versionSizer.Add(actionSizer, 0, wx.EXPAND, 5)
mainSizer.Add(self.versionSizer, 0, wx.EXPAND, 5)
panel.SetSizer( mainSizer )
panel.SetSizer(mainSizer)
panel.Layout()
def OnPrereleaseStateChange(self, event):
@@ -95,9 +91,10 @@ class PFUpdatePref (PreferenceView):
self.resetButton.Hide()
def OnDownload(self, event):
wx.LaunchDefaultBrowser('https://github.com/pyfa-org/Pyfa/releases/tag/'+self.UpdateSettings.get('version'))
wx.LaunchDefaultBrowser('https://github.com/pyfa-org/Pyfa/releases/tag/' + self.UpdateSettings.get('version'))
def getImage(self):
return BitmapLoader.getBitmap("prefs_update", "gui")
PFUpdatePref.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,24 +15,26 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
class CapacitorViewFull(StatsView):
name = "capacitorViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
def getHeaderText(self, fit):
return "Capacitor"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
width, height = self.parent.GetTextExtent(text)
return width
def populatePanel(self, contentPanel, headerPanel):
@@ -104,12 +106,13 @@ class CapacitorViewFull(StatsView):
chargeSizer.Add(lbl, 0, wx.ALIGN_CENTER)
chargeSizer.Add(wx.StaticText(parent, wx.ID_ANY, " GJ/s"), 0, wx.ALIGN_CENTER)
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
stats= (("label%sCapacitorCapacity", lambda: fit.ship.getModifiedItemAttr("capacitorCapacity"), 3, 0, 9),
("label%sCapacitorRecharge", lambda: fit.capRecharge, 3, 0, 0),
("label%sCapacitorDischarge", lambda: fit.capUsed, 3, 0, 0))
# If we did anything intresting, we'd update our labels to reflect the new fit's stats here
stats = (
("label%sCapacitorCapacity", lambda: fit.ship.getModifiedItemAttr("capacitorCapacity"), 3, 0, 9),
("label%sCapacitorRecharge", lambda: fit.capRecharge, 3, 0, 0),
("label%sCapacitorDischarge", lambda: fit.capUsed, 3, 0, 0),
)
panel = "Full"
for labelName, value, prec, lowest, highest in stats:
@@ -147,4 +150,5 @@ class CapacitorViewFull(StatsView):
self.panel.Layout()
self.headerPanel.Layout()
CapacitorViewFull.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.mainFrame
@@ -170,4 +170,5 @@ class FirepowerViewFull(StatsView):
self.panel.Layout()
self.headerPanel.Layout()
FirepowerViewFull.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2014 Alexandros Kosiaris
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.mainFrame
@@ -142,4 +142,5 @@ class MiningYieldViewFull(StatsView):
self.panel.Layout()
self.headerPanel.Layout()
MiningYieldViewFull.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,17 +15,18 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from service.market import Market
class PriceViewFull(StatsView):
name = "priceViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
@@ -81,15 +82,15 @@ class PriceViewFull(StatsView):
typeIDs.append(mod.itemID)
for drone in fit.drones:
for _ in xrange(drone.amount):
for _ in range(drone.amount):
typeIDs.append(drone.itemID)
for fighter in fit.fighters:
for _ in xrange(fighter.amountActive):
for _ in range(fighter.amountActive):
typeIDs.append(fighter.itemID)
for cargo in fit.cargo:
for _ in xrange(cargo.amount):
for _ in range(cargo.amount):
typeIDs.append(cargo.itemID)
sMkt = Market.getInstance()
@@ -117,10 +118,11 @@ class PriceViewFull(StatsView):
self.labelPriceFittings.SetLabel("%s ISK" % formatAmount(modPrice, 3, 3, 9, currency=True))
self.labelPriceFittings.SetToolTip(wx.ToolTip('{:,.2f}'.format(modPrice)))
self._cachedFittings = modPrice
if self._cachedTotal != (shipPrice+modPrice):
if self._cachedTotal != (shipPrice + modPrice):
self.labelPriceTotal.SetLabel("%s ISK" % formatAmount(shipPrice + modPrice, 3, 3, 9, currency=True))
self.labelPriceTotal.SetToolTip(wx.ToolTip('{:,.2f}'.format(shipPrice + modPrice)))
self._cachedTotal = shipPrice + modPrice
self.panel.Layout()
PriceViewFull.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.statsView import StatsView
@@ -25,8 +25,10 @@ import gui.mainFrame
import gui.builtinStatsViews.resistancesViewFull as rvf
from service.fit import Fit
class RechargeViewFull(StatsView):
name = "rechargeViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
@@ -38,7 +40,7 @@ class RechargeViewFull(StatsView):
return "Recharge rates"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
width, height = self.parent.GetTextExtent(text)
return width
def toggleEffective(self, event):
@@ -53,21 +55,21 @@ class RechargeViewFull(StatsView):
self.panel = contentPanel
self.headerPanel = headerPanel
sizerTankStats = wx.FlexGridSizer(3, 5)
for i in xrange(4):
for i in range(4):
sizerTankStats.AddGrowableCol(i + 1)
contentSizer.Add(sizerTankStats, 0, wx.EXPAND, 0)
#Add an empty label first for correct alignment.
# Add an empty label first for correct alignment.
sizerTankStats.Add(wx.StaticText(contentPanel, wx.ID_ANY, ""), 0)
toolTipText = {"shieldPassive" : "Passive shield recharge", "shieldActive" : "Active shield boost", "armorActive" : "Armor repair amount", "hullActive" : "Hull repair amount"}
toolTipText = {"shieldPassive": "Passive shield recharge", "shieldActive": "Active shield boost", "armorActive": "Armor repair amount", "hullActive": "Hull repair amount"}
for tankType in ("shieldPassive", "shieldActive", "armorActive", "hullActive"):
bitmap = BitmapLoader.getStaticBitmap("%s_big" % tankType, contentPanel, "gui")
tooltip = wx.ToolTip(toolTipText[tankType])
bitmap.SetToolTip(tooltip)
sizerTankStats.Add(bitmap, 0, wx.ALIGN_CENTER)
toolTipText = {"reinforced" : "Reinforced", "sustained" : "Sustained"}
toolTipText = {"reinforced": "Reinforced", "sustained": "Sustained"}
for stability in ("reinforced", "sustained"):
bitmap = BitmapLoader.getStaticBitmap("regen%s_big" % stability.capitalize(), contentPanel, "gui")
tooltip = wx.ToolTip(toolTipText[stability])
@@ -79,7 +81,7 @@ class RechargeViewFull(StatsView):
continue
tankTypeCap = tankType[0].capitalize() + tankType[1:]
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0.0", style = wx.ALIGN_RIGHT)
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0.0", style=wx.ALIGN_RIGHT)
setattr(self, "labelTank%s%s" % (stability.capitalize(), tankTypeCap), lbl)
box = wx.BoxSizer(wx.HORIZONTAL)
@@ -91,12 +93,12 @@ class RechargeViewFull(StatsView):
contentPanel.Layout()
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
# If we did anything intresting, we'd update our labels to reflect the new fit's stats here
for stability in ("reinforced", "sustained"):
if stability == "reinforced" and fit != None:
if stability == "reinforced" and fit is not None:
tank = fit.effectiveTank if self.effective else fit.tank
elif stability == "sustained" and fit != None:
elif stability == "sustained" and fit is not None:
tank = fit.effectiveSustainableTank if self.effective else fit.sustainableTank
else:
tank = None
@@ -122,4 +124,5 @@ class RechargeViewFull(StatsView):
self.panel.Layout()
self.headerPanel.Layout()
RechargeViewFull.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.statsView import StatsView
@@ -222,5 +222,6 @@ class ResistancesViewFull(StatsView):
self.panel.Layout()
self.headerPanel.Layout()
ResistancesViewFull.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,11 +15,10 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui.bitmapLoader import BitmapLoader
from gui import pygauge as PG
import gui.mainFrame
@@ -29,6 +28,7 @@ from eos.types import Hardpoint
from gui.utils.numberFormatter import formatAmount
class ResourcesViewFull(StatsView):
name = "resourcesViewFull"
contexts = ["drone", "fighter", "cargo"]
@@ -79,7 +79,7 @@ class ResourcesViewFull(StatsView):
return "Resources"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
width, height = self.parent.GetTextExtent(text)
return width
def populatePanel(self, contentPanel, headerPanel):
@@ -99,54 +99,52 @@ class ResourcesViewFull(StatsView):
self.headerPanel = headerPanel
panel = "full"
base = sizerResources
sizer.AddSpacer((0, 0), 1, wx.EXPAND, 5)
#Turrets & launcher hardslots display
tooltipText = {"turret":"Turret hardpoints", "launcher":"Launcher hardpoints", "drones":"Drones active", "fighter": "Fighter squadrons active", "calibration":"Calibration"}
for type in ("turret", "launcher", "drones", "fighter", "calibration"):
# Turrets & launcher hardslots display
tooltipText = {"turret": "Turret hardpoints", "launcher": "Launcher hardpoints", "drones": "Drones active", "fighter": "Fighter squadrons active", "calibration": "Calibration"}
for type_ in ("turret", "launcher", "drones", "fighter", "calibration"):
box = wx.BoxSizer(wx.HORIZONTAL)
bitmap = BitmapLoader.getStaticBitmap("%s_big" % type, parent, "gui")
tooltip = wx.ToolTip(tooltipText[type])
tooltip = wx.ToolTip(tooltipText[type_])
bitmap.SetToolTip(tooltip)
box.Add(bitmap, 0, wx.ALIGN_CENTER)
sizer.Add(box, 0, wx.ALIGN_CENTER)
suffix = {'turret':'Hardpoints', 'launcher':'Hardpoints', 'drones':'Active', 'fighter':'Tubes', 'calibration':'Points'}
suffix = {'turret': 'Hardpoints', 'launcher': 'Hardpoints', 'drones': 'Active', 'fighter': 'Tubes', 'calibration': 'Points'}
lbl = wx.StaticText(parent, wx.ID_ANY, "0")
setattr(self, "label%sUsed%s%s" % (panel.capitalize(), type.capitalize(), suffix[type].capitalize()), lbl)
setattr(self, "label%sUsed%s%s" % (panel.capitalize(), type_.capitalize(), suffix[type_].capitalize()), lbl)
box.Add(lbl, 0, wx.ALIGN_CENTER | wx.LEFT, 5)
box.Add(wx.StaticText(parent, wx.ID_ANY, "/"), 0, wx.ALIGN_CENTER)
lbl = wx.StaticText(parent, wx.ID_ANY, "0")
setattr(self, "label%sTotal%s%s" % (panel.capitalize(), type.capitalize(), suffix[type].capitalize()), lbl)
setattr(self, "label%sTotal%s%s" % (panel.capitalize(), type_.capitalize(), suffix[type_].capitalize()), lbl)
box.Add(lbl, 0, wx.ALIGN_CENTER)
setattr(self, "boxSizer{}".format(type.capitalize()), box)
setattr(self, "boxSizer{}".format(type_.capitalize()), box)
# Hack - We add a spacer after each thing, but we are always hiding something. The spacer is stil there.
# This way, we only have one space after the drones/fighters
if type != "drones":
if type_ != "drones":
sizer.AddSpacer((0, 0), 1, wx.EXPAND, 5)
#PG, Cpu & drone stuff
tooltipText = {"cpu":"CPU", "pg":"PowerGrid", "droneBay":"Drone bay", "fighterBay": "Fighter bay", "droneBandwidth":"Drone bandwidth", "cargoBay":"Cargo bay"}
# PG, Cpu & drone stuff
tooltipText = {"cpu": "CPU", "pg": "PowerGrid", "droneBay": "Drone bay", "fighterBay": "Fighter bay", "droneBandwidth": "Drone bandwidth", "cargoBay": "Cargo bay"}
for i, group in enumerate((("cpu", "pg"), ("cargoBay", "droneBay", "fighterBay", "droneBandwidth"))):
main = wx.BoxSizer(wx.VERTICAL)
base.Add(main, 1 , wx.ALIGN_CENTER)
base.Add(main, 1, wx.ALIGN_CENTER)
for type in group:
capitalizedType = type[0].capitalize() + type[1:]
bitmap = BitmapLoader.getStaticBitmap(type + "_big", parent, "gui")
tooltip = wx.ToolTip(tooltipText[type])
for type_ in group:
capitalizedType = type_[0].capitalize() + type_[1:]
bitmap = BitmapLoader.getStaticBitmap(type_ + "_big", parent, "gui")
tooltip = wx.ToolTip(tooltipText[type_])
bitmap.SetToolTip(tooltip)
stats = wx.BoxSizer(wx.VERTICAL)
absolute = wx.BoxSizer(wx.HORIZONTAL)
absolute = wx.BoxSizer(wx.HORIZONTAL)
stats.Add(absolute, 0, wx.EXPAND)
b = wx.BoxSizer(wx.HORIZONTAL)
@@ -166,8 +164,8 @@ class ResourcesViewFull(StatsView):
setattr(self, "label%sTotal%s" % (panel.capitalize(), capitalizedType), lbl)
absolute.Add(lbl, 0, wx.ALIGN_LEFT)
units = {"cpu":" tf", "pg":" MW", "droneBandwidth":" mbit/s", "droneBay":u" m\u00B3", "fighterBay":u" m\u00B3", "cargoBay":u" m\u00B3"}
lbl = wx.StaticText(parent, wx.ID_ANY, "%s" % units[type])
units = {"cpu": " tf", "pg": " MW", "droneBandwidth": " mbit/s", "droneBay": u" m\u00B3", "fighterBay": u" m\u00B3", "cargoBay": u" m\u00B3"}
lbl = wx.StaticText(parent, wx.ID_ANY, "%s" % units[type_])
absolute.Add(lbl, 0, wx.ALIGN_LEFT)
# Gauges modif. - Darriele
@@ -177,7 +175,7 @@ class ResourcesViewFull(StatsView):
gauge.SetMinSize((self.getTextExtentW("1.999M/1.99M MW"), 23))
gauge.SetFractionDigits(2)
setattr(self, "gauge%s%s" % (panel.capitalize(),capitalizedType), gauge)
setattr(self, "gauge%s%s" % (panel.capitalize(), capitalizedType), gauge)
stats.Add(gauge, 0, wx.ALIGN_CENTER)
setattr(self, "base%s%s" % (panel.capitalize(), capitalizedType), b)
@@ -186,30 +184,32 @@ class ResourcesViewFull(StatsView):
self.toggleContext("drone")
def refreshPanel(self, fit):
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
# If we did anything intresting, we'd update our labels to reflect the new fit's stats here
stats = (("label%sUsedTurretHardpoints", lambda: fit.getHardpointsUsed(Hardpoint.TURRET), 0, 0, 0),
("label%sTotalTurretHardpoints", lambda: fit.ship.getModifiedItemAttr('turretSlotsLeft'), 0, 0, 0),
("label%sUsedLauncherHardpoints", lambda: fit.getHardpointsUsed(Hardpoint.MISSILE), 0, 0, 0),
("label%sTotalLauncherHardpoints", lambda: fit.ship.getModifiedItemAttr('launcherSlotsLeft'), 0, 0, 0),
("label%sUsedDronesActive", lambda: fit.activeDrones, 0, 0, 0),
("label%sTotalDronesActive", lambda: fit.extraAttributes["maxActiveDrones"], 0, 0, 0),
("label%sUsedFighterTubes", lambda: fit.fighterTubesUsed, 3, 0, 9),
("label%sTotalFighterTubes", lambda: fit.ship.getModifiedItemAttr("fighterTubes"), 3, 0, 9),
("label%sUsedCalibrationPoints", lambda: fit.calibrationUsed, 0, 0, 0),
("label%sTotalCalibrationPoints", lambda: fit.ship.getModifiedItemAttr('upgradeCapacity'), 0, 0, 0),
("label%sUsedPg", lambda: fit.pgUsed, 4, 0, 9),
("label%sUsedCpu", lambda: fit.cpuUsed, 4, 0, 9),
("label%sTotalPg", lambda: fit.ship.getModifiedItemAttr("powerOutput"), 4, 0, 9),
("label%sTotalCpu", lambda: fit.ship.getModifiedItemAttr("cpuOutput"), 4, 0, 9),
("label%sUsedDroneBay", lambda: fit.droneBayUsed, 3, 0, 9),
("label%sUsedFighterBay", lambda: fit.fighterBayUsed, 3, 0, 9),
("label%sUsedDroneBandwidth", lambda: fit.droneBandwidthUsed, 3, 0, 9),
("label%sTotalDroneBay", lambda: fit.ship.getModifiedItemAttr("droneCapacity"), 3, 0, 9),
("label%sTotalDroneBandwidth", lambda: fit.ship.getModifiedItemAttr("droneBandwidth"), 3, 0, 9),
("label%sTotalFighterBay", lambda: fit.ship.getModifiedItemAttr("fighterCapacity"), 3, 0, 9),
("label%sUsedCargoBay", lambda: fit.cargoBayUsed, 3, 0, 9),
("label%sTotalCargoBay", lambda: fit.ship.getModifiedItemAttr("capacity"), 3, 0, 9))
stats = (
("label%sUsedTurretHardpoints", lambda: fit.getHardpointsUsed(Hardpoint.TURRET), 0, 0, 0),
("label%sTotalTurretHardpoints", lambda: fit.ship.getModifiedItemAttr('turretSlotsLeft'), 0, 0, 0),
("label%sUsedLauncherHardpoints", lambda: fit.getHardpointsUsed(Hardpoint.MISSILE), 0, 0, 0),
("label%sTotalLauncherHardpoints", lambda: fit.ship.getModifiedItemAttr('launcherSlotsLeft'), 0, 0, 0),
("label%sUsedDronesActive", lambda: fit.activeDrones, 0, 0, 0),
("label%sTotalDronesActive", lambda: fit.extraAttributes["maxActiveDrones"], 0, 0, 0),
("label%sUsedFighterTubes", lambda: fit.fighterTubesUsed, 3, 0, 9),
("label%sTotalFighterTubes", lambda: fit.ship.getModifiedItemAttr("fighterTubes"), 3, 0, 9),
("label%sUsedCalibrationPoints", lambda: fit.calibrationUsed, 0, 0, 0),
("label%sTotalCalibrationPoints", lambda: fit.ship.getModifiedItemAttr('upgradeCapacity'), 0, 0, 0),
("label%sUsedPg", lambda: fit.pgUsed, 4, 0, 9),
("label%sUsedCpu", lambda: fit.cpuUsed, 4, 0, 9),
("label%sTotalPg", lambda: fit.ship.getModifiedItemAttr("powerOutput"), 4, 0, 9),
("label%sTotalCpu", lambda: fit.ship.getModifiedItemAttr("cpuOutput"), 4, 0, 9),
("label%sUsedDroneBay", lambda: fit.droneBayUsed, 3, 0, 9),
("label%sUsedFighterBay", lambda: fit.fighterBayUsed, 3, 0, 9),
("label%sUsedDroneBandwidth", lambda: fit.droneBandwidthUsed, 3, 0, 9),
("label%sTotalDroneBay", lambda: fit.ship.getModifiedItemAttr("droneCapacity"), 3, 0, 9),
("label%sTotalDroneBandwidth", lambda: fit.ship.getModifiedItemAttr("droneBandwidth"), 3, 0, 9),
("label%sTotalFighterBay", lambda: fit.ship.getModifiedItemAttr("fighterCapacity"), 3, 0, 9),
("label%sUsedCargoBay", lambda: fit.cargoBayUsed, 3, 0, 9),
("label%sTotalCargoBay", lambda: fit.ship.getModifiedItemAttr("capacity"), 3, 0, 9),
)
panel = "Full"
usedTurretHardpoints = 0
totalTurretHardpoints = 0
@@ -303,12 +303,14 @@ class ResourcesViewFull(StatsView):
labelTCP.SetForegroundColour(colorC)
if fit is not None:
resMax = (lambda: fit.ship.getModifiedItemAttr("cpuOutput"),
lambda: fit.ship.getModifiedItemAttr("powerOutput"),
lambda: fit.ship.getModifiedItemAttr("droneCapacity"),
lambda: fit.ship.getModifiedItemAttr("fighterCapacity"),
lambda: fit.ship.getModifiedItemAttr("droneBandwidth"),
lambda: fit.ship.getModifiedItemAttr("capacity"))
resMax = (
lambda: fit.ship.getModifiedItemAttr("cpuOutput"),
lambda: fit.ship.getModifiedItemAttr("powerOutput"),
lambda: fit.ship.getModifiedItemAttr("droneCapacity"),
lambda: fit.ship.getModifiedItemAttr("fighterCapacity"),
lambda: fit.ship.getModifiedItemAttr("droneBandwidth"),
lambda: fit.ship.getModifiedItemAttr("capacity"),
)
i = 0
for resourceType in ("cpu", "pg", "droneBay", "fighterBay", "droneBandwidth", "cargoBay"):
@@ -316,11 +318,11 @@ class ResourcesViewFull(StatsView):
capitalizedType = resourceType[0].capitalize() + resourceType[1:]
gauge = getattr(self, "gauge%s%s" % (panel, capitalizedType))
resUsed = getattr(fit,"%sUsed" % resourceType)
resUsed = getattr(fit, "%sUsed" % resourceType)
gauge.SetValueRange(resUsed or 0, resMax[i]() or 0)
i+=1
i += 1
else:
capitalizedType = resourceType[0].capitalize() + resourceType[1:]
@@ -328,9 +330,10 @@ class ResourcesViewFull(StatsView):
gauge.SetValueRange(0, 0)
i+=1
i += 1
self.panel.Layout()
self.headerPanel.Layout()
ResourcesViewFull.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,29 +15,31 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui.utils.numberFormatter import formatAmount
import locale
try:
from collections import OrderedDict
except ImportError:
from utils.compat import OrderedDict
class TargetingMiscViewFull(StatsView):
name = "targetingmiscViewFull"
def __init__(self, parent):
StatsView.__init__(self)
self.parent = parent
self._cachedValues = []
def getHeaderText(self, fit):
return "Targeting && Misc"
def getTextExtentW(self, text):
width, height = self.parent.GetTextExtent( text )
width, height = self.parent.GetTextExtent(text)
return width
def populatePanel(self, contentPanel, headerPanel):
@@ -46,7 +48,7 @@ class TargetingMiscViewFull(StatsView):
self.panel = contentPanel
self.headerPanel = headerPanel
gridTargetingMisc = wx.FlexGridSizer(1, 3)
contentSizer.Add( gridTargetingMisc, 0, wx.EXPAND | wx.ALL, 0)
contentSizer.Add(gridTargetingMisc, 0, wx.EXPAND | wx.ALL, 0)
gridTargetingMisc.AddGrowableCol(0)
gridTargetingMisc.AddGrowableCol(2)
# Targeting
@@ -68,17 +70,17 @@ class TargetingMiscViewFull(StatsView):
box = wx.BoxSizer(wx.HORIZONTAL)
gridTargeting.Add(box, 0, wx.ALIGN_LEFT)
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0 %s" %unit)
lbl = wx.StaticText(contentPanel, wx.ID_ANY, "0 %s" % unit)
setattr(self, "label%s" % labelShort, lbl)
box.Add(lbl, 0, wx.ALIGN_LEFT)
self._cachedValues.append({"main": 0})
# Misc
gridTargetingMisc.Add( wx.StaticLine( contentPanel, wx.ID_ANY, style = wx.VERTICAL),0, wx.EXPAND, 3 )
gridTargetingMisc.Add(wx.StaticLine(contentPanel, wx.ID_ANY, style=wx.VERTICAL), 0, wx.EXPAND, 3)
gridMisc = wx.FlexGridSizer(5, 2)
gridMisc.AddGrowableCol(1)
gridTargetingMisc.Add(gridMisc,0 , wx.ALIGN_LEFT | wx.ALL, 5)
gridTargetingMisc.Add(gridMisc, 0, wx.ALIGN_LEFT | wx.ALL, 5)
labels = (("Speed", "Speed", "m/s"),
("Align time", "AlignTime", "s"),
@@ -98,9 +100,8 @@ class TargetingMiscViewFull(StatsView):
self._cachedValues.append({"main": 0})
def refreshPanel(self, fit):
#If we did anything interesting, we'd update our labels to reflect the new fit's stats here
# If we did anything interesting, we'd update our labels to reflect the new fit's stats here
cargoNamesOrder = OrderedDict((
("fleetHangarCapacity", "Fleet hangar"),
@@ -155,9 +156,9 @@ class TargetingMiscViewFull(StatsView):
("labelFullCargo", cargoValues, 4, 0, 9, u"m\u00B3"))
counter = 0
RADII = [("Pod",25), ("Interceptor",33), ("Frigate",38),
RADII = [("Pod", 25), ("Interceptor", 33), ("Frigate", 38),
("Destroyer", 83), ("Cruiser", 130),
("Battlecruiser", 265), ("Battleship",420),
("Battlecruiser", 265), ("Battleship", 420),
("Carrier", 3000)]
for labelName, valueDict, prec, lowest, highest, unit in stats:
label = getattr(self, labelName)
@@ -173,13 +174,13 @@ class TargetingMiscViewFull(StatsView):
# Get sum of all cargoholds except for maintenance bay
additionalCargo = sum(otherValues.values())
if additionalCargo > 0:
label.SetLabel("%s+%s %s" %(formatAmount(mainValue, prec, lowest, highest),
formatAmount(additionalCargo, prec, lowest, highest),
unit))
label.SetLabel("%s+%s %s" % (formatAmount(mainValue, prec, lowest, highest),
formatAmount(additionalCargo, prec, lowest, highest),
unit))
else:
label.SetLabel("%s %s" %(formatAmount(mainValue, prec, lowest, highest), unit))
label.SetLabel("%s %s" % (formatAmount(mainValue, prec, lowest, highest), unit))
else:
label.SetLabel("%s %s" %(formatAmount(mainValue, prec, lowest, highest), unit))
label.SetLabel("%s %s" % (formatAmount(mainValue, prec, lowest, highest), unit))
# Tooltip stuff
if fit:
if labelName == "labelScanRes":
@@ -187,21 +188,21 @@ class TargetingMiscViewFull(StatsView):
for size, radius in RADII:
left = "%.1fs" % fit.calculateLockTime(radius)
right = "%s [%d]" % (size, radius)
lockTime += "%5s\t%s\n" % (left,right)
lockTime += "%5s\t%s\n" % (left, right)
label.SetToolTip(wx.ToolTip(lockTime))
elif labelName == "labelFullSigRadius":
label.SetToolTip(wx.ToolTip("Probe Size: %.3f" % (fit.probeSize or 0) ))
label.SetToolTip(wx.ToolTip("Probe Size: %.3f" % (fit.probeSize or 0)))
elif labelName == "labelFullWarpSpeed":
label.SetToolTip(wx.ToolTip("Max Warp Distance: %.1f AU" % fit.maxWarpDistance))
elif labelName == "labelSensorStr":
if fit.jamChance > 0:
label.SetToolTip(wx.ToolTip("Type: %s\n%.1f%% Chance of Jam" % (fit.scanType, fit.jamChance)))
label.SetToolTip(wx.ToolTip("Type: %s\n%.1f%% Chance of Jam" % (fit.scanType, fit.jamChance)))
else:
label.SetToolTip(wx.ToolTip("Type: %s" % (fit.scanType)))
label.SetToolTip(wx.ToolTip("Type: %s" % (fit.scanType)))
elif labelName == "labelFullAlignTime":
alignTime = "Align:\t%.3fs"%mainValue
alignTime = "Align:\t%.3fs" % mainValue
mass = 'Mass:\t{:,.0f}kg'.format(fit.ship.getModifiedItemAttr("mass"))
agility = "Agility:\t%.3fx"%(fit.ship.getModifiedItemAttr("agility") or 0)
agility = "Agility:\t%.3fx" % (fit.ship.getModifiedItemAttr("agility") or 0)
label.SetToolTip(wx.ToolTip("%s\n%s\n%s" % (alignTime, mass, agility)))
elif labelName == "labelFullCargo":
tipLines = []
@@ -247,4 +248,5 @@ class TargetingMiscViewFull(StatsView):
self.panel.Layout()
self.headerPanel.Layout()
TargetingMiscViewFull.register()

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -16,17 +15,18 @@
#
# 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.mainFrame
import wx
from eos.types import Fighter
from gui.viewColumn import ViewColumn
import gui.mainFrame
class Abilities(ViewColumn):
name = "Fighter Abilities"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
@@ -41,4 +41,5 @@ class Abilities(ViewColumn):
return "None"
return ", ".join(active)
Abilities.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,17 +15,17 @@
#
# 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.bitmapLoader import BitmapLoader
import wx
from eos.types import Fighter
from gui.viewColumn import ViewColumn
from gui.bitmapLoader import BitmapLoader
class Ammo(ViewColumn):
name = "Ammo"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.mask = wx.LIST_MASK_IMAGE
@@ -43,7 +43,7 @@ class Ammo(ViewColumn):
charges = stuff.numCharges
if charges > 0:
cycles = stuff.numShots
if cycles !=0 and charges != cycles:
if cycles != 0 and charges != cycles:
return "%s (%d, %d cycles)" % (stuff.charge.name, charges, cycles)
else:
return "%s (%d)" % (stuff.charge.name, charges)
@@ -54,5 +54,5 @@ class Ammo(ViewColumn):
def getImageId(self, mod):
return -1
Ammo.register()
Ammo.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,16 +15,16 @@
#
# 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.bitmapLoader import BitmapLoader
import wx
from eos.types import Module
class AmmoIcon(ViewColumn):
name = "Ammo Icon"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.size = 24
@@ -52,4 +52,5 @@ class AmmoIcon(ViewColumn):
if isinstance(mod, Module) and mod.charge is not None:
return mod.charge.name
AmmoIcon.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,9 +15,10 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
@@ -25,10 +26,10 @@ from gui.utils.numberFormatter import formatAmount
from service.attribute import Attribute
from service.market import Market
import wx
class AttributeDisplay(ViewColumn):
name = "attr"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
sAttr = Attribute.getInstance()
@@ -60,8 +61,9 @@ class AttributeDisplay(ViewColumn):
self.view = fittingView
originalRefresh = fittingView.refresh
sMkt = Market.getInstance()
#Hack into our master view and add a callback for ourselves to know when to query
def refresh(stuff):
# Hack into our master view and add a callback for ourselves to know when to query
self.directInfo = sMkt.directAttrRequest(stuff, info) if stuff else None
originalRefresh(stuff)
@@ -78,10 +80,10 @@ class AttributeDisplay(ViewColumn):
attr = mod.getAttribute(self.info.name)
if self.info.name == "volume":
str = (formatAmount(attr, 3, 0, 3))
str_ = (formatAmount(attr, 3, 0, 3))
if hasattr(mod, "amount"):
str = str + u"m\u00B3 (%s m\u00B3)"%(formatAmount(attr*mod.amount, 3, 0, 3))
attr = str
str_ = str_ + u"m\u00B3 (%s m\u00B3)" % (formatAmount(attr * mod.amount, 3, 0, 3))
attr = str_
if isinstance(attr, (float, int)):
attr = (formatAmount(attr, 3, 0, 3))
@@ -104,4 +106,5 @@ class AttributeDisplay(ViewColumn):
("showIcon", bool, True),
("direct", bool, False))
AttributeDisplay.register()

View File

@@ -1,11 +1,11 @@
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui.bitmapLoader import BitmapLoader
import wx
from eos.types import Drone, Fit, Module, Slot, Rack, Implant
from gui.viewColumn import ViewColumn
class BaseIcon(ViewColumn):
name = "Base Icon"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.size = 24
@@ -17,16 +17,16 @@ class BaseIcon(ViewColumn):
def getImageId(self, stuff):
if isinstance(stuff, Drone):
return -1
if isinstance(stuff, Fit):
elif isinstance(stuff, Fit):
return self.shipImage
if isinstance(stuff, Rack):
elif isinstance(stuff, Rack):
return -1
if isinstance(stuff, Implant):
elif isinstance(stuff, Implant):
if stuff.character: # if it has a character as it's parent
return self.fittingView.imageList.GetImageIndex("character_small", "gui")
else:
return self.shipImage
if isinstance(stuff, Module):
elif isinstance(stuff, Module):
if stuff.isEmpty:
return self.fittingView.imageList.GetImageIndex("slot_%s_small" % Slot.getName(stuff.slot).lower(), "gui")
else:
@@ -41,4 +41,5 @@ class BaseIcon(ViewColumn):
else:
return -1
BaseIcon.register()

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -16,18 +15,18 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from eos.types import Drone, Cargo, Module, Slot, Rack, Implant, Fighter
from service.fit import Fit
from gui.viewColumn import ViewColumn
import gui.mainFrame
#from eos.saveddata.fit import Fit
from service.fit import Fit
import wx
from eos.types import Drone, Cargo, Module, Slot, Rack, Implant, Fighter
class BaseName(ViewColumn):
name = "Base Name"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
@@ -40,7 +39,7 @@ class BaseName(ViewColumn):
def getText(self, stuff):
if isinstance(stuff, Drone):
return "%dx %s" % (stuff.amount, stuff.item.name)
if isinstance(stuff, Fighter):
elif isinstance(stuff, Fighter):
return "%d/%d %s" % (stuff.amountActive, stuff.getModifiedItemAttr("fighterSquadronMaxSize"), stuff.item.name)
elif isinstance(stuff, Cargo):
return "%dx %s" % (stuff.amount, stuff.item.name)
@@ -74,10 +73,11 @@ class BaseName(ViewColumn):
if marketShortcut:
# use unicode subscript to display shortcut value
shortcut = unichr(marketShortcut+8320)+u" "
shortcut = unichr(marketShortcut + 8320) + u" "
del item.marketShortcut
return shortcut+item.name
return shortcut + item.name
return item.name
BaseName.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,25 +15,26 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from eos.types import Mode
from service.attribute import Attribute
from gui.utils.numberFormatter import formatAmount
from gui.viewColumn import ViewColumn
from gui.bitmapLoader import BitmapLoader
from eos.types import Mode
from service.attribute import Attribute
class CapacitorUse(ViewColumn):
name = "Capacitor Usage"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.mask = wx.LIST_MASK_IMAGE
sAttr = Attribute.getInstance()
info = sAttr.getAttributeInfo("capacitorNeed")
Attribute.getInstance().getAttributeInfo("capacitorNeed")
self.imageId = fittingView.imageList.GetImageIndex("capacitorRecharge_small", "gui")
self.bitmap = BitmapLoader.getBitmap("capacitorRecharge_small", "gui")
@@ -53,4 +54,5 @@ class CapacitorUse(ViewColumn):
def getToolTip(self, mod):
return self.name
CapacitorUse.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,23 +15,24 @@
#
# 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
import wx
from eos.types import Mode
from service.attribute import Attribute
from gui.viewColumn import ViewColumn
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
import wx
from eos.types import Mode
from service.attribute import Attribute
class MaxRange(ViewColumn):
name = "Max Range"
def __init__(self, fittingView, params = None):
if params == None:
params = {"showIcon": True,
"displayName": False}
def __init__(self, fittingView, params=None):
if params is None:
params = {"showIcon": True, "displayName": False}
ViewColumn.__init__(self, fittingView)
sAttr = Attribute.getInstance()
@@ -72,10 +73,10 @@ class MaxRange(ViewColumn):
return -1
def getParameters(self):
return (("displayName", bool, False),
("showIcon", bool, True))
return (("displayName", bool, False), ("showIcon", bool, True))
def getToolTip(self, mod):
return "Optimal + Falloff"
MaxRange.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,24 +15,26 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from service.fit import Fit
from service.market import Market
import gui.mainFrame
from gui.viewColumn import ViewColumn
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from gui.utils.listFormatter import formatList
from service.fit import Fit, Market
import wx
class Miscellanea(ViewColumn):
name = "Miscellanea"
def __init__(self, fittingView, params = None):
if params == None:
params = {"showIcon": True,
"displayName": False}
def __init__(self, fittingView, params=None):
if params is None:
params = {"showIcon": True, "displayName": False}
ViewColumn.__init__(self, fittingView)
if params["showIcon"]:
self.imageId = fittingView.imageList.GetImageIndex("column_misc", "gui")
@@ -47,19 +49,16 @@ class Miscellanea(ViewColumn):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def getText(self, stuff):
text = self.__getData(stuff)[0]
return text
return self.__getData(stuff)[0]
def getToolTip(self, mod):
text = self.__getData(mod)[1]
return text
return self.__getData(mod)[1]
def getImageId(self, mod):
return -1
def getParameters(self):
return (("displayName", bool, False),
("showIcon", bool, True))
return (("displayName", bool, False), ("showIcon", bool, True))
def __getData(self, stuff):
item = stuff.item
@@ -81,10 +80,10 @@ class Miscellanea(ViewColumn):
slots = ("hi", "med", "low")
info = []
for slot in slots:
n = int(stuff.getModifiedItemAttr("%sSlotModifier"%slot))
n = int(stuff.getModifiedItemAttr("%sSlotModifier" % slot))
if n > 0:
info.append("{0}{1}".format(n, slot[0].upper()))
return "+ "+", ".join(info), "Slot Modifiers"
return "+ " + ", ".join(info), "Slot Modifiers"
elif itemGroup == "Energy Neutralizer":
neutAmount = stuff.getModifiedItemAttr("energyNeutralizerAmount")
cycleTime = stuff.cycleTime
@@ -276,7 +275,7 @@ class Miscellanea(ViewColumn):
recalibration = stuff.getModifiedItemAttr("cloakingTargetingDelay")
if recalibration is None:
return "", None
text = "{0}s".format(formatAmount(float(recalibration)/1000, 3, 0, 3))
text = "{0}s".format(formatAmount(float(recalibration) / 1000, 3, 0, 3))
tooltip = "Sensor recalibration time"
return text, tooltip
elif itemGroup == "Remote Armor Repairer":
@@ -487,10 +486,10 @@ class Miscellanea(ViewColumn):
return text, tooltip
elif itemGroup == "Armor Resistance Shift Hardener":
itemArmorResistanceShiftHardenerEM = (1-stuff.getModifiedItemAttr("armorEmDamageResonance"))*100
itemArmorResistanceShiftHardenerTherm = (1-stuff.getModifiedItemAttr("armorThermalDamageResonance")) * 100
itemArmorResistanceShiftHardenerKin = (1-stuff.getModifiedItemAttr("armorKineticDamageResonance")) * 100
itemArmorResistanceShiftHardenerExp = (1-stuff.getModifiedItemAttr("armorExplosiveDamageResonance")) * 100
itemArmorResistanceShiftHardenerEM = (1 - stuff.getModifiedItemAttr("armorEmDamageResonance")) * 100
itemArmorResistanceShiftHardenerTherm = (1 - stuff.getModifiedItemAttr("armorThermalDamageResonance")) * 100
itemArmorResistanceShiftHardenerKin = (1 - stuff.getModifiedItemAttr("armorKineticDamageResonance")) * 100
itemArmorResistanceShiftHardenerExp = (1 - stuff.getModifiedItemAttr("armorExplosiveDamageResonance")) * 100
text = "{0}% | {1}% | {2}% | {3}%".format(
formatAmount(itemArmorResistanceShiftHardenerEM, 3, 0, 3),
@@ -540,4 +539,5 @@ class Miscellanea(ViewColumn):
else:
return "", None
Miscellanea.register()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos, Lucas Thode
#
# This file is part of pyfa.
@@ -15,17 +15,20 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from eos.types import Drone, Cargo
from service.market import Market
from gui.viewColumn import ViewColumn
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from eos.types import Drone, Cargo
import wx
from service.market import Market
class Price(ViewColumn):
name = "Price"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.mask = wx.LIST_MASK_IMAGE
@@ -45,21 +48,22 @@ class Price(ViewColumn):
price = price.price # Set new price variable with what we need
if isinstance(stuff, Drone) or isinstance(stuff, Cargo):
price *= stuff.amount
price *= stuff.amount
return formatAmount(price, 3, 3, 9, currency=True)
def delayedText(self, mod, display, colItem):
sMkt = Market.getInstance()
def callback(item):
price = sMkt.getPriceNow(item.ID)
text = formatAmount(price.price, 3, 3, 9, currency=True) if price.price else ""
if price.failed: text += " (!)"
if price.failed:
text += " (!)"
colItem.SetText(text)
display.SetItem(colItem)
sMkt.waitForPrice(mod.item, callback)
def getImageId(self, mod):
@@ -68,4 +72,5 @@ class Price(ViewColumn):
def getToolTip(self, mod):
return self.name
Price.register()

View File

@@ -1,69 +1,73 @@
#===============================================================================
# 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.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
import wx
class PropertyDisplay(ViewColumn):
name = "prop"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
sAttr = Attribute.getInstance()
attributeSlave = params["attributeSlave"] or params["property"]
# This function can throw an exception if the database isn't sane
# We need to do a sanity check before this runs
info = sAttr.getAttributeInfo(attributeSlave)
self.mask = 0
self.propertyName = params["property"]
self.info = info
if params["showIcon"]:
if info.name == "power":
iconFile = "pg_small"
iconType = "gui"
else:
iconFile = info.icon.iconFile if info.icon else None
iconType = "icons"
if iconFile:
self.imageId = fittingView.imageList.GetImageIndex(iconFile, iconType)
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()
# =============================================================================
# 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.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from service.attribute import Attribute
import wx
class PropertyDisplay(ViewColumn):
name = "prop"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
sAttr = Attribute.getInstance()
attributeSlave = params["attributeSlave"] or params["property"]
# This function can throw an exception if the database isn't sane
# We need to do a sanity check before this runs
info = sAttr.getAttributeInfo(attributeSlave)
self.mask = 0
self.propertyName = params["property"]
self.info = info
if params["showIcon"]:
if info.name == "power":
iconFile = "pg_small"
iconType = "gui"
else:
iconFile = info.icon.iconFile if info.icon else None
iconType = "icons"
if iconFile:
self.imageId = fittingView.imageList.GetImageIndex(iconFile, iconType)
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,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,18 +15,21 @@
#
# 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.bitmapLoader import BitmapLoader
import gui.mainFrame
import wx
from eos.types import Drone, Module, Rack, Fit, Implant
from eos.types import State as State_
from gui.viewColumn import ViewColumn
import gui.mainFrame
class State(ViewColumn):
name = "State"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
@@ -78,4 +81,5 @@ class State(ViewColumn):
return generic_active
return generic_inactive
State.register()

View File

@@ -3,6 +3,7 @@ import gui.globalEvents as GE
import gui.chromeTabs
import gui.mainFrame
class BlankPage(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, size=(0, 0))
@@ -22,8 +23,8 @@ class BlankPage(wx.Panel):
def pageChanged(self, event):
if self.parent.IsActive(self):
fitID = None
# sFit = Fit.getInstance()
# sFit.switchFit(fitID)
# sFit = Fit.getInstance()
# sFit.switchFit(fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
event.Skip()
event.Skip()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import wx.lib.newevent
@@ -36,7 +36,8 @@ from service.market import Market
import gui.globalEvents as GE
#Tab spawning handler
# Tab spawning handler
class FitSpawner(gui.multiSwitch.TabSpawner):
def __init__(self, multiSwitch):
self.multiSwitch = multiSwitch
@@ -86,9 +87,11 @@ class FitSpawner(gui.multiSwitch.TabSpawner):
self.multiSwitch.AddPage(view)
view.handleDrag(type, fitID)
FitSpawner.register()
#Drag'n'drop handler
# Drag'n'drop handler
class FittingViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
@@ -103,6 +106,7 @@ class FittingViewDrop(wx.PyDropTarget):
self.dropFn(x, y, data)
return t
class FittingView(d.Display):
DEFAULT_COLS = ["State",
"Ammo Icon",
@@ -118,7 +122,7 @@ class FittingView(d.Display):
]
def __init__(self, parent):
d.Display.__init__(self, parent, size = (0,0), style = wx.BORDER_NONE)
d.Display.__init__(self, parent, size=(0, 0), style=wx.BORDER_NONE)
self.Show(False)
self.parent = parent
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
@@ -128,7 +132,7 @@ class FittingView(d.Display):
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag)
if "__WXGTK__" in wx.PlatformInfo:
if "__WXGTK__" in wx.PlatformInfo:
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
else:
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
@@ -193,7 +197,7 @@ class FittingView(d.Display):
self.addModule(x, y, int(data[1]))
def handleDrag(self, type, fitID):
#Those are drags coming from pyfa sources, NOT builtin wx drags
# Those are drags coming from pyfa sources, NOT builtin wx drags
if type == "fit":
wx.PostEvent(self.mainFrame, gui.shipBrowser.FitSelected(fitID=fitID))
@@ -223,11 +227,11 @@ class FittingView(d.Display):
if row != -1 and row not in self.blanks:
data = wx.PyTextDataObject()
data.SetText("fitting:"+str(self.mods[row].position))
data.SetText("fitting:" + str(self.mods[row].position))
dropSource = wx.DropSource(self)
dropSource.SetData(data)
res = dropSource.DoDragDrop()
dropSource.DoDragDrop()
def getSelectedMods(self):
sel = []
@@ -238,15 +242,14 @@ class FittingView(d.Display):
return sel
def kbEvent(self,event):
def kbEvent(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_DELETE or keycode == wx.WXK_NUMPAD_DELETE:
row = self.GetFirstSelected()
firstSel = row
while row != -1:
if row not in self.blanks:
self.removeModule(self.mods[row])
self.Select(row,0)
self.Select(row, 0)
row = self.GetNextSelected(row)
event.Skip()
@@ -309,7 +312,7 @@ class FittingView(d.Display):
if self.parent.IsActive(self):
itemID = event.itemID
fitID = self.activeFitID
if fitID != None:
if fitID is not None:
sFit = Fit.getInstance()
if sFit.isAmmo(itemID):
modules = []
@@ -349,7 +352,6 @@ class FittingView(d.Display):
def addModule(self, x, y, srcIdx):
'''Add a module from the market browser'''
mstate = wx.GetMouseState()
dstRow, _ = self.HitTest((x, y))
if dstRow != -1 and dstRow not in self.blanks:
@@ -433,12 +435,12 @@ class FittingView(d.Display):
for i, mod in enumerate(self.mods):
if mod.slot != slotDivider:
slotDivider = mod.slot
self.blanks.append((i, slotDivider)) # where and what
self.blanks.append((i, slotDivider)) # where and what
# second loop modifies self.mods, rewrites self.blanks to represent actual index of blanks
for i, (x, slot) in enumerate(self.blanks):
self.blanks[i] = x+i # modify blanks with actual index
self.mods.insert(x+i, Rack.buildRack(slot))
self.blanks[i] = x + i # modify blanks with actual index
self.mods.insert(x + i, Rack.buildRack(slot))
if fit.mode:
# Modes are special snowflakes and need a little manual loving
@@ -494,13 +496,13 @@ class FittingView(d.Display):
srcContext = "fittingModule"
itemContext = sMkt.getCategoryByItem(mod.item).name
fullContext = (srcContext, itemContext)
if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
if srcContext not in tuple(fCtxt[0] for fCtxt in contexts):
contexts.append(fullContext)
if mod.charge is not None:
srcContext = "fittingCharge"
itemContext = sMkt.getCategoryByItem(mod.charge).name
fullContext = (srcContext, itemContext)
if not srcContext in tuple(fCtxt[0] for fCtxt in contexts):
if srcContext not in tuple(fCtxt[0] for fCtxt in contexts):
contexts.append(fullContext)
selection.append(mod)
@@ -530,7 +532,7 @@ class FittingView(d.Display):
sel = []
curr = self.GetFirstSelected()
while curr != -1 and row not in self.blanks :
while curr != -1 and row not in self.blanks:
sel.append(curr)
curr = self.GetNextSelected(curr)
@@ -611,7 +613,7 @@ class FittingView(d.Display):
try:
self.MakeSnapshot()
except:
pass
pass
def OnShow(self, event):
if event.GetShow():
@@ -624,19 +626,19 @@ class FittingView(d.Display):
def Snapshot(self):
return self.FVsnapshot
def MakeSnapshot(self, maxColumns = 1337):
def MakeSnapshot(self, maxColumns=1337):
if self.FVsnapshot:
del self.FVsnapshot
tbmp = wx.EmptyBitmap(16,16)
tbmp = wx.EmptyBitmap(16, 16)
tdc = wx.MemoryDC()
tdc.SelectObject(tbmp)
font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
tdc.SetFont(font)
columnsWidths = []
for i in xrange(len(self.DEFAULT_COLS)):
for i in range(len(self.DEFAULT_COLS)):
columnsWidths.append(0)
sFit = Fit.getInstance()
@@ -660,25 +662,25 @@ class FittingView(d.Display):
maxWidth = 0
maxRowHeight = isize
rows = 0
for id,st in enumerate(self.mods):
for st in self.mods:
for i, col in enumerate(self.activeColumns):
if i>maxColumns:
if i > maxColumns:
break
name = col.getText(st)
if not isinstance(name, basestring):
name = ""
nx,ny = tdc.GetTextExtent(name)
nx, ny = tdc.GetTextExtent(name)
imgId = col.getImageId(st)
cw = 0
if imgId != -1:
cw += isize + padding
if name != "":
cw += nx + 4*padding
cw += nx + 4 * padding
if imgId == -1 and name == "":
cw += isize +padding
cw += isize + padding
maxRowHeight = max(ny, maxRowHeight)
columnsWidths[i] = max(columnsWidths[i], cw)
@@ -687,7 +689,7 @@ class FittingView(d.Display):
render = wx.RendererNative.Get()
#Fix column widths (use biggest between header or items)
# Fix column widths (use biggest between header or items)
for i, col in enumerate(self.activeColumns):
if i > maxColumns:
@@ -705,26 +707,23 @@ class FittingView(d.Display):
opts.m_labelText = name
if imgId != -1:
opts.m_labelBitmap = wx.EmptyBitmap(isize,isize)
opts.m_labelBitmap = wx.EmptyBitmap(isize, isize)
width = render.DrawHeaderButton(self, tdc, (0, 0, 16, 16),
sortArrow = wx.HDR_SORT_ICON_NONE, params = opts)
width = render.DrawHeaderButton(self, tdc, (0, 0, 16, 16), sortArrow=wx.HDR_SORT_ICON_NONE, params=opts)
columnsWidths[i] = max(columnsWidths[i], width)
tdc.SelectObject(wx.NullBitmap)
maxWidth = padding * 2
for i in xrange(len(self.DEFAULT_COLS)):
for i in range(len(self.DEFAULT_COLS)):
if i > maxColumns:
break
maxWidth += columnsWidths[i]
mdc = wx.MemoryDC()
mbmp = wx.EmptyBitmap(maxWidth, (maxRowHeight) * rows + padding*4 + headerSize)
mbmp = wx.EmptyBitmap(maxWidth, (maxRowHeight) * rows + padding * 4 + headerSize)
mdc.SelectObject(mbmp)
@@ -754,8 +753,8 @@ class FittingView(d.Display):
bmp = col.bitmap
opts.m_labelBitmap = bmp
width = render.DrawHeaderButton (self, mdc, (cx, padding, columnsWidths[i], headerSize), wx.CONTROL_CURRENT,
sortArrow = wx.HDR_SORT_ICON_NONE, params = opts)
width = render.DrawHeaderButton(self, mdc, (cx, padding, columnsWidths[i], headerSize), wx.CONTROL_CURRENT,
sortArrow=wx.HDR_SORT_ICON_NONE, params=opts)
cx += columnsWidths[i]
@@ -765,15 +764,15 @@ class FittingView(d.Display):
mdc.SetPen(pen)
mdc.SetBrush(brush)
cy = padding*2 + headerSize
for id,st in enumerate(self.mods):
cy = padding * 2 + headerSize
for st in self.mods:
cx = padding
if slotMap[st.slot]:
mdc.DrawRectangle(cx,cy,maxWidth - cx,maxRowHeight)
mdc.DrawRectangle(cx, cy, maxWidth - cx, maxRowHeight)
for i, col in enumerate(self.activeColumns):
if i>maxColumns:
if i > maxColumns:
break
name = col.getText(st)
@@ -784,14 +783,14 @@ class FittingView(d.Display):
tcx = cx
if imgId != -1:
self.imageList.Draw(imgId,mdc,cx,cy,wx.IMAGELIST_DRAW_TRANSPARENT,False)
self.imageList.Draw(imgId, mdc, cx, cy, wx.IMAGELIST_DRAW_TRANSPARENT, False)
tcx += isize + padding
if name != "":
nx,ny = mdc.GetTextExtent(name)
nx, ny = mdc.GetTextExtent(name)
rect = wx.Rect()
rect.top = cy
rect.left = cx + 2*padding
rect.left = cx + 2 * padding
rect.width = nx
rect.height = maxRowHeight + padding
mdc.DrawLabel(name, rect, wx.ALIGN_CENTER_VERTICAL)
@@ -803,4 +802,4 @@ class FittingView(d.Display):
mdc.SelectObject(wx.NullBitmap)
self.FVsnapshot = mbmp
self.FVsnapshot = mbmp

View File

@@ -1,139 +1,142 @@
import wx.gizmos
import gui.fleetBrowser
from gui.bitmapLoader import BitmapLoader
#Tab spawning handler
class FleetSpawner(gui.multiSwitch.TabSpawner):
def __init__(self, multiSwitch):
self.multiSwitch = multiSwitch
mainFrame = gui.mainFrame.MainFrame.getInstance()
mainFrame.Bind(gui.fleetBrowser.EVT_FLEET_SELECTED, self.fleetSelected)
def fleetSelected(self, event):
if self.multiSwitch.GetPageCount() == 0:
self.multiSwitch.AddPage(wx.Panel(self.multiSwitch, size = (0,0)), "Empty Tab")
view = FleetView(self.multiSwitch)
self.multiSwitch.ReplaceActivePage(view)
view.populate(event.fleetID)
view.Show()
FleetSpawner.register()
class FleetView(wx.gizmos.TreeListCtrl):
def __init__(self, parent, size = (0,0)):
wx.gizmos.TreeListCtrl.__init__(self, parent, size = size)
self.tabManager = parent
self.fleetId = None
self.fleetImg = BitmapLoader.getImage("53_16", "icons")
self.imageList = wx.ImageList(16, 16)
self.SetImageList(self.imageList)
for col in ("", "Fit", "Shiptype", "Character", "Bonusses"):
self.AddColumn(col)
self.SetMainColumn(1)
self.icons = {}
self.addImage = self.imageList.Add(BitmapLoader.getBitmap("add_small", "gui"))
for icon in ("fb", "fc", "sb", "sc", "wb", "wc"):
self.icons[icon] = self.imageList.Add(BitmapLoader.getBitmap("fleet_%s_small" % icon, "gui"))
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.checkNew)
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.mainFrame.Bind(gui.fleetBrowser.EVT_FLEET_RENAMED, self.fleetRenamed)
self.mainFrame.Bind(gui.fleetBrowser.EVT_FLEET_REMOVED, self.fleetRemoved)
def Destroy(self):
self.mainFrame.Unbind(gui.fleetBrowser.EVT_FLEET_REMOVED, handler = self.fleetRemoved)
self.mainFrame.Unbind(gui.fleetBrowser.EVT_FLEET_RENAMED, handler = self.fleetRenamed)
wx.gizmos.TreeListCtrl.Destroy(self)
def fleetRenamed(self, event):
if event.fleetID == self.fleetId:
sFleet = service.Fleet.getInstance()
f = sFleet.getFleetByID(event.fleetID)
self.UpdateTab(f.name, self.fleetImg)
event.Skip()
def fleetRemoved(self, event):
if event.fleetID == self.fleetId:
self.tabManager.DeletePage(self.tabManager.GetPageIndex(self))
event.Skip()
def checkNew(self, event):
data = self.GetPyData(event.Item)
if data and isinstance(data, tuple) and data[0] == "add":
layer = data[1]
def UpdateTab(self, name, img):
self.tabManager.SetPageTextIcon(self.tabManager.GetSelection(), name, img)
def populate(self, fleetID):
sFleet = service.Fleet.getInstance()
f = sFleet.getFleetByID(fleetID)
self.fleetId = fleetID
self.UpdateTab( f.name, self.fleetImg)
self.fleet = f
self.DeleteAllItems()
root = self.AddRoot("")
self.setEntry(root, f.leader, "fleet", f)
for wing in f.wings:
wingId = self.AppendItem(root, "")
self.setEntry(wingId, wing.leader, "wing", wing)
for squad in wing.squads:
for member in squad.members:
memberId = self.AppendItem(wingId, "")
self.setEntry(memberId, member, "squad", squad)
self.addAdder(wingId, "squad")
self.addAdder(root, "wing")
self.ExpandAll(root)
self.SetColumnWidth(0, 16)
for i in xrange(1, 5):
self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER)
headerWidth = self.GetColumnWidth(i) + 5
self.SetColumnWidth(i, wx.LIST_AUTOSIZE)
baseWidth = self.GetColumnWidth(i)
if baseWidth < headerWidth:
self.SetColumnWidth(i, headerWidth)
else:
self.SetColumnWidth(i, baseWidth)
def addAdder(self, treeItemId, layer):
id = self.AppendItem(treeItemId, "Add new %s" % layer.capitalize())
self.SetPyData(id, ("add", layer))
self.SetItemImage(id, self.addImage, 1)
def setEntry(self, treeItemId, fit, layer, info):
self.SetPyData(treeItemId, info)
if fit is None:
self.SetItemText(treeItemId, "%s Commander" % layer.capitalize(), 1)
else:
fleet = self.fleet
if fit == info.booster:
self.SetItemImage(treeItemId, self.icons["%sb" % layer[0]], 0)
elif fit == info.leader:
self.SetItemImage(treeItemId, self.icons["%sc" % layer[0]], 1)
self.SetItemText(treeItemId, fit.name, 1)
self.SetItemText(treeItemId, fit.ship.item.name, 2)
self.SetItemText(treeItemId, fit.character.name, 3)
boosts = fleet.store.getBoosts(fit)
if boosts:
bonusses = []
for name, info in boosts.iteritems():
bonusses.append("%s: %.2g" % (name, info[0]))
self.SetItemText(treeItemId, ", ".join(bonusses), 3)
import wx.gizmos
import gui.fleetBrowser
from gui.bitmapLoader import BitmapLoader
from service.fleet import Fleet
# Tab spawning handler
class FleetSpawner(gui.multiSwitch.TabSpawner):
def __init__(self, multiSwitch):
self.multiSwitch = multiSwitch
mainFrame = gui.mainFrame.MainFrame.getInstance()
mainFrame.Bind(gui.fleetBrowser.EVT_FLEET_SELECTED, self.fleetSelected)
def fleetSelected(self, event):
if self.multiSwitch.GetPageCount() == 0:
self.multiSwitch.AddPage(wx.Panel(self.multiSwitch, size=(0, 0)), "Empty Tab")
view = FleetView(self.multiSwitch)
self.multiSwitch.ReplaceActivePage(view)
view.populate(event.fleetID)
view.Show()
FleetSpawner.register()
class FleetView(wx.gizmos.TreeListCtrl):
def __init__(self, parent, size=(0, 0)):
wx.gizmos.TreeListCtrl.__init__(self, parent, size=size)
self.tabManager = parent
self.fleetId = None
self.fleetImg = BitmapLoader.getImage("53_16", "icons")
self.imageList = wx.ImageList(16, 16)
self.SetImageList(self.imageList)
for col in ("", "Fit", "Shiptype", "Character", "Bonusses"):
self.AddColumn(col)
self.SetMainColumn(1)
self.icons = {}
self.addImage = self.imageList.Add(BitmapLoader.getBitmap("add_small", "gui"))
for icon in ("fb", "fc", "sb", "sc", "wb", "wc"):
self.icons[icon] = self.imageList.Add(BitmapLoader.getBitmap("fleet_%s_small" % icon, "gui"))
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.checkNew)
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.mainFrame.Bind(gui.fleetBrowser.EVT_FLEET_RENAMED, self.fleetRenamed)
self.mainFrame.Bind(gui.fleetBrowser.EVT_FLEET_REMOVED, self.fleetRemoved)
def Destroy(self):
self.mainFrame.Unbind(gui.fleetBrowser.EVT_FLEET_REMOVED, handler=self.fleetRemoved)
self.mainFrame.Unbind(gui.fleetBrowser.EVT_FLEET_RENAMED, handler=self.fleetRenamed)
wx.gizmos.TreeListCtrl.Destroy(self)
def fleetRenamed(self, event):
if event.fleetID == self.fleetId:
sFleet = Fleet.getInstance()
f = sFleet.getFleetByID(event.fleetID)
self.UpdateTab(f.name, self.fleetImg)
event.Skip()
def fleetRemoved(self, event):
if event.fleetID == self.fleetId:
self.tabManager.DeletePage(self.tabManager.GetPageIndex(self))
event.Skip()
def checkNew(self, event):
data = self.GetPyData(event.Item)
if data and isinstance(data, tuple) and data[0] == "add":
layer = data[1]
def UpdateTab(self, name, img):
self.tabManager.SetPageTextIcon(self.tabManager.GetSelection(), name, img)
def populate(self, fleetID):
sFleet = Fleet.getInstance()
f = sFleet.getFleetByID(fleetID)
self.fleetId = fleetID
self.UpdateTab(f.name, self.fleetImg)
self.fleet = f
self.DeleteAllItems()
root = self.AddRoot("")
self.setEntry(root, f.leader, "fleet", f)
for wing in f.wings:
wingId = self.AppendItem(root, "")
self.setEntry(wingId, wing.leader, "wing", wing)
for squad in wing.squads:
for member in squad.members:
memberId = self.AppendItem(wingId, "")
self.setEntry(memberId, member, "squad", squad)
self.addAdder(wingId, "squad")
self.addAdder(root, "wing")
self.ExpandAll(root)
self.SetColumnWidth(0, 16)
for i in range(1, 5):
self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER)
headerWidth = self.GetColumnWidth(i) + 5
self.SetColumnWidth(i, wx.LIST_AUTOSIZE)
baseWidth = self.GetColumnWidth(i)
if baseWidth < headerWidth:
self.SetColumnWidth(i, headerWidth)
else:
self.SetColumnWidth(i, baseWidth)
def addAdder(self, treeItemId, layer):
id_ = self.AppendItem(treeItemId, "Add new %s" % layer.capitalize())
self.SetPyData(id_, ("add", layer))
self.SetItemImage(id_, self.addImage, 1)
def setEntry(self, treeItemId, fit, layer, info):
self.SetPyData(treeItemId, info)
if fit is None:
self.SetItemText(treeItemId, "%s Commander" % layer.capitalize(), 1)
else:
fleet = self.fleet
if fit == info.booster:
self.SetItemImage(treeItemId, self.icons["%sb" % layer[0]], 0)
elif fit == info.leader:
self.SetItemImage(treeItemId, self.icons["%sc" % layer[0]], 1)
self.SetItemText(treeItemId, fit.name, 1)
self.SetItemText(treeItemId, fit.ship.item.name, 2)
self.SetItemText(treeItemId, fit.character.name, 3)
boosts = fleet.store.getBoosts(fit)
if boosts:
bonusses = []
for name, info in boosts.iteritems():
bonusses.append("%s: %.2g" % (name, info[0]))
self.SetItemText(treeItemId, ", ".join(bonusses), 3)

View File

@@ -1,10 +1,12 @@
import wx
import gui.display as d
from gui.bitmapLoader import BitmapLoader
import gui.PFSearchBox as SBox
from gui.marketBrowser import SearchBox
from wx.lib.buttons import GenBitmapButton
from service.market import Market
import gui.display as d
import gui.PFSearchBox as SBox
from gui.bitmapLoader import BitmapLoader
from gui.marketBrowser import SearchBox
class BaseImplantEditorView (wx.Panel):
def addMarketViewImage(self, iconFile):
@@ -17,7 +19,7 @@ class BaseImplantEditorView (wx.Panel):
return self.availableImplantsImageList.Add(bitmap)
def __init__(self, parent):
wx.Panel.__init__ (self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL)
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL)
self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
pmainSizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -46,25 +48,23 @@ class BaseImplantEditorView (wx.Panel):
availableSizer.Add(self.availableImplantsTree, 1, wx.EXPAND)
pmainSizer.Add(availableSizer, 1, wx.ALL | wx.EXPAND, 5)
buttonSizer = wx.BoxSizer(wx.VERTICAL)
buttonSizer.AddSpacer(( 0, 0), 1)
buttonSizer.AddSpacer((0, 0), 1)
self.btnAdd = GenBitmapButton(self, wx.ID_ADD, BitmapLoader.getBitmap("fit_add_small", "gui"), style = wx.BORDER_NONE)
self.btnAdd = GenBitmapButton(self, wx.ID_ADD, BitmapLoader.getBitmap("fit_add_small", "gui"), style=wx.BORDER_NONE)
buttonSizer.Add(self.btnAdd, 0)
self.btnRemove = GenBitmapButton(self, wx.ID_REMOVE, BitmapLoader.getBitmap("fit_delete_small", "gui"), style = wx.BORDER_NONE)
self.btnRemove = GenBitmapButton(self, wx.ID_REMOVE, BitmapLoader.getBitmap("fit_delete_small", "gui"), style=wx.BORDER_NONE)
buttonSizer.Add(self.btnRemove, 0)
buttonSizer.AddSpacer(( 0, 0), 1)
buttonSizer.AddSpacer((0, 0), 1)
pmainSizer.Add(buttonSizer, 0, wx.EXPAND, 0)
characterImplantSizer = wx.BoxSizer(wx.VERTICAL)
self.pluggedImplantsTree = AvailableImplantsView(self)
characterImplantSizer.Add(self.pluggedImplantsTree, 1, wx.ALL|wx.EXPAND, 5)
characterImplantSizer.Add(self.pluggedImplantsTree, 1, wx.ALL | wx.EXPAND, 5)
pmainSizer.Add(characterImplantSizer, 1, wx.EXPAND, 5)
self.SetSizer(pmainSizer)
@@ -80,13 +80,13 @@ class BaseImplantEditorView (wx.Panel):
self.availableImplantsTree.SortChildren(self.availableRoot)
#Bind the event to replace dummies by real data
# Bind the event to replace dummies by real data
self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.expandLookup)
self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.itemSelected)
self.itemView.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.itemSelected)
#Bind add & remove buttons
# Bind add & remove buttons
self.btnAdd.Bind(wx.EVT_BUTTON, self.itemSelected)
self.btnRemove.Bind(wx.EVT_BUTTON, self.removeItem)
@@ -136,7 +136,7 @@ class BaseImplantEditorView (wx.Panel):
# if the dummy item is a market group, replace with actual market groups
if text == "dummy":
#Add 'real stoof!' instead
# Add 'real stoof!' instead
currentMktGrp = sMkt.getMarketGroup(tree.GetPyData(parent), eager="children")
for childMktGrp in sMkt.getMarketGroupChildren(currentMktGrp):
iconId = self.addMarketViewImage(sMkt.getIconByMarketGroup(childMktGrp))
@@ -194,6 +194,7 @@ class BaseImplantEditorView (wx.Panel):
self.removeImplantFromContext(self.implants[pos])
self.update()
class AvailableImplantsView(d.Display):
DEFAULT_COLS = ["attr:implantness",
"Base Icon",
@@ -203,6 +204,7 @@ class AvailableImplantsView(d.Display):
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL)
self.Bind(wx.EVT_LEFT_DCLICK, parent.removeItem)
class ItemView(d.Display):
DEFAULT_COLS = ["Base Icon",
"Base Name",
@@ -255,4 +257,4 @@ class ItemView(d.Display):
self.items = sorted(list(items), key=lambda i: i.name)
self.update(self.items)
self.update(self.items)

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,21 +15,23 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.bitmapLoader import BitmapLoader
class CachingImageList(wx.ImageList):
def __init__(self, width, height):
wx.ImageList.__init__(self, width, height)
self.map = {}
def GetImageIndex(self, *loaderArgs):
id = self.map.get(loaderArgs)
if id is None:
id_ = self.map.get(loaderArgs)
if id_ is None:
bitmap = BitmapLoader.getBitmap(*loaderArgs)
if bitmap is None:
return -1
id = self.map[loaderArgs] = wx.ImageList.Add(self,bitmap)
return id
id_ = self.map[loaderArgs] = wx.ImageList.Add(self, bitmap)
return id_

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,17 +15,17 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.display as d
import gui.marketBrowser as mb
from gui.builtinViewColumns.state import State
from gui.contextMenu import ContextMenu
import globalEvents as GE
from service.fit import Fit
from service.market import Market
class CargoViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
@@ -40,6 +40,7 @@ class CargoViewDrop(wx.PyDropTarget):
self.dropFn(x, y, data)
return t
# @todo: Was copied form another class and modified. Look through entire file, refine
class CargoView(d.Display):
DEFAULT_COLS = ["Base Icon",
@@ -59,7 +60,7 @@ class CargoView(d.Display):
self.SetDropTarget(CargoViewDrop(self.handleListDrag))
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag)
if "__WXGTK__" in wx.PlatformInfo:
if "__WXGTK__" in wx.PlatformInfo:
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
else:
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
@@ -85,13 +86,13 @@ class CargoView(d.Display):
if row != -1:
data = wx.PyTextDataObject()
data.SetText("cargo:"+str(row))
data.SetText("cargo:" + str(row))
dropSource = wx.DropSource(self)
dropSource.SetData(data)
res = dropSource.DoDragDrop()
dropSource.DoDragDrop()
def kbEvent(self,event):
def kbEvent(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_DELETE or keycode == wx.WXK_NUMPAD_DELETE:
fitID = self.mainFrame.getActiveFit()
@@ -112,16 +113,16 @@ class CargoView(d.Display):
# Gather module information to get position
module = fit.modules[modIdx]
if dstRow != -1: # we're swapping with cargo
if mstate.CmdDown(): # if copying, append to cargo
if dstRow != -1: # we're swapping with cargo
if mstate.CmdDown(): # if copying, append to cargo
sFit.addCargo(self.mainFrame.getActiveFit(), module.item.ID)
else: # else, move / swap
else: # else, move / swap
sFit.moveCargoToModule(self.mainFrame.getActiveFit(), module.position, dstRow)
else: # dragging to blank spot, append
else: # dragging to blank spot, append
sFit.addCargo(self.mainFrame.getActiveFit(), module.item.ID)
if not mstate.CmdDown(): # if not copying, remove module
sFit.removeModule(self.mainFrame.getActiveFit(), module.position)
if not mstate.CmdDown(): # if not copying, remove module
sFit.removeModule(self.mainFrame.getActiveFit(), module.position)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
@@ -131,7 +132,7 @@ class CargoView(d.Display):
self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)
#Clear list and get out if current fitId is None
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
@@ -140,7 +141,8 @@ class CargoView(d.Display):
self.original = fit.cargo if fit is not None else None
self.cargo = stuff = fit.cargo if fit is not None else None
if stuff is not None: stuff.sort(key=lambda cargo: cargo.itemID)
if stuff is not None:
stuff.sort(key=lambda cargo: cargo.itemID)
if event.fitID != self.lastFitId:
self.lastFitId = event.fitID

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.bitmapLoader import BitmapLoader
@@ -24,6 +24,7 @@ import gui.mainFrame
from service.character import Character
from service.fit import Fit
class CharacterSelection(wx.Panel):
def __init__(self, parent):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
@@ -43,9 +44,9 @@ class CharacterSelection(wx.Panel):
self.refreshCharacterList()
self.cleanSkills = BitmapLoader.getBitmap("skill_big", "gui")
self.redSkills = BitmapLoader.getBitmap("skillRed_big", "gui")
self.redSkills = BitmapLoader.getBitmap("skillRed_big", "gui")
self.greenSkills = BitmapLoader.getBitmap("skillGreen_big", "gui")
self.refresh = BitmapLoader.getBitmap("refresh", "gui")
self.refresh = BitmapLoader.getBitmap("refresh", "gui")
self.btnRefresh = wx.BitmapButton(self, wx.ID_ANY, self.refresh)
size = self.btnRefresh.GetSize()
@@ -67,7 +68,7 @@ class CharacterSelection(wx.Panel):
self.mainFrame.Bind(GE.CHAR_LIST_UPDATED, self.refreshCharacterList)
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
self.SetMinSize(wx.Size(25,-1))
self.SetMinSize(wx.Size(25, -1))
self.charChoice.Enable(False)
@@ -138,16 +139,16 @@ class CharacterSelection(wx.Panel):
def selectChar(self, charID):
choice = self.charChoice
numItems = len(choice.GetItems())
for i in xrange(numItems):
id = choice.GetClientData(i)
if id == charID:
for i in range(numItems):
id_ = choice.GetClientData(i)
if id_ == charID:
choice.SetSelection(i)
return True
return False
def fitChanged(self, event):
self.charChoice.Enable(event.fitID != None)
self.charChoice.Enable(event.fitID is not None)
choice = self.charChoice
sFit = Fit.getInstance()
currCharID = choice.GetClientData(choice.GetCurrentSelection())
@@ -159,23 +160,23 @@ class CharacterSelection(wx.Panel):
else:
sCharacter = Character.getInstance()
reqs = sCharacter.checkRequirements(fit)
sCharacter.skillReqsDict = {'charname':fit.character.name, 'skills':[]}
sCharacter.skillReqsDict = {'charname': fit.character.name, 'skills': []}
if len(reqs) == 0:
tip = "All skill prerequisites have been met"
self.skillReqsStaticBitmap.SetBitmap(self.greenSkills)
else:
tip = "Skills required:\n"
tip = "Skills required:\n"
condensed = sFit.serviceFittingOptions["compactSkills"]
if condensed:
dict = self._buildSkillsTooltipCondensed(reqs, skillsMap = {})
for key in sorted(dict):
tip += "%s: %d\n" % (key, dict[key])
dict_ = self._buildSkillsTooltipCondensed(reqs, skillsMap={})
for key in sorted(dict_):
tip += "%s: %d\n" % (key, dict_[key])
else:
tip += self._buildSkillsTooltip(reqs)
self.skillReqsStaticBitmap.SetBitmap(self.redSkills)
self.skillReqsStaticBitmap.SetToolTipString(tip.strip())
if newCharID == None:
if newCharID is None:
sChar = Character.getInstance()
self.selectChar(sChar.all5ID())
@@ -183,10 +184,9 @@ class CharacterSelection(wx.Panel):
self.selectChar(newCharID)
self.charChanged(None)
event.Skip()
def _buildSkillsTooltip(self, reqs, currItem = "", tabulationLevel = 0):
def _buildSkillsTooltip(self, reqs, currItem="", tabulationLevel=0):
tip = ""
sCharacter = Character.getInstance()
@@ -198,11 +198,11 @@ class CharacterSelection(wx.Panel):
for name, info in reqs.iteritems():
level, ID, more = info
sCharacter.skillReqsDict['skills'].append({
'item' : currItem,
'skillID' : ID,
'skill' : name,
'level' : level,
'indent' : tabulationLevel
'item': currItem,
'skillID': ID,
'skill': name,
'level': level,
'indent': tabulationLevel,
})
tip += "%s%s: %d\n" % (" " * tabulationLevel, name, level)
@@ -210,7 +210,10 @@ class CharacterSelection(wx.Panel):
return tip
def _buildSkillsTooltipCondensed(self, reqs, currItem = "", tabulationLevel = 0, skillsMap = {}):
def _buildSkillsTooltipCondensed(self, reqs, currItem="", tabulationLevel=0, skillsMap=None):
if skillsMap is None:
skillsMap = {}
sCharacter = Character.getInstance()
if tabulationLevel == 0:
@@ -221,11 +224,11 @@ class CharacterSelection(wx.Panel):
for name, info in reqs.iteritems():
level, ID, more = info
sCharacter.skillReqsDict['skills'].append({
'item' : currItem,
'skillID' : ID,
'skill' : name,
'level' : level,
'indent' : tabulationLevel
'item': currItem,
'skillID': ID,
'skill': name,
'level': level,
'indent': tabulationLevel,
})
if name not in skillsMap:
@@ -233,6 +236,6 @@ class CharacterSelection(wx.Panel):
elif skillsMap[name] < level:
skillsMap[name] = level
skillMap = self._buildSkillsTooltipCondensed(more, currItem, tabulationLevel + 1, skillsMap)
skillsMap = self._buildSkillsTooltipCondensed(more, currItem, tabulationLevel + 1, skillsMap)
return skillsMap

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Darriele
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import wx.lib.newevent
@@ -23,7 +23,6 @@ import gui.utils.colorUtils as colorUtils
import gui.utils.drawUtils as drawUtils
import gui.utils.fonts as fonts
from gui.bitmapLoader import BitmapLoader
import gui.utils.fonts as fonts
from service.fit import Fit
@@ -35,6 +34,7 @@ _PageClosing, EVT_NOTEBOOK_PAGE_CLOSING = wx.lib.newevent.NewEvent()
PageAdded, EVT_NOTEBOOK_PAGE_ADDED = wx.lib.newevent.NewEvent()
PageClosed, EVT_NOTEBOOK_PAGE_CLOSED = wx.lib.newevent.NewEvent()
class VetoAble():
def __init__(self):
self.__vetoed = False
@@ -92,7 +92,6 @@ class PageAdding(_PageAdding, VetoAble):
class PFNotebook(wx.Panel):
def __init__(self, parent, canAdd=True):
"""
Instance of Pyfa Notebook. Initializes general layout, includes methods
@@ -101,8 +100,8 @@ class PFNotebook(wx.Panel):
parent - wx parent element
canAdd - True if tabs be deleted and added, passed directly to
PFTabsContainer
"""
wx.Panel.__init__(self, parent, wx.ID_ANY, size=(-1, -1))
self.pages = []
@@ -235,7 +234,7 @@ class PFNotebook(wx.Panel):
try:
# Set page to the first non-disabled page
self.SetSelection(next(i for i, _ in enumerate(self.pages) if not self.tabsContainer.tabs[i].disabled))
except StopIteration, ex:
except StopIteration:
self.SetSelection(0)
self.tabsContainer.DisableTab(idx, toggle)
@@ -338,7 +337,7 @@ class PFNotebook(wx.Panel):
class PFTabRenderer:
def __init__(self, size=(36, 24), text=wx.EmptyString, img=None, inclination=6 , closeButton=True):
def __init__(self, size=(36, 24), text=wx.EmptyString, img=None, inclination=6, closeButton=True):
"""
Renders a new tab
@@ -433,7 +432,7 @@ class PFTabRenderer:
mdc.SelectObject(ebmp)
mdc.SetFont(self.font)
textSizeX, textSizeY = mdc.GetTextExtent(self.text)
totalSize = self.leftWidth + self.rightWidth + textSizeX + self.closeBtnWidth/2 + 16 + self.padding*2
totalSize = self.leftWidth + self.rightWidth + textSizeX + self.closeBtnWidth / 2 + 16 + self.padding * 2
mdc.SelectObject(wx.NullBitmap)
return totalSize, self.tabHeight
@@ -498,7 +497,7 @@ class PFTabRenderer:
mdc = wx.MemoryDC()
mdc.SelectObject(bkbmp)
#mdc.SetBackground(wx.Brush((0x12, 0x23, 0x32)))
# mdc.SetBackground(wx.Brush((0x12, 0x23, 0x32)))
mdc.Clear()
mdc.DrawBitmap(self.ctabLeftBmp, 0, 0) # set the left bitmap
@@ -507,14 +506,14 @@ class PFTabRenderer:
cm = self.ctabMiddleBmp.ConvertToImage()
mimg = cm.Scale(self.contentWidth, self.ctabMiddle.GetHeight(), wx.IMAGE_QUALITY_NORMAL)
mbmp = wx.BitmapFromImage(mimg)
mdc.DrawBitmap(mbmp, self.leftWidth, 0 ) # set middle bitmap, offset by left
mdc.DrawBitmap(mbmp, self.leftWidth, 0) # set middle bitmap, offset by left
# set right bitmap offset by left + middle
mdc.DrawBitmap(self.ctabRightBmp, self.contentWidth + self.leftWidth, 0)
mdc.SelectObject(wx.NullBitmap)
#bkbmp.SetMaskColour((0x12, 0x23, 0x32))
# bkbmp.SetMaskColour((0x12, 0x23, 0x32))
if self.tabBackBitmap:
del self.tabBackBitmap
@@ -528,7 +527,7 @@ class PFTabRenderer:
"""
self.tabRegion = wx.RegionFromBitmap(self.tabBackBitmap)
self.closeBtnRegion = wx.RegionFromBitmap(self.ctabCloseBmp)
self.closeBtnRegion.Offset(self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth()/2, (self.tabHeight - self.ctabCloseBmp.GetHeight())/2)
self.closeBtnRegion.Offset(self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2, (self.tabHeight - self.ctabCloseBmp.GetHeight()) / 2)
def InitColors(self):
"""Determines colors used for tab, based on system settings"""
@@ -546,33 +545,33 @@ class PFTabRenderer:
height = self.tabHeight
#rect = wx.Rect(0, 0, self.tabWidth, self.tabHeight)
# rect = wx.Rect(0, 0, self.tabWidth, self.tabHeight)
canvas = wx.EmptyBitmap(self.tabWidth, self.tabHeight, 24)
mdc = wx.MemoryDC()
mdc.SelectObject(canvas)
#mdc.SetBackground(wx.Brush ((0x12,0x23,0x32)))
# mdc.SetBackground(wx.Brush ((0x12,0x23,0x32)))
mdc.Clear()
#r = copy.copy(rect)
#r.top = r.left = 0
#r.height = height
# r = copy.copy(rect)
# r.top = r.left = 0
# r.height = height
mdc.DrawBitmap(self.tabBackBitmap, 0, 0, True)
if self.tabImg:
bmp = wx.BitmapFromImage(self.tabImg.ConvertToGreyscale() if self.disabled else self.tabImg)
if self.contentWidth > 16: # @todo: is this conditional relevant anymore?
# Draw tab icon
mdc.DrawBitmap(bmp, self.leftWidth + self.padding - bmp.GetWidth()/2, (height - bmp.GetHeight())/2)
textStart = self.leftWidth + self.padding + bmp.GetWidth()/2
mdc.DrawBitmap(bmp, self.leftWidth + self.padding - bmp.GetWidth() / 2, (height - bmp.GetHeight()) / 2)
textStart = self.leftWidth + self.padding + bmp.GetWidth() / 2
else:
textStart = self.leftWidth
mdc.SetFont(self.font)
maxsize = self.tabWidth - textStart - self.rightWidth - self.padding*4
maxsize = self.tabWidth - textStart - self.rightWidth - self.padding * 4
color = self.selectedColor if self.selected else self.inactiveColor
mdc.SetTextForeground(colorUtils.GetSuitableColor(color, 1))
@@ -590,9 +589,10 @@ class PFTabRenderer:
cbmp = wx.BitmapFromImage(cimg)
mdc.DrawBitmap(
cbmp,
self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth()/2,
(height - self.ctabCloseBmp.GetHeight())/2)
cbmp,
self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2,
(height - self.ctabCloseBmp.GetHeight()) / 2,
)
mdc.SelectObject(wx.NullBitmap)
@@ -610,6 +610,7 @@ class PFTabRenderer:
self.text, self.disabled, hex(id(self))
)
class PFAddRenderer:
def __init__(self):
"""Renders the add tab button"""
@@ -629,7 +630,7 @@ class PFAddRenderer:
def GetPosition(self):
return self.position
def SetPosition(self,pos):
def SetPosition(self, pos):
self.position = pos
def GetSize(self):
@@ -690,7 +691,7 @@ class PFTabsContainer(wx.Panel):
"""
wx.Panel.__init__(self, parent, id, pos, size)
if wx.VERSION >= (3,0):
if wx.VERSION >= (3, 0):
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
self.tabs = []
@@ -866,7 +867,8 @@ class PFTabsContainer(wx.Panel):
return True
if self.TabHitTest(tab, x, y):
if tab.disabled: return
if tab.disabled:
return
tab.SetSelected(True)
oldSelTab.SetSelected(False)
@@ -943,7 +945,7 @@ class PFTabsContainer(wx.Panel):
closeBtnReg = tab.GetCloseButtonRegion()
tabPos = tab.GetPosition()
tabPosX, tabPosY = tabPos
closeBtnReg.Offset(tabPosX,tabPosY)
closeBtnReg.Offset(tabPosX, tabPosY)
if closeBtnReg.Contains(x, y):
if not tab.GetCloseButtonHoverStatus():
@@ -986,7 +988,6 @@ class PFTabsContainer(wx.Panel):
def GetTabAtRight(self, tabIndex):
return self.tabs[tabIndex + 1] if tabIndex < self.GetTabsCount() - 1 else None
def SwitchTabs(self, src, dest, draggedTab=None):
self.tabs[src], self.tabs[dest] = self.tabs[dest], self.tabs[src]
self.UpdateTabsPosition(draggedTab)
@@ -1111,14 +1112,12 @@ class PFTabsContainer(wx.Panel):
def OnPaint(self, event):
if "wxGTK" in wx.PlatformInfo:
mdc = wx.AutoBufferedPaintDC(self)
else:
rect = self.GetRect()
mdc = wx.BufferedPaintDC(self)
selected = 0
if 'wxMac' in wx.PlatformInfo and wx.VERSION < (3,0):
if 'wxMac' in wx.PlatformInfo and wx.VERSION < (3, 0):
color = wx.Colour(0, 0, 0)
brush = wx.Brush(color)
@@ -1129,7 +1128,7 @@ class PFTabsContainer(wx.Panel):
brush = wx.Brush(color)
if "wxGTK" not in wx.PlatformInfo:
mdc.SetBackground (brush)
mdc.SetBackground(brush)
mdc.Clear()
selected = None
@@ -1137,21 +1136,18 @@ class PFTabsContainer(wx.Panel):
tabsWidth = 0
for tab in self.tabs:
tabsWidth += tab.tabWidth - self.inclination*2
pos = tabsWidth
tabsWidth += tab.tabWidth - self.inclination * 2
if self.showAddButton:
ax,ay = self.addButton.GetPosition()
ax, ay = self.addButton.GetPosition()
mdc.DrawBitmap(self.addButton.Render(), ax, ay, True)
for i in xrange(len(self.tabs) - 1, -1, -1):
for i in range(len(self.tabs) - 1, -1, -1):
tab = self.tabs[i]
width = tab.tabWidth - 6
posx, posy = tab.GetPosition()
if not tab.IsSelected():
mdc.DrawBitmap(self.efxBmp, posx, posy, True )
mdc.DrawBitmap(self.efxBmp, posx, posy, True)
bmp = tab.Render()
img = bmp.ConvertToImage()
img = img.AdjustChannels(1, 1, 1, 0.85)
@@ -1266,13 +1262,13 @@ class PFTabsContainer(wx.Panel):
def UpdateTabsPosition(self, skipTab=None):
tabsWidth = 0
for tab in self.tabs:
tabsWidth += tab.tabWidth - self.inclination*2
tabsWidth += tab.tabWidth - self.inclination * 2
pos = tabsWidth
selected = None
for i in xrange(len(self.tabs) - 1, -1, -1):
for i in range(len(self.tabs) - 1, -1, -1):
tab = self.tabs[i]
width = tab.tabWidth - self.inclination*2
width = tab.tabWidth - self.inclination * 2
pos -= width
if not tab.IsSelected():
tab.SetPosition((pos, self.containerHeight - self.height))
@@ -1281,7 +1277,7 @@ class PFTabsContainer(wx.Panel):
selpos = pos
if selected is not skipTab:
selected.SetPosition((selpos, self.containerHeight - self.height))
self.addButton.SetPosition((round(tabsWidth) + self.inclination*2, self.containerHeight - self.height/2 - self.addButton.GetHeight()/3))
self.addButton.SetPosition((round(tabsWidth) + self.inclination * 2, self.containerHeight - self.height / 2 - self.addButton.GetHeight() / 3))
def OnLeaveWindow(self, event):
@@ -1306,17 +1302,15 @@ class PFTabsContainer(wx.Panel):
if not self.previewTab.GetSelected():
page = self.Parent.GetPage(self.GetTabIndex(self.previewTab))
if page.Snapshot():
self.previewWnd = PFNotebookPagePreview(self, (mposx+3, mposy+3), page.Snapshot(), self.previewTab.text)
self.previewWnd = PFNotebookPagePreview(self, (mposx + 3, mposy + 3), page.Snapshot(), self.previewTab.text)
self.previewWnd.Show()
event.Skip()
class PFNotebookPagePreview(wx.Frame):
def __init__ (self,parent, pos, bitmap, title):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=pos, size=wx.DefaultSize, style=
wx.NO_BORDER
| wx.FRAME_NO_TASKBAR
| wx.STAY_ON_TOP)
def __init__(self, parent, pos, bitmap, title):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=pos, size=wx.DefaultSize, style=wx.NO_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP)
self.title = title
self.bitmap = bitmap
@@ -1343,13 +1337,13 @@ class PFNotebookPagePreview(wx.Frame):
else:
width = bitmap.GetWidth()
self.SetSize((width, bitmap.GetHeight()+16))
self.SetSize((width, bitmap.GetHeight() + 16))
self.SetTransparent(0)
self.Refresh()
def OnTimer(self, event):
self.transp += 20*self.direction
self.transp += 20 * self.direction
if self.transp > 220:
self.transp = 220
@@ -1358,7 +1352,7 @@ class PFNotebookPagePreview(wx.Frame):
if self.transp < 0:
self.transp = 0
self.timer.Stop()
wx.Frame.Show(self,False)
wx.Frame.Show(self, False)
self.Destroy()
return
self.SetTransparent(self.transp)
@@ -1382,8 +1376,7 @@ class PFNotebookPagePreview(wx.Frame):
self.direction = -1
self.timer.Start(10)
def OnWindowEraseBk(self,event):
def OnWindowEraseBk(self, event):
pass
def OnWindowPaint(self, event):
@@ -1395,17 +1388,17 @@ class PFNotebookPagePreview(wx.Frame):
mdc.SetBackground(wx.Brush(color))
mdc.Clear()
font = wx.Font(fonts.NORMAL, wx.SWISS, wx.NORMAL,wx.NORMAL, False)
font = wx.Font(fonts.NORMAL, wx.SWISS, wx.NORMAL, wx.NORMAL, False)
mdc.SetFont(font)
x,y = mdc.GetTextExtent(self.title)
x, y = mdc.GetTextExtent(self.title)
mdc.SetBrush(wx.Brush(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)))
mdc.DrawRectangle(0, 0, rect.width, 16)
mdc.SetTextForeground(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
mdc.DrawText(self.title, (rect.width - x)/2, (16 - y)/2)
mdc.DrawText(self.title, (rect.width - x) / 2, (16 - y) / 2)
mdc.DrawBitmap(self.bitmap, 0, 16)

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.display as d
@@ -34,29 +34,32 @@ class DummyItem:
self.name = txt
self.icon = None
class DummyEntry:
def __init__(self, txt):
self.item = DummyItem(txt)
class CommandViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID
self.dropData = wx.PyTextDataObject()
self.SetDataObject(self.dropData)
def OnData(self, x, y, t):
if self.GetData():
data = self.dropData.GetText().split(':')
self.dropFn(x, y, data)
return t
class CommandViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID
self.dropData = wx.PyTextDataObject()
self.SetDataObject(self.dropData)
def OnData(self, x, y, t):
if self.GetData():
data = self.dropData.GetText().split(':')
self.dropFn(x, y, data)
return t
class CommandView(d.Display):
DEFAULT_COLS = ["Base Name",]
DEFAULT_COLS = ["Base Name"]
def __init__(self, parent):
d.Display.__init__(self, parent, style = wx.LC_SINGLE_SEL | wx.BORDER_NONE)
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL | wx.BORDER_NONE)
self.lastFitId = None
@@ -68,7 +71,7 @@ class CommandView(d.Display):
self.droneView = gui.droneView.DroneView
if "__WXGTK__" in wx.PlatformInfo:
if "__WXGTK__" in wx.PlatformInfo:
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
else:
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
@@ -86,7 +89,7 @@ class CommandView(d.Display):
'''
pass
def kbEvent(self,event):
def kbEvent(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_DELETE or keycode == wx.WXK_NUMPAD_DELETE:
fitID = self.mainFrame.getActiveFit()
@@ -97,7 +100,7 @@ class CommandView(d.Display):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
def handleDrag(self, type, fitID):
#Those are drags coming from pyfa sources, NOT builtin wx drags
# Those are drags coming from pyfa sources, NOT builtin wx drags
if type == "fit":
activeFit = self.mainFrame.getActiveFit()
if activeFit:
@@ -110,7 +113,7 @@ class CommandView(d.Display):
row = event.GetIndex()
if row != -1 and isinstance(self.get(row), es_Drone):
data = wx.PyTextDataObject()
data.SetText("command:"+str(self.GetItemData(row)))
data.SetText("command:" + str(self.GetItemData(row)))
dropSource = wx.DropSource(self)
dropSource.SetData(data)
@@ -125,7 +128,7 @@ class CommandView(d.Display):
self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)
#Clear list and get out if current fitId is None
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
@@ -184,11 +187,11 @@ class CommandView(d.Display):
menu = None
if sel != -1:
item = self.get(sel)
if item is None: return
sMkt = Market.getInstance()
if item is None:
return
fitSrcContext = "commandFit"
fitItemContext = item.name
context = ((fitSrcContext,fitItemContext),)
context = ((fitSrcContext, fitItemContext),)
context = context + (("command",),)
menu = ContextMenu.getMenu((item,), *context)
elif sel == -1:

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,16 +15,18 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import logging
logger = logging.getLogger(__name__)
class ContextMenu(object):
menus = []
_ids = [] #[wx.NewId() for x in xrange(200)] # init with decent amount
_ids = [] # [wx.NewId() for x in xrange(200)] # init with decent amount
_idxid = -1
@classmethod
@@ -175,4 +177,4 @@ class ContextMenu(object):
return None
from gui.builtinContextMenus import *
from gui.builtinContextMenus import * # noqa

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Lucas Thode
#
# This file is part of pyfa.
@@ -15,11 +15,12 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
class CopySelectDialog(wx.Dialog):
copyFormatEft = 0
copyFormatEftImps = 1
@@ -29,7 +30,7 @@ class CopySelectDialog(wx.Dialog):
copyFormatMultiBuy = 5
def __init__(self, parent):
wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Select a format", size = (-1,-1), style = wx.DEFAULT_DIALOG_STYLE)
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"Select a format", size=(-1, -1), style=wx.DEFAULT_DIALOG_STYLE)
mainSizer = wx.BoxSizer(wx.VERTICAL)
copyFormats = [u"EFT", u"EFT (Implants)", u"XML", u"DNA", u"CREST", u"MultiBuy"]
@@ -39,7 +40,7 @@ class CopySelectDialog(wx.Dialog):
CopySelectDialog.copyFormatDna: u"A one-line text format",
CopySelectDialog.copyFormatCrest: u"A JSON format used for EVE CREST",
CopySelectDialog.copyFormatMultiBuy: u"MultiBuy text format"}
selector = wx.RadioBox(self, wx.ID_ANY, label = u"Copy to the clipboard using:", choices = copyFormats, style = wx.RA_SPECIFY_ROWS)
selector = wx.RadioBox(self, wx.ID_ANY, label=u"Copy to the clipboard using:", choices=copyFormats, style=wx.RA_SPECIFY_ROWS)
selector.Bind(wx.EVT_RADIOBOX, self.Selected)
for format, tooltip in copyFormatTooltips.iteritems():
selector.SetItemToolTip(format, tooltip)
@@ -47,21 +48,18 @@ class CopySelectDialog(wx.Dialog):
self.copyFormat = CopySelectDialog.copyFormatEft
selector.SetSelection(self.copyFormat)
mainSizer.Add(selector,0,wx.EXPAND | wx.ALL, 5)
mainSizer.Add(selector, 0, wx.EXPAND | wx.ALL, 5)
buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
if (buttonSizer):
mainSizer.Add(buttonSizer,0, wx.EXPAND | wx.ALL, 5)
mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.ALL, 5)
self.SetSizer(mainSizer)
self.Fit()
self.Center()
def Selected(self, event):
self.copyFormat = event.GetSelection()
def GetSelected(self):
return self.copyFormat

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,19 +15,19 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import sys
import wx
import gui.mainFrame
from gui.viewColumn import ViewColumn
from gui.cachingImageList import CachingImageList
class Display(wx.ListCtrl):
def __init__(self, parent, size = wx.DefaultSize, style = 0):
wx.ListCtrl.__init__(self, parent,size = size, style=wx.LC_REPORT | style )
class Display(wx.ListCtrl):
def __init__(self, parent, size=wx.DefaultSize, style=0):
wx.ListCtrl.__init__(self, parent, size=size, style=wx.LC_REPORT | style)
self.imageList = CachingImageList(16, 16)
self.SetImageList(self.imageList, wx.IMAGE_LIST_SMALL)
self.activeColumns = []
@@ -110,15 +110,14 @@ class Display(wx.ListCtrl):
return (rowIndex, 0, -1)
def OnEraseBk(self,event):
if self.GetItemCount() >0:
def OnEraseBk(self, event):
if self.GetItemCount() > 0:
width, height = self.GetClientSize()
dc = event.GetDC()
dc.DestroyClippingRegion()
dc.SetClippingRegion(0, 0, width, height)
x,y,w,h = dc.GetClippingBox()
x, y, w, h = dc.GetClippingBox()
topItem = self.GetTopItem()
bottomItem = topItem + self.GetCountPerPage()
@@ -129,10 +128,9 @@ class Display(wx.ListCtrl):
topRect = self.GetItemRect(topItem, wx.LIST_RECT_LABEL)
bottomRect = self.GetItemRect(bottomItem, wx.LIST_RECT_BOUNDS)
items_rect = wx.Rect(topRect.left, 0, bottomRect.right - topRect.left, bottomRect.bottom)
items_rect = wx.Rect(topRect.left, 0, bottomRect.right - topRect.left, bottomRect.bottom )
updateRegion = wx.Region(x,y,w,h)
updateRegion = wx.Region(x, y, w, h)
updateRegion.SubtractRect(items_rect)
dc.DestroyClippingRegion()
@@ -171,41 +169,37 @@ class Display(wx.ListCtrl):
# we veto header cell resize by default till we find a way
# to assure a minimal size for the resized header cell
column = event.GetColumn()
wx.CallAfter(self.checkColumnSize,column)
wx.CallAfter(self.checkColumnSize, column)
event.Skip()
def resizeSkip(self, event):
column = event.GetColumn()
if column > len (self.activeColumns)-1:
if column > len(self.activeColumns) - 1:
self.SetColumnWidth(column, 0)
event.Veto()
return
colItem = self.activeColumns[column]
# colItem = self.activeColumns[column]
if self.activeColumns[column].maxsize != -1:
event.Veto()
else:
event.Skip()
def checkColumnSize(self,column):
def checkColumnSize(self, column):
colItem = self.activeColumns[column]
if self.GetColumnWidth(column) < self.columnsMinWidth[column]:
self.SetColumnWidth(column,self.columnsMinWidth[column])
self.SetColumnWidth(column, self.columnsMinWidth[column])
colItem.resized = True
def getLastItem( self, state = wx.LIST_STATE_DONTCARE):
lastFound = -1
while True:
index = self.GetNextItem(
lastFound,
wx.LIST_NEXT_ALL,
state,
)
if index == -1:
break
else:
lastFound = index
def getLastItem(self, state=wx.LIST_STATE_DONTCARE):
lastFound = -1
while True:
index = self.GetNextItem(lastFound, wx.LIST_NEXT_ALL, state)
if index == -1:
break
else:
lastFound = index
return lastFound
return lastFound
def deselectItems(self):
sel = self.GetFirstSelected()
@@ -220,26 +214,25 @@ class Display(wx.ListCtrl):
stuffItemCount = len(stuff)
if listItemCount < stuffItemCount:
for i in xrange(stuffItemCount - listItemCount):
index = self.InsertStringItem(sys.maxint, "")
for i in range(stuffItemCount - listItemCount):
self.InsertStringItem(sys.maxint, "")
if listItemCount > stuffItemCount:
if listItemCount - stuffItemCount > 20 and stuffItemCount < 20:
self.DeleteAllItems()
for i in xrange(stuffItemCount):
index = self.InsertStringItem(sys.maxint, "")
for i in range(stuffItemCount):
self.InsertStringItem(sys.maxint, "")
else:
for i in xrange(listItemCount - stuffItemCount):
for i in range(listItemCount - stuffItemCount):
self.DeleteItem(self.getLastItem())
self.Refresh()
def refresh(self, stuff):
if stuff == None:
if stuff is None:
return
item = -1
for id, st in enumerate(stuff):
for id_, st in enumerate(stuff):
item = self.GetNextItem(item)
@@ -270,11 +263,11 @@ class Display(wx.ListCtrl):
colItem.SetMask(mask)
self.SetItem(colItem)
self.SetItemData(item, id)
self.SetItemData(item, id_)
# self.Freeze()
# self.Freeze()
if 'wxMSW' in wx.PlatformInfo:
for i,col in enumerate(self.activeColumns):
for i, col in enumerate(self.activeColumns):
if not col.resized:
self.SetColumnWidth(i, col.size)
else:
@@ -289,9 +282,7 @@ class Display(wx.ListCtrl):
self.SetColumnWidth(i, headerWidth)
else:
self.SetColumnWidth(i, col.size)
# self.Thaw()
# self.Thaw()
def update(self, stuff):
self.populate(stuff)

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
@@ -27,29 +27,33 @@ from gui.contextMenu import ContextMenu
from service.fit import Fit
from service.market import Market
class DroneViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID
self.dropData = wx.PyTextDataObject()
self.SetDataObject(self.dropData)
def OnData(self, x, y, t):
if self.GetData():
data = self.dropData.GetText().split(':')
self.dropFn(x, y, data)
return t
class DroneViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID
self.dropData = wx.PyTextDataObject()
self.SetDataObject(self.dropData)
def OnData(self, x, y, t):
if self.GetData():
data = self.dropData.GetText().split(':')
self.dropFn(x, y, data)
return t
class DroneView(d.Display):
DEFAULT_COLS = ["State",
#"Base Icon",
"Base Name",
# "prop:droneDps,droneBandwidth",
"Max Range",
"Miscellanea",
"attr:maxVelocity",
"Price",]
DEFAULT_COLS = [
"State",
# "Base Icon",
"Base Name",
# "prop:droneDps,droneBandwidth",
"Max Range",
"Miscellanea",
"attr:maxVelocity",
"Price",
]
def __init__(self, parent):
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL | wx.BORDER_NONE)
@@ -67,12 +71,11 @@ class DroneView(d.Display):
self.Bind(wx.EVT_MOTION, self.OnMouseMove)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
if "__WXGTK__" in wx.PlatformInfo:
if "__WXGTK__" in wx.PlatformInfo:
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
else:
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag)
self.SetDropTarget(DroneViewDrop(self.handleDragDrop))
@@ -108,7 +111,6 @@ class DroneView(d.Display):
keycode = event.GetKeyCode()
if keycode == wx.WXK_DELETE or keycode == wx.WXK_NUMPAD_DELETE:
row = self.GetFirstSelected()
firstSel = row
if row != -1:
drone = self.drones[self.GetItemData(row)]
self.removeDrone(drone)
@@ -119,11 +121,11 @@ class DroneView(d.Display):
row = event.GetIndex()
if row != -1:
data = wx.PyTextDataObject()
data.SetText("drone:"+str(row))
data.SetText("drone:" + str(row))
dropSource = wx.DropSource(self)
dropSource.SetData(data)
res = dropSource.DoDragDrop()
dropSource.DoDragDrop()
def handleDragDrop(self, x, y, data):
'''
@@ -151,6 +153,7 @@ class DroneView(d.Display):
'Heavy Attack Drones', 'Sentry Drones', 'Fighters',
'Fighter Bombers', 'Combat Utility Drones',
'Electronic Warfare Drones', 'Logistic Drones', 'Mining Drones', 'Salvage Drones')
def droneKey(self, drone):
sMkt = Market.getInstance()
@@ -165,7 +168,7 @@ class DroneView(d.Display):
self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)
#Clear list and get out if current fitId is None
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
@@ -178,7 +181,6 @@ class DroneView(d.Display):
if stuff is not None:
stuff.sort(key=self.droneKey)
if event.fitID != self.lastFitId:
self.lastFitId = event.fitID
@@ -192,7 +194,6 @@ class DroneView(d.Display):
self.update(stuff)
event.Skip()
def addItem(self, event):
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx

View File

@@ -1,23 +1,18 @@
import wx
import copy
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
from gui.PFListPane import PFListPane
import service.fleet
from gui.utils.drawUtils import GetPartialText
from wx.lib.buttons import GenBitmapButton
import service.fleet
import gui.mainFrame
import gui.utils.colorUtils as colorUtils
import gui.utils.drawUtils as drawUtils
import gui.sfBrowserItem as SFItem
from gui.bitmapLoader import BitmapLoader
from gui.PFListPane import PFListPane
from gui.utils.drawUtils import GetPartialText
FleetSelected, EVT_FLEET_SELECTED = wx.lib.newevent.NewEvent()
FleetRenamed, EVT_FLEET_RENAMED = wx.lib.newevent.NewEvent()
FleetRemoved, EVT_FLEET_REMOVED = wx.lib.newevent.NewEvent()
FleetItemSelect, EVT_FLEET_ITEM_SELECT = wx.lib.newevent.NewEvent()
FleetItemDelete, EVT_FLEET_ITEM_DELETE = wx.lib.newevent.NewEvent()
FleetItemNew, EVT_FLEET_ITEM_NEW = wx.lib.newevent.NewEvent()
@@ -25,7 +20,6 @@ FleetItemCopy, EVT_FLEET_ITEM_COPY = wx.lib.newevent.NewEvent()
FleetItemRename, EVT_FLEET_ITEM_RENAME = wx.lib.newevent.NewEvent()
class FleetBrowser(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
@@ -38,8 +32,8 @@ class FleetBrowser(wx.Panel):
self.hpane = FleetBrowserHeader(self)
mainSizer.Add(self.hpane, 0, wx.EXPAND)
self.m_sl2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_sl2, 0, wx.EXPAND, 0 )
self.m_sl2 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_sl2, 0, wx.EXPAND, 0)
self.fleetItemContainer = PFFleetItemContainer(self)
@@ -79,7 +73,7 @@ class FleetBrowser(wx.Panel):
fleet = self.sFleet.copyFleetByID(fleetID)
fleetName = fleet.name + " Copy"
self.sFleet.renameFleet(fleet,fleetName)
self.sFleet.renameFleet(fleet, fleetName)
self.fleetIDMustEditName = fleet.ID
self.AddItem(fleet.ID, fleet.name, fleet.count())
@@ -94,27 +88,27 @@ class FleetBrowser(wx.Panel):
newFleetName = event.fleetName
self.sFleet.renameFleet(fleet, newFleetName)
wx.PostEvent(self.mainFrame, FleetRenamed(fleetID = fleet.ID))
wx.PostEvent(self.mainFrame, FleetRenamed(fleetID=fleet.ID))
def DeleteFleetItem(self, event):
self.sFleet.deleteFleetByID(event.fleetID)
self.PopulateFleetList()
wx.PostEvent(self.mainFrame, FleetRemoved(fleetID = event.fleetID))
wx.PostEvent(self.mainFrame, FleetRemoved(fleetID=event.fleetID))
def AddItem (self, ID, name, count):
def AddItem(self, ID, name, count):
self.fleetItemContainer.AddWidget(FleetItem(self, ID, name, count))
widget = self.fleetItemContainer.GetWidgetByFleetID(ID)
self.fleetItemContainer.RefreshList(True)
self.fleetItemContainer.ScrollChildIntoView(widget)
wx.PostEvent(self, FleetItemSelect(fleetID = ID))
wx.PostEvent(self, FleetItemSelect(fleetID=ID))
def PopulateFleetList(self):
self.Freeze()
filter = self.filter
filter_ = self.filter
self.fleetItemContainer.RemoveAllChildren()
fleetList = self.sFleet.getFleetList()
for fleetID, fleetName, fleetCount in fleetList:
if fleetName.lower().find(filter.lower()) != -1:
if fleetName.lower().find(filter_.lower()) != -1:
self.fleetItemContainer.AddWidget(FleetItem(self, fleetID, fleetName, fleetCount))
self.fleetItemContainer.RefreshList()
self.Thaw()
@@ -130,34 +124,34 @@ class FleetBrowser(wx.Panel):
event.Skip()
class FleetBrowserHeader (wx.Panel):
class FleetBrowserHeader(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__ (self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(500, 24), style=wx.TAB_TRAVERSAL)
self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ) )
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(500, 24), style=wx.TAB_TRAVERSAL)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
self.newBmp = BitmapLoader.getBitmap("fit_add_small","gui")
bmpSize = (16,16)
self.newBmp = BitmapLoader.getBitmap("fit_add_small", "gui")
bmpSize = (16, 16)
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
if 'wxMac' in wx.PlatformInfo:
bgcolour = wx.Colour(0, 0, 0, 0)
else:
bgcolour = wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE )
bgcolour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
self.fbNewFleet = PFGenBitmapButton( self, wx.ID_ANY, self.newBmp, wx.DefaultPosition, bmpSize, wx.BORDER_NONE )
mainSizer.Add(self.fbNewFleet, 0, wx.LEFT | wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL , 5)
self.fbNewFleet.SetBackgroundColour( bgcolour )
self.fbNewFleet = PFGenBitmapButton(self, wx.ID_ANY, self.newBmp, wx.DefaultPosition, bmpSize, wx.BORDER_NONE)
mainSizer.Add(self.fbNewFleet, 0, wx.LEFT | wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL, 5)
self.fbNewFleet.SetBackgroundColour(bgcolour)
self.sl1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL )
mainSizer.Add( self.sl1, 0, wx.EXPAND |wx.LEFT, 5 )
self.sl1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL)
mainSizer.Add(self.sl1, 0, wx.EXPAND | wx.LEFT, 5)
self.tcFilter = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.tcFilter, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5 )
self.tcFilter = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.tcFilter, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
self.stStatus = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stStatus.Wrap( -1 )
mainSizer.Add( self.stStatus, 1, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5 )
self.stStatus = wx.StaticText(self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0)
self.stStatus.Wrap(-1)
mainSizer.Add(self.stStatus, 1, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
self.SetSizer(mainSizer)
self.Layout()
@@ -178,7 +172,7 @@ class FleetBrowserHeader (wx.Panel):
event.Skip()
def OnNewFleetItem(self, event):
wx.PostEvent(self.Parent, FleetItemNew(fleetName = "New Fleet"))
wx.PostEvent(self.Parent, FleetItemNew(fleetName="New Fleet"))
def fbNewEnterWindow(self, event):
self.stStatus.SetLabel("New fleet")
@@ -195,10 +189,9 @@ class FleetBrowserHeader (wx.Panel):
event.Skip()
class PFFleetItemContainer(PFListPane):
def __init__(self,parent):
PFListPane.__init__(self,parent)
def __init__(self, parent):
PFListPane.__init__(self, parent)
self.selectedWidget = -1
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
@@ -236,7 +229,6 @@ class PFFleetItemContainer(PFListPane):
self.selectedWidget = -1
self._wList.remove(child)
def RemoveAllChildren(self):
for widget in self._wList:
widget.Destroy()
@@ -247,11 +239,12 @@ class PFFleetItemContainer(PFListPane):
def OnLeftUp(self, event):
event.Skip()
class FleetItem(SFItem.SFBrowserItem):
def __init__(self, parent, fleetID, fleetName, fleetCount,
id=wx.ID_ANY, pos=wx.DefaultPosition,
size=(0,40), style=0):
SFItem.SFBrowserItem.__init__(self, parent, size = size)
size=(0, 40), style=0):
SFItem.SFBrowserItem.__init__(self, parent, size=size)
self.fleetBrowser = self.Parent
self.fleetID = fleetID
@@ -260,13 +253,13 @@ class FleetItem(SFItem.SFBrowserItem):
self.padding = 4
self.fontBig = wx.FontFromPixelSize((0,15),wx.SWISS, wx.NORMAL, wx.BOLD, False)
self.fontNormal = wx.FontFromPixelSize((0,14),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontSmall = wx.FontFromPixelSize((0,12),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontBig = wx.FontFromPixelSize((0, 15), wx.SWISS, wx.NORMAL, wx.BOLD, False)
self.fontNormal = wx.FontFromPixelSize((0, 14), wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontSmall = wx.FontFromPixelSize((0, 12), wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.copyBmp = BitmapLoader.getBitmap("fit_add_small", "gui")
self.renameBmp = BitmapLoader.getBitmap("fit_rename_small", "gui")
self.deleteBmp = BitmapLoader.getBitmap("fit_delete_small","gui")
self.deleteBmp = BitmapLoader.getBitmap("fit_delete_small", "gui")
self.acceptBmp = BitmapLoader.getBitmap("faccept_small", "gui")
self.fleetBmp = BitmapLoader.getBitmap("fleet_item_big", "gui")
@@ -284,7 +277,7 @@ class FleetItem(SFItem.SFBrowserItem):
self.toolbar.AddButton(self.deleteBmp, "Delete", self.DeleteFleetCB)
self.editWidth = 150
self.tcFleetName = wx.TextCtrl(self, wx.ID_ANY, "%s" % self.fleetName, wx.DefaultPosition, (self.editWidth,-1), wx.TE_PROCESS_ENTER)
self.tcFleetName = wx.TextCtrl(self, wx.ID_ANY, "%s" % self.fleetName, wx.DefaultPosition, (self.editWidth, -1), wx.TE_PROCESS_ENTER)
if self.fleetBrowser.fleetIDMustEditName != self.fleetID:
self.tcFleetName.Show(False)
@@ -299,21 +292,20 @@ class FleetItem(SFItem.SFBrowserItem):
self.tcFleetName.Bind(wx.EVT_TEXT_ENTER, self.RenameFleet)
self.tcFleetName.Bind(wx.EVT_KEY_DOWN, self.EditCheckEsc)
self.animCount = 0
def MouseLeftUp(self, event):
if self.tcFleetName.IsShown():
self.RestoreEditButton()
else:
wx.PostEvent(self.fleetBrowser, FleetItemSelect(fleetID = self.fleetID))
wx.PostEvent(self.fleetBrowser, FleetItemSelect(fleetID=self.fleetID))
def CopyFleetCB(self):
if self.tcFleetName.IsShown():
self.RestoreEditButton()
return
wx.PostEvent(self.fleetBrowser, FleetItemCopy(fleetID = self.fleetID))
wx.PostEvent(self.fleetBrowser, FleetItemCopy(fleetID=self.fleetID))
def RenameFleetCB(self):
@@ -341,14 +333,14 @@ class FleetItem(SFItem.SFBrowserItem):
self.tcFleetName.Show(False)
wx.PostEvent(self.fleetBrowser, FleetItemRename(fleetID = self.fleetID, fleetName = self.fleetName))
wx.PostEvent(self.fleetBrowser, FleetItemRename(fleetID=self.fleetID, fleetName=self.fleetName))
self.Refresh()
def DeleteFleetCB(self):
if self.tcFleetName.IsShown():
self.RestoreEditButton()
return
wx.PostEvent(self.fleetBrowser, FleetItemDelete(fleetID = self.fleetID))
wx.PostEvent(self.fleetBrowser, FleetItemDelete(fleetID=self.fleetID))
def RestoreEditButton(self):
self.tcFleetName.Show(False)
@@ -392,14 +384,14 @@ class FleetItem(SFItem.SFBrowserItem):
mdc.SetFont(self.fontSmall)
wlabel,hlabel = mdc.GetTextExtent(self.toolbar.hoverLabel)
wlabel, hlabel = mdc.GetTextExtent(self.toolbar.hoverLabel)
self.thoverx = self.toolbarx - self.padding - wlabel
self.thovery = (rect.height - hlabel)/2
self.thovery = (rect.height - hlabel) / 2
self.thoverw = wlabel
def DrawItem(self, mdc):
rect = self.GetRect()
# rect = self.GetRect()
windowColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
textColor = colorUtils.GetSuitableColor(windowColor, 1)
@@ -410,13 +402,13 @@ class FleetItem(SFItem.SFBrowserItem):
self.toolbar.SetPosition((self.toolbarx, self.toolbary))
mdc.DrawBitmap(self.fleetEffBmp, self.fleetBmpx + 3, self.fleetBmpy + 2)
mdc.DrawBitmap(self.fleetBmp, self.fleetBmpx,self.fleetBmpy)
mdc.DrawBitmap(self.fleetBmp, self.fleetBmpx, self.fleetBmpy)
mdc.SetFont(self.fontNormal)
suffix = "%d ships" % self.fleetCount if self.fleetCount >1 else "%d ship" % self.fleetCount if self.fleetCount == 1 else "No ships"
suffix = "%d ships" % self.fleetCount if self.fleetCount > 1 else "%d ship" % self.fleetCount if self.fleetCount == 1 else "No ships"
fleetCount = "Fleet size: %s" % suffix
fleetCount = drawUtils.GetPartialText(mdc, fleetCount, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw)
fleetCount = GetPartialText(mdc, fleetCount, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw)
mdc.DrawText(fleetCount, self.textStartx, self.fleetCounty)
@@ -425,7 +417,7 @@ class FleetItem(SFItem.SFBrowserItem):
mdc.SetFont(self.fontBig)
pfname = drawUtils.GetPartialText(mdc, self.fleetName, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw)
pfname = GetPartialText(mdc, self.fleetName, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw)
mdc.DrawText(pfname, self.textStartx, self.fleetNamey)
if self.tcFleetName.IsShown():
@@ -435,13 +427,13 @@ class FleetItem(SFItem.SFBrowserItem):
fnEditSize = editCtl.GetSize()
wSize = self.GetSize()
fnEditPosX = end
fnEditPosY = (wSize.height - fnEditSize.height)/2
fnEditPosY = (wSize.height - fnEditSize.height) / 2
if fnEditPosX < start:
editCtl.SetSize((self.editWidth + fnEditPosX - start,-1))
editCtl.SetPosition((start,fnEditPosY))
editCtl.SetSize((self.editWidth + fnEditPosX - start, -1))
editCtl.SetPosition((start, fnEditPosY))
else:
editCtl.SetSize((self.editWidth,-1))
editCtl.SetPosition((fnEditPosX,fnEditPosY))
editCtl.SetSize((self.editWidth, -1))
editCtl.SetPosition((fnEditPosX, fnEditPosY))
class PFGenBitmapButton(GenBitmapButton):

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,111 +15,109 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from wx.lib.scrolledpanel import ScrolledPanel
import gui.mainFrame
import gui.shipBrowser
import gui.globalEvents as GE
from service.fit import Fit
from service.fleet import Fleet
from service.character import Character
from service.market import Market
import gui.mainFrame
import gui.shipBrowser
import gui.globalEvents as GE
from gui import characterEditor as CharEditor
class GangView ( ScrolledPanel ):
def __init__( self, parent ):
ScrolledPanel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 100,20 ), style = wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL )
mainSizer = wx.BoxSizer( wx.VERTICAL )
class GangView(ScrolledPanel):
def __init__(self, parent):
ScrolledPanel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(100, 20), style=wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL)
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.draggedFitID = None
help = '''Set fit as booster to display in dropdown, or drag fitting from\nship browser to this window, or right click fit and select booster role.'''
helpSizer = wx.BoxSizer( wx.HORIZONTAL )
self.helpText = wx.StaticText( self, wx.ID_ANY, help, wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
helpSizer.Add( self.helpText, 1, wx.ALL, 5 )
help_msg = '''Set fit as booster to display in dropdown, or drag fitting from\nship browser to this window, or right click fit and select booster role.'''
helpSizer = wx.BoxSizer(wx.HORIZONTAL)
self.helpText = wx.StaticText(self, wx.ID_ANY, help_msg, wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE)
helpSizer.Add(self.helpText, 1, wx.ALL, 5)
self.options = ["Fleet", "Wing", "Squad"]
self.fleet = {}
for id, option in enumerate(self.options):
for id_, option in enumerate(self.options):
# set content for each commander
self.fleet[id] = {}
self.fleet[id]['stLabel'] = wx.StaticText( self, wx.ID_ANY, self.options[id]+':', wx.DefaultPosition, wx.DefaultSize, 0 )
self.fleet[id]['stText'] = wx.StaticText( self, wx.ID_ANY, 'None', wx.DefaultPosition, wx.DefaultSize, 0 )
self.fleet[id]['chFit'] = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [] )
self.fleet[id]['chChar'] = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [] )
self.fleet[id]['fitSizer'] = wx.BoxSizer( wx.VERTICAL )
self.fleet[id_] = {}
self.fleet[id_]['stLabel'] = wx.StaticText(self, wx.ID_ANY, self.options[id_] + ':', wx.DefaultPosition, wx.DefaultSize, 0)
self.fleet[id_]['stText'] = wx.StaticText(self, wx.ID_ANY, 'None', wx.DefaultPosition, wx.DefaultSize, 0)
self.fleet[id_]['chFit'] = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
self.fleet[id_]['chChar'] = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
self.fleet[id_]['fitSizer'] = wx.BoxSizer(wx.VERTICAL)
self.FitDNDPopupMenu = self.buildBoostermenu()
contentFGSizer = wx.FlexGridSizer( 5, 3, 0, 0 )
contentFGSizer.AddGrowableCol( 1 )
contentFGSizer.SetFlexibleDirection( wx.BOTH )
contentFGSizer.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
contentFGSizer = wx.FlexGridSizer(5, 3, 0, 0)
contentFGSizer.AddGrowableCol(1)
contentFGSizer.SetFlexibleDirection(wx.BOTH)
contentFGSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
### Header
self.stBooster = wx.StaticText( self, wx.ID_ANY, u"Booster", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stBooster.Wrap( -1 )
self.stBooster.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString ) )
contentFGSizer.Add( self.stBooster, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5 )
# Header
self.stBooster = wx.StaticText(self, wx.ID_ANY, u"Booster", wx.DefaultPosition, wx.DefaultSize, 0)
self.stBooster.Wrap(-1)
self.stBooster.SetFont(wx.Font(wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString))
contentFGSizer.Add(self.stBooster, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5)
self.stFits = wx.StaticText( self, wx.ID_ANY, u"Fits", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stFits.Wrap( -1 )
self.stFits.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString ) )
contentFGSizer.Add( self.stFits, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
self.stFits = wx.StaticText(self, wx.ID_ANY, u"Fits", wx.DefaultPosition, wx.DefaultSize, 0)
self.stFits.Wrap(-1)
self.stFits.SetFont(wx.Font(wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString))
contentFGSizer.Add(self.stFits, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
self.stCharacters = wx.StaticText( self, wx.ID_ANY, u"Characters", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stCharacters.Wrap( -1 )
self.stCharacters.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString ) )
contentFGSizer.Add( self.stCharacters, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
self.stCharacters = wx.StaticText(self, wx.ID_ANY, u"Characters", wx.DefaultPosition, wx.DefaultSize, 0)
self.stCharacters.Wrap(-1)
self.stCharacters.SetFont(wx.Font(wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString))
contentFGSizer.Add(self.stCharacters, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
contentFGSizer.Add( self.m_staticline2, 0, wx.EXPAND, 5 )
self.m_staticline2 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
contentFGSizer.Add(self.m_staticline2, 0, wx.EXPAND, 5)
self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
contentFGSizer.Add( self.m_staticline3, 0, wx.EXPAND, 5 )
self.m_staticline3 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
contentFGSizer.Add(self.m_staticline3, 0, wx.EXPAND, 5)
self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
contentFGSizer.Add( self.m_staticline4, 0, wx.EXPAND, 5 )
self.m_staticline4 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
contentFGSizer.Add(self.m_staticline4, 0, wx.EXPAND, 5)
### Content
for id in self.fleet:
# Content
for id_ in self.fleet:
# set various properties
self.fleet[id]['stLabel'].Wrap( -1 )
self.fleet[id]['stLabel'].SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString ) )
self.fleet[id]['stText'].Wrap( -1 )
self.fleet[id_]['stLabel'].Wrap(-1)
self.fleet[id_]['stLabel'].SetFont(wx.Font(wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString))
self.fleet[id_]['stText'].Wrap(-1)
# bind text and choice events
self.fleet[id]['stText'].Bind(wx.EVT_LEFT_DCLICK, self.RemoveBooster)
self.fleet[id]['stText'].Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
self.fleet[id]['stText'].Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
self.fleet[id]['stText'].SetToolTip(wx.ToolTip("Double click to remove booster"))
self.fleet[id]['chChar'].Bind(wx.EVT_CHOICE, self.CharChanged)
self.fleet[id]['chFit'].Bind(wx.EVT_CHOICE, self.OnFitChoiceSelected)
self.fleet[id_]['stText'].Bind(wx.EVT_LEFT_DCLICK, self.RemoveBooster)
self.fleet[id_]['stText'].Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
self.fleet[id_]['stText'].Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
self.fleet[id_]['stText'].SetToolTip(wx.ToolTip("Double click to remove booster"))
self.fleet[id_]['chChar'].Bind(wx.EVT_CHOICE, self.CharChanged)
self.fleet[id_]['chFit'].Bind(wx.EVT_CHOICE, self.OnFitChoiceSelected)
# add fit text and choice to the fit sizer
self.fleet[id]['fitSizer'].Add( self.fleet[id]['stText'], 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
self.fleet[id]['fitSizer'].Add( self.fleet[id]['chFit'], 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 1 )
self.fleet[id_]['fitSizer'].Add(self.fleet[id_]['stText'], 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
self.fleet[id_]['fitSizer'].Add(self.fleet[id_]['chFit'], 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL | wx.EXPAND, 1)
# add everything to the content sizer
contentFGSizer.Add( self.fleet[id]['stLabel'], 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
contentFGSizer.Add( self.fleet[id]['fitSizer'], 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
contentFGSizer.Add( self.fleet[id]['chChar'], 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
contentFGSizer.Add(self.fleet[id_]['stLabel'], 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
contentFGSizer.Add(self.fleet[id_]['fitSizer'], 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL | wx.EXPAND, 5)
contentFGSizer.Add(self.fleet[id_]['chChar'], 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
mainSizer.Add( contentFGSizer, 1, wx.EXPAND, 0 )
mainSizer.Add( helpSizer, 0, wx.EXPAND, 0 )
mainSizer.Add(contentFGSizer, 1, wx.EXPAND, 0)
mainSizer.Add(helpSizer, 0, wx.EXPAND, 0)
self.SetSizer( mainSizer )
self.SetSizer(mainSizer)
self.SetAutoLayout(True)
self.SetupScrolling()
@@ -134,7 +132,7 @@ class GangView ( ScrolledPanel ):
def buildBoostermenu(self):
menu = wx.Menu()
for id, option in enumerate(self.options):
for option in self.options:
item = menu.Append(-1, option)
# We bind it to the mainFrame because it may be called from either this class or from FitItem via shipBrowser
self.mainFrame.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item)
@@ -154,11 +152,12 @@ class GangView ( ScrolledPanel ):
''' Change booster character '''
chBooster = event.GetEventObject()
type = -1
for id in self.fleet:
if chBooster == self.fleet[id]['chChar']: type = id
type_ = -1
for id_ in self.fleet:
if chBooster == self.fleet[id_]['chChar']:
type_ = id_
if type == -1:
if type_ == -1:
event.Skip()
return
@@ -169,8 +168,8 @@ class GangView ( ScrolledPanel ):
activeFitID = self.mainFrame.getActiveFit()
fit = sFit.getFit(activeFitID)
sChar = Character.getInstance()
charList = sChar.getCharacterList()
# sChar = Character.getInstance()
# charList = sChar.getCharacterList()
if activeFitID:
commanders = fleetSrv.loadLinearFleet(fit)
@@ -179,21 +178,21 @@ class GangView ( ScrolledPanel ):
else:
fleetCom, wingCom, squadCom = commanders
if type == 0:
if type_ == 0:
if fleetCom:
charID = chBooster.GetClientData(chBooster.GetSelection())
sFit.changeChar(fleetCom.ID, charID)
else:
chBooster.SetSelection(0)
if type == 1:
if type_ == 1:
if wingCom:
charID = chBooster.GetClientData(chBooster.GetSelection())
sFit.changeChar(wingCom.ID, charID)
else:
chBooster.SetSelection(0)
if type == 2:
if type_ == 2:
if squadCom:
charID = chBooster.GetClientData(chBooster.GetSelection())
sFit.changeChar(squadCom.ID, charID)
@@ -208,13 +207,14 @@ class GangView ( ScrolledPanel ):
def RemoveBooster(self, event):
activeFitID = self.mainFrame.getActiveFit()
if not activeFitID:
if not activeFitID:
return
location = event.GetEventObject()
for id in self.fleet:
if location == self.fleet[id]['stText']: type = id
for id_ in self.fleet:
if location == self.fleet[id_]['stText']:
type_ = id_
sFit = Fit.getInstance()
boostee = sFit.getFit(activeFitID)
@@ -222,13 +222,16 @@ class GangView ( ScrolledPanel ):
fleetSrv = Fleet.getInstance()
if type == 0: fleetSrv.setLinearFleetCom(boostee, booster)
if type == 1: fleetSrv.setLinearWingCom(boostee, booster)
if type == 2: fleetSrv.setLinearSquadCom(boostee, booster)
if type_ == 0:
fleetSrv.setLinearFleetCom(boostee, booster)
elif type_ == 1:
fleetSrv.setLinearWingCom(boostee, booster)
elif type_ == 2:
fleetSrv.setLinearSquadCom(boostee, booster)
# Hide stText and, default fit selection, and enable it
location.Hide()
choice = self.fleet[type]['chFit']
choice = self.fleet[type_]['chFit']
choice.SetSelection(0)
choice.Show()
@@ -236,7 +239,7 @@ class GangView ( ScrolledPanel ):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=activeFitID))
def fitRenamed(self, event):
fleetSrv = Fleet.getInstance()
# fleetSrv = Fleet.getInstance()
activeFitID = self.mainFrame.getActiveFit()
if activeFitID:
@@ -259,27 +262,27 @@ class GangView ( ScrolledPanel ):
if activeFitID:
commanders = fleetSrv.loadLinearFleet(fit)
for id in self.fleet:
for id_ in self.fleet:
# try...except here as we're trying 2 different criteria and want to fall back on the same code
try:
commander = commanders[id]
commander = commanders[id_]
if not activeFitID or commander is None:
raise Exception()
self.fleet[id]['stText'].SetLabel(commander.ship.item.name + ": " + commander.name)
self.fleet[id]['chChar'].SetStringSelection(commander.character.name if commander.character is not None else "All 0")
self.fleet[id]['chChar'].Enable()
self.fleet[id]['chFit'].Hide()
self.fleet[id]['stText'].Show()
self.fleet[id_]['stText'].SetLabel(commander.ship.item.name + ": " + commander.name)
self.fleet[id_]['chChar'].SetStringSelection(commander.character.name if commander.character is not None else "All 0")
self.fleet[id_]['chChar'].Enable()
self.fleet[id_]['chFit'].Hide()
self.fleet[id_]['stText'].Show()
except:
#set defaults, disable char selection, and enable fit selection
self.fleet[id]['stText'].SetLabel("None")
self.fleet[id]['chChar'].SetStringSelection("All 0")
self.fleet[id]['chChar'].Disable()
self.fleet[id]['chFit'].SetSelection(0)
self.fleet[id]['chFit'].Show()
self.fleet[id]['stText'].Hide()
# set defaults, disable char selection, and enable fit selection
self.fleet[id_]['stText'].SetLabel("None")
self.fleet[id_]['chChar'].SetStringSelection("All 0")
self.fleet[id_]['chChar'].Disable()
self.fleet[id_]['chFit'].SetSelection(0)
self.fleet[id_]['chFit'].Show()
self.fleet[id_]['stText'].Hide()
if activeFitID:
self.Enable()
@@ -289,7 +292,7 @@ class GangView ( ScrolledPanel ):
self.Layout()
self.SendSizeEvent()
def AddCommander(self, fitID, type = None):
def AddCommander(self, fitID, type=None):
''' Adds booster to a fit, then recalculates active fit '''
if type is None:
return
@@ -303,20 +306,23 @@ class GangView ( ScrolledPanel ):
fleetSrv = Fleet.getInstance()
if type == 0: fleetSrv.setLinearFleetCom(boostee, booster)
if type == 1: fleetSrv.setLinearWingCom(boostee, booster)
if type == 2: fleetSrv.setLinearSquadCom(boostee, booster)
if type == 0:
fleetSrv.setLinearFleetCom(boostee, booster)
elif type == 1:
fleetSrv.setLinearWingCom(boostee, booster)
elif type == 2:
fleetSrv.setLinearSquadCom(boostee, booster)
sFit.recalc(boostee)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=activeFitID))
def RefreshBoosterFits(self, event = None):
def RefreshBoosterFits(self, event=None):
sFit = Fit.getInstance()
sMkt = Market.getInstance()
fitList = sFit.getBoosterFits()
for id in self.fleet:
choice = self.fleet[id]['chFit']
for id_ in self.fleet:
choice = self.fleet[id_]['chFit']
chCurrSelection = choice.GetSelection()
chCurrData = -1
if chCurrSelection != -1:
@@ -326,10 +332,10 @@ class GangView ( ScrolledPanel ):
currSelFound = False
choice.Append("None", -1)
for fit in fitList:
id,name,type = fit
ship = sMkt.getItem(type)
choice.Append(ship.name+': '+name, id)
if chCurrData == id:
fit_id, name, type_ = fit
ship = sMkt.getItem(type_)
choice.Append(ship.name + ': ' + name, fit_id)
if chCurrData == fit_id:
currSelFound = True
if chCurrSelection == -1:
@@ -340,11 +346,11 @@ class GangView ( ScrolledPanel ):
else:
choice.SetSelection(0)
def RefreshCharacterList(self, event = None):
def RefreshCharacterList(self, event=None):
sChar = Character.getInstance()
charList = sChar.getCharacterList()
for id in self.fleet:
choice = self.fleet[id]['chChar']
for id_ in self.fleet:
choice = self.fleet[id_]['chChar']
chCurrSelection = choice.GetSelection()
chCurrData = -1
if chCurrSelection != -1:
@@ -367,7 +373,7 @@ class GangView ( ScrolledPanel ):
def handleDrag(self, type, fitID):
''' Handle dragging of fit to fleet interface '''
#Those are drags coming from pyfa sources, NOT builtin wx drags
# Those are drags coming from pyfa sources, NOT builtin wx drags
self.draggedFitID = None
if type == "fit":
sFit = Fit.getInstance()
@@ -381,18 +387,17 @@ class GangView ( ScrolledPanel ):
self.PopupMenu(self.FitDNDPopupMenu, pos)
def OnPopupItemSelected(self, event):
''' Fired when booster popup item is selected '''
# Get menu selection ID via self.options
menuItem = event.EventObject.FindItemById(event.GetId())
type = self.options.index(menuItem.GetText())
type_ = self.options.index(menuItem.GetText())
if self.draggedFitID:
sFit = Fit.getInstance()
draggedFit = sFit.getFit(self.draggedFitID)
self.AddCommander(draggedFit.ID, type)
self.AddCommander(draggedFit.ID, type_)
self.mainFrame.additionsPane.select("Fleet")
def OnFitChoiceSelected(self, event):
@@ -403,15 +408,16 @@ class GangView ( ScrolledPanel ):
chFit = event.GetEventObject()
fitID = chFit.GetClientData(chFit.GetSelection())
type = -1
for id in self.fleet:
if chFit == self.fleet[id]['chFit']: type = id
type_ = -1
for id_ in self.fleet:
if chFit == self.fleet[id_]['chFit']:
type_ = id_
if type == -1 or fitID == -1:
if type_ == -1 or fitID == -1:
event.Skip()
return
fit = sFit.getFit(fitID)
self.AddCommander(fit.ID, type)
self.AddCommander(fit.ID, type_)
self.mainFrame.additionsPane.select("Fleet")

View File

@@ -1,5 +1,6 @@
import wx.lib.newevent
FitChanged, FIT_CHANGED = wx.lib.newevent.NewEvent()
CharListUpdated, CHAR_LIST_UPDATED = wx.lib.newevent.NewEvent()
CharChanged, CHAR_CHANGED = wx.lib.newevent.NewEvent()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,8 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
class Graph(object):
views = []
@@ -33,4 +34,5 @@ class Graph(object):
def getIcons(self):
return None
from gui.builtinGraphs import *
from gui.builtinGraphs import * # noqa

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,21 +15,24 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import os
import wx
import os
from gui.bitmapLoader import BitmapLoader
import gui.display
import gui.globalEvents as GE
from gui.graph import Graph
import gui.mainFrame
from service.fit import Fit
import gui.display
import gui.mainFrame
import gui.globalEvents as GE
from gui.graph import Graph
from gui.bitmapLoader import BitmapLoader
enabled = True
mplImported = False
class GraphFrame(wx.Frame):
def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.FRAME_FLOAT_ON_PARENT):
@@ -58,11 +61,11 @@ class GraphFrame(wx.Frame):
from matplotlib.figure import Figure
enabled = True
if mpl.__version__[0] != "1":
print "pyfa: Found matplotlib version ",mpl.__version__, " - activating OVER9000 workarounds"
print "pyfa: Recommended minimum matplotlib version is 1.0.0"
print("pyfa: Found matplotlib version ", mpl.__version__, " - activating OVER9000 workarounds")
print("pyfa: Recommended minimum matplotlib version is 1.0.0")
self.legendFix = True
except:
print "Problems importing matplotlib; continuing without graphs"
print("Problems importing matplotlib; continuing without graphs")
enabled = False
return
@@ -91,19 +94,19 @@ class GraphFrame(wx.Frame):
self.figure = Figure(figsize=(4, 3))
rgbtuple = wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ).Get()
clr = [c/255. for c in rgbtuple]
self.figure.set_facecolor( clr )
self.figure.set_edgecolor( clr )
rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get()
clr = [c / 255. for c in rgbtuple]
self.figure.set_facecolor(clr)
self.figure.set_edgecolor(clr)
self.canvas = Canvas(self, -1, self.figure)
self.canvas.SetBackgroundColour( wx.Colour( *rgbtuple ) )
self.canvas.SetBackgroundColour(wx.Colour(*rgbtuple))
self.subplot = self.figure.add_subplot(111)
self.subplot.grid(True)
self.mainSizer.Add(self.canvas, 1, wx.EXPAND)
self.mainSizer.Add(wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ), 0 , wx.EXPAND)
self.mainSizer.Add(wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND)
self.gridPanel = wx.Panel(self)
self.mainSizer.Add(self.gridPanel, 0, wx.EXPAND)
@@ -122,8 +125,8 @@ class GraphFrame(wx.Frame):
self.graphSelection.SetSelection(0)
self.fields = {}
self.select(0)
self.sl1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
self.mainSizer.Add(self.sl1,0, wx.EXPAND)
self.sl1 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
self.mainSizer.Add(self.sl1, 0, wx.EXPAND)
self.mainSizer.Add(self.fitList, 0, wx.EXPAND)
self.fitList.fitList.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
@@ -160,13 +163,13 @@ class GraphFrame(wx.Frame):
self.gridPanel.DestroyChildren()
self.fields.clear()
#Setup textboxes
# Setup textboxes
for field, defaultVal in view.getFields().iteritems():
textBox = wx.TextCtrl(self.gridPanel, wx.ID_ANY, style=0)
self.fields[field] = textBox
textBox.Bind(wx.EVT_TEXT, self.onFieldChanged)
sizer.Add(textBox, 1, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3)
sizer.Add(textBox, 1, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3)
if defaultVal is not None:
if not isinstance(defaultVal, basestring):
defaultVal = ("%f" % defaultVal).rstrip("0")
@@ -204,7 +207,7 @@ class GraphFrame(wx.Frame):
try:
success, status = view.getPoints(fit, values)
if not success:
#TODO: Add a pwetty statys bar to report errors with
# TODO: Add a pwetty statys bar to report errors with
self.SetStatusText(status)
return
@@ -218,15 +221,15 @@ class GraphFrame(wx.Frame):
return
if self.legendFix and len(legend) > 0:
leg = self.subplot.legend(tuple(legend), "upper right" , shadow = False)
leg = self.subplot.legend(tuple(legend), "upper right", shadow=False)
for t in leg.get_texts():
t.set_fontsize('small')
for l in leg.get_lines():
l.set_linewidth(1)
elif not self.legendFix and len(legend) >0:
leg = self.subplot.legend(tuple(legend), "upper right" , shadow = False, frameon = False)
elif not self.legendFix and len(legend) > 0:
leg = self.subplot.legend(tuple(legend), "upper right", shadow=False, frameon=False)
for t in leg.get_texts():
t.set_fontsize('small')
@@ -269,10 +272,10 @@ class FitList(wx.Panel):
fitToolTip = wx.ToolTip("Drag a fit into this list to graph it")
self.fitList.SetToolTip(fitToolTip)
class FitDisplay(gui.display.Display):
DEFAULT_COLS = ["Base Icon",
"Base Name"]
def __init__(self, parent):
gui.display.Display.__init__(self, parent)

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.display as d
@@ -26,20 +26,21 @@ from gui.contextMenu import ContextMenu
import globalEvents as GE
from eos.types import ImplantLocation
from service.fit import Fit
from service.market import Market
class ImplantView(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL )
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL)
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.implantDisplay = ImplantDisplay(self)
mainSizer.Add(self.implantDisplay, 1, wx.EXPAND, 0 )
mainSizer.Add(self.implantDisplay, 1, wx.EXPAND, 0)
radioSizer = wx.BoxSizer(wx.HORIZONTAL)
radioSizer.AddSpacer(( 0, 0), 1, wx.EXPAND, 5)
radioSizer.AddSpacer((0, 0), 1, wx.EXPAND, 5)
self.rbFit = wx.RadioButton(self, id=wx.ID_ANY, label="Use Fit-specific Implants", style=wx.RB_GROUP)
self.rbChar = wx.RadioButton(self, id=wx.ID_ANY, label="Use Character Implants")
radioSizer.Add(self.rbFit, 0, wx.ALL, 5)
@@ -48,7 +49,7 @@ class ImplantView(wx.Panel):
mainSizer.Add(radioSizer, 0, wx.EXPAND, 5)
self.SetSizer( mainSizer )
self.SetSizer(mainSizer)
self.SetAutoLayout(True)
self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioSelect, self.rbFit)
@@ -93,12 +94,12 @@ class ImplantDisplay(d.Display):
self.Bind(wx.EVT_LEFT_DOWN, self.click)
self.Bind(wx.EVT_KEY_UP, self.kbEvent)
if "__WXGTK__" in wx.PlatformInfo:
if "__WXGTK__" in wx.PlatformInfo:
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
else:
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
def kbEvent(self,event):
def kbEvent(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_DELETE or keycode == wx.WXK_NUMPAD_DELETE:
row = self.GetFirstSelected()
@@ -112,7 +113,7 @@ class ImplantDisplay(d.Display):
self.Parent.Parent.Parent.DisablePage(self.Parent, not fit or fit.isStructure)
#Clear list and get out if current fitId is None
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
@@ -121,7 +122,8 @@ class ImplantDisplay(d.Display):
self.original = fit.implants if fit is not None else None
self.implants = stuff = fit.appliedImplants if fit is not None else None
if stuff is not None: stuff.sort(key=lambda implant: implant.slot)
if stuff is not None:
stuff.sort(key=lambda implant: implant.slot)
if event.fitID != self.lastFitId:
self.lastFitId = event.fitID

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,39 +15,32 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import re
import os
import csv
import sys
import subprocess
import wx
import re
import gui.mainFrame
from gui.bitmapLoader import BitmapLoader
import sys
import wx.lib.mixins.listctrl as listmix
import wx.html
from eos.types import Fit, Ship, Citadel, Module, Skill, Booster, Implant, Drone, Mode, Fighter
from gui.utils.numberFormatter import formatAmount
import wx.lib.mixins.listctrl as listmix
import config
from gui.contextMenu import ContextMenu
from gui.utils.numberFormatter import formatAmount
import csv
from eos.types import Fit, Ship, Citadel, Module, Skill, Booster, Implant, Drone, Mode, Fighter
from service.market import Market
from service.attribute import Attribute
import gui.mainFrame
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from gui.contextMenu import ContextMenu
try:
from collections import OrderedDict
except ImportError:
from utils.compat import OrderedDict
class ItemStatsDialog(wx.Dialog):
counter = 0
def __init__(
self,
victim,
fullContext=None,
pos=wx.DefaultPosition,
size=wx.DefaultSize,
maximized = False
):
def __init__(self, victim, fullContext=None, pos=wx.DefaultPosition, size=wx.DefaultSize, maximized=False):
wx.Dialog.__init__(
self,
@@ -56,7 +49,7 @@ class ItemStatsDialog(wx.Dialog):
title="Item stats",
pos=pos,
size=size,
style=wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER| wx.SYSTEM_MENU
style=wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.SYSTEM_MENU
)
empty = getattr(victim, "isEmpty", False)
@@ -78,26 +71,26 @@ class ItemStatsDialog(wx.Dialog):
victim = None
self.context = itmContext
if item.icon is not None:
before,sep,after = item.icon.iconFile.rpartition("_")
iconFile = "%s%s%s" % (before,sep,"0%s" % after if len(after) < 2 else after)
before, sep, after = item.icon.iconFile.rpartition("_")
iconFile = "%s%s%s" % (before, sep, "0%s" % after if len(after) < 2 else after)
itemImg = BitmapLoader.getBitmap(iconFile, "icons")
if itemImg is not None:
self.SetIcon(wx.IconFromBitmap(itemImg))
self.SetTitle("%s: %s%s" % ("%s Stats" % itmContext if itmContext is not None else "Stats", item.name, " (%d)"%item.ID if config.debug else ""))
self.SetTitle("%s: %s%s" % ("%s Stats" % itmContext if itmContext is not None else "Stats", item.name, " (%d)" % item.ID if config.debug else ""))
self.SetMinSize((300, 200))
if "wxGTK" in wx.PlatformInfo: # GTK has huge tab widgets, give it a bit more room
self.SetSize((580, 500))
else:
self.SetSize((550, 500))
#self.SetMaxSize((500, -1))
# self.SetMaxSize((500, -1))
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
self.container = ItemStatsContainer(self, victim, item, itmContext)
self.mainSizer.Add(self.container, 1, wx.EXPAND)
if "wxGTK" in wx.PlatformInfo:
self.closeBtn = wx.Button( self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0 )
self.mainSizer.Add( self.closeBtn, 0, wx.ALL|wx.ALIGN_RIGHT, 5 )
self.closeBtn = wx.Button(self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0)
self.mainSizer.Add(self.closeBtn, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
self.closeBtn.Bind(wx.EVT_BUTTON, self.closeEvent)
self.SetSizer(self.mainSizer)
@@ -113,13 +106,13 @@ class ItemStatsDialog(wx.Dialog):
counter = ItemStatsDialog.counter
dlgStep = 30
if counter * dlgStep > ppos.x+psize.width-dlgsize.x or counter * dlgStep > ppos.y+psize.height-dlgsize.y:
if counter * dlgStep > ppos.x + psize.width - dlgsize.x or counter * dlgStep > ppos.y + psize.height - dlgsize.y:
ItemStatsDialog.counter = 1
dlgx = ppos.x + counter * dlgStep
dlgy = ppos.y + counter * dlgStep
if pos == wx.DefaultPosition:
self.SetPosition((dlgx,dlgy))
self.SetPosition((dlgx, dlgy))
else:
self.SetPosition(pos)
if maximized:
@@ -139,26 +132,22 @@ class ItemStatsDialog(wx.Dialog):
def closeEvent(self, event):
if self.dlgOrder==ItemStatsDialog.counter:
if self.dlgOrder == ItemStatsDialog.counter:
ItemStatsDialog.counter -= 1
self.parentWnd.UnregisterStatsWindow(self)
self.Destroy()
###########################################################################
## Class ItemStatsContainer
###########################################################################
class ItemStatsContainer ( wx.Panel ):
def __init__( self, parent, stuff, item, context = None):
wx.Panel.__init__ ( self, parent )
class ItemStatsContainer(wx.Panel):
def __init__(self, parent, stuff, item, context=None):
wx.Panel.__init__(self, parent)
sMkt = Market.getInstance()
mainSizer = wx.BoxSizer( wx.VERTICAL )
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.nbContainer = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.nbContainer, 1, wx.EXPAND |wx.ALL, 2 )
self.nbContainer = wx.Notebook(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.nbContainer, 1, wx.EXPAND | wx.ALL, 2)
if item.traits is not None:
self.traits = ItemTraits(self.nbContainer, stuff, item)
@@ -189,7 +178,7 @@ class ItemStatsContainer ( wx.Panel ):
self.SetSizer(mainSizer)
self.Layout()
def __del__( self ):
def __del__(self):
pass
def mouseHit(self, event):
@@ -197,54 +186,36 @@ class ItemStatsContainer ( wx.Panel ):
if tab != -1:
self.nbContainer.SetSelection(tab)
###########################################################################
## Class AutoListCtrl
###########################################################################
class AutoListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ListRowHighlighter):
def __init__(self, parent, ID, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
listmix.ListCtrlAutoWidthMixin.__init__(self)
listmix.ListRowHighlighter.__init__(self)
###########################################################################
## Class AutoListCtrl
###########################################################################
class AutoListCtrlNoHighlight(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ListRowHighlighter):
def __init__(self, parent, ID, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
listmix.ListCtrlAutoWidthMixin.__init__(self)
###########################################################################
## Class ItemTraits
###########################################################################
class ItemTraits ( wx.Panel ):
class ItemTraits(wx.Panel):
def __init__(self, parent, stuff, item):
wx.Panel.__init__ (self, parent)
wx.Panel.__init__(self, parent)
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(mainSizer)
self.traits = wx.html.HtmlWindow(self)
self.traits.SetPage(item.traits.traitText)
mainSizer.Add(self.traits, 1, wx.ALL|wx.EXPAND, 0)
mainSizer.Add(self.traits, 1, wx.ALL | wx.EXPAND, 0)
self.Layout()
###########################################################################
## Class ItemDescription
###########################################################################
class ItemDescription ( wx.Panel ):
class ItemDescription(wx.Panel):
def __init__(self, parent, stuff, item):
wx.Panel.__init__ (self, parent)
wx.Panel.__init__(self, parent)
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(mainSizer)
@@ -265,24 +236,18 @@ class ItemDescription ( wx.Panel ):
self.description.SetPage(desc)
mainSizer.Add(self.description, 1, wx.ALL|wx.EXPAND, 0)
mainSizer.Add(self.description, 1, wx.ALL | wx.EXPAND, 0)
self.Layout()
###########################################################################
## Class ItemParams
###########################################################################
class ItemParams (wx.Panel):
def __init__(self, parent, stuff, item, context = None):
wx.Panel.__init__ (self, parent)
mainSizer = wx.BoxSizer( wx.VERTICAL )
def __init__(self, parent, stuff, item, context=None):
wx.Panel.__init__(self, parent)
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.paramList = AutoListCtrl(self, wx.ID_ANY,
style = #wx.LC_HRULES |
#wx.LC_NO_HEADER |
wx.LC_REPORT |wx.LC_SINGLE_SEL |wx.LC_VRULES |wx.NO_BORDER)
mainSizer.Add( self.paramList, 1, wx.ALL|wx.EXPAND, 0 )
self.SetSizer( mainSizer )
self.paramList = AutoListCtrl(self, wx.ID_ANY, style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER)
mainSizer.Add(self.paramList, 1, wx.ALL | wx.EXPAND, 0)
self.SetSizer(mainSizer)
self.toggleView = 1
self.stuff = stuff
@@ -291,29 +256,29 @@ class ItemParams (wx.Panel):
self.attrValues = {}
self._fetchValues()
self.m_staticline = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline, 0, wx.EXPAND)
bSizer = wx.BoxSizer( wx.HORIZONTAL )
self.m_staticline = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline, 0, wx.EXPAND)
bSizer = wx.BoxSizer(wx.HORIZONTAL)
self.totalAttrsLabel = wx.StaticText( self, wx.ID_ANY, u" ", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer.Add( self.totalAttrsLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT)
self.totalAttrsLabel = wx.StaticText(self, wx.ID_ANY, u" ", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer.Add(self.totalAttrsLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT)
self.toggleViewBtn = wx.ToggleButton( self, wx.ID_ANY, u"Toggle view mode", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer.Add( self.toggleViewBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.toggleViewBtn = wx.ToggleButton(self, wx.ID_ANY, u"Toggle view mode", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer.Add(self.toggleViewBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.exportStatsBtn = wx.ToggleButton( self, wx.ID_ANY, u"Export Item Stats", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer.Add( self.exportStatsBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.exportStatsBtn = wx.ToggleButton(self, wx.ID_ANY, u"Export Item Stats", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer.Add(self.exportStatsBtn, 0, wx.ALIGN_CENTER_VERTICAL)
if stuff is not None:
self.refreshBtn = wx.Button( self, wx.ID_ANY, u"Refresh", wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
bSizer.Add( self.refreshBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.refreshBtn.Bind( wx.EVT_BUTTON, self.RefreshValues )
self.refreshBtn = wx.Button(self, wx.ID_ANY, u"Refresh", wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT)
bSizer.Add(self.refreshBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.refreshBtn.Bind(wx.EVT_BUTTON, self.RefreshValues)
mainSizer.Add( bSizer, 0, wx.ALIGN_RIGHT)
mainSizer.Add(bSizer, 0, wx.ALIGN_RIGHT)
self.PopulateList()
self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON,self.ToggleViewMode)
self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleViewMode)
self.exportStatsBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ExportItemStats)
def _fetchValues(self):
@@ -349,7 +314,7 @@ class ItemParams (wx.Panel):
event.Skip()
def ToggleViewMode(self, event):
self.toggleView *=-1
self.toggleView *= -1
self.UpdateList()
event.Skip()
@@ -413,17 +378,17 @@ class ItemParams (wx.Panel):
)
def PopulateList(self):
self.paramList.InsertColumn(0,"Attribute")
self.paramList.InsertColumn(1,"Current Value")
self.paramList.InsertColumn(0, "Attribute")
self.paramList.InsertColumn(1, "Current Value")
if self.stuff is not None:
self.paramList.InsertColumn(2,"Base Value")
self.paramList.SetColumnWidth(0,110)
self.paramList.SetColumnWidth(1,90)
self.paramList.InsertColumn(2, "Base Value")
self.paramList.SetColumnWidth(0, 110)
self.paramList.SetColumnWidth(1, 90)
if self.stuff is not None:
self.paramList.SetColumnWidth(2,90)
self.paramList.SetColumnWidth(2, 90)
self.paramList.setResizeColumn(0)
self.imageList = wx.ImageList(16, 16)
self.paramList.SetImageList(self.imageList,wx.IMAGE_LIST_SMALL)
self.paramList.SetImageList(self.imageList, wx.IMAGE_LIST_SMALL)
names = list(self.attrValues.iterkeys())
names.sort()
@@ -462,7 +427,6 @@ class ItemParams (wx.Panel):
else:
attrIcon = self.imageList.Add(BitmapLoader.getBitmap("7_15", "icons"))
index = self.paramList.InsertImageStringItem(sys.maxint, attrName, attrIcon)
idNameMap[idCount] = attrName
self.paramList.SetItemData(index, idCount)
@@ -486,11 +450,9 @@ class ItemParams (wx.Panel):
if self.stuff is not None:
self.paramList.SetStringItem(index, 2, valueUnitDefault)
self.paramList.SortItems(lambda id1, id2: cmp(idNameMap[id1], idNameMap[id2]))
self.paramList.RefreshRows()
self.totalAttrsLabel.SetLabel("%d attributes. " %idCount)
self.totalAttrsLabel.SetLabel("%d attributes. " % idCount)
self.Layout()
def TranslateValueUnit(self, value, unitName, unitDisplayName):
@@ -506,31 +468,30 @@ class ItemParams (wx.Panel):
attribute = Attribute.getInstance().getAttributeInfo(value)
return "%s (%d)" % (attribute.name.capitalize(), value)
trans = {"Inverse Absolute Percent": (lambda: (1-value)*100, unitName),
"Inversed Modifier Percent": (lambda: (1-value) * 100, unitName),
trans = {"Inverse Absolute Percent": (lambda: (1 - value) * 100, unitName),
"Inversed Modifier Percent": (lambda: (1 - value) * 100, unitName),
"Modifier Percent": (lambda: ("%+.2f" if ((value - 1) * 100) % 1 else "%+d") % ((value - 1) * 100), unitName),
"Volume": (lambda: value, u"m\u00B3"),
"Sizeclass": (lambda: value, ""),
"Absolute Percent": (lambda: (value * 100) , unitName),
"Absolute Percent": (lambda: (value * 100), unitName),
"Milliseconds": (lambda: value / 1000.0, unitName),
"typeID": (itemIDCallback, ""),
"groupID": (groupIDCallback,""),
"groupID": (groupIDCallback, ""),
"attributeID": (attributeIDCallback, "")}
override = trans.get(unitDisplayName)
if override is not None:
if type(override[0]()) == type(str()):
fvalue = override[0]()
v = override[0]()
if isinstance(v, str):
fvalue = v
elif isinstance(v, (int, float, long)):
fvalue = formatAmount(v, 3, 0, 0)
else:
v = override[0]()
if isinstance(v, (int, float, long)):
fvalue = formatAmount(v, 3, 0, 0)
else:
fvalue = v
return "%s %s" % (fvalue , override[1])
fvalue = v
return "%s %s" % (fvalue, override[1])
else:
return "%s %s" % (formatAmount(value, 3, 0),unitName)
return "%s %s" % (formatAmount(value, 3, 0), unitName)
class ItemCompare(wx.Panel):
def __init__(self, parent, stuff, item, items, context=None):
@@ -538,9 +499,7 @@ class ItemCompare(wx.Panel):
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.paramList = AutoListCtrl(self, wx.ID_ANY,
style= # wx.LC_HRULES |
# wx.LC_NO_HEADER |
wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER)
style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER)
mainSizer.Add(self.paramList, 1, wx.ALL | wx.EXPAND, 0)
self.SetSizer(mainSizer)
@@ -604,7 +563,7 @@ class ItemCompare(wx.Panel):
self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleViewMode)
self.Bind(wx.EVT_LIST_COL_CLICK, self.SortCompareCols)
def SortCompareCols(self,event):
def SortCompareCols(self, event):
self.Freeze()
self.paramList.ClearAll()
self.PopulateList(event.Column)
@@ -628,7 +587,7 @@ class ItemCompare(wx.Panel):
def processPrices(self, prices):
for i, price in enumerate(prices):
self.paramList.SetStringItem(i, len(self.attrs)+1, formatAmount(price.price, 3, 3, 9, currency=True))
self.paramList.SetStringItem(i, len(self.attrs) + 1, formatAmount(price.price, 3, 3, 9, currency=True))
def PopulateList(self, sort=None):
@@ -659,11 +618,11 @@ class ItemCompare(wx.Panel):
for i, attr in enumerate(self.attrs.keys()):
name = self.attrs[attr].displayName if self.attrs[attr].displayName else attr
self.paramList.InsertColumn(i+1, name)
self.paramList.SetColumnWidth(i+1, 120)
self.paramList.InsertColumn(i + 1, name)
self.paramList.SetColumnWidth(i + 1, 120)
self.paramList.InsertColumn(len(self.attrs)+1, "Price")
self.paramList.SetColumnWidth(len(self.attrs)+1, 60)
self.paramList.InsertColumn(len(self.attrs) + 1, "Price")
self.paramList.SetColumnWidth(len(self.attrs) + 1, 60)
sMkt = Market.getInstance()
sMkt.getPrices([x.ID for x in self.items], self.processPrices)
@@ -681,7 +640,7 @@ class ItemCompare(wx.Panel):
else:
valueUnit = formatAmount(value, 3, 0, 0)
self.paramList.SetStringItem(i, x+1, valueUnit)
self.paramList.SetStringItem(i, x + 1, valueUnit)
self.paramList.RefreshRows()
self.Layout()
@@ -713,37 +672,30 @@ class ItemCompare(wx.Panel):
override = trans.get(unitDisplayName)
if override is not None:
if type(override[0]()) == type(str()):
fvalue = override[0]()
v = override[0]()
if isinstance(v, str):
fvalue = v
elif isinstance(v, (int, float, long)):
fvalue = formatAmount(v, 3, 0, 0)
else:
v = override[0]()
if isinstance(v, (int, float, long)):
fvalue = formatAmount(v, 3, 0, 0)
else:
fvalue = v
fvalue = v
return "%s %s" % (fvalue, override[1])
else:
return "%s %s" % (formatAmount(value, 3, 0), unitName)
###########################################################################
## Class ItemRequirements
###########################################################################
class ItemRequirements ( wx.Panel ):
class ItemRequirements(wx.Panel):
def __init__(self, parent, stuff, item):
wx.Panel.__init__ (self, parent, style = wx.TAB_TRAVERSAL)
wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)
#itemId is set by the parent.
self.romanNb = ["0","I","II","III","IV","V","VI","VII","VIII","IX","X"]
self.skillIdHistory=[]
mainSizer = wx.BoxSizer( wx.VERTICAL )
# itemId is set by the parent.
self.romanNb = ["0", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]
self.skillIdHistory = []
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.reqTree = wx.TreeCtrl(self, style = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.NO_BORDER)
self.reqTree = wx.TreeCtrl(self, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.NO_BORDER)
mainSizer.Add(self.reqTree, 1, wx.ALL|wx.EXPAND, 0)
mainSizer.Add(self.reqTree, 1, wx.ALL | wx.EXPAND, 0)
self.SetSizer(mainSizer)
self.root = self.reqTree.AddRoot("WINRARZOR")
@@ -753,24 +705,20 @@ class ItemRequirements ( wx.Panel ):
self.reqTree.SetImageList(self.imageList)
skillBookId = self.imageList.Add(BitmapLoader.getBitmap("skill_small", "gui"))
self.getFullSkillTree(item,self.root,skillBookId)
self.getFullSkillTree(item, self.root, skillBookId)
self.reqTree.ExpandAll()
self.Layout()
def getFullSkillTree(self,parentSkill,parent,sbIconId):
def getFullSkillTree(self, parentSkill, parent, sbIconId):
for skill, level in parentSkill.requiredSkills.iteritems():
child = self.reqTree.AppendItem(parent,"%s %s" %(skill.name,self.romanNb[int(level)]), sbIconId)
child = self.reqTree.AppendItem(parent, "%s %s" % (skill.name, self.romanNb[int(level)]), sbIconId)
if skill.ID not in self.skillIdHistory:
self.getFullSkillTree(skill,child,sbIconId)
self.getFullSkillTree(skill, child, sbIconId)
self.skillIdHistory.append(skill.ID)
###########################################################################
## Class ItemEffects
###########################################################################
class ItemEffects (wx.Panel):
def __init__(self, parent, stuff, item):
wx.Panel.__init__(self, parent)
@@ -778,11 +726,7 @@ class ItemEffects (wx.Panel):
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.effectList = AutoListCtrl(self, wx.ID_ANY,
style=
# wx.LC_HRULES |
# wx.LC_NO_HEADER |
wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER)
self.effectList = AutoListCtrl(self, wx.ID_ANY, style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER)
mainSizer.Add(self.effectList, 1, wx.ALL | wx.EXPAND, 0)
self.SetSizer(mainSizer)
@@ -794,17 +738,17 @@ class ItemEffects (wx.Panel):
def PopulateList(self):
self.effectList.InsertColumn(0,"Name")
self.effectList.InsertColumn(1,"Active")
self.effectList.InsertColumn(0, "Name")
self.effectList.InsertColumn(1, "Active")
self.effectList.InsertColumn(2, "Type")
if config.debug:
self.effectList.InsertColumn(3, "Run Time")
self.effectList.InsertColumn(4,"ID")
self.effectList.InsertColumn(4, "ID")
#self.effectList.SetColumnWidth(0,385)
# self.effectList.SetColumnWidth(0,385)
self.effectList.setResizeColumn(0)
self.effectList.SetColumnWidth(1,50)
self.effectList.SetColumnWidth(1, 50)
self.effectList.SetColumnWidth(2, 80)
if config.debug:
self.effectList.SetColumnWidth(3, 65)
@@ -872,19 +816,17 @@ class ItemEffects (wx.Panel):
If effect file does not exist, create it
"""
import os
file = os.path.join(config.pyfaPath, "eos", "effects", "%s.py"%event.GetText().lower())
file_ = os.path.join(config.pyfaPath, "eos", "effects", "%s.py" % event.GetText().lower())
if not os.path.isfile(file):
open(file, 'a').close()
if not os.path.isfile(file_):
open(file_, 'a').close()
if 'wxMSW' in wx.PlatformInfo:
os.startfile(file)
os.startfile(file_)
elif 'wxMac' in wx.PlatformInfo:
os.system("open "+file)
os.system("open " + file_)
else:
import subprocess
subprocess.call(["xdg-open", file])
subprocess.call(["xdg-open", file_])
def RefreshValues(self, event):
self.Freeze()
@@ -895,13 +837,10 @@ class ItemEffects (wx.Panel):
self.Thaw()
event.Skip()
###########################################################################
## Class ItemAffectedBy
###########################################################################
class ItemAffectedBy (wx.Panel):
class ItemAffectedBy(wx.Panel):
ORDER = [Fit, Ship, Citadel, Mode, Module, Drone, Fighter, Implant, Booster, Skill]
def __init__(self, parent, stuff, item):
wx.Panel.__init__(self, parent)
self.stuff = stuff
@@ -917,33 +856,33 @@ class ItemAffectedBy (wx.Panel):
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.affectedBy = wx.TreeCtrl(self, style = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.NO_BORDER)
mainSizer.Add(self.affectedBy, 1, wx.ALL|wx.EXPAND, 0)
self.affectedBy = wx.TreeCtrl(self, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.NO_BORDER)
mainSizer.Add(self.affectedBy, 1, wx.ALL | wx.EXPAND, 0)
self.m_staticline = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
self.m_staticline = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add( self.m_staticline, 0, wx.EXPAND)
bSizer = wx.BoxSizer( wx.HORIZONTAL )
mainSizer.Add(self.m_staticline, 0, wx.EXPAND)
bSizer = wx.BoxSizer(wx.HORIZONTAL)
self.toggleExpandBtn = wx.ToggleButton( self, wx.ID_ANY, u"Expand All", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer.Add( self.toggleExpandBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.toggleExpandBtn = wx.ToggleButton(self, wx.ID_ANY, u"Expand All", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer.Add(self.toggleExpandBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.toggleNameBtn = wx.ToggleButton( self, wx.ID_ANY, u"Toggle Names", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer.Add( self.toggleNameBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.toggleNameBtn = wx.ToggleButton(self, wx.ID_ANY, u"Toggle Names", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer.Add(self.toggleNameBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.toggleViewBtn = wx.ToggleButton( self, wx.ID_ANY, u"Toggle View", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer.Add( self.toggleViewBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.toggleViewBtn = wx.ToggleButton(self, wx.ID_ANY, u"Toggle View", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer.Add(self.toggleViewBtn, 0, wx.ALIGN_CENTER_VERTICAL)
if stuff is not None:
self.refreshBtn = wx.Button( self, wx.ID_ANY, u"Refresh", wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
bSizer.Add( self.refreshBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.refreshBtn.Bind( wx.EVT_BUTTON, self.RefreshTree )
self.refreshBtn = wx.Button(self, wx.ID_ANY, u"Refresh", wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT)
bSizer.Add(self.refreshBtn, 0, wx.ALIGN_CENTER_VERTICAL)
self.refreshBtn.Bind(wx.EVT_BUTTON, self.RefreshTree)
self.toggleNameBtn.Bind(wx.EVT_TOGGLEBUTTON,self.ToggleNameMode)
self.toggleExpandBtn.Bind(wx.EVT_TOGGLEBUTTON,self.ToggleExpand)
self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON,self.ToggleViewMode)
self.toggleNameBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleNameMode)
self.toggleExpandBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleExpand)
self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleViewMode)
mainSizer.Add( bSizer, 0, wx.ALIGN_RIGHT)
mainSizer.Add(bSizer, 0, wx.ALIGN_RIGHT)
self.SetSizer(mainSizer)
self.PopulateTree()
self.Layout()
@@ -965,9 +904,9 @@ class ItemAffectedBy (wx.Panel):
# Skills are different in that they don't have itemModifiedAttributes,
# which is needed if we send the container to itemStats dialog. So
# instead, we send the item.
type = stuff.__class__.__name__
contexts.append(("itemStats", type))
menu = ContextMenu.getMenu(stuff if type != "Skill" else stuff.item, *contexts)
type_ = stuff.__class__.__name__
contexts.append(("itemStats", type_))
menu = ContextMenu.getMenu(stuff if type_ != "Skill" else stuff.item, *contexts)
self.PopupMenu(menu)
def ExpandCollapseTree(self):
@@ -983,7 +922,7 @@ class ItemAffectedBy (wx.Panel):
self.Thaw()
def ToggleExpand(self,event):
def ToggleExpand(self, event):
self.expand *= -1
self.ExpandCollapseTree()
@@ -1043,20 +982,22 @@ class ItemAffectedBy (wx.Panel):
return attr
def buildAttributeView(self, root):
# We first build a usable dictionary of items. The key is either a fit
# if the afflictions stem from a projected fit, or self.stuff if they
# are local afflictions (everything else, even gang boosts at this time)
# The value of this is yet another dictionary in the following format:
#
# "attribute name": {
# "Module Name": [
# class of affliction,
# affliction item (required due to GH issue #335)
# modifier type
# amount of modification
# whether this affliction was projected
# ]
# }
"""
We first build a usable dictionary of items. The key is either a fit
if the afflictions stem from a projected fit, or self.stuff if they
are local afflictions (everything else, even gang boosts at this time)
The value of this is yet another dictionary in the following format:
"attribute name": {
"Module Name": [
class of affliction,
affliction item (required due to GH issue #335)
modifier type
amount of modification
whether this affliction was projected
]
}
"""
attributes = self.stuff.itemModifiedAttributes if self.item == self.stuff.item else self.stuff.chargeModifiedAttributes
container = {}
@@ -1168,20 +1109,21 @@ class ItemAffectedBy (wx.Panel):
treeItem = self.affectedBy.AppendItem(child, display, itemIcon)
self.affectedBy.SetPyData(treeItem, afflictor)
def buildModuleView(self, root):
# We first build a usable dictionary of items. The key is either a fit
# if the afflictions stem from a projected fit, or self.stuff if they
# are local afflictions (everything else, even gang boosts at this time)
# The value of this is yet another dictionary in the following format:
#
# "Module Name": [
# class of affliction,
# set of afflictors (such as 2 of the same module),
# info on affliction (attribute name, modifier, and modification amount),
# item that will be used to determine icon (required due to GH issue #335)
# whether this affliction is actually used (unlearned skills are not used)
# ]
"""
We first build a usable dictionary of items. The key is either a fit
if the afflictions stem from a projected fit, or self.stuff if they
are local afflictions (everything else, even gang boosts at this time)
The value of this is yet another dictionary in the following format:
"Module Name": [
class of affliction,
set of afflictors (such as 2 of the same module),
info on affliction (attribute name, modifier, and modification amount),
item that will be used to determine icon (required due to GH issue #335)
whether this affliction is actually used (unlearned skills are not used)
]
"""
attributes = self.stuff.itemModifiedAttributes if self.item == self.stuff.item else self.stuff.chargeModifiedAttributes
container = {}
@@ -1294,7 +1236,7 @@ class ItemAffectedBy (wx.Panel):
attributes.append((attrName, (displayName if displayName != "" else attrName), attrModifier, attrAmount, penalized, attrIcon))
attrSorted = sorted(attributes, key = lambda attribName: attribName[0])
attrSorted = sorted(attributes, key=lambda attribName: attribName[0])
for attr in attrSorted:
attrName, displayName, attrModifier, attrAmount, penalized, attrIcon = attr

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import sys
import os.path
@@ -30,8 +30,6 @@ from wx._core import PyDeadObjectError
from wx.lib.wordwrap import wordwrap
import config
import threading
import webbrowser
import gui.aboutData
import gui.chromeTabs
@@ -74,29 +72,32 @@ from service.settings import HTMLExportSettings
from time import gmtime, strftime
if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)):
if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)):
from service.crest import CrestModes
from gui.crestFittings import CrestFittings, ExportToEve, CrestMgmt
try:
from gui.propertyEditor import AttributeEditor
disableOverrideEditor = False
except ImportError, e:
print "Error loading Attribute Editor: %s.\nAccess to Attribute Editor is disabled."%e.message
except ImportError as e:
print("Error loading Attribute Editor: %s.\nAccess to Attribute Editor is disabled." % e.message)
disableOverrideEditor = True
#dummy panel(no paint no erasebk)
# dummy panel(no paint no erasebk)
class PFPanel(wx.Panel):
def __init__(self,parent):
wx.Panel.__init__(self,parent)
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnBkErase)
def OnPaint(self, event):
event.Skip()
def OnBkErase(self, event):
pass
class OpenFitsThread(threading.Thread):
def __init__(self, fits, callback):
threading.Thread.__init__(self)
@@ -121,34 +122,36 @@ class OpenFitsThread(threading.Thread):
wx.PostEvent(self.mainFrame, FitSelected(fitID=self.fits[-1], startup=2))
wx.CallAfter(self.callback)
class MainFrame(wx.Frame):
__instance = None
@classmethod
def getInstance(cls):
return cls.__instance if cls.__instance is not None else MainFrame()
def __init__(self, title):
self.title=title
self.title = title
wx.Frame.__init__(self, None, wx.ID_ANY, self.title)
MainFrame.__instance = self
#Load stored settings (width/height/maximized..)
# Load stored settings (width/height/maximized..)
self.LoadMainFrameAttribs()
#Fix for msw (have the frame background color match panel color
# Fix for msw (have the frame background color match panel color
if 'wxMSW' in wx.PlatformInfo:
self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ) )
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
#Load and set the icon for pyfa main window
# Load and set the icon for pyfa main window
i = wx.IconFromBitmap(BitmapLoader.getBitmap("pyfa", "gui"))
self.SetIcon(i)
#Create the layout and windows
# Create the layout and windows
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
self.browser_fitting_split = wx.SplitterWindow(self, style = wx.SP_LIVE_UPDATE)
self.fitting_additions_split = wx.SplitterWindow(self.browser_fitting_split, style = wx.SP_LIVE_UPDATE)
self.browser_fitting_split = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE)
self.fitting_additions_split = wx.SplitterWindow(self.browser_fitting_split, style=wx.SP_LIVE_UPDATE)
mainSizer.Add(self.browser_fitting_split, 1, wx.EXPAND | wx.LEFT, 2)
@@ -161,17 +164,17 @@ class MainFrame(wx.Frame):
shipBrowserImg = BitmapLoader.getImage("ship_small", "gui")
self.marketBrowser = MarketBrowser(self.notebookBrowsers)
self.notebookBrowsers.AddPage(self.marketBrowser, "Market", tabImage = marketImg, showClose = False)
self.notebookBrowsers.AddPage(self.marketBrowser, "Market", tabImage=marketImg, showClose=False)
self.marketBrowser.splitter.SetSashPosition(self.marketHeight)
self.shipBrowser = ShipBrowser(self.notebookBrowsers)
self.notebookBrowsers.AddPage(self.shipBrowser, "Fittings", tabImage = shipBrowserImg, showClose = False)
self.notebookBrowsers.AddPage(self.shipBrowser, "Fittings", tabImage=shipBrowserImg, showClose=False)
#=======================================================================
# =====================================================================
# DISABLED FOR RC2 RELEASE
#self.fleetBrowser = FleetBrowser(self.notebookBrowsers)
#self.notebookBrowsers.AddPage(self.fleetBrowser, "Fleets", showClose = False)
#=======================================================================
# self.fleetBrowser = FleetBrowser(self.notebookBrowsers)
# self.notebookBrowsers.AddPage(self.fleetBrowser, "Fleets", showClose = False)
# =====================================================================
self.notebookBrowsers.SetSelection(1)
@@ -196,7 +199,7 @@ class MainFrame(wx.Frame):
self.SetSizer(mainSizer)
#Add menu
# Add menu
self.addPageId = wx.NewId()
self.closePageId = wx.NewId()
@@ -204,23 +207,23 @@ class MainFrame(wx.Frame):
self.SetMenuBar(MainMenuBar())
self.registerMenu()
#Internal vars to keep track of other windows (graphing/stats)
# Internal vars to keep track of other windows (graphing/stats)
self.graphFrame = None
self.statsWnds = []
self.activeStatsWnd = None
self.Bind(wx.EVT_CLOSE, self.OnClose)
#Show ourselves
# Show ourselves
self.Show()
self.LoadPreviousOpenFits()
#Check for updates
# Check for updates
self.sUpdate = Update.getInstance()
self.sUpdate.CheckUpdate(self.ShowUpdateBox)
if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)):
if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)):
self.Bind(GE.EVT_SSO_LOGIN, self.onSSOLogin)
self.Bind(GE.EVT_SSO_LOGOUT, self.onSSOLogout)
@@ -274,7 +277,7 @@ class MainFrame(wx.Frame):
def UpdateMainFrameAttribs(self):
if self.IsIconized():
return
width,height = self.GetSize()
width, height = self.GetSize()
self.mainFrameAttribs["wnd_width"] = width
self.mainFrameAttribs["wnd_height"] = height
@@ -308,7 +311,7 @@ class MainFrame(wx.Frame):
return m() if m is not None else None
def getActiveView(self):
sel = self.fitMultiSwitch.GetSelectedPage()
self.fitMultiSwitch.GetSelectedPage()
def CloseCurrentPage(self, evt):
ms = self.fitMultiSwitch
@@ -321,11 +324,11 @@ class MainFrame(wx.Frame):
self.UpdateMainFrameAttribs()
# save open fits
self.prevOpenFits['pyfaOpenFits'] = [] # clear old list
self.prevOpenFits['pyfaOpenFits'] = [] # clear old list
for page in self.fitMultiSwitch.pages:
m = getattr(page, "getActiveFit", None)
if m is not None:
self.prevOpenFits['pyfaOpenFits'].append(m())
self.prevOpenFits['pyfaOpenFits'].append(m())
# save all teh settingz
SettingsProvider.getInstance().saveAll()
@@ -342,37 +345,36 @@ class MainFrame(wx.Frame):
info.Name = "pyfa"
info.Version = gui.aboutData.versionString
info.Description = wordwrap(gui.aboutData.description + "\n\nDevelopers:\n\t" +
"\n\t".join(gui.aboutData.developers) +
"\n\nAdditional credits:\n\t" +
"\n\t".join(gui.aboutData.credits) +
"\n\nLicenses:\n\t" +
"\n\t".join(gui.aboutData.licenses) +
"\n\nEVE Data: \t" + eos.config.gamedata_version +
"\nPython: \t\t" + '{}.{}.{}'.format(v.major, v.minor, v.micro) +
"\nwxPython: \t" + wx.__version__ +
"\nSQLAlchemy: \t" + sqlalchemy.__version__,
500, wx.ClientDC(self))
if "__WXGTK__" in wx.PlatformInfo:
"\n\t".join(gui.aboutData.developers) +
"\n\nAdditional credits:\n\t" +
"\n\t".join(gui.aboutData.credits) +
"\n\nLicenses:\n\t" +
"\n\t".join(gui.aboutData.licenses) +
"\n\nEVE Data: \t" + eos.config.gamedata_version +
"\nPython: \t\t" + '{}.{}.{}'.format(v.major, v.minor, v.micro) +
"\nwxPython: \t" + wx.__version__ +
"\nSQLAlchemy: \t" + sqlalchemy.__version__,
500, wx.ClientDC(self))
if "__WXGTK__" in wx.PlatformInfo:
forumUrl = "http://forums.eveonline.com/default.aspx?g=posts&amp;t=466425"
else:
forumUrl = "http://forums.eveonline.com/default.aspx?g=posts&t=466425"
info.WebSite = (forumUrl, "pyfa thread at EVE Online forum")
wx.AboutBox(info)
def showCharacterEditor(self, event):
dlg=CharacterEditor(self)
dlg = CharacterEditor(self)
dlg.Show()
def showAttrEditor(self, event):
dlg=AttributeEditor(self)
dlg = AttributeEditor(self)
dlg.Show()
def showTargetResistsEditor(self, event):
ResistsEditorDlg(self)
def showDamagePatternEditor(self, event):
dlg=DmgPatternEditorDlg(self)
dlg = DmgPatternEditorDlg(self)
dlg.ShowModal()
dlg.Destroy()
@@ -383,26 +385,28 @@ class MainFrame(wx.Frame):
""" Export active fit """
sFit = Fit.getInstance()
fit = sFit.getFit(self.getActiveFit())
defaultFile = "%s - %s.xml"%(fit.ship.item.name, fit.name) if fit else None
defaultFile = "%s - %s.xml" % (fit.ship.item.name, fit.name) if fit else None
dlg = wx.FileDialog(self, "Save Fitting As...",
wildcard = "EVE XML fitting files (*.xml)|*.xml",
style = wx.FD_SAVE,
wildcard="EVE XML fitting files (*.xml)|*.xml",
style=wx.FD_SAVE,
defaultFile=defaultFile)
if dlg.ShowModal() == wx.ID_OK:
format = dlg.GetFilterIndex()
format_ = dlg.GetFilterIndex()
path = dlg.GetPath()
if format == 0:
if format_ == 0:
output = sFit.exportXml(None, self.getActiveFit())
if '.' not in os.path.basename(path):
path += ".xml"
else:
print "oops, invalid fit format %d" % format
print("oops, invalid fit format %d" % format_)
dlg.Destroy()
return
file = open(path, "w", encoding="utf-8")
file.write(output)
file.close()
with open(path, "w", encoding="utf-8") as openfile:
openfile.write(output)
openfile.close()
dlg.Destroy()
def showPreferenceDialog(self, event):
@@ -431,7 +435,7 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.loadDatabaseDefaults, id=menuBar.importDatabaseDefaultsId)
# Widgets Inspector
if config.debug:
self.Bind(wx.EVT_MENU, self.openWXInspectTool, id = self.widgetInspectMenuID)
self.Bind(wx.EVT_MENU, self.openWXInspectTool, id=self.widgetInspectMenuID)
# About
self.Bind(wx.EVT_MENU, self.ShowAboutBox, id=wx.ID_ABOUT)
# Char editor
@@ -459,32 +463,32 @@ class MainFrame(wx.Frame):
# Preference dialog
self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id=wx.ID_PREFERENCES)
# User guide
self.Bind(wx.EVT_MENU, self.goWiki, id = menuBar.wikiId)
self.Bind(wx.EVT_MENU, self.goWiki, id=menuBar.wikiId)
# EVE Forums
self.Bind(wx.EVT_MENU, self.goForums, id = menuBar.forumId)
self.Bind(wx.EVT_MENU, self.goForums, id=menuBar.forumId)
# Save current character
self.Bind(wx.EVT_MENU, self.saveChar, id = menuBar.saveCharId)
self.Bind(wx.EVT_MENU, self.saveChar, id=menuBar.saveCharId)
# Save current character as another character
self.Bind(wx.EVT_MENU, self.saveCharAs, id = menuBar.saveCharAsId)
self.Bind(wx.EVT_MENU, self.saveCharAs, id=menuBar.saveCharAsId)
# Save current character
self.Bind(wx.EVT_MENU, self.revertChar, id = menuBar.revertCharId)
self.Bind(wx.EVT_MENU, self.revertChar, id=menuBar.revertCharId)
# Browse fittings
self.Bind(wx.EVT_MENU, self.eveFittings, id = menuBar.eveFittingsId)
self.Bind(wx.EVT_MENU, self.eveFittings, id=menuBar.eveFittingsId)
# Export to EVE
self.Bind(wx.EVT_MENU, self.exportToEve, id = menuBar.exportToEveId)
self.Bind(wx.EVT_MENU, self.exportToEve, id=menuBar.exportToEveId)
# Handle SSO event (login/logout/manage characters, depending on mode and current state)
self.Bind(wx.EVT_MENU, self.ssoHandler, id = menuBar.ssoLoginId)
self.Bind(wx.EVT_MENU, self.ssoHandler, id=menuBar.ssoLoginId)
# Open attribute editor
self.Bind(wx.EVT_MENU, self.showAttrEditor, id = menuBar.attrEditorId)
self.Bind(wx.EVT_MENU, self.showAttrEditor, id=menuBar.attrEditorId)
# Toggle Overrides
self.Bind(wx.EVT_MENU, self.toggleOverrides, id = menuBar.toggleOverridesId)
self.Bind(wx.EVT_MENU, self.toggleOverrides, id=menuBar.toggleOverridesId)
#Clipboard exports
# Clipboard exports
self.Bind(wx.EVT_MENU, self.exportToClipboard, id=wx.ID_COPY)
#Graphs
# Graphs
self.Bind(wx.EVT_MENU, self.openGraphFrame, id=menuBar.graphFrameId)
toggleSearchBoxId = wx.NewId()
@@ -494,11 +498,11 @@ class MainFrame(wx.Frame):
# Close Page
self.Bind(wx.EVT_MENU, self.CloseCurrentPage, id=self.closePageId)
self.Bind(wx.EVT_MENU, self.HAddPage, id = self.addPageId)
self.Bind(wx.EVT_MENU, self.toggleSearchBox, id = toggleSearchBoxId)
self.Bind(wx.EVT_MENU, self.toggleShipMarket, id = toggleShipMarketId)
self.Bind(wx.EVT_MENU, self.CTabNext, id = ctabnext)
self.Bind(wx.EVT_MENU, self.CTabPrev, id = ctabprev)
self.Bind(wx.EVT_MENU, self.HAddPage, id=self.addPageId)
self.Bind(wx.EVT_MENU, self.toggleSearchBox, id=toggleSearchBoxId)
self.Bind(wx.EVT_MENU, self.toggleShipMarket, id=toggleShipMarketId)
self.Bind(wx.EVT_MENU, self.CTabNext, id=ctabnext)
self.Bind(wx.EVT_MENU, self.CTabPrev, id=ctabprev)
actb = [(wx.ACCEL_CTRL, ord('T'), self.addPageId),
(wx.ACCEL_CMD, ord('T'), self.addPageId),
@@ -531,30 +535,30 @@ class MainFrame(wx.Frame):
for i in range(0, self.additionsPane.notebook.GetPageCount()):
self.additionsSelect.append(wx.NewId())
self.Bind(wx.EVT_MENU, self.AdditionsTabSelect, id=self.additionsSelect[i])
actb.append((wx.ACCEL_CMD, i+49, self.additionsSelect[i]))
actb.append((wx.ACCEL_CTRL, i+49, self.additionsSelect[i]))
actb.append((wx.ACCEL_CMD, i + 49, self.additionsSelect[i]))
actb.append((wx.ACCEL_CTRL, i + 49, self.additionsSelect[i]))
# Alt+1-9 for market item selection
self.itemSelect = []
for i in range(0, 9):
self.itemSelect.append(wx.NewId())
self.Bind(wx.EVT_MENU, self.ItemSelect, id = self.itemSelect[i])
self.Bind(wx.EVT_MENU, self.ItemSelect, id=self.itemSelect[i])
actb.append((wx.ACCEL_ALT, i + 49, self.itemSelect[i]))
atable = wx.AcceleratorTable(actb)
self.SetAcceleratorTable(atable)
def eveFittings(self, event):
dlg=CrestFittings(self)
dlg = CrestFittings(self)
dlg.Show()
def updateTitle(self, event):
sCrest = Crest.getInstance()
char = sCrest.implicitCharacter
if char:
t = time.gmtime(char.eve.expires-time.time())
t = time.gmtime(char.eve.expires - time.time())
sTime = time.strftime("%H:%M:%S", t if t >= 0 else 0)
newTitle = "%s | %s - %s"%(self.title, char.name, sTime)
newTitle = "%s | %s - %s" % (self.title, char.name, sTime)
self.SetTitle(newTitle)
def onSSOLogin(self, event):
@@ -605,11 +609,11 @@ class MainFrame(wx.Frame):
uri = sCrest.startServer()
webbrowser.open(uri)
else:
dlg=CrestMgmt(self)
dlg = CrestMgmt(self)
dlg.Show()
def exportToEve(self, event):
dlg=ExportToEve(self)
dlg = ExportToEve(self)
dlg.Show()
def toggleOverrides(self, event):
@@ -653,7 +657,7 @@ class MainFrame(wx.Frame):
def CTabPrev(self, event):
self.fitMultiSwitch.PrevPage()
def HAddPage(self,event):
def HAddPage(self, event):
self.fitMultiSwitch.AddPage()
def toggleShipMarket(self, event):
@@ -714,17 +718,19 @@ class MainFrame(wx.Frame):
CopySelectDict[selected]()
dlg.Destroy()
def exportSkillsNeeded(self, event):
""" Exports skills needed for active fit and active character """
sCharacter = Character.getInstance()
saveDialog = wx.FileDialog(self, "Export Skills Needed As...",
wildcard = "EVEMon skills training file (*.emp)|*.emp|" \
"EVEMon skills training XML file (*.xml)|*.xml|" \
"Text skills training file (*.txt)|*.txt",
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
saveDialog = wx.FileDialog(
self,
"Export Skills Needed As...",
wildcard=("EVEMon skills training file (*.emp)|*.emp|"
"EVEMon skills training XML file (*.xml)|*.xml|"
"Text skills training file (*.txt)|*.txt"),
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
)
if saveDialog.ShowModal() == wx.ID_OK:
saveFmtInt = saveDialog.GetFilterIndex()
@@ -748,16 +754,21 @@ class MainFrame(wx.Frame):
def fileImportDialog(self, event):
"""Handles importing single/multiple EVE XML / EFT cfg fit files"""
sFit = Fit.getInstance()
dlg = wx.FileDialog(self, "Open One Or More Fitting Files",
wildcard = "EVE XML fitting files (*.xml)|*.xml|" \
"EFT text fitting files (*.cfg)|*.cfg|" \
"All Files (*)|*",
style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE)
dlg = wx.FileDialog(
self,
"Open One Or More Fitting Files",
wildcard=("EVE XML fitting files (*.xml)|*.xml|"
"EFT text fitting files (*.cfg)|*.cfg|"
"All Files (*)|*"),
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE
)
if (dlg.ShowModal() == wx.ID_OK):
self.progressDialog = wx.ProgressDialog(
"Importing fits",
" "*100, # set some arbitrary spacing to create width in window
parent=self, style = wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)
"Importing fits",
" " * 100, # set some arbitrary spacing to create width in window
parent=self,
style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME
)
self.progressDialog.message = None
sFit.importFitsThreaded(dlg.GetPaths(), self.fileImportCallback)
self.progressDialog.ShowModal()
@@ -765,12 +776,15 @@ class MainFrame(wx.Frame):
def backupToXml(self, event):
""" Back up all fits to EVE XML file """
defaultFile = "pyfa-fits-%s.xml"%strftime("%Y%m%d_%H%M%S", gmtime())
defaultFile = "pyfa-fits-%s.xml" % strftime("%Y%m%d_%H%M%S", gmtime())
saveDialog = wx.FileDialog(self, "Save Backup As...",
wildcard = "EVE XML fitting file (*.xml)|*.xml",
style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
defaultFile=defaultFile)
saveDialog = wx.FileDialog(
self,
"Save Backup As...",
wildcard="EVE XML fitting file (*.xml)|*.xml",
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
defaultFile=defaultFile,
)
if saveDialog.ShowModal() == wx.ID_OK:
filePath = saveDialog.GetPath()
@@ -778,13 +792,15 @@ class MainFrame(wx.Frame):
filePath += ".xml"
sFit = Fit.getInstance()
max = sFit.countAllFits()
self.progressDialog = wx.ProgressDialog("Backup fits",
"Backing up %d fits to: %s"%(max, filePath),
maximum=max, parent=self,
style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)
max_ = sFit.countAllFits()
self.progressDialog = wx.ProgressDialog(
"Backup fits",
"Backing up %d fits to: %s" % (max_, filePath),
maximum=max_,
parent=self,
style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME,
)
Port.backupFits(filePath, self.backupCallback)
self.progressDialog.ShowModal()
@@ -793,21 +809,26 @@ class MainFrame(wx.Frame):
sFit = Fit.getInstance()
settings = HTMLExportSettings.getInstance()
max = sFit.countAllFits()
max_ = sFit.countAllFits()
path = settings.getPath()
if not os.path.isdir(os.path.dirname(path)):
dlg = wx.MessageDialog(self,
"Invalid Path\n\nThe following path is invalid or does not exist: \n%s\n\nPlease verify path location pyfa's preferences."%path,
"Error", wx.OK | wx.ICON_ERROR)
dlg = wx.MessageDialog(
self,
"Invalid Path\n\nThe following path is invalid or does not exist: \n%s\n\nPlease verify path location pyfa's preferences." % path,
"Error",
wx.OK | wx.ICON_ERROR
)
if dlg.ShowModal() == wx.ID_OK:
return
self.progressDialog = wx.ProgressDialog("Backup fits",
"Generating HTML file at: %s"%path,
maximum=max, parent=self,
style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)
self.progressDialog = wx.ProgressDialog(
"Backup fits",
"Generating HTML file at: %s" % path,
maximum=max_, parent=self,
style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME
)
exportHtml.getInstance().refreshFittingHtml(True, self.backupCallback)
self.progressDialog.ShowModal()
@@ -844,7 +865,7 @@ class MainFrame(wx.Frame):
self._openAfterImport(data)
elif action == -2:
dlg = wx.MessageDialog(self,
"The following error was generated\n\n%s\n\nBe aware that already processed fits were not saved"%data,
"The following error was generated\n\n%s\n\nBe aware that already processed fits were not saved" % data,
"Import Error", wx.OK | wx.ICON_ERROR)
if dlg.ShowModal() == wx.ID_OK:
return
@@ -869,10 +890,12 @@ class MainFrame(wx.Frame):
def importCharacter(self, event):
""" Imports character XML file from EVE API """
dlg = wx.FileDialog(self, "Open One Or More Character Files",
wildcard="EVE API XML character files (*.xml)|*.xml|" \
"All Files (*)|*",
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE)
dlg = wx.FileDialog(
self,
"Open One Or More Character Files",
wildcard="EVE API XML character files (*.xml)|*.xml|All Files (*)|*",
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE
)
if dlg.ShowModal() == wx.ID_OK:
self.waitDialog = wx.BusyInfo("Importing Character...")
@@ -906,4 +929,3 @@ class MainFrame(wx.Frame):
if not wnd:
wnd = self
InspectionTool().Show(wnd, True)

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,20 +15,23 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import config
from gui.bitmapLoader import BitmapLoader
from service.crest import Crest
from service.character import Character
import gui.mainFrame
import gui.graphFrame
import gui.globalEvents as GE
from service.crest import Crest
from service.character import Character
from gui.bitmapLoader import BitmapLoader
if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)):
if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)):
from service.crest import CrestModes
class MainMenuBar(wx.MenuBar):
def __init__(self):
self.characterEditorId = wx.NewId()
@@ -52,7 +55,7 @@ class MainMenuBar(wx.MenuBar):
self.toggleOverridesId = wx.NewId()
self.importDatabaseDefaultsId = wx.NewId()
if 'wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0):
if 'wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0):
wx.ID_COPY = wx.NewId()
wx.ID_PASTE = wx.NewId()
@@ -81,8 +84,8 @@ class MainMenuBar(wx.MenuBar):
editMenu = wx.Menu()
self.Append(editMenu, "&Edit")
#editMenu.Append(wx.ID_UNDO)
#editMenu.Append(wx.ID_REDO)
# editMenu.Append(wx.ID_UNDO)
# editMenu.Append(wx.ID_REDO)
editMenu.Append(wx.ID_COPY, "To Clipboard\tCTRL+C", "Export a fit to the clipboard")
editMenu.Append(wx.ID_PASTE, "From Clipboard\tCTRL+V", "Import a fit from the clipboard")
@@ -116,11 +119,11 @@ class MainMenuBar(wx.MenuBar):
windowMenu.AppendItem(graphFrameItem)
preferencesShortCut = "CTRL+," if 'wxMac' in wx.PlatformInfo else "CTRL+P"
preferencesItem = wx.MenuItem(windowMenu, wx.ID_PREFERENCES, "Preferences\t"+preferencesShortCut)
preferencesItem = wx.MenuItem(windowMenu, wx.ID_PREFERENCES, "Preferences\t" + preferencesShortCut)
preferencesItem.SetBitmap(BitmapLoader.getBitmap("preferences_small", "gui"))
windowMenu.AppendItem(preferencesItem)
if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)):
if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)):
self.sCrest = Crest.getInstance()
# CREST Menu
@@ -155,7 +158,7 @@ class MainMenuBar(wx.MenuBar):
helpMenu.Append(wx.ID_ABOUT)
if config.debug:
helpMenu.Append( self.mainFrame.widgetInspectMenuID, "Open Widgets Inspect tool", "Open Widgets Inspect tool")
helpMenu.Append(self.mainFrame.widgetInspectMenuID, "Open Widgets Inspect tool", "Open Widgets Inspect tool")
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
@@ -175,5 +178,3 @@ class MainMenuBar(wx.MenuBar):
self.Enable(self.revertCharId, char.isDirty)
event.Skip()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,23 +15,24 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.display as d
from gui.cachingImageList import CachingImageList
from gui.contextMenu import ContextMenu
import gui.PFSearchBox as SBox
from service.market import Market
from service.attribute import Attribute
import gui.display as d
import gui.PFSearchBox as SBox
from gui.cachingImageList import CachingImageList
from gui.contextMenu import ContextMenu
from gui.bitmapLoader import BitmapLoader
ItemSelected, ITEM_SELECTED = wx.lib.newevent.NewEvent()
RECENTLY_USED_MODULES = -2
MAX_RECENTLY_USED_MODULES = 20
class MarketBrowser(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
@@ -42,7 +43,7 @@ class MarketBrowser(wx.Panel):
self.search = SearchBox(self)
vbox.Add(self.search, 0, wx.EXPAND)
self.splitter = wx.SplitterWindow(self, style = wx.SP_LIVE_UPDATE)
self.splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE)
vbox.Add(self.splitter, 1, wx.EXPAND)
# Grab market service instance and create child objects
@@ -103,16 +104,18 @@ class MarketBrowser(wx.Panel):
def jump(self, item):
self.marketView.jump(item)
class SearchBox(SBox.PFSearchBox):
def __init__(self, parent, **kwargs):
SBox.PFSearchBox.__init__(self, parent, **kwargs)
cancelBitmap = BitmapLoader.getBitmap("fit_delete_small","gui")
searchBitmap = BitmapLoader.getBitmap("fsearch_small","gui")
cancelBitmap = BitmapLoader.getBitmap("fit_delete_small", "gui")
searchBitmap = BitmapLoader.getBitmap("fsearch_small", "gui")
self.SetSearchBitmap(searchBitmap)
self.SetCancelBitmap(cancelBitmap)
self.ShowSearchButton()
self.ShowCancelButton()
class MarketTree(wx.TreeCtrl):
def __init__(self, parent, marketBrowser):
wx.TreeCtrl.__init__(self, parent, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT)
@@ -136,7 +139,7 @@ class MarketTree(wx.TreeCtrl):
# Add recently used modules node
rumIconId = self.addImage("market_small", "gui")
self.AppendItem(self.root, "Recently Used Modules", rumIconId, data = wx.TreeItemData(RECENTLY_USED_MODULES))
self.AppendItem(self.root, "Recently Used Modules", rumIconId, data=wx.TreeItemData(RECENTLY_USED_MODULES))
# Bind our lookup method to when the tree gets expanded
self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.expandLookup)
@@ -185,10 +188,10 @@ class MarketTree(wx.TreeCtrl):
for id in sMkt.ROOT_MARKET_GROUPS:
if id in jumpList:
jumpList = jumpList[:jumpList.index(id)+1]
jumpList = jumpList[:jumpList.index(id) + 1]
item = self.root
for i in range(len(jumpList) -1, -1, -1):
for i in range(len(jumpList) - 1, -1, -1):
target = jumpList[i]
child, cookie = self.GetFirstChild(item)
while self.GetItemPyData(child) != target:
@@ -200,6 +203,7 @@ class MarketTree(wx.TreeCtrl):
self.SelectItem(item)
self.marketBrowser.itemView.selectionMade(forcedMetaSelect=metaId)
class ItemView(d.Display):
DEFAULT_COLS = ["Base Icon",
"Base Name",
@@ -242,12 +246,11 @@ class ItemView(d.Display):
if row != -1:
data = wx.PyTextDataObject()
data.SetText("market:"+str(self.active[row].ID))
data.SetText("market:" + str(self.active[row].ID))
dropSource = wx.DropSource(self)
dropSource.SetData(data)
res = dropSource.DoDragDrop()
dropSource.DoDragDrop()
def itemActivated(self, event=None):
# Check if something is selected, if so, spawn the menu for it
@@ -391,12 +394,12 @@ class ItemView(d.Display):
mktgrpid = sMkt.getMarketGroupByItem(item).ID
except AttributeError:
mktgrpid = None
print "unable to find market group for", item.name
print("unable to find market group for", item.name)
parentname = sMkt.getParentItemByItem(item).name
# Get position of market group
metagrpid = sMkt.getMetaGroupIdByItem(item)
metatab = self.metaMap.get(metagrpid)
metalvl = self.metalvls.get(item.ID, 0)
metalvl = self.metalvls.get(item.ID, 0)
return (catname, mktgrpid, parentname, metatab, metalvl, item.name)
def contextMenu(self, event):
@@ -442,7 +445,7 @@ class ItemView(d.Display):
for i, item in enumerate(items[:9]):
# set shortcut info for first 9 modules
item.marketShortcut = i+1
item.marketShortcut = i + 1
d.Display.refresh(self, items)

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import gui.chromeTabs
import gui.builtinViews.emptyView
@@ -24,7 +24,7 @@ import gui.builtinViews.emptyView
class MultiSwitch(gui.chromeTabs.PFNotebook):
def __init__(self, parent):
gui.chromeTabs.PFNotebook.__init__(self, parent)
#self.AddPage() # now handled by mainFrame
# self.AddPage() # now handled by mainFrame
self.handlers = handlers = []
for type in TabSpawner.tabTypes:
handlers.append(type(self))

View File

@@ -1,9 +1,8 @@
import wx
from service.fit import Fit
import gui.globalEvents as GE
import gui.mainFrame
from service.fit import Fit
class NotesView(wx.Panel):
@@ -36,7 +35,7 @@ class NotesView(wx.Panel):
def onText(self, event):
# delay the save so we're not writing to sqlite on every keystroke
self.saveTimer.Stop() # cancel the existing timer
self.saveTimer.Stop() # cancel the existing timer
self.saveTimer.Start(1000, True)
def delayedSave(self, event):

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,18 +15,15 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.bitmapLoader import BitmapLoader
from wx.lib.intctrl import IntCtrl
from gui.utils.clipboard import toClipboard, fromClipboard
from service.damagePattern import ImportError
from gui.builtinViews.entityEditor import EntityEditor, BaseValidator
from service.damagePattern import DamagePattern, ImportError
###########################################################################
## Class DmgPatternEditorDlg
###########################################################################
class DmgPatternTextValidor(BaseValidator):
def __init__(self):
@@ -47,7 +44,7 @@ class DmgPatternTextValidor(BaseValidator):
raise ValueError("Damage Profile name already in use, please choose another.")
return True
except ValueError, e:
except ValueError as e:
wx.MessageBox(u"{}".format(e), "Error")
textCtrl.SetFocus()
return False
@@ -81,11 +78,12 @@ class DmgPatternEntityEditor(EntityEditor):
sDP = DamagePattern.getInstance()
sDP.deletePattern(entity)
class DmgPatternEditorDlg(wx.Dialog):
DAMAGE_TYPES = ("em", "thermal", "kinetic", "explosive")
def __init__(self, parent):
wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Damage Pattern Editor", size = wx.Size( 400,240 ))
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"Damage Pattern Editor", size=wx.Size(400, 240))
self.block = False
self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)
@@ -111,11 +109,11 @@ class DmgPatternEditorDlg(wx.Dialog):
dmgeditSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
width = -1
defSize = wx.Size(width,-1)
defSize = wx.Size(width, -1)
for i, type in enumerate(self.DAMAGE_TYPES):
bmp = wx.StaticBitmap(self, wx.ID_ANY, BitmapLoader.getBitmap("%s_big"%type, "gui"))
if i%2:
for i, type_ in enumerate(self.DAMAGE_TYPES):
bmp = wx.StaticBitmap(self, wx.ID_ANY, BitmapLoader.getBitmap("%s_big" % type_, "gui"))
if i % 2:
style = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT
border = 20
else:
@@ -123,13 +121,13 @@ class DmgPatternEditorDlg(wx.Dialog):
border = 5
# set text edit
setattr(self, "%sEdit"%type, IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize))
setattr(self, "%sPerc"%type, wx.StaticText(self, wx.ID_ANY, u"0%"))
editObj = getattr(self, "%sEdit"%type)
setattr(self, "%sEdit" % type_, IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize))
setattr(self, "%sPerc" % type_, wx.StaticText(self, wx.ID_ANY, u"0%"))
editObj = getattr(self, "%sEdit" % type_)
dmgeditSizer.Add(bmp, 0, style, border)
dmgeditSizer.Add(editObj, 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5)
dmgeditSizer.Add(getattr(self, "%sPerc"%type), 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
dmgeditSizer.Add(getattr(self, "%sPerc" % type_), 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
editObj.Bind(wx.EVT_TEXT, self.ValuesUpdated)
editObj.SetLimited(True)
@@ -147,7 +145,7 @@ class DmgPatternEditorDlg(wx.Dialog):
self.stNotice.Wrap(-1)
perSizer.Add(self.stNotice, 0, wx.BOTTOM | wx.TOP | wx.LEFT, 5)
footerSizer.Add(perSizer, 1, wx.ALIGN_CENTER_VERTICAL, 5)
footerSizer.Add(perSizer, 1, wx.ALIGN_CENTER_VERTICAL, 5)
self.totSizer = wx.BoxSizer(wx.VERTICAL)
@@ -156,8 +154,8 @@ class DmgPatternEditorDlg(wx.Dialog):
mainSizer.Add(contentSizer, 1, wx.EXPAND, 0)
if "wxGTK" in wx.PlatformInfo:
self.closeBtn = wx.Button( self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.closeBtn, 0, wx.ALL|wx.ALIGN_RIGHT, 5 )
self.closeBtn = wx.Button(self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.closeBtn, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
self.closeBtn.Bind(wx.EVT_BUTTON, self.closeEvent)
self.SetSizer(mainSizer)
@@ -169,13 +167,13 @@ class DmgPatternEditorDlg(wx.Dialog):
bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON)
btn = wx.BitmapButton(self, wx.ID_ANY, bitmap)
btn.SetMinSize( btn.GetSize() )
btn.SetMaxSize( btn.GetSize() )
btn.SetMinSize(btn.GetSize())
btn.SetMaxSize(btn.GetSize())
btn.Layout()
setattr(self, name, btn)
btn.Enable(True)
btn.SetToolTipString("%s patterns %s clipboard" % (name, direction) )
btn.SetToolTipString("%s patterns %s clipboard" % (name, direction))
footerSizer.Add(btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_RIGHT)
btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Patterns".format(name.lower())))
@@ -196,12 +194,12 @@ class DmgPatternEditorDlg(wx.Dialog):
return
p = self.entityEditor.getActiveEntity()
total = sum(map(lambda attr: getattr(self, "%sEdit"%attr).GetValue(), self.DAMAGE_TYPES))
for type in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit"%type)
percObj = getattr(self, "%sPerc"%type)
setattr(p, "%sAmount"%type, editObj.GetValue())
percObj.SetLabel("%.1f%%"%(float(editObj.GetValue())*100/total if total > 0 else 0))
total = sum(map(lambda attr: getattr(self, "%sEdit" % attr).GetValue(), self.DAMAGE_TYPES))
for type_ in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit" % type_)
percObj = getattr(self, "%sPerc" % type_)
setattr(p, "%sAmount" % type_, editObj.GetValue())
percObj.SetLabel("%.1f%%" % (float(editObj.GetValue()) * 100 / total if total > 0 else 0))
self.totSizer.Layout()
@@ -211,15 +209,15 @@ class DmgPatternEditorDlg(wx.Dialog):
DamagePattern.getInstance().saveChanges(p)
def restrict(self):
for type in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit"%type)
for type_ in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit" % type_)
editObj.Enable(False)
self.entityEditor.btnRename.Enable(False)
self.entityEditor.btnDelete.Enable(False)
def unrestrict(self):
for type in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit"%type)
for type_ in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit" % type_)
editObj.Enable()
self.entityEditor.btnRename.Enable()
self.entityEditor.btnDelete.Enable()
@@ -255,9 +253,9 @@ class DmgPatternEditorDlg(wx.Dialog):
try:
sDP.importPatterns(text)
self.stNotice.SetLabel("Patterns successfully imported from clipboard")
except ImportError, e:
except ImportError as e:
self.stNotice.SetLabel(str(e))
except Exception, e:
except Exception:
self.stNotice.SetLabel("Could not import from clipboard: unknown errors")
finally:
self.entityEditor.refreshEntityList()
@@ -266,5 +264,5 @@ class DmgPatternEditorDlg(wx.Dialog):
def exportPatterns(self, event):
sDP = DamagePattern.getInstance()
toClipboard( sDP.exportPatterns() )
toClipboard(sDP.exportPatterns())
self.stNotice.SetLabel("Patterns exported to clipboard")

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,14 +15,14 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
class PreferenceDialog(wx.Dialog):
class PreferenceDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE)
self.SetTitle("pyfa - Preferences")
@@ -33,22 +33,22 @@ class PreferenceDialog(wx.Dialog):
self.listbook = wx.Listbook(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LB_DEFAULT)
self.listview = self.listbook.GetListView()
#self.listview.SetMinSize((500, -1))
#self.listview.SetSize((500, -1))
# self.listview.SetMinSize((500, -1))
# self.listview.SetSize((500, -1))
self.imageList = wx.ImageList(32,32)
self.imageList = wx.ImageList(32, 32)
self.listbook.SetImageList(self.imageList)
mainSizer.Add(self.listbook, 1, wx.EXPAND | wx.TOP|wx.BOTTOM|wx.LEFT, 5)
mainSizer.Add(self.listbook, 1, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.LEFT, 5)
self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline2, 0, wx.EXPAND, 5 )
self.m_staticline2 = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline2, 0, wx.EXPAND, 5)
btnSizer = wx.BoxSizer( wx.HORIZONTAL )
btnSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
self.btnOK = wx.Button( self, wx.ID_ANY, u"OK", wx.DefaultPosition, wx.DefaultSize, 0 )
btnSizer.Add( self.btnOK, 0, wx.ALL, 5 )
mainSizer.Add(btnSizer,0 , wx.EXPAND, 5)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.AddSpacer((0, 0), 1, wx.EXPAND, 5)
self.btnOK = wx.Button(self, wx.ID_ANY, u"OK", wx.DefaultPosition, wx.DefaultSize, 0)
btnSizer.Add(self.btnOK, 0, wx.ALL, 5)
mainSizer.Add(btnSizer, 0, wx.EXPAND, 5)
self.SetSizer(mainSizer)
self.Centre(wx.BOTH)
@@ -61,12 +61,12 @@ class PreferenceDialog(wx.Dialog):
else:
imgID = -1
prefView.populatePanel(page)
self.listbook.AddPage(page, prefView.title, imageId = imgID)
self.listbook.AddPage(page, prefView.title, imageId=imgID)
# Set the height based on a condition. Can all the panels fit in the current height?
# If not, use the .GetBestVirtualSize() to ensure that all content is available.
minHeight = 360
bestFit = self.GetBestVirtualSize()
bestFit = self.GetBestVirtualSize()
if minHeight > bestFit[1]:
self.SetSizeWH(450, minHeight)
else:

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,14 +15,13 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
class PreferenceView(object):
views = []
def __init__(self):
pass
@classmethod
def register(cls):
@@ -37,5 +36,5 @@ class PreferenceView(object):
def getImage(self):
return wx.NullBitmap
from gui.builtinPreferenceViews import *
from gui.builtinPreferenceViews import * # noqa

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
import gui.display as d
@@ -25,6 +25,7 @@ from gui.builtinViewColumns.state import State
from gui.contextMenu import ContextMenu
import eos.types
from service.fit import Fit
from service.market import Market
class DummyItem:
@@ -32,23 +33,26 @@ class DummyItem:
self.name = txt
self.icon = None
class DummyEntry:
def __init__(self, txt):
self.item = DummyItem(txt)
class ProjectedViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID
self.dropData = wx.PyTextDataObject()
self.SetDataObject(self.dropData)
def OnData(self, x, y, t):
if self.GetData():
data = self.dropData.GetText().split(':')
self.dropFn(x, y, data)
return t
class ProjectedViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID
self.dropData = wx.PyTextDataObject()
self.SetDataObject(self.dropData)
def OnData(self, x, y, t):
if self.GetData():
data = self.dropData.GetText().split(':')
self.dropFn(x, y, data)
return t
class ProjectedView(d.Display):
DEFAULT_COLS = ["State",
@@ -58,7 +62,7 @@ class ProjectedView(d.Display):
"Ammo"]
def __init__(self, parent):
d.Display.__init__(self, parent, style = wx.LC_SINGLE_SEL | wx.BORDER_NONE)
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL | wx.BORDER_NONE)
self.lastFitId = None
@@ -70,7 +74,7 @@ class ProjectedView(d.Display):
self.droneView = gui.droneView.DroneView
if "__WXGTK__" in wx.PlatformInfo:
if "__WXGTK__" in wx.PlatformInfo:
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
else:
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
@@ -96,7 +100,7 @@ class ProjectedView(d.Display):
sFit.project(fitID, int(data[1]))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
def kbEvent(self,event):
def kbEvent(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_DELETE or keycode == wx.WXK_NUMPAD_DELETE:
fitID = self.mainFrame.getActiveFit()
@@ -107,7 +111,7 @@ class ProjectedView(d.Display):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
def handleDrag(self, type, fitID):
#Those are drags coming from pyfa sources, NOT builtin wx drags
# Those are drags coming from pyfa sources, NOT builtin wx drags
if type == "fit":
activeFit = self.mainFrame.getActiveFit()
if activeFit:
@@ -120,14 +124,14 @@ class ProjectedView(d.Display):
row = event.GetIndex()
if row != -1 and isinstance(self.get(row), es_Drone):
data = wx.PyTextDataObject()
data.SetText("projected:"+str(self.GetItemData(row)))
data.SetText("projected:" + str(self.GetItemData(row)))
dropSource = wx.DropSource(self)
dropSource.SetData(data)
dropSource.DoDragDrop()
def mergeDrones(self, x, y, itemID):
srcRow = self.FindItemData(-1,itemID)
srcRow = self.FindItemData(-1, itemID)
dstRow, _ = self.HitTest((x, y))
if srcRow != -1 and dstRow != -1:
self._merge(srcRow, dstRow)
@@ -140,7 +144,6 @@ class ProjectedView(d.Display):
if sFit.mergeDrones(fitID, self.get(src), dstDrone, True):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
def moduleSort(self, module):
return module.item.name
@@ -164,7 +167,7 @@ class ProjectedView(d.Display):
self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)
#Clear list and get out if current fitId is None
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
@@ -245,7 +248,8 @@ class ProjectedView(d.Display):
menu = None
if sel != -1:
item = self.get(sel)
if item is None: return
if item is None:
return
sMkt = Market.getInstance()
if isinstance(item, es_Drone):
srcContext = "projectedDrone"
@@ -269,7 +273,7 @@ class ProjectedView(d.Display):
else:
fitSrcContext = "projectedFit"
fitItemContext = item.name
context = ((fitSrcContext,fitItemContext),)
context = ((fitSrcContext, fitItemContext),)
context = context + (("projected",),)
menu = ContextMenu.getMenu((item,), *context)
elif sel == -1:

View File

@@ -1,3 +1,6 @@
import csv
import logging
import wx
try:
@@ -8,25 +11,21 @@ except:
else:
raise
import gui.PFSearchBox as SBox
from gui.marketBrowser import SearchBox
import eos.db
from service.market import Market
import gui.display as d
import gui.globalEvents as GE
import gui.PFSearchBox as SBox
from gui.marketBrowser import SearchBox
from gui.bitmapLoader import BitmapLoader
import csv
import eos.db
import logging
from service.market import Market
logger = logging.getLogger(__name__)
class AttributeEditor( wx.Frame ):
def __init__( self, parent ):
class AttributeEditor(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, wx.ID_ANY, title="Attribute Editor", pos=wx.DefaultPosition,
size=wx.Size(650, 600), style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.TAB_TRAVERSAL)
size=wx.Size(650, 600), style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT | wx.TAB_TRAVERSAL)
i = wx.IconFromBitmap(BitmapLoader.getBitmap("fit_rename_small", "gui"))
self.SetIcon(i)
@@ -46,7 +45,6 @@ class AttributeEditor( wx.Frame ):
self.Bind(wx.EVT_MENU, self.OnExport, fileExport)
self.Bind(wx.EVT_MENU, self.OnClear, fileClear)
i = wx.IconFromBitmap(BitmapLoader.getBitmap("fit_rename_small", "gui"))
self.SetIcon(i)
@@ -68,10 +66,10 @@ class AttributeEditor( wx.Frame ):
mainSizer.Add(leftPanel, 1, wx.ALL | wx.EXPAND, 5)
rightSizer = wx.BoxSizer(wx.VERTICAL)
self.btnRemoveOverrides = wx.Button( panel, wx.ID_ANY, u"Remove Overides for Item", wx.DefaultPosition, wx.DefaultSize, 0 )
self.btnRemoveOverrides = wx.Button(panel, wx.ID_ANY, u"Remove Overides for Item", wx.DefaultPosition, wx.DefaultSize, 0)
self.pg = AttributeGrid(panel)
rightSizer.Add(self.pg, 1, wx.ALL|wx.EXPAND, 5)
rightSizer.Add(self.btnRemoveOverrides, 0, wx.ALL | wx.EXPAND, 5 )
rightSizer.Add(self.pg, 1, wx.ALL | wx.EXPAND, 5)
rightSizer.Add(self.btnRemoveOverrides, 0, wx.ALL | wx.EXPAND, 5)
self.btnRemoveOverrides.Bind(wx.EVT_BUTTON, self.pg.removeOverrides)
self.btnRemoveOverrides.Enable(False)
@@ -95,8 +93,8 @@ class AttributeEditor( wx.Frame ):
def OnImport(self, event):
dlg = wx.FileDialog(self, "Import pyfa override file",
wildcard = "pyfa override file (*.csv)|*.csv",
style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
wildcard="pyfa override file (*.csv)|*.csv",
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if (dlg.ShowModal() == wx.ID_OK):
path = dlg.GetPath()
with open(path, 'rb') as csvfile:
@@ -114,8 +112,8 @@ class AttributeEditor( wx.Frame ):
defaultFile = "pyfa_overrides.csv"
dlg = wx.FileDialog(self, "Save Overrides As...",
wildcard = "pyfa overrides (*.csv)|*.csv",
style = wx.FD_SAVE,
wildcard="pyfa overrides (*.csv)|*.csv",
style=wx.FD_SAVE,
defaultFile=defaultFile)
if dlg.ShowModal() == wx.ID_OK:
@@ -127,9 +125,12 @@ class AttributeEditor( wx.Frame ):
writer.writerow([item.ID, override.attrID, override.value])
def OnClear(self, event):
dlg = wx.MessageDialog(self,
"Are you sure you want to delete all overrides?",
"Confirm Delete", wx.YES | wx.NO | wx.ICON_EXCLAMATION)
dlg = wx.MessageDialog(
self,
"Are you sure you want to delete all overrides?",
"Confirm Delete",
wx.YES | wx.NO | wx.ICON_EXCLAMATION
)
if dlg.ShowModal() == wx.ID_YES:
sMkt = Market.getInstance()
@@ -144,6 +145,7 @@ class AttributeEditor( wx.Frame ):
self.itemView.updateItems(True)
self.pg.Clear()
# This is literally a stripped down version of the market.
class ItemView(d.Display):
DEFAULT_COLS = ["Base Icon",
@@ -199,9 +201,8 @@ class ItemView(d.Display):
class AttributeGrid(wxpg.PropertyGrid):
def __init__(self, parent):
wxpg.PropertyGrid.__init__(self, parent, style=wxpg.PG_HIDE_MARGIN|wxpg.PG_HIDE_CATEGORIES|wxpg.PG_BOLD_MODIFIED|wxpg.PG_TOOLTIPS)
wxpg.PropertyGrid.__init__(self, parent, style=wxpg.PG_HIDE_MARGIN | wxpg.PG_HIDE_CATEGORIES | wxpg.PG_BOLD_MODIFIED | wxpg.PG_TOOLTIPS)
self.SetExtraStyle(wxpg.PG_EX_HELP_AS_TOOLTIPS)
self.item = None
@@ -210,9 +211,9 @@ class AttributeGrid(wxpg.PropertyGrid):
self.btn = parent.Parent.btnRemoveOverrides
self.Bind( wxpg.EVT_PG_CHANGED, self.OnPropGridChange )
self.Bind( wxpg.EVT_PG_SELECTED, self.OnPropGridSelect )
self.Bind( wxpg.EVT_PG_RIGHT_CLICK, self.OnPropGridRightClick )
self.Bind(wxpg.EVT_PG_CHANGED, self.OnPropGridChange)
self.Bind(wxpg.EVT_PG_SELECTED, self.OnPropGridSelect)
self.Bind(wxpg.EVT_PG_RIGHT_CLICK, self.OnPropGridRightClick)
self.itemView.Bind(wx.EVT_LIST_ITEM_SELECTED, self.itemActivated)
self.itemView.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.itemActivated)
@@ -233,14 +234,14 @@ class AttributeGrid(wxpg.PropertyGrid):
prop = wxpg.FloatProperty(key, value=default)
prop.SetClientData(item.attributes[key]) # set this so that we may access it later
prop.SetHelpString("%s\n%s"%(item.attributes[key].displayName or key, "Default Value: %0.3f"%default))
prop.SetHelpString("%s\n%s" % (item.attributes[key].displayName or key, "Default Value: %0.3f" % default))
self.Append(prop)
def removeOverrides(self, event):
if self.item is None:
return
for _, x in self.item.overrides.items():
for x in self.item.overrides.values():
self.item.deleteOverride(x.attr)
self.itemView.updateItems(True)
self.ClearModifiedStatus()

View File

@@ -1,65 +1,54 @@
# -*- coding: utf-8 -*-
###########################################################################
## pyfatogllepanel.py
##
## Author: Darriele - HomeWorld
##
## Project home: https://github.com/pyfa-org/Pyfa - pyfa project
## Some portions of code are based on
## AGW:pycollapsiblepane generic implementation of wx.CollapsiblePane
## AGW:pycollapsiblepane credits ( from the original source file used ):
## Andrea Gavana, @ 09 Aug 2007
## Latest Revision: 12 Apr 2010, 12.00 GMT
##
## Module description:
## TogglePanel class is a wx.collipsablepane like implementation that uses
## some optimization from awg::pycollipsablepane to provide certain
## features tailored for PYFA needs.
##
## This module is part of PYFA (PYthon Fitting Assitant) and it shares the same
## licence ( read PYFA licence notice: gpl.txt )
##
## Notes: leave the commented code as it is, those line will be removed someday
# pyfatogllepanel.py
#
# Author: Darriele - HomeWorld
#
# Project home: https://github.com/pyfa-org/Pyfa - pyfa project
# Some portions of code are based on
# AGW:pycollapsiblepane generic implementation of wx.CollapsiblePane
# AGW:pycollapsiblepane credits ( from the original source file used ):
# Andrea Gavana, @ 09 Aug 2007
# Latest Revision: 12 Apr 2010, 12.00 GMT
#
# Module description:
# TogglePanel class is a wx.collipsablepane like implementation that uses
# some optimization from awg::pycollipsablepane to provide certain
# features tailored for PYFA needs.
#
# This module is part of PYFA (PYthon Fitting Assitant) and it shares the same
# licence ( read PYFA licence notice: gpl.txt )
#
# Notes: leave the commented code as it is, those line will be removed someday
###########################################################################
import wx
from gui.bitmapLoader import BitmapLoader
###########################################################################
## Class TogglePanel
###########################################################################
class TogglePanel ( wx.Panel ):
def __init__( self, parent , forceLayout = -1):
wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL )
class TogglePanel(wx.Panel):
def __init__(self, parent, forceLayout=-1):
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
self._toggle = 1
self.parent = parent
self.forceLayout = forceLayout
self.bkColour = self.GetBackgroundColour()
# Create the main sizer of this panel
self.mainSizer = wx.BoxSizer( wx.VERTICAL )
self.SetSizer( self.mainSizer )
parentSize = parent.GetMinSize()
# Create the header panel
# Create the main sizer of this panel
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self.mainSizer)
# parentSize = parent.GetMinSize()
# Create the header panel
self.headerPanel = wx.Panel(self)
self.mainSizer.Add(self.headerPanel, 0, wx.EXPAND | wx.TOP | wx.BOTTOM | wx.RIGHT, 1)
self.mainSizer.Add(self.headerPanel,0,wx.EXPAND | wx.TOP|wx.BOTTOM|wx.RIGHT, 1)
# Load expanded/collapsed bitmaps from the icons folder
self.bmpExpanded = BitmapLoader.getBitmap("down-arrow2", "gui")
self.bmpCollapsed = BitmapLoader.getBitmap("up-arrow2", "gui")
# Load expanded/collapsed bitmaps from the icons folder
self.bmpExpanded = BitmapLoader.getBitmap("down-arrow2","gui")
self.bmpCollapsed = BitmapLoader.getBitmap("up-arrow2","gui")
# Make the bitmaps have the same color as window text
sysTextColour = wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOWTEXT )
# Make the bitmaps have the same color as window text
sysTextColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT)
img = self.bmpExpanded.ConvertToImage()
img.Replace(0, 0, 0, sysTextColour[0], sysTextColour[1], sysTextColour[2])
@@ -69,55 +58,53 @@ class TogglePanel ( wx.Panel ):
img.Replace(0, 0, 0, sysTextColour[0], sysTextColour[1], sysTextColour[2])
self.bmpCollapsed = wx.BitmapFromImage(img)
self.headerBmp = wx.StaticBitmap(self.headerPanel )
self.headerBmp.SetBitmap( self.bmpExpanded)
self.headerBmp = wx.StaticBitmap(self.headerPanel)
self.headerBmp.SetBitmap(self.bmpExpanded)
# Create the header sizer and add static bitmap and static text controls to it
# Create the header sizer and add static bitmap and static text controls to it
headerSizer = wx.BoxSizer( wx.HORIZONTAL )
self.headerPanel.SetSizer( headerSizer)
headerSizer = wx.BoxSizer(wx.HORIZONTAL)
self.headerPanel.SetSizer(headerSizer)
hbmpSizer = wx.BoxSizer( wx.HORIZONTAL )
hlblSizer = wx.BoxSizer( wx.HORIZONTAL )
self.hcntSizer = wx.BoxSizer( wx.HORIZONTAL)
hbmpSizer = wx.BoxSizer(wx.HORIZONTAL)
hlblSizer = wx.BoxSizer(wx.HORIZONTAL)
self.hcntSizer = wx.BoxSizer(wx.HORIZONTAL)
hbmpSizer.Add( self.headerBmp, 0,0, 5 )
hbmpSizer.Add(self.headerBmp, 0, 0, 5)
self.headerLabel = wx.StaticText( self.headerPanel, wx.ID_ANY, u"PYFA", wx.DefaultPosition, wx.DefaultSize, 0 )
hlblSizer.Add( self.headerLabel, 0, wx.EXPAND , 5 )
self.headerLabel = wx.StaticText(self.headerPanel, wx.ID_ANY, u"PYFA", wx.DefaultPosition, wx.DefaultSize, 0)
hlblSizer.Add(self.headerLabel, 0, wx.EXPAND, 5)
headerSizer.Add( hbmpSizer, 0, wx.RIGHT, 5 )
headerSizer.Add( hlblSizer, 0, wx.RIGHT, 5 )
headerSizer.Add( self.hcntSizer, 0, wx.RIGHT, 5)
headerSizer.Add(hbmpSizer, 0, wx.RIGHT, 5)
headerSizer.Add(hlblSizer, 0, wx.RIGHT, 5)
headerSizer.Add(self.hcntSizer, 0, wx.RIGHT, 5)
# Set the static text font weight to BOLD
# Set the static text font weight to BOLD
headerFont=parent.GetFont()
headerFont = parent.GetFont()
headerFont.SetWeight(wx.BOLD)
self.headerLabel.SetFont(headerFont)
# Create the content panel and its main sizer
# Create the content panel and its main sizer
self.contentSizer = wx.BoxSizer( wx.VERTICAL )
self.contentSizer = wx.BoxSizer(wx.VERTICAL)
self.contentPanel = wx.Panel(self)
self.contentPanel.SetSizer(self.contentSizer)
self.mainSizer.Add( self.contentPanel, 0, wx.EXPAND | wx.RIGHT | wx.LEFT , 5)
self.mainSizer.Add(self.contentPanel, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, 5)
self.Layout()
# Connect Events
# Connect Events
self.headerLabel.Bind(wx.EVT_LEFT_UP, self.toggleContent)
self.headerBmp.Bind(wx.EVT_LEFT_UP, self.toggleContent)
self.headerPanel.Bind(wx.EVT_LEFT_UP, self.toggleContent)
self.headerLabel.Bind( wx.EVT_LEFT_UP, self.toggleContent )
self.headerBmp.Bind( wx.EVT_LEFT_UP, self.toggleContent )
self.headerPanel.Bind( wx.EVT_LEFT_UP, self.toggleContent )
def __del__( self ):
def __del__(self):
pass
def AddToggleItem(self, hitem):
hitem.Bind( wx.EVT_LEFT_UP, self.toggleContent )
hitem.Bind(wx.EVT_LEFT_UP, self.toggleContent)
def GetHeaderContentSizer(self):
return self.hcntSizer
@@ -126,7 +113,7 @@ class TogglePanel ( wx.Panel ):
return self.headerPanel
def InsertItemInHeader(self, item):
self.hcntSizer.Add(item,0,0,0)
self.hcntSizer.Add(item, 0, 0, 0)
self.Layout()
def AddSizer(self, sizer):

View File

@@ -13,7 +13,6 @@ It uses the easeOutQuad equation from caurina.transitions.Tweener to do the anim
import wx
import copy
import math
from gui.utils import colorUtils
import gui.utils.drawUtils as drawUtils
@@ -22,6 +21,7 @@ import gui.utils.fonts as fonts
from service import fit
class PyGauge(wx.PyWindow):
"""
This class provides a visual alternative for `wx.Gauge`. It currently
@@ -29,7 +29,7 @@ class PyGauge(wx.PyWindow):
"""
def __init__(self, parent, id=wx.ID_ANY, range=100, pos=wx.DefaultPosition,
size=(-1,30), style=0):
size=(-1, 30), style=0):
"""
Default class constructor.
@@ -46,8 +46,8 @@ class PyGauge(wx.PyWindow):
self._size = size
self._border_colour = wx.BLACK
self._barColour = self._barColourSorted = [wx.Colour(212,228,255)]
self._barGradient = self._barGradientSorted = None
self._barColour = self._barColourSorted = [wx.Colour(212, 228, 255)]
self._barGradient = self._barGradientSorted = None
self._border_padding = 0
self._range = range
@@ -67,10 +67,10 @@ class PyGauge(wx.PyWindow):
self._animDirection = 0
self.animEffect = animEffects.OUT_QUAD
self.transitionsColors = [( wx.Colour(191, 191, 191, 255) , wx.Colour(96, 191, 0, 255) ),
( wx.Colour(191, 167, 96, 255) , wx.Colour(255, 191, 0, 255) ),
( wx.Colour(255, 191, 0, 255) , wx.Colour(255, 128, 0, 255) ),
( wx.Colour(255, 128, 0, 255) , wx.Colour(255, 0, 0, 255) )]
self.transitionsColors = [(wx.Colour(191, 191, 191, 255), wx.Colour(96, 191, 0, 255)),
(wx.Colour(191, 167, 96, 255), wx.Colour(255, 191, 0, 255)),
(wx.Colour(255, 191, 0, 255), wx.Colour(255, 128, 0, 255)),
(wx.Colour(255, 128, 0, 255), wx.Colour(255, 0, 0, 255))]
self.gradientEffect = -35
self._percentage = 0
@@ -79,8 +79,8 @@ class PyGauge(wx.PyWindow):
self.font = wx.Font(fonts.NORMAL, wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.SetBarGradient((wx.Colour(119,119,119),wx.Colour(153,153,153)))
self.SetBackgroundColour(wx.Colour(51,51,51))
self.SetBarGradient((wx.Colour(119, 119, 119), wx.Colour(153, 153, 153)))
self.SetBackgroundColour(wx.Colour(51, 51, 51))
self._tooltip = wx.ToolTip("")
self.SetToolTip(self._tooltip)
self._tooltip.SetTip("0.00/100.00")
@@ -107,7 +107,6 @@ class PyGauge(wx.PyWindow):
return wx.Size(self._size[0], self._size[1])
def GetBorderColour(self):
return self._border_colour
@@ -121,7 +120,7 @@ class PyGauge(wx.PyWindow):
return self._barColour[0]
def SetBarColour(self, colour):
if type(colour) != type([]):
if not isinstance(colour, list):
self._barColour = [colour]
else:
self._barColour = list(colour)
@@ -130,31 +129,30 @@ class PyGauge(wx.PyWindow):
GetBarColor = GetBarColour
def SetFractionDigits(self, digits):
self._fractionDigits=digits
self._fractionDigits = digits
def GetBarGradient(self):
""" Returns a tuple containing the gradient start and end colours. """
if self._barGradient == None:
if self._barGradient is None:
return None
return self._barGradient[0]
def SetBarGradient(self, gradient = None):
def SetBarGradient(self, gradient=None):
"""
Sets the bar gradient. This overrides the BarColour.
:param `gradient`: a tuple containing the gradient start and end colours.
"""
if gradient == None:
if gradient is None:
self._barGradient = None
else:
if type(gradient) != type([]):
if not isinstance(gradient, list):
self._barGradient = [gradient]
else:
self._barGradient = list(gradient)
def GetBorderPadding(self):
""" Gets the border padding. """
@@ -169,7 +167,6 @@ class PyGauge(wx.PyWindow):
self._border_padding = padding
def GetRange(self):
""" Returns the maximum value of the gauge. """
@@ -186,7 +183,7 @@ class PyGauge(wx.PyWindow):
self._animValue = self._percentage
self.Refresh()
def SetRange(self, range, reinit = False):
def SetRange(self, range, reinit=False):
"""
Sets the range of the gauge. The gauge length is its
value as a proportion of the range.
@@ -197,16 +194,16 @@ class PyGauge(wx.PyWindow):
if self._range == range:
return
range = float(range)
range_ = float(range)
if range <= 0:
if range_ <= 0:
self._range = 0.01
else:
self._range = range
self._range = range_
if reinit is False:
self._oldPercentage = self._percentage
self._percentage = (self._value/self._range) * 100
self._percentage = (self._value / self._range) * 100
else:
self._oldPercentage = self._percentage
self._percentage = 0
@@ -214,9 +211,7 @@ class PyGauge(wx.PyWindow):
self.Animate()
self._tooltip.SetTip("%.2f/%.2f" % (self._value, self._range if self._range >0.01 else 0))
self._tooltip.SetTip("%.2f/%.2f" % (self._value, self._range if self._range > 0.01 else 0))
def GetValue(self):
""" Returns the current position of the gauge. """
@@ -233,22 +228,22 @@ class PyGauge(wx.PyWindow):
self._value = value
if value < 0:
self._value = 0
self._percentage = (self._value/self._range) * 100
self._percentage = (self._value / self._range) * 100
self.Animate()
self._tooltip.SetTip("%.2f/%.2f" % (self._value, self._range))
def SetValueRange(self, value, range, reinit = False):
def SetValueRange(self, value, range, reinit=False):
if self._value == value and self._range == range:
return
range = float(range)
range_ = float(range)
if range <= 0:
if range_ <= 0:
self._range = 0.01
else:
self._range = range
self._range = range_
value = float(value)
@@ -258,15 +253,14 @@ class PyGauge(wx.PyWindow):
if reinit is False:
self._oldPercentage = self._percentage
self._percentage = (self._value/self._range) * 100
self._percentage = (self._value / self._range) * 100
else:
self._oldPercentage = self._percentage
self._percentage = 0
self.Animate()
self._tooltip.SetTip("%.2f/%.2f" % (self._value, self._range if self._range >0.01 else 0))
self._tooltip.SetTip("%.2f/%.2f" % (self._value, self._range if self._range > 0.01 else 0))
def OnEraseBackground(self, event):
"""
@@ -308,7 +302,7 @@ class PyGauge(wx.PyWindow):
dc.SetPen(wx.Pen(self.GetBorderColour()))
dc.DrawRectangleRect(rect)
pad = 1 + self.GetBorderPadding()
rect.Deflate(pad,pad)
rect.Deflate(pad, pad)
if self.GetBarGradient():
@@ -326,48 +320,48 @@ class PyGauge(wx.PyWindow):
# time on them if not needed. See GH issue #282
pv = value
xv=1
xv = 1
transition = 0
if pv <= 100:
xv = pv/100
xv = pv / 100
transition = 0
elif pv <=101:
xv = pv -100
elif pv <= 101:
xv = pv - 100
transition = 1
elif pv <= 103:
xv = (pv -101)/2
xv = (pv - 101) / 2
transition = 2
elif pv <= 105:
xv = (pv -103)/2
xv = (pv - 103) / 2
transition = 3
else:
pv = 106
xv = pv -100
xv = pv - 100
transition = -1
if transition != -1:
colorS,colorE = self.transitionsColors[transition]
colorS, colorE = self.transitionsColors[transition]
color = colorUtils.CalculateTransitionColor(colorS, colorE, xv)
else:
color = wx.Colour(191,48,48)
color = wx.Colour(191, 48, 48)
if self.gradientEffect > 0:
gcolor = colorUtils.BrightenColor(color, float(self.gradientEffect) / 100)
gMid = colorUtils.BrightenColor(color, float(self.gradientEffect/2) / 100)
gcolor = colorUtils.BrightenColor(color, float(self.gradientEffect) / 100)
gMid = colorUtils.BrightenColor(color, float(self.gradientEffect / 2) / 100)
else:
gcolor = colorUtils.DarkenColor(color, float(-self.gradientEffect) / 100)
gMid = colorUtils.DarkenColor(color, float(-self.gradientEffect/2) / 100)
gcolor = colorUtils.DarkenColor(color, float(-self.gradientEffect) / 100)
gMid = colorUtils.DarkenColor(color, float(-self.gradientEffect / 2) / 100)
gBmp = drawUtils.DrawGradientBar(r.width, r.height, gMid, color, gcolor)
dc.DrawBitmap(gBmp, r.left, r.top)
else:
colour=self.GetBarColour()
colour = self.GetBarColour()
dc.SetBrush(wx.Brush(colour))
dc.SetPen(wx.Pen(colour))
if value > 100:
@@ -381,14 +375,14 @@ class PyGauge(wx.PyWindow):
dc.SetFont(self.font)
r = copy.copy(rect)
r.left +=1
r.top +=1
r.left += 1
r.top += 1
if self._range == 0.01 and self._value > 0:
formatStr = u'\u221e'
dc.SetTextForeground(wx.Colour(80,80,80))
formatStr = u'\u221e'
dc.SetTextForeground(wx.Colour(80, 80, 80))
dc.DrawLabel(formatStr, r, wx.ALIGN_CENTER)
dc.SetTextForeground(wx.Colour(255,255,255))
dc.SetTextForeground(wx.Colour(255, 255, 255))
dc.DrawLabel(formatStr, rect, wx.ALIGN_CENTER)
else:
if self.GetBarGradient() and self._showRemaining:
@@ -404,20 +398,20 @@ class PyGauge(wx.PyWindow):
else:
formatStr = "{0:." + str(self._fractionDigits) + "f}%"
dc.SetTextForeground(wx.Colour(80,80,80))
dc.SetTextForeground(wx.Colour(80, 80, 80))
dc.DrawLabel(formatStr.format(value), r, wx.ALIGN_CENTER)
dc.SetTextForeground(wx.Colour(255,255,255))
dc.SetTextForeground(wx.Colour(255, 255, 255))
dc.DrawLabel(formatStr.format(value), rect, wx.ALIGN_CENTER)
def OnTimer(self,event):
def OnTimer(self, event):
"""
Handles the ``wx.EVT_TIMER`` event for L{PyfaGauge}.
:param `event`: a timer event
"""
oldValue=self._oldPercentage
value=self._percentage
oldValue = self._oldPercentage
value = self._percentage
start = 0
direction = 1 if oldValue < value else -1
@@ -436,13 +430,13 @@ class PyGauge(wx.PyWindow):
stop_timer = True
if direction == 1:
if (oldValue+step) < value:
self._animValue = oldValue+step
if (oldValue + step) < value:
self._animValue = oldValue + step
else:
stop_timer = True
else:
if (oldValue-step) > value:
self._animValue = oldValue-step
if (oldValue - step) > value:
self._animValue = oldValue - step
else:
stop_timer = True
@@ -451,4 +445,3 @@ class PyGauge(wx.PyWindow):
self._timer.Stop()
self.Refresh()

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2014 Ryan Holmes
#
# This file is part of pyfa.
@@ -15,14 +15,13 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from service.targetResists import TargetResists
from gui.bitmapLoader import BitmapLoader
from gui.utils.clipboard import toClipboard, fromClipboard
from service.targetResists import ImportError
from gui.builtinViews.entityEditor import EntityEditor, BaseValidator
from service.targetResists import TargetResists
class TargetResistsTextValidor(BaseValidator):
@@ -44,7 +43,7 @@ class TargetResistsTextValidor(BaseValidator):
raise ValueError("Target Resist Profile name already in use, please choose another.")
return True
except ValueError, e:
except ValueError as e:
wx.MessageBox(u"{}".format(e), "Error")
textCtrl.SetFocus()
return False
@@ -78,12 +77,13 @@ class TargetResistsEntityEditor(EntityEditor):
sTR = TargetResists.getInstance()
sTR.deletePattern(entity)
class ResistsEditorDlg(wx.Dialog):
DAMAGE_TYPES = ("em", "thermal", "kinetic", "explosive")
def __init__(self, parent):
wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Target Resists Editor", size = wx.Size( 350,240 ))
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"Target Resists Editor", size=wx.Size(350, 240))
self.block = False
self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)
@@ -104,24 +104,23 @@ class ResistsEditorDlg(wx.Dialog):
resistEditSizer.SetFlexibleDirection(wx.BOTH)
resistEditSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
width = -1
defSize = wx.Size(50,-1)
defSize = wx.Size(50, -1)
for i, type in enumerate(self.DAMAGE_TYPES):
if i%2:
for i, type_ in enumerate(self.DAMAGE_TYPES):
if i % 2:
style = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT
border = 25
else:
style = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT
border = 5
bmp = wx.StaticBitmap(self, wx.ID_ANY, BitmapLoader.getBitmap("%s_big"%type, "gui"))
bmp = wx.StaticBitmap(self, wx.ID_ANY, BitmapLoader.getBitmap("%s_big" % type_, "gui"))
resistEditSizer.Add(bmp, 0, style, border)
# set text edit
setattr(self, "%sEdit"%type, wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, defSize))
editObj = getattr(self, "%sEdit"%type)
setattr(self, "%sEdit" % type_, wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, defSize))
editObj = getattr(self, "%sEdit" % type_)
resistEditSizer.Add(editObj, 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5)
resistEditSizer.Add(wx.StaticText( self, wx.ID_ANY, u"%", wx.DefaultPosition, wx.DefaultSize, 0 ), 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5)
resistEditSizer.Add(wx.StaticText(self, wx.ID_ANY, u"%", wx.DefaultPosition, wx.DefaultSize, 0), 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5)
editObj.Bind(wx.EVT_TEXT, self.ValuesUpdated)
# Color we use to reset invalid value color
@@ -138,7 +137,7 @@ class ResistsEditorDlg(wx.Dialog):
self.stNotice.Wrap(-1)
perSizer.Add(self.stNotice, 0, wx.BOTTOM | wx.TOP | wx.LEFT, 5)
footerSizer.Add(perSizer, 1, wx.ALIGN_CENTER_VERTICAL, 5)
footerSizer.Add(perSizer, 1, wx.ALIGN_CENTER_VERTICAL, 5)
self.totSizer = wx.BoxSizer(wx.VERTICAL)
@@ -147,8 +146,8 @@ class ResistsEditorDlg(wx.Dialog):
mainSizer.Add(contentSizer, 1, wx.EXPAND, 0)
if "wxGTK" in wx.PlatformInfo:
self.closeBtn = wx.Button( self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.closeBtn, 0, wx.ALL|wx.ALIGN_RIGHT, 5 )
self.closeBtn = wx.Button(self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.closeBtn, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
self.closeBtn.Bind(wx.EVT_BUTTON, self.closeEvent)
self.SetSizer(mainSizer)
@@ -160,13 +159,13 @@ class ResistsEditorDlg(wx.Dialog):
bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON)
btn = wx.BitmapButton(self, wx.ID_ANY, bitmap)
btn.SetMinSize( btn.GetSize() )
btn.SetMaxSize( btn.GetSize() )
btn.SetMinSize(btn.GetSize())
btn.SetMaxSize(btn.GetSize())
btn.Layout()
setattr(self, name, btn)
btn.Enable(True)
btn.SetToolTipString("%s patterns %s clipboard" % (name, direction) )
btn.SetToolTipString("%s patterns %s clipboard" % (name, direction))
footerSizer.Add(btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_RIGHT)
btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Patterns".format(name.lower())))
@@ -201,8 +200,8 @@ class ResistsEditorDlg(wx.Dialog):
try:
p = self.entityEditor.getActiveEntity()
for type in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit"%type)
for type_ in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit" % type_)
if editObj.GetValue() == "":
# if we are blank, overwrite with 0
@@ -215,7 +214,7 @@ class ResistsEditorDlg(wx.Dialog):
assert 0 <= value <= 100
# if everything checks out, set resist attribute
setattr(p, "%sAmount"%type, value/100)
setattr(p, "%sAmount" % type_, value / 100)
editObj.SetForegroundColour(self.colorReset)
self.stNotice.SetLabel("")
@@ -250,13 +249,13 @@ class ResistsEditorDlg(wx.Dialog):
# Set new values
for field in self.DAMAGE_TYPES:
edit = getattr(self, "%sEdit" % field)
amount = getattr(p, "%sAmount" % field)*100
amount = getattr(p, "%sAmount" % field) * 100
edit.ChangeValue(str(amount))
self.block = False
self.ValuesUpdated()
def __del__( self ):
def __del__(self):
pass
def importPatterns(self, event):
@@ -268,9 +267,9 @@ class ResistsEditorDlg(wx.Dialog):
try:
sTR.importPatterns(text)
self.stNotice.SetLabel("Patterns successfully imported from clipboard")
except service.targetResists.ImportError, e:
except ImportError as e:
self.stNotice.SetLabel(str(e))
except Exception, e:
except Exception:
self.stNotice.SetLabel("Could not import from clipboard: unknown errors")
finally:
self.entityEditor.refreshEntityList()
@@ -280,5 +279,5 @@ class ResistsEditorDlg(wx.Dialog):
def exportPatterns(self, event):
"Event fired when export to clipboard button is clicked"
sTR = TargetResists.getInstance()
toClipboard( sTR.exportPatterns() )
toClipboard(sTR.exportPatterns())
self.stNotice.SetLabel("Patterns exported to clipboard")

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2016 Ryan Holmes
#
# This file is part of pyfa.
@@ -15,19 +15,19 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import logging
import wx
from gui.bitmapLoader import BitmapLoader
from service.implantSet import ImplantSets
from gui.builtinViews.implantEditor import BaseImplantEditorView
from gui.utils.clipboard import toClipboard, fromClipboard
from service.implantSet import ImportError
import logging
from gui.builtinViews.entityEditor import EntityEditor, BaseValidator
from service.implantSet import ImplantSets
logger = logging.getLogger(__name__)
class ImplantTextValidor(BaseValidator):
def __init__(self):
BaseValidator.__init__(self)
@@ -47,7 +47,7 @@ class ImplantTextValidor(BaseValidator):
raise ValueError("Imlplant Set name already in use, please choose another.")
return True
except ValueError, e:
except ValueError as e:
wx.MessageBox(u"{}".format(e), "Error")
textCtrl.SetFocus()
return False
@@ -92,27 +92,27 @@ class ImplantSetEditor(BaseImplantEditorView):
def getImplantsFromContext(self):
sIS = ImplantSets.getInstance()
set = self.Parent.entityEditor.getActiveEntity()
if set:
return sIS.getImplants(set.ID)
set_ = self.Parent.entityEditor.getActiveEntity()
if set_:
return sIS.getImplants(set_.ID)
return []
def addImplantToContext(self, item):
sIS = ImplantSets.getInstance()
set = self.Parent.entityEditor.getActiveEntity()
set_ = self.Parent.entityEditor.getActiveEntity()
sIS.addImplant(set.ID, item.ID)
sIS.addImplant(set_.ID, item.ID)
def removeImplantFromContext(self, implant):
sIS = ImplantSets.getInstance()
set = self.Parent.entityEditor.getActiveEntity()
set_ = self.Parent.entityEditor.getActiveEntity()
sIS.removeImplant(set_.ID, implant)
sIS.removeImplant(set.ID, implant)
class ImplantSetEditorDlg(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Implant Set Editor", size = wx.Size(640, 600))
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"Implant Set Editor", size=wx.Size(640, 600))
self.block = False
self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)
@@ -138,8 +138,8 @@ class ImplantSetEditorDlg(wx.Dialog):
footerSizer.Add(self.stNotice, 1, wx.BOTTOM | wx.TOP | wx.LEFT, 5)
if "wxGTK" in wx.PlatformInfo:
self.closeBtn = wx.Button( self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.closeBtn, 0, wx.ALL|wx.ALIGN_RIGHT, 5 )
self.closeBtn = wx.Button(self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.closeBtn, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
self.closeBtn.Bind(wx.EVT_BUTTON, self.closeEvent)
importExport = (("Import", wx.ART_FILE_OPEN, "from"),
@@ -149,13 +149,13 @@ class ImplantSetEditorDlg(wx.Dialog):
bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON)
btn = wx.BitmapButton(self, wx.ID_ANY, bitmap)
btn.SetMinSize( btn.GetSize() )
btn.SetMaxSize( btn.GetSize() )
btn.SetMinSize(btn.GetSize())
btn.SetMaxSize(btn.GetSize())
btn.Layout()
setattr(self, name, btn)
btn.Enable(True)
btn.SetToolTipString("%s implant sets %s clipboard" % (name, direction) )
btn.SetToolTipString("%s implant sets %s clipboard" % (name, direction))
footerSizer.Add(btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_RIGHT)
mainSizer.Add(footerSizer, 0, wx.ALL | wx.EXPAND, 5)
@@ -183,7 +183,7 @@ class ImplantSetEditorDlg(wx.Dialog):
def closeEvent(self, event):
self.Destroy()
def __del__( self ):
def __del__(self):
pass
def importPatterns(self, event):
@@ -196,9 +196,9 @@ class ImplantSetEditorDlg(wx.Dialog):
sIS.importSets(text)
self.stNotice.SetLabel("Patterns successfully imported from clipboard")
self.showInput(False)
except ImportError, e:
except ImportError as e:
self.stNotice.SetLabel(str(e))
except Exception, e:
except Exception as e:
logging.exception("Unhandled Exception")
self.stNotice.SetLabel("Could not import from clipboard: unknown errors")
finally:

View File

@@ -1,5 +1,4 @@
import wx
import gui.utils.colorUtils as colorUtils
import gui.utils.drawUtils as drawUtils
SB_ITEM_NORMAL = 0
@@ -7,14 +6,14 @@ SB_ITEM_SELECTED = 1
SB_ITEM_HIGHLIGHTED = 2
SB_ITEM_DISABLED = 4
BTN_NORMAL = 1
BTN_PRESSED = 2
BTN_HOVER = 4
BTN_NORMAL = 1
BTN_PRESSED = 2
BTN_HOVER = 4
BTN_DISABLED = 8
class PFBaseButton(object):
def __init__(self, normalBitmap = wx.NullBitmap,label = "", callback = None, hoverBitmap = None, disabledBitmap = None, show = True):
def __init__(self, normalBitmap=wx.NullBitmap, label="", callback=None, hoverBitmap=None, disabledBitmap=None, show=True):
self.normalBmp = normalBitmap
self.dropShadowOpacity = 0.2
@@ -48,7 +47,7 @@ class PFBaseButton(object):
if self.callback:
self.callback()
def SetState(self, state = BTN_NORMAL):
def SetState(self, state=BTN_NORMAL):
self.state = state
def GetState(self):
@@ -57,7 +56,7 @@ class PFBaseButton(object):
def GetSize(self):
w = self.normalBmp.GetWidth()
h = self.normalBmp.GetHeight()
return (w,h)
return (w, h)
def GetBitmap(self):
return self.normalBmp
@@ -70,22 +69,23 @@ class PFBaseButton(object):
return self.label
def GetHoverBitmap(self):
if self.hoverBmp == None:
if self.hoverBmp is None:
return self.normalBmp
return self.hoverBmp
def GetDisabledBitmap(self):
if self.disabledBmp == None:
if self.disabledBmp is None:
return self.normalBmp
return self.disabledBmp
def GetDropShadowBitmap(self):
return self.dropShadowBmp
class PFToolbar(object):
def __init__(self, parent):
self.Parent = parent
self.buttons =[]
self.buttons = []
self.toolbarX = 0
self.toolbarY = 0
self.padding = 2
@@ -94,7 +94,7 @@ class PFToolbar(object):
def SetPosition(self, pos):
self.toolbarX, self.toolbarY = pos
def AddButton(self, btnBitmap, label = "", clickCallback = None, hoverBitmap = None, disabledBitmap = None, show = True):
def AddButton(self, btnBitmap, label="", clickCallback=None, hoverBitmap=None, disabledBitmap=None, show=True):
btn = PFBaseButton(btnBitmap, label, clickCallback, hoverBitmap, disabledBitmap, show)
self.buttons.append(btn)
return btn
@@ -115,7 +115,7 @@ class PFToolbar(object):
continue
state = button.GetState()
if self.HitTest( (bx, self.toolbarY), event.GetPosition(), button.GetSize()):
if self.HitTest((bx, self.toolbarY), event.GetPosition(), button.GetSize()):
changeCursor = True
if not state & BTN_HOVER:
button.SetState(state | BTN_HOVER)
@@ -135,7 +135,7 @@ class PFToolbar(object):
return doRefresh
def MouseClick(self, event):
mx,my = event.GetPosition()
mx, my = event.GetPosition()
bx = self.toolbarX
for button in self.buttons:
if not button.IsVisible():
@@ -143,8 +143,8 @@ class PFToolbar(object):
state = button.GetState()
if state & BTN_PRESSED:
button.SetState(state ^ BTN_PRESSED )
if self.HitTest( (bx, self.toolbarY), event.GetPosition(), button.GetSize()):
button.SetState(state ^ BTN_PRESSED)
if self.HitTest((bx, self.toolbarY), event.GetPosition(), button.GetSize()):
return button
else:
return False
@@ -158,7 +158,7 @@ class PFToolbar(object):
state = button.GetState()
if self.HitTest( (bx, self.toolbarY), event.GetPosition(), button.GetSize()):
if self.HitTest((bx, self.toolbarY), event.GetPosition(), button.GetSize()):
if event.LeftDown() or event.LeftDClick():
button.SetState(state | BTN_PRESSED)
@@ -230,14 +230,14 @@ class PFToolbar(object):
bmpWidth = bmp.GetWidth()
pdc.DrawBitmap(dropShadowBmp,bx + self.padding / 2, self.toolbarY + self.padding / 2)
pdc.DrawBitmap(dropShadowBmp, bx + self.padding / 2, self.toolbarY + self.padding / 2)
pdc.DrawBitmap(bmp, tbx, by)
bx += bmpWidth + self.padding
class SFBrowserItem(wx.Window):
def __init__(self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = (0,16), style = 0):
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=(0, 16), style=0):
wx.Window.__init__(self, parent, id, pos, size, style)
self.highlighted = False
@@ -248,7 +248,6 @@ class SFBrowserItem(wx.Window):
self.toolbar = PFToolbar(self)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
@@ -256,8 +255,7 @@ class SFBrowserItem(wx.Window):
if "wxMSW" in wx.PlatformInfo:
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_DOWN,self.OnLeftDown)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
self.Bind(wx.EVT_MOTION, self.OnMotion)
@@ -271,7 +269,7 @@ class SFBrowserItem(wx.Window):
self.RenderBackground()
mdc.DrawBitmap(self.bkBitmap, 0,0)
mdc.DrawBitmap(self.bkBitmap, 0, 0)
self.DrawItem(mdc)
self.toolbar.Render(mdc)
@@ -291,7 +289,7 @@ class SFBrowserItem(wx.Window):
def MouseMove(self, event):
pass
def SetDraggable(self, mode = True):
def SetDraggable(self, mode=True):
self.canBeDragged = mode
def OnLeftUp(self, event):
@@ -302,14 +300,13 @@ class SFBrowserItem(wx.Window):
mposx, mposy = wx.GetMousePosition()
rect = self.GetRect()
rect.top = rect.left = 0
cx,cy = self.ScreenToClient((mposx,mposy))
if not rect.Contains((cx,cy)):
cx, cy = self.ScreenToClient((mposx, mposy))
if not rect.Contains((cx, cy)):
self.SetHighlighted(False)
self.toolbar.ClearState()
self.Refresh()
return
btn = self.toolbar.MouseClick(event)
if btn is not None:
@@ -323,7 +320,6 @@ class SFBrowserItem(wx.Window):
self.MouseLeftUp(event)
def OnLeftDown(self, event):
if not self.HasCapture():
self.CaptureMouse()
@@ -360,10 +356,10 @@ class SFBrowserItem(wx.Window):
def GetType(self):
return -1
def SetSelected(self, select = True):
def SetSelected(self, select=True):
self.selected = select
def SetHighlighted(self, highlight = True):
def SetHighlighted(self, highlight=True):
self.highlighted = highlight
def GetState(self):
@@ -373,7 +369,7 @@ class SFBrowserItem(wx.Window):
elif self.selected:
if self.highlighted:
state = SB_ITEM_SELECTED | SB_ITEM_HIGHLIGHTED
state = SB_ITEM_SELECTED | SB_ITEM_HIGHLIGHTED
else:
state = SB_ITEM_SELECTED
else:
@@ -396,7 +392,7 @@ class SFBrowserItem(wx.Window):
mFactor = 0.45
eFactor = 0.30
elif state == SB_ITEM_SELECTED | SB_ITEM_HIGHLIGHTED:
elif state == SB_ITEM_SELECTED | SB_ITEM_HIGHLIGHTED:
eFactor = 0.3
elif state == SB_ITEM_SELECTED:
eFactor = 0.15
@@ -405,7 +401,7 @@ class SFBrowserItem(wx.Window):
if self.bkBitmap:
if self.bkBitmap.eFactor == eFactor and self.bkBitmap.sFactor == sFactor and self.bkBitmap.mFactor == mFactor \
and rect.width == self.bkBitmap.GetWidth() and rect.height == self.bkBitmap.GetHeight() :
and rect.width == self.bkBitmap.GetWidth() and rect.height == self.bkBitmap.GetHeight():
return
else:
del self.bkBitmap

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,22 +15,24 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.statsView import StatsView
from service.fit import Fit
from gui.pyfatogglepanel import TogglePanel
import gui.builtinStatsViews
from gui.contextMenu import ContextMenu
#import gui.builtinViews.fittingView as fv
import gui.mainFrame
import gui.builtinStatsViews
import gui.globalEvents as GE
# import gui.builtinViews.fittingView as fv
from gui.statsView import StatsView
from gui.contextMenu import ContextMenu
from gui.pyfatogglepanel import TogglePanel
class StatsPane(wx.Panel):
DEFAULT_VIEWS = ["resourcesViewFull", "resistancesViewFull" ,"rechargeViewFull", "firepowerViewFull",
DEFAULT_VIEWS = ["resourcesViewFull", "resistancesViewFull", "rechargeViewFull", "firepowerViewFull",
"capacitorViewFull", "targetingmiscViewFull",
"priceViewFull",]
"priceViewFull"]
def fitChanged(self, event):
sFit = Fit.getInstance()
@@ -44,7 +46,7 @@ class StatsPane(wx.Panel):
# Use 25% smaller fonts if MAC or force font size to 8 for msw/linux
if "__WXMAC__" in wx.PlatformInfo :
if "__WXMAC__" in wx.PlatformInfo:
self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
else:
standardFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
@@ -57,7 +59,7 @@ class StatsPane(wx.Panel):
self.views = []
self.nameViewMap = {}
maxviews = len(self.DEFAULT_VIEWS)
i=0
i = 0
for viewName in self.DEFAULT_VIEWS:
tp = TogglePanel(self)
contentPanel = tp.GetContentPane()
@@ -80,18 +82,18 @@ class StatsPane(wx.Panel):
mainSizer.Add(tp, 0, wx.EXPAND | wx.LEFT, 3)
if i < maxviews - 1:
mainSizer.Add(wx.StaticLine(self, wx.ID_ANY, style=wx.HORIZONTAL), 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 2)
i+=1
i += 1
tp.OnStateChange(tp.GetBestSize())
width,height = self.GetSize()
self.SetMinSize((width+9,-1))
width, height = self.GetSize()
self.SetMinSize((width + 9, -1))
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
def contextHandler(self, contentPanel):
viewName = contentPanel.viewName
def handler(event):
menu = ContextMenu.getMenu(None, (viewName,))
if menu is not None:

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,10 +15,12 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
class StatsView(object):
views = {}
def __init__(self):
pass
@@ -39,4 +41,5 @@ class StatsView(object):
def refreshPanel(self, fit):
raise NotImplementedError()
from gui.builtinStatsViews import *
from gui.builtinStatsViews import * # noqa

View File

@@ -1,4 +1,4 @@
#===============================================================================
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
# =============================================================================
import wx
from gui.bitmapLoader import BitmapLoader

View File

@@ -1,83 +1,98 @@
import math
def OUT_CIRC (t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d -1
return c * math.sqrt(1 - t*t) + b;
def OUT_CIRC(t, b, c, d):
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t = t / d - 1
return c * math.sqrt(1 - t * t) + b
def OUT_QUART(t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d -1
return -c * ((t)*t*t*t - 1) + b;
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t = t / d - 1
return -c * (t * t * t * t - 1) + b
def INOUT_CIRC(t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t1 = t / (d / 2)
if ((t / (d/2)) < 1):
return -c/2 * (math.sqrt(1 - (t/(d/2))**2) - 1) + b
return c/2 * (math.sqrt(1 - (t1-2)**2) + 1) + b;
def IN_CUBIC (t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d
return c*t*t*t + b
def OUT_QUAD (t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t/=d
return -c *(t)*(t-2) + b
def OUT_BOUNCE (t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t/=d
if ((t) < (1/2.75)):
return c*(7.5625*t*t) + b
if (t / (d / 2)) < 1:
return -c / 2 * (math.sqrt(1 - (t / (d / 2)) ** 2) - 1) + b
else:
if (t < (2/2.75)):
t-=(1.5/2.75)
return c*(7.5625*t*t + .75) + b
else:
if (t < (2.5/2.75)):
t-=(2.25/2.75)
return c*(7.5625*(t)*t + .9375) + b
else:
t-=(2.625/2.75)
return c*(7.5625*(t)*t + .984375) + b
return c / 2 * (math.sqrt(1 - (t1 - 2) ** 2) + 1) + b
def IN_CUBIC(t, b, c, d):
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t = t / d
return c * t * t * t + b
def OUT_QUAD(t, b, c, d):
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t /= d
return -c * t * (t - 2) + b
def OUT_BOUNCE(t, b, c, d):
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t /= d
if t < (1 / 2.75):
return c * (7.5625 * t * t) + b
elif t < (2 / 2.75):
t -= (1.5 / 2.75)
return c * (7.5625 * t * t + .75) + b
elif t < (2.5 / 2.75):
t -= (2.25 / 2.75)
return c * (7.5625 * t * t + .9375) + b
else:
t -= (2.625 / 2.75)
return c * (7.5625 * t * t + .984375) + b
def INOUT_EXP(t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t1 = t / (d/2)
if t==0:
return b
if t==d:
return b+c
if (t1) < 1:
return c/2 * math.pow(2, 10 * (t1 - 1)) + b - c * 0.0005
return c/2 * 1.0005 * (-math.pow(2, -10 * (t1-1)) + 2) + b
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t1 = t / (d / 2)
if t == 0:
return b
elif t == d:
return b + c
elif t1 < 1:
return c / 2 * math.pow(2, 10 * (t1 - 1)) + b - c * 0.0005
else:
return c / 2 * 1.0005 * (-math.pow(2, -10 * (t1 - 1)) + 2) + b

View File

@@ -1,9 +1,10 @@
import wx
import gui.utils.colorUtils as colorUtils
class LoadAnimation(wx.Window):
def __init__ (self, parent, id = wx.ID_ANY, label = "", pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0):
wx.Window.__init__(self, parent, id, pos = pos, size = size, style = style)
def __init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.Window.__init__(self, parent, id, pos=pos, size=size, style=style)
self.label = label
@@ -16,7 +17,6 @@ class LoadAnimation(wx.Window):
self.bars = 10
self.padding = 2
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_TIMER, self.OnTimer)
self.Bind(wx.EVT_PAINT, self.OnPaint)
@@ -64,14 +64,14 @@ class LoadAnimation(wx.Window):
x = self.padding
for bar in xrange(self.bars):
for bar in range(self.bars):
if bar != self.animCount:
dc.SetPen(wx.Pen(shadeColor))
dc.SetBrush(wx.Brush(shadeColor))
bh = barHeight
y = self.padding
else:
barColor = colorUtils.GetSuitableColor(barColor,float(self.animCount/2)/10)
barColor = colorUtils.GetSuitableColor(barColor, float(self.animCount / 2) / 10)
dc.SetPen(wx.Pen(barColor))
dc.SetBrush(wx.Brush(barColor))
bh = rect.height
@@ -82,17 +82,17 @@ class LoadAnimation(wx.Window):
textColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)
dc.SetTextForeground(textColor)
dc.DrawLabel(self.label,rect,wx.ALIGN_CENTER)
dc.DrawLabel(self.label, rect, wx.ALIGN_CENTER)
class WaitDialog(wx.Dialog):
def __init__(self, parent, title = "Processing"):
wx.Dialog.__init__ (self, parent, id=wx.ID_ANY, title = title, size=(300,30),
def __init__(self, parent, title="Processing"):
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=title, size=(300, 30),
style=wx.NO_BORDER)
mainSizer = wx.BoxSizer( wx.HORIZONTAL )
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
self.progress = LoadAnimation(self,label = title, size=(300,30))
mainSizer.Add( self.progress, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 0 )
self.SetSizer( mainSizer )
self.progress = LoadAnimation(self, label=title, size=(300, 30))
mainSizer.Add(self.progress, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 0)
self.SetSizer(mainSizer)
self.Layout()
self.CenterOnParent()

View File

@@ -1,5 +1,6 @@
import wx
def toClipboard(text):
clip = wx.TheClipboard
clip.Open()
@@ -7,6 +8,7 @@ def toClipboard(text):
clip.SetData(data)
clip.Close()
def fromClipboard():
clip = wx.TheClipboard
clip.Open()
@@ -16,4 +18,4 @@ def fromClipboard():
return data.GetText()
else:
clip.Close()
return None
return None

View File

@@ -1,25 +1,26 @@
import wx
import math
#Brightens a color (wx.Colour), factor = [0,1]
def BrightenColor(color, factor):
# Brightens a color (wx.Colour), factor = [0,1]
r,g,b = color
r, g, b = color
a = color.Alpha()
factor = min(max(factor, 0), 1)
r+=(255-r)*factor
b+=(255-b)*factor
g+=(255-g)*factor
r += (255 - r) * factor
b += (255 - b) * factor
g += (255 - g) * factor
return wx.Colour(r,g,b,a)
return wx.Colour(r, g, b, a)
#Darkens a color (wx.Colour), factor = [0, 1]
def DarkenColor(color, factor):
bkR ,bkG , bkB = color
# Darkens a color (wx.Colour), factor = [0, 1]
bkR, bkG, bkB = color
alpha = color.Alpha()
@@ -30,50 +31,50 @@ def DarkenColor(color, factor):
g = float(bkG * factor)
b = float(bkB * factor)
r = min(max(r,0),255)
b = min(max(b,0),255)
g = min(max(g,0),255)
r = min(max(r, 0), 255)
b = min(max(b, 0), 255)
g = min(max(g, 0), 255)
return wx.Colour(r, g, b, alpha)
#Calculates the brightness of a color, different options
def GetBrightnessO1(color):
r,g,b = color
return (0.299*r + 0.587*g + 0.114*b)
# Calculates the brightness of a color, different options
r, g, b = color
return (0.299 * r + 0.587 * g + 0.114 * b)
def GetBrightnessO2(color):
r,g,b = color
return math.sqrt( 0.241 * r * r + 0.691 * g * g + 0.068 * b * b )
r, g, b = color
return math.sqrt(0.241 * r * r + 0.691 * g * g + 0.068 * b * b)
#Calculates a suitable color based on original color (wx.Colour), its brightness, a factor=[0,1] (darken/brighten by factor depending on calculated brightness)
def GetSuitableColor(color, factor):
# Calculates a suitable color based on original color (wx.Colour), its brightness, a factor=[0,1] (darken/brighten by factor depending on calculated brightness)
brightness = GetBrightnessO1(color)
if brightness >129:
if brightness > 129:
return DarkenColor(color, factor)
else:
return BrightenColor(color, factor)
#Calculates the color between a given start and end colors, delta = [0,1]
#Colors are wx.Colour objects
def CalculateTransitionColor(startColor, endColor, delta):
sR,sG,sB = startColor
eR,eG,eB = endColor
"""
Calculates the color between a given start and end colors, delta = [0,1]
Colors are wx.Colour objects
"""
sR, sG, sB = startColor
eR, eG, eB = endColor
alphaS = startColor.Alpha()
alphaE = endColor.Alpha()
tR = sR + (eR - sR) * delta
tG = sG + (eG - sG) * delta
tB = sB + (eB - sB) * delta
tR = sR + (eR - sR) * delta
tG = sG + (eG - sG) * delta
tB = sB + (eB - sB) * delta
return wx.Colour(tR, tG, tB, (alphaS + alphaE)/2)
return wx.Colour(tR, tG, tB, (alphaS + alphaE) / 2)

Some files were not shown because too many files have changed in this diff Show More