Merge branch 'master' into charImplants

Conflicts:
	gui/characterEditor.py
This commit is contained in:
blitzmann
2015-11-08 21:19:04 -05:00
1885 changed files with 3742 additions and 928 deletions

View File

@@ -1,7 +1,7 @@
import wx
import gui.utils.colorUtils as colorUtils
import gui.utils.drawUtils as drawUtils
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
SearchButton, EVT_SEARCH_BTN = wx.lib.newevent.NewEvent()
@@ -11,7 +11,7 @@ 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 = 0)
wx.Window.__init__(self, parent, id, pos, size, style = style)
self.isSearchButtonVisible = False
self.isCancelButtonVisible = False
@@ -49,10 +49,6 @@ class PFSearchBox(wx.Window):
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
self.Bind(wx.EVT_MOTION, self.OnMouseMove)
self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterLeaveWindow)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnEnterLeaveWindow)
# self.EditBox.ChangeValue(self.descriptiveText)
@@ -64,25 +60,26 @@ class PFSearchBox(wx.Window):
self.SetMinSize(size)
def OnEnterLeaveWindow(self, event):
self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
self._hl = False
def OnText(self, event):
wx.PostEvent(self, TextTyped())
event.Skip()
def OnTextEnter(self, event):
wx.PostEvent(self, TextEnter())
event.Skip()
def OnEditSetFocus(self, event):
# value = self.EditBox.GetValue()
# if value == self.descriptiveText:
# self.EditBox.ChangeValue("")
pass
event.Skip()
def OnEditKillFocus(self, event):
if self.EditBox.GetValue() == "":
self.Clear()
event.Skip()
def Clear(self):
self.EditBox.Clear()
@@ -138,20 +135,6 @@ class PFSearchBox(wx.Window):
btnsize.append( (cw,ch))
return btnsize
def OnMouseMove(self, event):
btnpos = self.GetButtonsPos()
btnsize = self.GetButtonsSize()
for btn in xrange(2):
if self.HitTest(btnpos[btn], event.GetPosition(), btnsize[btn]):
if not self._hl:
self.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
self._hl = True
break
else:
if self._hl:
self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
self._hl = False
def OnLeftDown(self, event):
btnpos = self.GetButtonsPos()
btnsize = self.GetButtonsSize()

View File

@@ -20,7 +20,7 @@ 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 gpl.txt",
"pyfa is released under GNU GPLv3 - see included LICENSE file",
"All EVE-Online related materials are property of CCP hf.",
"Silk Icons Set by famfamfam.com - Creative Commons Attribution 2.5 License",
"Fat Cow Icons by fatcow.com - Creative Commons Attribution 3.0 License"

View File

@@ -26,7 +26,7 @@ from gui.implantView import ImplantView
from gui.projectedView import ProjectedView
from gui.pyfatogglepanel import TogglePanel
from gui.gangView import GangView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.chromeTabs
@@ -45,18 +45,16 @@ class AdditionsPane(TogglePanel):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.notebook = gui.chromeTabs.PFNotebook(pane, False)
size = wx.Size()
# This size lets you see 4 drones at a time
size.SetHeight(180)
self.notebook.SetMinSize(size)
self.notebook.SetMinSize((-1, 1000))
baseSizer.Add(self.notebook, 1, wx.EXPAND)
droneImg = bitmapLoader.getImage("drone_small", "icons")
implantImg = bitmapLoader.getImage("implant_small", "icons")
boosterImg = bitmapLoader.getImage("booster_small", "icons")
projectedImg = bitmapLoader.getImage("projected_small", "icons")
gangImg = bitmapLoader.getImage("fleet_fc_small", "icons")
cargoImg = bitmapLoader.getImage("cargo_small", "icons")
droneImg = BitmapLoader.getImage("drone_small", "gui")
implantImg = BitmapLoader.getImage("implant_small", "gui")
boosterImg = BitmapLoader.getImage("booster_small", "gui")
projectedImg = BitmapLoader.getImage("projected_small", "gui")
gangImg = BitmapLoader.getImage("fleet_fc_small", "gui")
cargoImg = BitmapLoader.getImage("cargo_small", "gui")
self.notebook.AddPage(DroneView(self.notebook), "Drones", tabImage = droneImg, showClose = False)
self.notebook.AddPage(CargoView(self.notebook), "Cargo", tabImage = cargoImg, showClose = False)
@@ -76,3 +74,21 @@ class AdditionsPane(TogglePanel):
def getName(self, idx):
return self.PANES[idx]
def toggleContent(self, event):
TogglePanel.toggleContent(self, event)
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)
# only available in >= wx2.9
if getattr(self.parent, "SetSashInvisible", None):
self.parent.SetSashInvisible(True)
else:
if getattr(self.parent, "SetSashInvisible", None):
self.parent.SetSashInvisible(False)
self.parent.SetMinimumPaneSize(200)
self.parent.SetSashPosition(self.old_pos, True)

View File

@@ -20,87 +20,74 @@
import os.path
import config
import wx
import time
import zipfile
import cStringIO
try:
from collections import OrderedDict
except ImportError:
from utils.compat import OrderedDict
cachedBitmapsCount = 0
cachedBitmaps = OrderedDict()
dontUseCachedBitmaps = False
class BitmapLoader():
def getStaticBitmap(name, parent, location):
static = wx.StaticBitmap(parent)
static.SetBitmap(getBitmap(name,location))
return static
try:
archive = zipfile.ZipFile(os.path.join(config.pyfaPath, 'imgs.zip'), 'r')
except IOError:
archive = None
locationMap = {"pack": os.path.join(config.staticPath, "icons"),
"ships": os.path.join(config.staticPath, "icons/ships")}
cachedBitmaps = OrderedDict()
dontUseCachedBitmaps = False
max_bmps = 500
def getBitmap(name,location):
@classmethod
def getStaticBitmap(cls, name, parent, location):
static = wx.StaticBitmap(parent)
static.SetBitmap(cls.getBitmap(name,location))
return static
global cachedBitmaps
global cachedBitmapsCount
global dontUseCachedBitmaps
@classmethod
def getBitmap(cls, name, location):
if cls.dontUseCachedBitmaps:
img = cls.getImage(name, location)
if img is not None:
return img.ConvertToBitmap()
if dontUseCachedBitmaps:
img = getImage(name, location)
if img is not None:
return img.ConvertToBitmap()
path = "%s%s" % (name, location)
path = "%s%s" % (name,location)
MAX_BMPS = 500
# start = time.clock()
if cachedBitmapsCount == MAX_BMPS:
cachedBitmaps.popitem(False)
cachedBitmapsCount -=1
if len(cls.cachedBitmaps) == cls.max_bmps:
cls.cachedBitmaps.popitem(False)
if path not in cachedBitmaps:
img = getImage(name, location)
if img is not None:
bmp = img.ConvertToBitmap()
if path not in cls.cachedBitmaps:
img = cls.getImage(name, location)
if img is not None:
bmp = img.ConvertToBitmap()
else:
bmp = None
cls.cachedBitmaps[path] = bmp
else:
bmp = None
cachedBitmaps[path] = bmp
cachedBitmapsCount += 1
else:
bmp = cachedBitmaps[path]
bmp = cls.cachedBitmaps[path]
# print "#BMPs:%d - Current took: %.8f" % (cachedBitmapsCount,time.clock() - start)
return bmp
return bmp
def stripPath(fname):
"""
Here we extract 'core' of icon name. Path and
extension are sometimes specified in database
but we don't need them.
"""
# Path before the icon file name
fname = fname.split('/')[-1]
# Extension
fname = fname.rsplit('.', 1)[0]
return fname
def getImage(name, location):
if location in locationMap:
if location == "pack":
location = locationMap[location]
name = stripPath(name)
filename = "icon{0}.png".format(name)
path = os.path.join(location, filename)
else:
location = locationMap[location]
filename = "{0}.png".format(name)
path = os.path.join(location, filename)
else:
location = os.path.join(config.pyfaPath, location)
@classmethod
def getImage(cls, name, location):
filename = "{0}.png".format(name)
path = os.path.join(location, filename)
if os.path.exists(path):
return wx.Image(path)
else:
print "Missing icon file: {0}".format(filename)
if cls.archive:
path = os.path.join(location, filename)
if os.sep != "/" and os.sep in path:
path = path.replace(os.sep, "/")
try:
img_data = cls.archive.read(path)
sbuf = cStringIO.StringIO(img_data)
return wx.ImageFromStream(sbuf)
except KeyError:
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)

View File

@@ -20,7 +20,6 @@ class ChangeAmount(ContextMenu):
srcContext = fullContext[0]
dlg = AmountChanger(self.mainFrame, selection[0], srcContext)
dlg.ShowModal()
dlg.Destroy()
ChangeAmount.register()
@@ -59,7 +58,7 @@ class AmountChanger(wx.Dialog):
wx.PostEvent(mainFrame, GE.FitChanged(fitID=fitID))
event.Skip()
self.Destroy()
self.Close()
## checks to make sure it's valid number
def onChar(self, event):

View File

@@ -3,7 +3,7 @@ from gui.contextMenu import ContextMenu
import gui.mainFrame
import service
import wx
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from eos.types import Skill
import gui.globalEvents as GE
@@ -74,7 +74,7 @@ class ChangeAffectingSkills(ContextMenu):
grandSub = wx.Menu()
skillItem.SetSubMenu(grandSub)
if skill.learned:
bitmap = bitmapLoader.getBitmap("lvl%s" % skill.level, "icons")
bitmap = BitmapLoader.getBitmap("lvl%s" % skill.level, "gui")
if bitmap is not None:
skillItem.SetBitmap(bitmap)

View File

@@ -3,7 +3,7 @@ import gui.mainFrame
import service
import gui.globalEvents as GE
import wx
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
try:
from collections import OrderedDict
@@ -65,7 +65,7 @@ class DamagePattern(ContextMenu):
dp = f.damagePattern
if dp == pattern:
bitmap = bitmapLoader.getBitmap("state_active_small", "icons")
bitmap = BitmapLoader.getBitmap("state_active_small", "gui")
menuItem.SetBitmap(bitmap)
return menuItem
@@ -80,7 +80,7 @@ class DamagePattern(ContextMenu):
self.patternIds[id] = self.singles[i]
rootMenu.Bind(wx.EVT_MENU, self.handlePatternSwitch, pitem)
if self.patternIds[id] == self.fit.damagePattern:
bitmap = bitmapLoader.getBitmap("state_active_small", "icons")
bitmap = BitmapLoader.getBitmap("state_active_small", "gui")
pitem.SetBitmap(bitmap)
return False

View File

@@ -3,7 +3,7 @@ import gui.mainFrame
import service
import gui.globalEvents as GE
import wx
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
class FactorReload(ContextMenu):
def __init__(self):
@@ -27,7 +27,7 @@ class FactorReload(ContextMenu):
fitID = self.mainFrame.getActiveFit()
fit = sFit.getFit(fitID)
if fit.factorReload:
return bitmapLoader.getBitmap("state_active_small", "icons")
return BitmapLoader.getBitmap("state_active_small", "gui")
else:
return None

View File

@@ -3,7 +3,7 @@ from gui.contextMenu import ContextMenu
import gui.mainFrame
import service
import wx
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from eos.types import Hardpoint
import gui.globalEvents as GE
@@ -105,7 +105,7 @@ class ModuleAmmoPicker(ContextMenu):
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, "pack")
bitmap = BitmapLoader.getBitmap(charge.icon.iconFile, "icons")
if bitmap is not None:
item.SetBitmap(bitmap)
@@ -181,7 +181,7 @@ class ModuleAmmoPicker(ContextMenu):
type = currType
item = wx.MenuItem(m, wx.ID_ANY, type.capitalize())
bitmap = bitmapLoader.getBitmap("%s_small" % type, "icons")
bitmap = BitmapLoader.getBitmap("%s_small" % type, "gui")
if bitmap is not None:
item.SetBitmap(bitmap)

View File

@@ -3,7 +3,7 @@ from gui.contextMenu import ContextMenu
import gui.mainFrame
import service
import wx
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from eos.types import Hardpoint
import gui.globalEvents as GE
from gui.builtinContextMenus.moduleAmmoPicker import ModuleAmmoPicker

View File

@@ -3,7 +3,7 @@ import gui.mainFrame
import service
import gui.globalEvents as GE
import wx
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
try:
from collections import OrderedDict
@@ -56,7 +56,7 @@ class TargetResists(ContextMenu):
tr = f.targetResists
if tr == pattern:
bitmap = bitmapLoader.getBitmap("state_active_small", "icons")
bitmap = BitmapLoader.getBitmap("state_active_small", "gui")
item.SetBitmap(bitmap)
return item

View File

@@ -19,7 +19,7 @@
from gui.graph import Graph
import service
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from eos.graph.fitDps import FitDpsGraph as FitDps
from eos.graph import Data
import gui.mainFrame
@@ -56,7 +56,7 @@ class FitDpsGraph(Graph):
sAttr = service.Attribute.getInstance()
for key, attrName in self.propertyAttributeMap.iteritems():
iconFile = sAttr.getAttributeInfo(attrName).icon.iconFile
bitmap = bitmapLoader.getBitmap(iconFile, "pack")
bitmap = BitmapLoader.getBitmap(iconFile, "icons")
if bitmap:
icons[key] = bitmap

View File

@@ -1 +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__.append("pyfaCrestPreferences")

View File

@@ -19,7 +19,7 @@
import wx
from gui.preferenceView import PreferenceView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
class DummyView(PreferenceView):
title = "Dummy"

View File

@@ -0,0 +1,120 @@
import wx
from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import service
from service.crest import CrestModes
class PFCrestPref ( PreferenceView):
title = "CREST"
def populatePanel( self, panel ):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.settings = service.settings.CRESTSettings.getInstance()
self.dirtySettings = False
dlgWidth = panel.GetParent().GetParent().ClientSize.width
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.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.Wrap(dlgWidth - 50)
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)
self.rbServer = wx.RadioBox(panel, -1, "Server", wx.DefaultPosition, wx.DefaultSize, ['Tranquility', 'Singularity'], 1, wx.RA_SPECIFY_COLS)
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 )
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)
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 )
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.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 )
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 )
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 )
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)
self.ToggleProxySettings(self.settings.get('mode'))
panel.SetSizer( mainSizer )
panel.Layout()
def OnModeChange(self, event):
self.settings.set('mode', event.GetInt())
self.ToggleProxySettings(self.settings.get('mode'))
service.Crest.restartService()
def OnServerChange(self, event):
self.settings.set('server', event.GetInt())
service.Crest.restartService()
def OnBtnApply(self, event):
self.settings.set('clientID', self.inputClientID.GetValue())
self.settings.set('clientSecret', self.inputClientSecret.GetValue())
sCrest = service.Crest.getInstance()
sCrest.delAllCharacters()
def ToggleProxySettings(self, mode):
if mode:
self.stSetID.Enable()
self.inputClientID.Enable()
self.stSetSecret.Enable()
self.inputClientSecret.Enable()
else:
self.stSetID.Disable()
self.inputClientID.Disable()
self.stSetSecret.Disable()
self.inputClientSecret.Disable()
def getImage(self):
return BitmapLoader.getBitmap("eve", "gui")
PFCrestPref.register()

View File

@@ -6,7 +6,7 @@ import wx
import copy
from gui.preferenceView import PreferenceView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils import colorUtils
import gui.utils.drawUtils as drawUtils
@@ -313,7 +313,7 @@ class PFGaugePref ( PreferenceView):
self.cp103105E.Bind( wx.EVT_COLOURPICKER_CHANGED, self.OnColourChanged )
def getImage(self):
return bitmapLoader.getBitmap("pref-gauges_big", "icons")
return BitmapLoader.getBitmap("pref-gauges_big", "gui")
def InitDefaultColours(self):
self.c0100S = wx.Colour(191, 191, 191, 255)

View File

@@ -1,7 +1,7 @@
import wx
from gui.preferenceView import PreferenceView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import service
@@ -144,6 +144,6 @@ class PFGeneralPref ( PreferenceView):
self.sFit.serviceFittingOptions["showMarketShortcuts"] = self.cbMarketShortcuts.GetValue()
def getImage(self):
return bitmapLoader.getBitmap("prefs_settings", "icons")
return BitmapLoader.getBitmap("prefs_settings", "gui")
PFGeneralPref.register()

View File

@@ -2,7 +2,7 @@ import wx
import os
from gui.preferenceView import PreferenceView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import service
@@ -76,6 +76,6 @@ class PFHTMLExportPref ( PreferenceView):
self.HTMLExportSettings.setEnabled(self.exportEnabled.GetValue())
def getImage(self):
return bitmapLoader.getBitmap("prefs_html", "icons")
return BitmapLoader.getBitmap("prefs_html", "gui")
PFHTMLExportPref.register()

View File

@@ -1,7 +1,7 @@
import wx
from gui.preferenceView import PreferenceView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import service
@@ -223,6 +223,6 @@ class PFNetworkPref ( PreferenceView):
self.editProxySettingsPort.Disable()
def getImage(self):
return bitmapLoader.getBitmap("prefs_proxy", "icons")
return BitmapLoader.getBitmap("prefs_proxy", "gui")
PFNetworkPref.register()

View File

@@ -3,7 +3,7 @@ import service
import os
from gui.preferenceView import PreferenceView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import service
import gui.globalEvents as GE
@@ -99,6 +99,6 @@ class PFUpdatePref (PreferenceView):
wx.LaunchDefaultBrowser('https://github.com/DarkFenX/Pyfa/releases/tag/'+self.UpdateSettings.get('version'))
def getImage(self):
return bitmapLoader.getBitmap("prefs_update", "icons")
return BitmapLoader.getBitmap("prefs_update", "gui")
PFUpdatePref.register()

View File

@@ -20,7 +20,7 @@
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
class CapacitorViewFull(StatsView):
@@ -48,7 +48,7 @@ class CapacitorViewFull(StatsView):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerCapacitor.Add(baseBox, 0, wx.ALIGN_LEFT)
bitmap = bitmapLoader.getStaticBitmap("capacitorInfo_big", parent, "icons")
bitmap = BitmapLoader.getStaticBitmap("capacitorInfo_big", parent, "gui")
tooltip = wx.ToolTip("Capacitor stability")
bitmap.SetToolTip(tooltip)
baseBox.Add(bitmap, 0, wx.ALIGN_CENTER)
@@ -83,7 +83,7 @@ class CapacitorViewFull(StatsView):
sizerCapacitor.Add(baseBox, 0, wx.ALIGN_CENTER_HORIZONTAL)
tooltip = wx.ToolTip("Capacitor throughput")
bitmap = bitmapLoader.getStaticBitmap("capacitorRecharge_big", parent, "icons")
bitmap = BitmapLoader.getStaticBitmap("capacitorRecharge_big", parent, "gui")
bitmap.SetToolTip(tooltip)
baseBox.Add(bitmap, 0, wx.ALIGN_CENTER)

View File

@@ -21,7 +21,7 @@ import wx
import service
import gui.mainFrame
from gui.statsView import StatsView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
class FirepowerViewFull(StatsView):
@@ -61,7 +61,7 @@ class FirepowerViewFull(StatsView):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerFirepower.Add(baseBox, 1, wx.ALIGN_LEFT if counter == 0 else wx.ALIGN_CENTER_HORIZONTAL)
baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, parent, "icons"), 0, wx.ALIGN_CENTER)
baseBox.Add(BitmapLoader.getStaticBitmap("%s_big" % image, parent, "gui"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 0, wx.ALIGN_CENTER)
@@ -82,7 +82,7 @@ class FirepowerViewFull(StatsView):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
targetSizer.Add(baseBox, 0, wx.ALIGN_RIGHT)
baseBox.Add(bitmapLoader.getStaticBitmap("volley_big", parent, "icons"), 0, wx.ALIGN_CENTER)
baseBox.Add(BitmapLoader.getStaticBitmap("volley_big", parent, "gui"), 0, wx.ALIGN_CENTER)
gridS = wx.GridSizer(2,2,0,0)
@@ -103,7 +103,7 @@ class FirepowerViewFull(StatsView):
gridS.Add(lbl, 0, wx.ALIGN_LEFT)
image = bitmapLoader.getBitmap("mining_small", "icons")
image = BitmapLoader.getBitmap("mining_small", "gui")
self.miningyield = wx.BitmapButton(contentPanel, -1, image)
self.miningyield.SetToolTip(wx.ToolTip("Click to toggle to Mining Yield "))
self.miningyield.Bind(wx.EVT_BUTTON, self.switchToMiningYieldView)

View File

@@ -21,7 +21,7 @@ import wx
import service
import gui.mainFrame
from gui.statsView import StatsView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
class MiningYieldViewFull(StatsView):
@@ -55,7 +55,7 @@ class MiningYieldViewFull(StatsView):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerMiningYield.Add(baseBox, 1, wx.ALIGN_LEFT if counter == 0 else wx.ALIGN_CENTER_HORIZONTAL)
baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, parent, "icons"), 0, wx.ALIGN_CENTER)
baseBox.Add(BitmapLoader.getStaticBitmap("%s_big" % image, parent, "gui"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 0, wx.ALIGN_CENTER)
@@ -76,7 +76,7 @@ class MiningYieldViewFull(StatsView):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
targetSizer.Add(baseBox, 0, wx.ALIGN_LEFT)
baseBox.Add(bitmapLoader.getStaticBitmap("cargoBay_big", parent, "icons"), 0, wx.ALIGN_CENTER)
baseBox.Add(BitmapLoader.getStaticBitmap("cargoBay_big", parent, "gui"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 0, wx.EXPAND)
@@ -92,7 +92,7 @@ class MiningYieldViewFull(StatsView):
self._cachedValues.append(0)
image = bitmapLoader.getBitmap("turret_small", "icons")
image = BitmapLoader.getBitmap("turret_small", "gui")
firepower = wx.BitmapButton(contentPanel, -1, image)
firepower.SetToolTip(wx.ToolTip("Click to toggle to Firepower View"))
firepower.Bind(wx.EVT_BUTTON, self.switchToFirepowerView)

View File

@@ -20,7 +20,7 @@
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
import service
import locale
@@ -56,7 +56,7 @@ class PriceViewFull(StatsView):
box = wx.BoxSizer(wx.HORIZONTAL)
gridPrice.Add(box, 0, wx.ALIGN_TOP)
box.Add(bitmapLoader.getStaticBitmap(image, contentPanel, "icons"), 0, wx.ALIGN_CENTER)
box.Add(BitmapLoader.getStaticBitmap(image, contentPanel, "gui"), 0, wx.ALIGN_CENTER)
vbox = wx.BoxSizer(wx.VERTICAL)
box.Add(vbox, 1, wx.EXPAND)

View File

@@ -19,7 +19,7 @@
import wx
from gui.statsView import StatsView
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
import gui.mainFrame
import gui.builtinStatsViews.resistancesViewFull as rvf
@@ -62,14 +62,14 @@ class RechargeViewFull(StatsView):
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"}
for tankType in ("shieldPassive", "shieldActive", "armorActive", "hullActive"):
bitmap = bitmapLoader.getStaticBitmap("%s_big" % tankType, contentPanel, "icons")
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"}
for stability in ("reinforced", "sustained"):
bitmap = bitmapLoader.getStaticBitmap("regen%s_big" % stability.capitalize(), contentPanel, "icons")
bitmap = BitmapLoader.getStaticBitmap("regen%s_big" % stability.capitalize(), contentPanel, "gui")
tooltip = wx.ToolTip(toolTipText[stability])
bitmap.SetToolTip(tooltip)
sizerTankStats.Add(bitmap, 0, wx.ALIGN_CENTER)

View File

@@ -20,7 +20,7 @@
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui import pygauge as PG
from gui.utils.numberFormatter import formatAmount
import service
@@ -74,18 +74,15 @@ class ResistancesViewFull(StatsView):
# Display table
col = 0
row = 0
sizerResistances = wx.GridBagSizer(0, 0)
sizerResistances = wx.GridBagSizer()
contentSizer.Add( sizerResistances, 0, wx.EXPAND , 0)
for i in xrange(6):
sizerResistances.AddGrowableCol(i + 1)
# Add an empty label, then the rest.
sizerResistances.Add(wx.StaticText(contentPanel, wx.ID_ANY), wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ))
col+=1
toolTipText = {"em" : "Electromagnetic resistance", "thermal" : "Thermal resistance", "kinetic" : "Kinetic resistance", "explosive" : "Explosive resistance"}
for damageType in ("em", "thermal", "kinetic", "explosive"):
bitmap = bitmapLoader.getStaticBitmap("%s_big" % damageType, contentPanel, "icons")
bitmap = BitmapLoader.getStaticBitmap("%s_big" % damageType, contentPanel, "gui")
tooltip = wx.ToolTip(toolTipText[damageType])
bitmap.SetToolTip(tooltip)
sizerResistances.Add(bitmap, wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ), wx.ALIGN_CENTER)
@@ -95,6 +92,8 @@ class ResistancesViewFull(StatsView):
self.stEHPs.Bind(wx.EVT_BUTTON, self.toggleEHP)
for i in xrange(4):
sizerResistances.AddGrowableCol(i+1)
sizerResistances.Add(self.stEHPs, wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ), wx.ALIGN_CENTER)
col=0
@@ -105,7 +104,7 @@ class ResistancesViewFull(StatsView):
toolTipText = {"shield" : "Shield resistance", "armor" : "Armor resistance", "hull" : "Hull resistance", "damagePattern" : "Incoming damage pattern"}
for tankType in ("shield", "armor", "hull", "separator", "damagePattern"):
if tankType != "separator":
bitmap = bitmapLoader.getStaticBitmap("%s_big" % tankType, contentPanel, "icons")
bitmap = BitmapLoader.getStaticBitmap("%s_big" % tankType, contentPanel, "gui")
tooltip = wx.ToolTip(toolTipText[tankType])
bitmap.SetToolTip(tooltip)
sizerResistances.Add(bitmap, wx.GBPosition( row, col ), wx.GBSpan( 1, 1 ), wx.ALIGN_CENTER)

View File

@@ -20,7 +20,7 @@
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui import pygauge as PG
import gui.mainFrame
import gui.chromeTabs
@@ -91,7 +91,7 @@ class ResourcesViewFull(StatsView):
for type in ("turret", "launcher", "drones", "calibration"):
box = wx.BoxSizer(wx.HORIZONTAL)
bitmap = bitmapLoader.getStaticBitmap("%s_big" % type, parent, "icons")
bitmap = BitmapLoader.getStaticBitmap("%s_big" % type, parent, "gui")
tooltip = wx.ToolTip(tooltipText[type])
bitmap.SetToolTip(tooltip)
@@ -119,7 +119,7 @@ class ResourcesViewFull(StatsView):
for type in group:
capitalizedType = type[0].capitalize() + type[1:]
bitmap = bitmapLoader.getStaticBitmap(type + "_big", parent, "icons")
bitmap = BitmapLoader.getStaticBitmap(type + "_big", parent, "gui")
tooltip = wx.ToolTip(tooltipText[type])
bitmap.SetToolTip(tooltip)

View File

@@ -52,7 +52,7 @@ class TargetingMiscViewFull(StatsView):
gridTargetingMisc.AddGrowableCol(2)
# Targeting
gridTargeting = wx.FlexGridSizer(4, 2)
gridTargeting = wx.FlexGridSizer(5, 2)
gridTargeting.AddGrowableCol(1)
gridTargetingMisc.Add(gridTargeting, 0, wx.ALIGN_LEFT | wx.ALL, 5)
@@ -77,7 +77,7 @@ class TargetingMiscViewFull(StatsView):
# Misc
gridTargetingMisc.Add( wx.StaticLine( contentPanel, wx.ID_ANY, style = wx.VERTICAL),0, wx.EXPAND, 3 )
gridMisc = wx.FlexGridSizer(4, 2)
gridMisc = wx.FlexGridSizer(5, 2)
gridMisc.AddGrowableCol(1)
gridTargetingMisc.Add(gridMisc,0 , wx.ALIGN_LEFT | wx.ALL, 5)

View File

@@ -19,7 +19,7 @@
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import wx
class Ammo(ViewColumn):
@@ -27,20 +27,21 @@ class Ammo(ViewColumn):
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.mask = wx.LIST_MASK_IMAGE
self.imageId = fittingView.imageList.GetImageIndex("damagePattern_small", "icons")
self.bitmap = bitmapLoader.getBitmap("damagePattern_small", "icons")
self.imageId = fittingView.imageList.GetImageIndex("damagePattern_small", "gui")
self.bitmap = BitmapLoader.getBitmap("damagePattern_small", "gui")
def getText(self, stuff):
if getattr(stuff, "charge", None) is not None:
shots = stuff.numShots
if shots > 0:
text = "%s (%s)" % (stuff.charge.name, stuff.numShots)
charges = stuff.numCharges
if charges > 0:
cycles = stuff.numShots
if cycles !=0 and charges != cycles:
return "%s (%d, %d cycles)" % (stuff.charge.name, charges, cycles)
else:
return "%s (%d)" % (stuff.charge.name, charges)
else:
text = stuff.charge.name
else:
text = ""
return text
return stuff.charge.name
return ""
def getImageId(self, mod):
return -1

View File

@@ -19,7 +19,7 @@
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import wx
from eos.types import Module
@@ -27,7 +27,7 @@ class AmmoIcon(ViewColumn):
name = "Ammo Icon"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.size = 16
self.size = 24
self.maxsize = self.size
self.mask = wx.LIST_MASK_IMAGE
self.columnText = ""
@@ -44,7 +44,7 @@ class AmmoIcon(ViewColumn):
else:
iconFile = stuff.charge.icon.iconFile if stuff.item.icon else ""
if iconFile:
return self.fittingView.imageList.GetImageIndex(iconFile, "pack")
return self.fittingView.imageList.GetImageIndex(iconFile, "icons")
else:
return -1

View File

@@ -19,7 +19,7 @@
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
import service
@@ -35,13 +35,13 @@ class AttributeDisplay(ViewColumn):
if params["showIcon"]:
if info.name == "power":
iconFile = "pg_small"
iconType = "icons"
iconType = "gui"
else:
iconFile = info.icon.iconFile if info.icon else None
iconType = "pack"
iconType = "icons"
if iconFile:
self.imageId = fittingView.imageList.GetImageIndex(iconFile, iconType)
self.bitmap = bitmapLoader.getBitmap(iconFile, iconType)
self.bitmap = BitmapLoader.getBitmap(iconFile, iconType)
else:
self.imageId = -1

View File

@@ -1,6 +1,6 @@
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import wx
from eos.types import Drone, Fit, Module, Slot, Rack
@@ -8,11 +8,11 @@ class BaseIcon(ViewColumn):
name = "Base Icon"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.size = 16
self.size = 24
self.maxsize = self.size
self.mask = wx.LIST_MASK_IMAGE
self.columnText = ""
self.shipImage = fittingView.imageList.GetImageIndex("ship_small", "icons")
self.shipImage = fittingView.imageList.GetImageIndex("ship_small", "gui")
def getImageId(self, stuff):
if isinstance(stuff, Drone):
@@ -23,7 +23,7 @@ class BaseIcon(ViewColumn):
return -1
if isinstance(stuff, Module):
if stuff.isEmpty:
return self.fittingView.imageList.GetImageIndex("slot_%s_small" % Slot.getName(stuff.slot).lower(), "icons")
return self.fittingView.imageList.GetImageIndex("slot_%s_small" % Slot.getName(stuff.slot).lower(), "gui")
else:
return self.loadIconFile(stuff.item.icon.iconFile if stuff.item.icon else "")
@@ -32,7 +32,7 @@ class BaseIcon(ViewColumn):
def loadIconFile(self, iconFile):
if iconFile:
return self.fittingView.imageList.GetImageIndex(iconFile, "pack")
return self.fittingView.imageList.GetImageIndex(iconFile, "icons")
else:
return -1

View File

@@ -32,7 +32,7 @@ class BaseName(ViewColumn):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.columnText = "Name"
self.shipImage = fittingView.imageList.GetImageIndex("ship_small", "icons")
self.shipImage = fittingView.imageList.GetImageIndex("ship_small", "gui")
self.mask = wx.LIST_MASK_TEXT
self.projectedView = isinstance(fittingView, gui.projectedView.ProjectedView)
@@ -70,6 +70,7 @@ class BaseName(ViewColumn):
if marketShortcut:
# use unicode subscript to display shortcut value
shortcut = unichr(marketShortcut+8320)+u" "
del item.marketShortcut
return shortcut+item.name
return item.name

View File

@@ -22,7 +22,7 @@ import service
from gui.utils.numberFormatter import formatAmount
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from eos.types import Mode
class CapacitorUse(ViewColumn):
@@ -34,8 +34,8 @@ class CapacitorUse(ViewColumn):
sAttr = service.Attribute.getInstance()
info = sAttr.getAttributeInfo("capacitorNeed")
self.imageId = fittingView.imageList.GetImageIndex("capacitorRecharge_small", "icons")
self.bitmap = bitmapLoader.getBitmap("capacitorRecharge_small", "icons")
self.imageId = fittingView.imageList.GetImageIndex("capacitorRecharge_small", "gui")
self.bitmap = BitmapLoader.getBitmap("capacitorRecharge_small", "gui")
def getText(self, mod):
if isinstance(mod, Mode):

View File

@@ -19,7 +19,7 @@
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import service
from gui.utils.numberFormatter import formatAmount
import wx
@@ -39,8 +39,8 @@ class MaxRange(ViewColumn):
if params["showIcon"]:
iconFile = info.icon.iconFile if info.icon else None
if iconFile:
self.imageId = fittingView.imageList.GetImageIndex(iconFile, "pack")
self.bitmap = bitmapLoader.getBitmap(iconFile, "pack")
self.imageId = fittingView.imageList.GetImageIndex(iconFile, "icons")
self.bitmap = BitmapLoader.getBitmap(iconFile, "icons")
else:
self.imageId = -1
self.mask = wx.LIST_MASK_IMAGE

View File

@@ -20,7 +20,7 @@
import gui.mainFrame
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from gui.utils.listFormatter import formatList
from service.fit import Fit, Market
@@ -35,8 +35,8 @@ class Miscellanea(ViewColumn):
"displayName": False}
ViewColumn.__init__(self, fittingView)
if params["showIcon"]:
self.imageId = fittingView.imageList.GetImageIndex("column_misc", "icons")
self.bitmap = bitmapLoader.getBitmap("column_misc", "icons")
self.imageId = fittingView.imageList.GetImageIndex("column_misc", "gui")
self.bitmap = BitmapLoader.getBitmap("column_misc", "gui")
self.mask = wx.LIST_MASK_IMAGE
else:
self.imageId = -1
@@ -374,7 +374,7 @@ class Miscellanea(ViewColumn):
tooltip = "Optimal signature radius"
return text, tooltip
elif itemGroup in ("Frequency Mining Laser", "Strip Miner", "Mining Laser", "Gas Cloud Harvester"):
miningAmount = stuff.getModifiedItemAttr("miningAmount")
miningAmount = stuff.getModifiedItemAttr("specialtyMiningAmount") or stuff.getModifiedItemAttr("miningAmount")
cycleTime = stuff.cycleTime
if not miningAmount or not cycleTime:
return "", None

View File

@@ -18,7 +18,7 @@
#===============================================================================
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
from eos.types import Drone, Cargo
import wx
@@ -29,8 +29,8 @@ class Price(ViewColumn):
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.mask = wx.LIST_MASK_IMAGE
self.bitmap = bitmapLoader.getBitmap("totalPrice_small", "icons")
self.imageId = fittingView.imageList.GetImageIndex("totalPrice_small", "icons")
self.bitmap = BitmapLoader.getBitmap("totalPrice_small", "gui")
self.imageId = fittingView.imageList.GetImageIndex("totalPrice_small", "gui")
def getText(self, stuff):
if stuff.item is None or stuff.item.group.name == "Ship Modifiers":

View File

@@ -18,7 +18,7 @@
#===============================================================================
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.utils.numberFormatter import formatAmount
import wx
import service
@@ -39,10 +39,10 @@ class PropertyDisplay(ViewColumn):
if params["showIcon"]:
if info.name == "power":
iconFile = "pg_small"
iconType = "icons"
iconType = "gui"
else:
iconFile = info.icon.iconFile if info.icon else None
iconType = "pack"
iconType = "icons"
if iconFile:
self.imageId = fittingView.imageList.GetImageIndex(iconFile, iconType)
else:

View File

@@ -18,7 +18,7 @@
#===============================================================================
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import wx
@@ -43,8 +43,8 @@ class State(ViewColumn):
return State_.getName(mod.state).title()
def getImageId(self, stuff):
generic_active = self.fittingView.imageList.GetImageIndex("state_%s_small" % State_.getName(1).lower(), "icons")
generic_inactive = self.fittingView.imageList.GetImageIndex("state_%s_small" % State_.getName(-1).lower(), "icons")
generic_active = self.fittingView.imageList.GetImageIndex("state_%s_small" % State_.getName(1).lower(), "gui")
generic_inactive = self.fittingView.imageList.GetImageIndex("state_%s_small" % State_.getName(-1).lower(), "gui")
if isinstance(stuff, Drone):
if stuff.amountActive > 0:
@@ -57,7 +57,7 @@ class State(ViewColumn):
if stuff.isEmpty:
return -1
else:
return self.fittingView.imageList.GetImageIndex("state_%s_small" % State_.getName(stuff.state).lower(), "icons")
return self.fittingView.imageList.GetImageIndex("state_%s_small" % State_.getName(stuff.state).lower(), "gui")
elif isinstance(stuff, Fit):
fitID = self.mainFrame.getActiveFit()
projectionInfo = stuff.getProjectionInfo(fitID)

View File

@@ -28,7 +28,7 @@ import gui.shipBrowser
import gui.multiSwitch
from eos.types import Slot, Rack, Module
from gui.builtinViewColumns.state import State
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.builtinViews.emptyView
from gui.utils.exportHtml import exportHtml
@@ -57,7 +57,7 @@ class FitSpawner(gui.multiSwitch.TabSpawner):
startup = getattr(event, "startup", False) # see OpenFitsThread in gui.mainFrame
mstate = wx.GetMouseState()
if mstate.CmdDown() or mstate.MiddleDown() or startup:
if mstate.CmdDown() or startup:
self.multiSwitch.AddPage()
view = FittingView(self.multiSwitch)
@@ -292,9 +292,9 @@ class FittingView(d.Display):
def updateTab(self):
sFit = service.Fit.getInstance()
fit = sFit.getFit(self.getActiveFit())
fit = sFit.getFit(self.getActiveFit(), basic=True)
bitmap = bitmapLoader.getImage("race_%s_small" % fit.ship.item.race, "icons")
bitmap = BitmapLoader.getImage("race_%s_small" % fit.ship.item.race, "gui")
text = "%s: %s" % (fit.ship.item.name, fit.name)
pageIndex = self.parent.GetPageIndex(self)
@@ -521,7 +521,7 @@ class FittingView(d.Display):
sFit = service.Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
ctrl = wx.GetMouseState().CmdDown() or wx.GetMouseState().MiddleDown()
click = "ctrl" if ctrl is True else "right" if event.Button == 3 else "left"
click = "ctrl" if ctrl is True else "right" if event.GetButton() == 3 else "left"
sFit.toggleModulesState(fitID, self.mods[self.GetItemData(row)], mods, click)
# update state tooltip
@@ -592,7 +592,7 @@ class FittingView(d.Display):
pass
def OnShow(self, event):
if not event.GetShow():
if event.GetShow():
try:
self.MakeSnapshot()
except:

View File

@@ -1,7 +1,7 @@
import wx.gizmos
import gui.fleetBrowser
import service
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
#Tab spawning handler
class FleetSpawner(gui.multiSwitch.TabSpawner):
@@ -28,7 +28,7 @@ class FleetView(wx.gizmos.TreeListCtrl):
self.tabManager = parent
self.fleetId = None
self.fleetImg = bitmapLoader.getImage("53_16", "pack")
self.fleetImg = BitmapLoader.getImage("53_16", "icons")
self.imageList = wx.ImageList(16, 16)
self.SetImageList(self.imageList)
@@ -38,9 +38,9 @@ class FleetView(wx.gizmos.TreeListCtrl):
self.SetMainColumn(1)
self.icons = {}
self.addImage = self.imageList.Add(bitmapLoader.getBitmap("add_small", "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, "icons"))
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()

View File

@@ -18,7 +18,7 @@
#===============================================================================
import wx
import bitmapLoader
from gui.bitmapLoader import BitmapLoader
class CachingImageList(wx.ImageList):
def __init__(self, width, height):
@@ -28,7 +28,7 @@ class CachingImageList(wx.ImageList):
def GetImageIndex(self, *loaderArgs):
id = self.map.get(loaderArgs)
if id is None:
bitmap = bitmapLoader.getBitmap(*loaderArgs)
bitmap = BitmapLoader.getBitmap(*loaderArgs)
if bitmap is None:
return -1
id = self.map[loaderArgs] = wx.ImageList.Add(self,bitmap)

View File

@@ -22,7 +22,7 @@ import wx
import gui.mainFrame
import wx.lib.newevent
import wx.gizmos
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import service
import gui.display as d
from gui.contextMenu import ContextMenu
@@ -34,11 +34,11 @@ class CharacterEditor(wx.Frame):
wx.Frame.__init__ (self, parent, id=wx.ID_ANY, title=u"pyfa: Character Editor", pos=wx.DefaultPosition,
size=wx.Size(641, 600), style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.TAB_TRAVERSAL)
self.mainFrame = parent
i = wx.IconFromBitmap(bitmapLoader.getBitmap("character_small", "icons"))
i = wx.IconFromBitmap(BitmapLoader.getBitmap("character_small", "gui"))
self.SetIcon(i)
self.mainFrame = parent
self.disableWin= wx.WindowDisabler(self)
self.SetSizeHintsSz(wx.Size(640, 600), wx.DefaultSize)
self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ) )
@@ -66,8 +66,11 @@ class CharacterEditor(wx.Frame):
if active:
self.charChoice.SetSelection(i)
self.navSizer.Add(self.btnSave, 0, wx.ALL , 5)
buttons = (("new", wx.ART_NEW),
("rename", bitmapLoader.getBitmap("rename", "icons")),
("rename", BitmapLoader.getBitmap("rename", "gui")),
("copy", wx.ART_COPY),
("delete", wx.ART_DELETE))
@@ -111,19 +114,19 @@ class CharacterEditor(wx.Frame):
bSizerButtons = wx.BoxSizer(wx.HORIZONTAL)
self.btnSave = wx.Button(self, wx.ID_ANY, "Save")
self.btnSaveChar = wx.Button(self, wx.ID_ANY, "Save")
self.btnSaveAs = wx.Button(self, wx.ID_ANY, "Save As...")
self.btnRevert = wx.Button(self, wx.ID_ANY, "Revert")
self.btnOK = wx.Button(self, wx.ID_OK)
bSizerButtons.Add(self.btnSave, 0, wx.ALL, 5)
bSizerButtons.Add(self.btnSaveChar, 0, wx.ALL, 5)
bSizerButtons.Add(self.btnSaveAs, 0, wx.ALL, 5)
bSizerButtons.Add(self.btnRevert, 0, wx.ALL, 5)
bSizerButtons.AddStretchSpacer()
bSizerButtons.Add(self.btnOK, 0, wx.ALL, 5)
self.btnSave.Bind(wx.EVT_BUTTON, self.saveChar)
self.btnSaveChar.Bind(wx.EVT_BUTTON, self.saveChar)
self.btnSaveAs.Bind(wx.EVT_BUTTON, self.saveCharAs)
self.btnRevert.Bind(wx.EVT_BUTTON, self.revertChar)
self.btnOK.Bind(wx.EVT_BUTTON, self.editingFinished)
@@ -149,7 +152,7 @@ class CharacterEditor(wx.Frame):
char = sChar.getCharacter(charID)
# enable/disable character saving stuff
self.btnSave.Enable(not char.ro and char.isDirty)
self.btnSaveChar.Enable(not char.ro and char.isDirty)
self.btnSaveAs.Enable(char.isDirty)
self.btnRevert.Enable(char.isDirty)
@@ -187,7 +190,6 @@ class CharacterEditor(wx.Frame):
charID = self.getActiveCharacter()
dlg = SaveCharacterAs(self, charID)
dlg.ShowModal()
dlg.Destroy()
self.sview.populateSkillTree()
def revertChar(self, event):
@@ -261,10 +263,8 @@ class CharacterEditor(wx.Frame):
self.characterRename.SetFocus()
for btn in (self.btnNew, self.btnCopy, self.btnRename, self.btnDelete):
btn.Hide()
self.navSizer.Remove(btn)
self.btnSave.Show()
self.navSizer.Add(self.btnSave, 0, wx.ALIGN_CENTER)
self.navSizer.Layout()
sChar = service.Character.getInstance()
@@ -287,9 +287,7 @@ class CharacterEditor(wx.Frame):
self.navSizer.Replace(self.characterRename, self.charChoice)
for btn in (self.btnNew, self.btnCopy, self.btnRename, self.btnDelete):
btn.Show()
self.navSizer.Add(btn, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
self.navSizer.Remove(self.btnSave)
self.btnSave.Hide()
self.navSizer.Layout()
self.refreshCharacterList()
@@ -305,16 +303,21 @@ class CharacterEditor(wx.Frame):
wx.PostEvent(self, GE.CharChanged())
def delete(self, event):
sChar = service.Character.getInstance()
sChar.delete(self.getActiveCharacter())
sel = self.charChoice.GetSelection()
self.charChoice.Delete(sel)
self.charChoice.SetSelection(sel - 1)
newSelection = self.getActiveCharacter()
if sChar.getCharName(newSelection) in ("All 0", "All 5"):
self.restrict()
dlg = wx.MessageDialog(self,
"Do you really want to delete this character?",
"Confirm Delete", wx.YES | wx.NO | wx.ICON_QUESTION)
wx.PostEvent(self, GE.CharChanged())
if dlg.ShowModal() == wx.ID_YES:
sChar = service.Character.getInstance()
sChar.delete(self.getActiveCharacter())
sel = self.charChoice.GetSelection()
self.charChoice.Delete(sel)
self.charChoice.SetSelection(sel - 1)
newSelection = self.getActiveCharacter()
if sChar.getCharName(newSelection) in ("All 0", "All 5"):
self.restrict()
wx.PostEvent(self, GE.CharChanged())
def Destroy(self):
sFit = service.Fit.getInstance()
@@ -338,7 +341,7 @@ class SkillTreeView (wx.Panel):
self.imageList = wx.ImageList(16, 16)
tree.SetImageList(self.imageList)
self.skillBookImageId = self.imageList.Add(bitmapLoader.getBitmap("skill_small", "icons"))
self.skillBookImageId = self.imageList.Add(BitmapLoader.getBitmap("skill_small", "gui"))
tree.AddColumn("Skill")
tree.AddColumn("Level")
@@ -478,7 +481,7 @@ class ImplantsTreeView (wx.Panel):
def addMarketViewImage(self, iconFile):
if iconFile is None:
return -1
bitmap = bitmapLoader.getBitmap(iconFile, "pack")
bitmap = BitmapLoader.getBitmap(iconFile, "icons")
if bitmap is None:
return -1
else:
@@ -504,15 +507,18 @@ class ImplantsTreeView (wx.Panel):
availableSizer.Add(self.availableImplantsTree, 1, wx.EXPAND)
buttonSizer = wx.BoxSizer(wx.VERTICAL)
buttonSizer.AddStretchSpacer()
self.btnAdd = GenBitmapButton(self, wx.ID_ADD, bitmapLoader.getBitmap("fit_add_small", "icons"), style = wx.BORDER_NONE)
pmainSizer.Add(buttonSizer, 0, wx.TOP, 5)
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", "icons"), 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.AddStretchSpacer()
pmainSizer.Add(buttonSizer, 0, wx.EXPAND, 5)
self.pluggedImplantsTree = AvailableImplantsView(self)
sChar = service.Character.getInstance()
@@ -814,5 +820,5 @@ class SaveCharacterAs(wx.Dialog):
wx.PostEvent(self.parent, GE.CharListUpdated())
event.Skip()
self.Destroy()
self.Close()

View File

@@ -19,7 +19,7 @@
import wx
import service
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.globalEvents as GE
import gui.mainFrame
@@ -41,10 +41,10 @@ class CharacterSelection(wx.Panel):
self.refreshCharacterList()
self.cleanSkills = bitmapLoader.getBitmap("skill_big", "icons")
self.redSkills = bitmapLoader.getBitmap("skillRed_big", "icons")
self.greenSkills = bitmapLoader.getBitmap("skillGreen_big", "icons")
self.refresh = bitmapLoader.getBitmap("refresh", "icons")
self.cleanSkills = BitmapLoader.getBitmap("skill_big", "gui")
self.redSkills = BitmapLoader.getBitmap("skillRed_big", "gui")
self.greenSkills = BitmapLoader.getBitmap("skillGreen_big", "gui")
self.refresh = BitmapLoader.getBitmap("refresh", "gui")
self.btnRefresh = wx.BitmapButton(self, wx.ID_ANY, self.refresh)
size = self.btnRefresh.GetSize()

View File

@@ -21,7 +21,8 @@ import wx
import wx.lib.newevent
import gui.utils.colorUtils as colorUtils
import gui.utils.drawUtils as drawUtils
from gui import bitmapLoader
import gui.utils.fonts as fonts
from gui.bitmapLoader import BitmapLoader
import gui.utils.fonts as fonts
import service
@@ -277,7 +278,7 @@ class PFNotebook(wx.Panel):
bx, by = self.GetBorders()
ww -= bx * 4
wh -= by * 4
self.activePage.SetSize((ww, wh))
self.activePage.SetSize((max(ww, -1), max(wh, -1)))
self.activePage.SetPosition((0, 0))
if not resizeOnly:
@@ -335,10 +336,10 @@ class PFTabRenderer:
closeButton -- True if tab can be closed
"""
# tab left/right zones inclination
self.ctabLeft = bitmapLoader.getImage("ctableft", "icons")
self.ctabMiddle = bitmapLoader.getImage("ctabmiddle", "icons")
self.ctabRight = bitmapLoader.getImage("ctabright", "icons")
self.ctabClose = bitmapLoader.getImage("ctabclose", "icons")
self.ctabLeft = BitmapLoader.getImage("ctableft", "gui")
self.ctabMiddle = BitmapLoader.getImage("ctabmiddle", "gui")
self.ctabRight = BitmapLoader.getImage("ctabright", "gui")
self.ctabClose = BitmapLoader.getImage("ctabclose", "gui")
self.leftWidth = self.ctabLeft.GetWidth()
self.rightWidth = self.ctabRight.GetWidth()
@@ -594,7 +595,7 @@ class PFTabRenderer:
class PFAddRenderer:
def __init__(self):
"""Renders the add tab button"""
self.addImg = bitmapLoader.getImage("ctabadd", "icons")
self.addImg = BitmapLoader.getImage("ctabadd", "gui")
self.width = self.addImg.GetWidth()
self.height = self.addImg.GetHeight()
@@ -671,6 +672,8 @@ class PFTabsContainer(wx.Panel):
"""
wx.Panel.__init__(self, parent, id, pos, size)
if wx.VERSION >= (3,0):
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
self.tabs = []
width, height = size
@@ -1073,13 +1076,12 @@ class PFTabsContainer(wx.Panel):
selected = 0
if 'wxMac' in wx.PlatformInfo:
if 'wxMac' in wx.PlatformInfo and wx.VERSION < (3,0):
color = wx.Colour(0, 0, 0)
brush = wx.Brush(color)
from Carbon.Appearance import kThemeBrushDialogBackgroundActive
brush.MacSetTheme(kThemeBrushDialogBackgroundActive)
else:
color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)
brush = wx.Brush(color)

View File

@@ -25,16 +25,18 @@ class CopySelectDialog(wx.Dialog):
copyFormatEftImps = 1
copyFormatXml = 2
copyFormatDna = 3
copyFormatCrest = 4
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)
mainSizer = wx.BoxSizer(wx.VERTICAL)
copyFormats = [u"EFT", u"EFT (Implants)", u"XML", u"DNA"]
copyFormats = [u"EFT", u"EFT (Implants)", u"XML", u"DNA", u"CREST"]
copyFormatTooltips = {CopySelectDialog.copyFormatEft: u"EFT text format",
CopySelectDialog.copyFormatEftImps: u"EFT text format",
CopySelectDialog.copyFormatXml: u"EVE native XML format",
CopySelectDialog.copyFormatDna: u"A one-line text format"}
CopySelectDialog.copyFormatDna: u"A one-line text format",
CopySelectDialog.copyFormatCrest: u"A JSON format used for EVE CREST"}
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():

407
gui/crestFittings.py Normal file
View File

@@ -0,0 +1,407 @@
import time
import webbrowser
import json
import wx
import requests
import service
from service.crest import CrestModes
from eos.types import Cargo
from eos.db import getItem
import gui.display as d
import gui.globalEvents as GE
class CrestFittings(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Browse EVE Fittings", pos=wx.DefaultPosition, size=wx.Size( 550,450 ), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
self.mainFrame = parent
mainSizer = wx.BoxSizer(wx.VERTICAL)
sCrest = service.Crest.getInstance()
characterSelectSizer = wx.BoxSizer( wx.HORIZONTAL )
if sCrest.settings.get('mode') == CrestModes.IMPLICIT:
self.stLogged = wx.StaticText(self, wx.ID_ANY, "Currently logged in as %s"%sCrest.implicitCharacter.name, wx.DefaultPosition, wx.DefaultSize)
self.stLogged.Wrap( -1 )
characterSelectSizer.Add( self.stLogged, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
else:
self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
characterSelectSizer.Add( self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
self.updateCharList()
self.fetchBtn = wx.Button( self, wx.ID_ANY, u"Fetch Fits", wx.DefaultPosition, wx.DefaultSize, 5 )
characterSelectSizer.Add( self.fetchBtn, 0, wx.ALL, 5 )
mainSizer.Add( characterSelectSizer, 0, wx.EXPAND, 5 )
self.sl = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.sl, 0, wx.EXPAND |wx.ALL, 5 )
contentSizer = wx.BoxSizer( wx.HORIZONTAL )
browserSizer = wx.BoxSizer( wx.VERTICAL )
self.fitTree = FittingsTreeView(self)
browserSizer.Add( self.fitTree, 1, wx.ALL|wx.EXPAND, 5 )
contentSizer.Add( browserSizer, 1, wx.EXPAND, 0 )
fitSizer = wx.BoxSizer( wx.VERTICAL )
self.fitView = FitView(self)
fitSizer.Add( self.fitView, 1, wx.ALL|wx.EXPAND, 5 )
btnSizer = wx.BoxSizer( wx.HORIZONTAL )
self.importBtn = wx.Button( self, wx.ID_ANY, u"Import to pyfa", wx.DefaultPosition, wx.DefaultSize, 5 )
self.deleteBtn = wx.Button( self, wx.ID_ANY, u"Delete from EVE", wx.DefaultPosition, wx.DefaultSize, 5 )
btnSizer.Add( self.importBtn, 1, wx.ALL, 5 )
btnSizer.Add( self.deleteBtn, 1, wx.ALL, 5 )
fitSizer.Add( btnSizer, 0, wx.EXPAND )
contentSizer.Add(fitSizer, 1, wx.EXPAND, 0)
mainSizer.Add(contentSizer, 1, wx.EXPAND, 5)
self.fetchBtn.Bind(wx.EVT_BUTTON, self.fetchFittings)
self.importBtn.Bind(wx.EVT_BUTTON, self.importFitting)
self.deleteBtn.Bind(wx.EVT_BUTTON, self.deleteFitting)
self.mainFrame.Bind(GE.EVT_SSO_LOGOUT, self.ssoLogout)
self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin)
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.statusbar = wx.StatusBar(self)
self.statusbar.SetFieldsCount()
self.SetStatusBar(self.statusbar)
self.cacheTimer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.updateCacheStatus, self.cacheTimer)
self.SetSizer(mainSizer)
self.Layout()
self.Centre(wx.BOTH)
def ssoLogin(self, event):
self.updateCharList()
event.Skip()
def updateCharList(self):
sCrest = service.Crest.getInstance()
chars = sCrest.getCrestCharacters()
if len(chars) == 0:
self.Close()
self.charChoice.Clear()
for char in chars:
self.charChoice.Append(char.name, char.ID)
self.charChoice.SetSelection(0)
def updateCacheStatus(self, event):
t = time.gmtime(self.cacheTime-time.time())
if t < 0:
self.cacheTimer.Stop()
else:
sTime = time.strftime("%H:%M:%S", t)
self.statusbar.SetStatusText("Cached for %s"%sTime, 0)
def ssoLogout(self, event):
if event.type == CrestModes.IMPLICIT:
self.Close()
else:
self.updateCharList()
event.Skip() # continue event
def OnClose(self, event):
self.mainFrame.Unbind(GE.EVT_SSO_LOGOUT, handler=self.ssoLogout)
self.mainFrame.Unbind(GE.EVT_SSO_LOGIN, handler=self.ssoLogin)
event.Skip()
def getActiveCharacter(self):
sCrest = service.Crest.getInstance()
if sCrest.settings.get('mode') == CrestModes.IMPLICIT:
return sCrest.implicitCharacter.ID
selection = self.charChoice.GetCurrentSelection()
return self.charChoice.GetClientData(selection) if selection is not None else None
def fetchFittings(self, event):
sCrest = service.Crest.getInstance()
try:
waitDialog = wx.BusyInfo("Fetching fits, please wait...", parent=self)
fittings = sCrest.getFittings(self.getActiveCharacter())
self.cacheTime = fittings.get('cached_until')
self.updateCacheStatus(None)
self.cacheTimer.Start(1000)
self.fitTree.populateSkillTree(fittings)
except requests.exceptions.ConnectionError:
self.statusbar.SetStatusText("Connection error, please check your internet connection")
finally:
del waitDialog
def importFitting(self, event):
selection = self.fitView.fitSelection
if not selection:
return
data = self.fitTree.fittingsTreeCtrl.GetPyData(selection)
sFit = service.Fit.getInstance()
fits = sFit.importFitFromBuffer(data)
self.mainFrame._openAfterImport(fits)
def deleteFitting(self, event):
sCrest = service.Crest.getInstance()
selection = self.fitView.fitSelection
if not selection:
return
data = json.loads(self.fitTree.fittingsTreeCtrl.GetPyData(selection))
dlg = wx.MessageDialog(self,
"Do you really want to delete %s (%s) from EVE?"%(data['name'], data['ship']['name']),
"Confirm Delete", wx.YES | wx.NO | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
try:
sCrest.delFitting(self.getActiveCharacter(), data['fittingID'])
except requests.exceptions.ConnectionError:
self.statusbar.SetStatusText("Connection error, please check your internet connection")
class ExportToEve(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Export fit to EVE", pos=wx.DefaultPosition, size=(wx.Size(350,100)), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
self.mainFrame = parent
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
sCrest = service.Crest.getInstance()
mainSizer = wx.BoxSizer(wx.VERTICAL)
hSizer = wx.BoxSizer(wx.HORIZONTAL)
if sCrest.settings.get('mode') == CrestModes.IMPLICIT:
self.stLogged = wx.StaticText(self, wx.ID_ANY, "Currently logged in as %s"%sCrest.implicitCharacter.name, wx.DefaultPosition, wx.DefaultSize)
self.stLogged.Wrap( -1 )
hSizer.Add( self.stLogged, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
else:
self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
hSizer.Add( self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
self.updateCharList()
self.charChoice.SetSelection(0)
self.exportBtn = wx.Button( self, wx.ID_ANY, u"Export Fit", wx.DefaultPosition, wx.DefaultSize, 5 )
hSizer.Add( self.exportBtn, 0, wx.ALL, 5 )
mainSizer.Add( hSizer, 0, wx.EXPAND, 5 )
self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting)
self.statusbar = wx.StatusBar(self)
self.statusbar.SetFieldsCount(2)
self.statusbar.SetStatusWidths([100, -1])
self.mainFrame.Bind(GE.EVT_SSO_LOGOUT, self.ssoLogout)
self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin)
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.SetSizer(hSizer)
self.SetStatusBar(self.statusbar)
self.Layout()
self.Centre(wx.BOTH)
def updateCharList(self):
sCrest = service.Crest.getInstance()
chars = sCrest.getCrestCharacters()
if len(chars) == 0:
self.Close()
self.charChoice.Clear()
for char in chars:
self.charChoice.Append(char.name, char.ID)
self.charChoice.SetSelection(0)
def ssoLogin(self, event):
self.updateCharList()
event.Skip()
def ssoLogout(self, event):
if event.type == CrestModes.IMPLICIT:
self.Close()
else:
self.updateCharList()
event.Skip() # continue event
def OnClose(self, event):
self.mainFrame.Unbind(GE.EVT_SSO_LOGOUT, handler=self.ssoLogout)
event.Skip()
def getActiveCharacter(self):
sCrest = service.Crest.getInstance()
if sCrest.settings.get('mode') == CrestModes.IMPLICIT:
return sCrest.implicitCharacter.ID
selection = self.charChoice.GetCurrentSelection()
return self.charChoice.GetClientData(selection) if selection is not None else None
def exportFitting(self, event):
self.statusbar.SetStatusText("", 0)
self.statusbar.SetStatusText("Sending request and awaiting response", 1)
sCrest = service.Crest.getInstance()
try:
sFit = service.Fit.getInstance()
data = sFit.exportCrest(self.mainFrame.getActiveFit())
res = sCrest.postFitting(self.getActiveCharacter(), data)
self.statusbar.SetStatusText("%d: %s"%(res.status_code, res.reason), 0)
try:
text = json.loads(res.text)
self.statusbar.SetStatusText(text['message'], 1)
except ValueError:
self.statusbar.SetStatusText("", 1)
except requests.exceptions.ConnectionError:
self.statusbar.SetStatusText("Connection error, please check your internet connection", 1)
class CrestMgmt(wx.Dialog):
def __init__( self, parent ):
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = "CREST Character Management", pos = wx.DefaultPosition, size = wx.Size( 550,250 ), style = wx.DEFAULT_DIALOG_STYLE )
self.mainFrame = parent
mainSizer = wx.BoxSizer( wx.HORIZONTAL )
self.lcCharacters = wx.ListCtrl( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT)
self.lcCharacters.InsertColumn(0, heading='Character')
self.lcCharacters.InsertColumn(1, heading='Refresh Token')
self.popCharList()
mainSizer.Add( self.lcCharacters, 1, wx.ALL|wx.EXPAND, 5 )
btnSizer = wx.BoxSizer( wx.VERTICAL )
self.addBtn = wx.Button( self, wx.ID_ANY, u"Add Character", wx.DefaultPosition, wx.DefaultSize, 0 )
btnSizer.Add( self.addBtn, 0, wx.ALL | wx.EXPAND, 5 )
self.deleteBtn = wx.Button( self, wx.ID_ANY, u"Revoke Character", wx.DefaultPosition, wx.DefaultSize, 0 )
btnSizer.Add( self.deleteBtn, 0, wx.ALL | wx.EXPAND, 5 )
mainSizer.Add( btnSizer, 0, wx.EXPAND, 5 )
self.addBtn.Bind(wx.EVT_BUTTON, self.addChar)
self.deleteBtn.Bind(wx.EVT_BUTTON, self.delChar)
self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin)
self.SetSizer( mainSizer )
self.Layout()
self.Centre( wx.BOTH )
def ssoLogin(self, event):
self.popCharList()
event.Skip()
def popCharList(self):
sCrest = service.Crest.getInstance()
chars = sCrest.getCrestCharacters()
self.lcCharacters.DeleteAllItems()
for index, char in enumerate(chars):
self.lcCharacters.InsertStringItem(index, char.name)
self.lcCharacters.SetStringItem(index, 1, char.refresh_token)
self.lcCharacters.SetItemData(index, char.ID)
self.lcCharacters.SetColumnWidth(0, wx.LIST_AUTOSIZE)
self.lcCharacters.SetColumnWidth(1, wx.LIST_AUTOSIZE)
def addChar(self, event):
sCrest = service.Crest.getInstance()
uri = sCrest.startServer()
webbrowser.open(uri)
def delChar(self, event):
item = self.lcCharacters.GetFirstSelected()
if item > -1:
charID = self.lcCharacters.GetItemData(item)
sCrest = service.Crest.getInstance()
sCrest.delCrestCharacter(charID)
self.popCharList()
class FittingsTreeView(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, id=wx.ID_ANY)
self.parent = parent
pmainSizer = wx.BoxSizer(wx.VERTICAL)
tree = self.fittingsTreeCtrl = wx.TreeCtrl(self, wx.ID_ANY, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT)
pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 0)
self.root = tree.AddRoot("Fits")
self.populateSkillTree(None)
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.displayFit)
self.SetSizer(pmainSizer)
self.Layout()
def populateSkillTree(self, data):
if data is None:
return
root = self.root
tree = self.fittingsTreeCtrl
tree.DeleteChildren(root)
dict = {}
fits = data['items']
for fit in fits:
if fit['ship']['name'] not in dict:
dict[fit['ship']['name']] = []
dict[fit['ship']['name']].append(fit)
for name, fits in dict.iteritems():
shipID = tree.AppendItem(root, name)
for fit in fits:
fitId = tree.AppendItem(shipID, fit['name'])
tree.SetPyData(fitId, json.dumps(fit))
tree.SortChildren(root)
def displayFit(self, event):
selection = self.fittingsTreeCtrl.GetSelection()
fit = json.loads(self.fittingsTreeCtrl.GetPyData(selection))
list = []
for item in fit['items']:
try:
cargo = Cargo(getItem(item['type']['id']))
cargo.amount = item['quantity']
list.append(cargo)
except:
pass
self.parent.fitView.fitSelection = selection
self.parent.fitView.update(list)
class FitView(d.Display):
DEFAULT_COLS = ["Base Icon",
"Base Name"]
def __init__(self, parent):
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL)
self.fitSelection = None

View File

@@ -1,6 +1,6 @@
import wx
import copy
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
from gui.PFListPane import PFListPane
import service.fleet
@@ -135,7 +135,7 @@ class FleetBrowserHeader (wx.Panel):
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","icons")
self.newBmp = BitmapLoader.getBitmap("fit_add_small","gui")
bmpSize = (16,16)
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -264,11 +264,11 @@ class FleetItem(SFItem.SFBrowserItem):
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", "icons")
self.renameBmp = bitmapLoader.getBitmap("fit_rename_small", "icons")
self.deleteBmp = bitmapLoader.getBitmap("fit_delete_small","icons")
self.acceptBmp = bitmapLoader.getBitmap("faccept_small", "icons")
self.fleetBmp = bitmapLoader.getBitmap("fleet_item_big", "icons")
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.acceptBmp = BitmapLoader.getBitmap("faccept_small", "gui")
self.fleetBmp = BitmapLoader.getBitmap("fleet_item_big", "gui")
fleetImg = self.fleetBmp.ConvertToImage()
fleetImg = fleetImg.Blur(2)
@@ -453,4 +453,4 @@ class PFGenBitmapButton(GenBitmapButton):
self.bgcolor = wx.Brush(color)
def GetBackgroundBrush(self, dc):
return self.bgcolor
return self.bgcolor

View File

@@ -3,3 +3,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()
SsoLogin, EVT_SSO_LOGIN = wx.lib.newevent.NewEvent()
SsoLogout, EVT_SSO_LOGOUT = wx.lib.newevent.NewEvent()

View File

@@ -19,7 +19,7 @@
import wx
import os
import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.display
import gui.globalEvents as GE
@@ -70,7 +70,7 @@ class GraphFrame(wx.Frame):
wx.Frame.__init__(self, parent, title=u"pyfa: Graph Generator", style=style, size=(520, 390))
i = wx.IconFromBitmap(bitmapLoader.getBitmap("graphs_small", "icons"))
i = wx.IconFromBitmap(BitmapLoader.getBitmap("graphs_small", "gui"))
self.SetIcon(i)
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.CreateStatusBar()

View File

@@ -20,7 +20,7 @@
import wx
import re
import gui.mainFrame
import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import sys
import wx.lib.mixins.listctrl as listmix
import wx.html
@@ -77,10 +77,10 @@ class ItemStatsDialog(wx.Dialog):
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)
itemImg = bitmapLoader.getBitmap(iconFile, "pack")
itemImg = BitmapLoader.getBitmap(iconFile, "icons")
if itemImg is not None:
self.SetIcon(wx.IconFromBitmap(itemImg))
self.SetTitle("%s: %s" % ("%s Stats" % itmContext if itmContext is not None else "Stats", item.name))
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
@@ -364,16 +364,16 @@ class ItemParams (wx.Panel):
if info:
if info.icon is not None:
iconFile = info.icon.iconFile
icon = bitmapLoader.getBitmap(iconFile, "pack")
icon = BitmapLoader.getBitmap(iconFile, "icons")
if icon is None:
icon = bitmapLoader.getBitmap("transparent16x16", "icons")
icon = BitmapLoader.getBitmap("transparent16x16", "gui")
attrIcon = self.imageList.Add(icon)
else:
attrIcon = self.imageList.Add(bitmapLoader.getBitmap("07_15", "pack"))
attrIcon = self.imageList.Add(BitmapLoader.getBitmap("07_15", "icons"))
else:
attrIcon = self.imageList.Add(bitmapLoader.getBitmap("07_15", "pack"))
attrIcon = self.imageList.Add(BitmapLoader.getBitmap("07_15", "icons"))
index = self.paramList.InsertImageStringItem(sys.maxint, attrName,attrIcon)
@@ -461,7 +461,7 @@ class ItemRequirements ( wx.Panel ):
self.imageList = wx.ImageList(16, 16)
self.reqTree.SetImageList(self.imageList)
skillBookId = self.imageList.Add(bitmapLoader.getBitmap("skill_small", "icons"))
skillBookId = self.imageList.Add(BitmapLoader.getBitmap("skill_small", "gui"))
self.getFullSkillTree(item,self.root,skillBookId)
@@ -753,7 +753,7 @@ class ItemAffectedBy (wx.Panel):
if thing == self.stuff:
parent = root
else: # projected fit
icon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
icon = self.imageList.Add(BitmapLoader.getBitmap("ship_small", "gui"))
child = self.affectedBy.AppendItem(root, "{} ({})".format(thing.name, thing.ship.item.name), icon)
parent = child
@@ -767,14 +767,14 @@ class ItemAffectedBy (wx.Panel):
if attrInfo:
if attrInfo.icon is not None:
iconFile = attrInfo.icon.iconFile
icon = bitmapLoader.getBitmap(iconFile, "pack")
icon = BitmapLoader.getBitmap(iconFile, "icons")
if icon is None:
icon = bitmapLoader.getBitmap("transparent16x16", "icons")
icon = BitmapLoader.getBitmap("transparent16x16", "gui")
attrIcon = self.imageList.Add(icon)
else:
attrIcon = self.imageList.Add(bitmapLoader.getBitmap("07_15", "pack"))
attrIcon = self.imageList.Add(BitmapLoader.getBitmap("07_15", "icons"))
else:
attrIcon = self.imageList.Add(bitmapLoader.getBitmap("07_15", "pack"))
attrIcon = self.imageList.Add(BitmapLoader.getBitmap("07_15", "icons"))
if self.showRealNames:
display = attrName
@@ -794,9 +794,9 @@ class ItemAffectedBy (wx.Panel):
afflictorType, afflictor, item, attrModifier, attrAmount, projected = itemInfo
if afflictorType == Ship:
itemIcon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
itemIcon = self.imageList.Add(BitmapLoader.getBitmap("ship_small", "gui"))
elif item.icon:
bitmap = bitmapLoader.getBitmap(item.icon.iconFile, "pack")
bitmap = BitmapLoader.getBitmap(item.icon.iconFile, "icons")
itemIcon = self.imageList.Add(bitmap) if bitmap else -1
else:
itemIcon = -1
@@ -884,7 +884,7 @@ class ItemAffectedBy (wx.Panel):
if thing == self.stuff:
parent = root
else: # projected fit
icon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
icon = self.imageList.Add(BitmapLoader.getBitmap("ship_small", "gui"))
child = self.affectedBy.AppendItem(root, "{} ({})".format(thing.name, thing.ship.item.name), icon)
parent = child
@@ -897,9 +897,9 @@ class ItemAffectedBy (wx.Panel):
afflictorType, afflictors, attrData, item, projected = info
counter = len(afflictors)
if afflictorType == Ship:
itemIcon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))
itemIcon = self.imageList.Add(BitmapLoader.getBitmap("ship_small", "gui"))
elif item.icon:
bitmap = bitmapLoader.getBitmap(item.icon.iconFile, "pack")
bitmap = BitmapLoader.getBitmap(item.icon.iconFile, "icons")
itemIcon = self.imageList.Add(bitmap) if bitmap else -1
else:
itemIcon = -1
@@ -925,15 +925,15 @@ class ItemAffectedBy (wx.Panel):
if attrInfo:
if attrInfo.icon is not None:
iconFile = attrInfo.icon.iconFile
icon = bitmapLoader.getBitmap(iconFile, "pack")
icon = BitmapLoader.getBitmap(iconFile, "icons")
if icon is None:
icon = bitmapLoader.getBitmap("transparent16x16", "icons")
icon = BitmapLoader.getBitmap("transparent16x16", "gui")
attrIcon = self.imageList.Add(icon)
else:
attrIcon = self.imageList.Add(bitmapLoader.getBitmap("07_15", "pack"))
attrIcon = self.imageList.Add(BitmapLoader.getBitmap("07_15", "icons"))
else:
attrIcon = self.imageList.Add(bitmapLoader.getBitmap("07_15", "pack"))
attrIcon = self.imageList.Add(BitmapLoader.getBitmap("07_15", "icons"))
if attrModifier == "s*":
attrModifier = "*"

View File

@@ -30,13 +30,14 @@ from wx.lib.wordwrap import wordwrap
import service
import config
import threading
import webbrowser
import gui.aboutData
import gui.chromeTabs
import gui.utils.animUtils as animUtils
import gui.globalEvents as GE
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
from gui.mainMenuBar import MainMenuBar
from gui.additionsPane import AdditionsPane
from gui.marketBrowser import MarketBrowser, ItemSelected
@@ -55,10 +56,21 @@ from gui.fleetBrowser import FleetBrowser
from gui.updateDialog import UpdateDialog
from gui.builtinViews import *
# import this to access override setting
from eos.modifiedAttributeDict import ModifiedAttributeDict
from time import gmtime, strftime
import locale
locale.setlocale(locale.LC_ALL, '')
if not 'wxMac' 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
disableOverrideEditor = True
#dummy panel(no paint no erasebk)
class PFPanel(wx.Panel):
@@ -103,8 +115,8 @@ class MainFrame(wx.Frame):
return cls.__instance if cls.__instance is not None else MainFrame()
def __init__(self):
title="pyfa %s%s - Python Fitting Assistant"%(config.version, "" if config.tag.lower() != 'git' else " (git)")
wx.Frame.__init__(self, None, wx.ID_ANY, title)
self.title="pyfa %s%s - Python Fitting Assistant"%(config.version, "" if config.tag.lower() != 'git' else " (git)")
wx.Frame.__init__(self, None, wx.ID_ANY, self.title)
MainFrame.__instance = self
@@ -116,33 +128,24 @@ class MainFrame(wx.Frame):
self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ) )
#Load and set the icon for pyfa main window
i = wx.IconFromBitmap(bitmapLoader.getBitmap("pyfa", "icons"))
i = wx.IconFromBitmap(BitmapLoader.getBitmap("pyfa", "gui"))
self.SetIcon(i)
#Create the layout and windows
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
self.splitter = wx.SplitterWindow(self, 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.splitter,1,wx.EXPAND | wx.LEFT, 2)
mainSizer.Add(self.browser_fitting_split, 1, wx.EXPAND | wx.LEFT, 2)
self.FitviewAdditionsPanel = PFPanel(self.splitter)
faSizer = wx.BoxSizer(wx.VERTICAL)
self.fitMultiSwitch = MultiSwitch(self.fitting_additions_split)
self.additionsPane = AdditionsPane(self.fitting_additions_split)
self.fitMultiSwitch = MultiSwitch(self.FitviewAdditionsPanel)
self.notebookBrowsers = gui.chromeTabs.PFNotebook(self.browser_fitting_split, False)
faSizer.Add(self.fitMultiSwitch,1,wx.EXPAND)
self.additionsPane = AdditionsPane(self.FitviewAdditionsPanel)
faSizer.Add(self.additionsPane, 0, wx.EXPAND)
self.FitviewAdditionsPanel.SetSizer(faSizer)
self.notebookBrowsers = gui.chromeTabs.PFNotebook(self.splitter, False)
marketImg = bitmapLoader.getImage("market_small", "icons")
shipBrowserImg = bitmapLoader.getImage("ship_small", "icons")
marketImg = BitmapLoader.getImage("market_small", "gui")
shipBrowserImg = BitmapLoader.getImage("ship_small", "gui")
self.marketBrowser = MarketBrowser(self.notebookBrowsers)
self.notebookBrowsers.AddPage(self.marketBrowser, "Market", tabImage = marketImg, showClose = False)
@@ -159,9 +162,14 @@ class MainFrame(wx.Frame):
self.notebookBrowsers.SetSelection(1)
self.splitter.SplitVertically(self.notebookBrowsers, self.FitviewAdditionsPanel)
self.splitter.SetMinimumPaneSize(204)
self.splitter.SetSashPosition(self.browserWidth)
self.browser_fitting_split.SplitVertically(self.notebookBrowsers, self.fitting_additions_split)
self.browser_fitting_split.SetMinimumPaneSize(204)
self.browser_fitting_split.SetSashPosition(self.browserWidth)
self.fitting_additions_split.SplitHorizontally(self.fitMultiSwitch, self.additionsPane, -200)
self.fitting_additions_split.SetMinimumPaneSize(200)
self.fitting_additions_split.SetSashPosition(self.fittingHeight)
self.fitting_additions_split.SetSashGravity(1.0)
cstatsSizer = wx.BoxSizer(wx.VERTICAL)
@@ -199,10 +207,16 @@ class MainFrame(wx.Frame):
self.sUpdate = service.Update.getInstance()
self.sUpdate.CheckUpdate(self.ShowUpdateBox)
if not 'wxMac' 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)
self.titleTimer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.updateTitle, self.titleTimer)
def ShowUpdateBox(self, release):
dlg = UpdateDialog(self, release)
dlg.ShowModal()
dlg.Destroy()
def LoadPreviousOpenFits(self):
sFit = service.Fit.getInstance()
@@ -213,7 +227,7 @@ class MainFrame(wx.Frame):
# Remove any fits that cause exception when fetching (non-existent fits)
for id in fits[:]:
try:
sFit.getFit(id)
sFit.getFit(id, basic=True)
except:
fits.remove(id)
@@ -222,13 +236,11 @@ class MainFrame(wx.Frame):
self.fitMultiSwitch.AddPage()
return
self.waitDialog = animUtils.WaitDialog(self, title="Opening previous fits")
self.waitDialog = wx.BusyInfo("Loading previous fits...")
OpenFitsThread(fits, self.closeWaitDialog)
self.waitDialog.ShowModal()
def LoadMainFrameAttribs(self):
mainFrameDefaultAttribs = {"wnd_width": 1000, "wnd_height": 680, "wnd_maximized": False, "browser_width": 300, "market_height": 0}
mainFrameDefaultAttribs = {"wnd_width": 1000, "wnd_height": 700, "wnd_maximized": False, "browser_width": 300, "market_height": 0, "fitting_height": -200}
self.mainFrameAttribs = service.SettingsProvider.getInstance().getSettings("pyfaMainWindowAttribs", mainFrameDefaultAttribs)
if self.mainFrameAttribs["wnd_maximized"]:
@@ -244,6 +256,7 @@ class MainFrame(wx.Frame):
self.browserWidth = self.mainFrameAttribs["browser_width"]
self.marketHeight = self.mainFrameAttribs["market_height"]
self.fittingHeight = self.mainFrameAttribs["fitting_height"]
def UpdateMainFrameAttribs(self):
if self.IsIconized():
@@ -256,6 +269,7 @@ class MainFrame(wx.Frame):
self.mainFrameAttribs["browser_width"] = self.notebookBrowsers.GetSize()[0]
self.mainFrameAttribs["market_height"] = self.marketBrowser.marketView.GetSize()[1]
self.mainFrameAttribs["fitting_height"] = self.fitting_additions_split.GetSashPosition()
def SetActiveStatsWindow(self, wnd):
self.activeStatsWnd = wnd
@@ -336,6 +350,10 @@ class MainFrame(wx.Frame):
dlg=CharacterEditor(self)
dlg.Show()
def showAttrEditor(self, event):
dlg=AttributeEditor(self)
dlg.Show()
def showTargetResistsEditor(self, event):
dlg=ResistsEditorDlg(self)
dlg.ShowModal()
@@ -375,13 +393,12 @@ class MainFrame(wx.Frame):
def showPreferenceDialog(self, event):
dlg = PreferenceDialog(self)
dlg.ShowModal()
dlg.Destroy()
def goWiki(self, event):
wx.LaunchDefaultBrowser('https://github.com/DarkFenX/Pyfa/wiki')
webbrowser.open('https://github.com/DarkFenX/Pyfa/wiki')
def goForums(self, event):
wx.LaunchDefaultBrowser('https://forums.eveonline.com/default.aspx?g=posts&t=247609')
webbrowser.open('https://forums.eveonline.com/default.aspx?g=posts&t=247609')
def registerMenu(self):
menuBar = self.GetMenuBar()
@@ -425,6 +442,18 @@ class MainFrame(wx.Frame):
# Save current character
self.Bind(wx.EVT_MENU, self.revertChar, id = menuBar.revertCharId)
# Browse fittings
self.Bind(wx.EVT_MENU, self.eveFittings, id = menuBar.eveFittingsId)
# Export to EVE
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)
# Open attribute editor
self.Bind(wx.EVT_MENU, self.showAttrEditor, id = menuBar.attrEditorId)
# Toggle Overrides
self.Bind(wx.EVT_MENU, self.toggleOverrides, id = menuBar.toggleOverridesId)
#Clipboard exports
self.Bind(wx.EVT_MENU, self.exportToClipboard, id=wx.ID_COPY)
@@ -488,6 +517,80 @@ class MainFrame(wx.Frame):
atable = wx.AcceleratorTable(actb)
self.SetAcceleratorTable(atable)
def eveFittings(self, event):
dlg=CrestFittings(self)
dlg.Show()
def updateTitle(self, event):
sCrest = service.Crest.getInstance()
char = sCrest.implicitCharacter
if char:
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)
self.SetTitle(newTitle)
def onSSOLogin(self, event):
menu = self.GetMenuBar()
menu.Enable(menu.eveFittingsId, True)
menu.Enable(menu.exportToEveId, True)
if event.type == CrestModes.IMPLICIT:
menu.SetLabel(menu.ssoLoginId, "Logout Character")
self.titleTimer.Start(1000)
def onSSOLogout(self, event):
self.titleTimer.Stop()
self.SetTitle(self.title)
menu = self.GetMenuBar()
if event.type == CrestModes.IMPLICIT or event.numChars == 0:
menu.Enable(menu.eveFittingsId, False)
menu.Enable(menu.exportToEveId, False)
if event.type == CrestModes.IMPLICIT:
menu.SetLabel(menu.ssoLoginId, "Login to EVE")
def updateCrestMenus(self, type):
# in case we are logged in when switching, change title back
self.titleTimer.Stop()
self.SetTitle(self.title)
menu = self.GetMenuBar()
sCrest = service.Crest.getInstance()
if type == CrestModes.IMPLICIT:
menu.SetLabel(menu.ssoLoginId, "Login to EVE")
menu.Enable(menu.eveFittingsId, False)
menu.Enable(menu.exportToEveId, False)
else:
menu.SetLabel(menu.ssoLoginId, "Manage Characters")
enable = len(sCrest.getCrestCharacters()) == 0
menu.Enable(menu.eveFittingsId, not enable)
menu.Enable(menu.exportToEveId, not enable)
def ssoHandler(self, event):
sCrest = service.Crest.getInstance()
if sCrest.settings.get('mode') == CrestModes.IMPLICIT:
if sCrest.implicitCharacter is not None:
sCrest.logout()
else:
uri = sCrest.startServer()
webbrowser.open(uri)
else:
dlg=CrestMgmt(self)
dlg.Show()
def exportToEve(self, event):
dlg=ExportToEve(self)
dlg.Show()
def toggleOverrides(self, event):
ModifiedAttributeDict.OVERRIDES = not ModifiedAttributeDict.OVERRIDES
wx.PostEvent(self, GE.FitChanged(fitID=self.getActiveFit()))
menu = self.GetMenuBar()
menu.SetLabel(menu.toggleOverridesId, "Turn Overrides Off" if ModifiedAttributeDict.OVERRIDES else "Turn Overrides On")
def saveChar(self, event):
sChr = service.Character.getInstance()
charID = self.charSelection.getActiveCharacter()
@@ -498,7 +601,6 @@ class MainFrame(wx.Frame):
charID = self.charSelection.getActiveCharacter()
dlg = SaveCharacterAs(self, charID)
dlg.ShowModal()
dlg.Destroy()
def revertChar(self, event):
sChr = service.Character.getInstance()
@@ -550,6 +652,10 @@ class MainFrame(wx.Frame):
sFit = service.Fit.getInstance()
toClipboard(sFit.exportDna(self.getActiveFit()))
def clipboardCrest(self):
sFit = service.Fit.getInstance()
toClipboard(sFit.exportCrest(self.getActiveFit()))
def clipboardXml(self):
sFit = service.Fit.getInstance()
toClipboard(sFit.exportXml(None, self.getActiveFit()))
@@ -567,96 +673,17 @@ class MainFrame(wx.Frame):
CopySelectDict = {CopySelectDialog.copyFormatEft: self.clipboardEft,
CopySelectDialog.copyFormatEftImps: self.clipboardEftImps,
CopySelectDialog.copyFormatXml: self.clipboardXml,
CopySelectDialog.copyFormatDna: self.clipboardDna}
CopySelectDialog.copyFormatDna: self.clipboardDna,
CopySelectDialog.copyFormatCrest: self.clipboardCrest}
dlg = CopySelectDialog(self)
dlg.ShowModal()
selected = dlg.GetSelected()
try:
CopySelectDict[selected]()
except:
pass
CopySelectDict[selected]()
dlg.Destroy()
def fileImportDialog(self, event):
"""Handles importing single/multiple EVE XML / EFT cfg fit files"""
sFit = service.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)
if (dlg.ShowModal() == wx.ID_OK):
self.progressDialog = wx.ProgressDialog(
"Importing fits",
" "*100, # set some arbitrary spacing to create wifth 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()
dlg.Destroy()
def fileImportCallback(self, info, fits=None):
"""
While importing fits from file, the logic calls back to this function to
update progress bar to show activity. XML files can contain multiple
ships with multiple fits, whereas EFT cfg files contain many fits of
a single ship. When iterating through the files, we update the message
when we start a new file, and then Pulse the progress bar with every fit
that is processed.
"""
if info == -1:
# Done processing
self.progressDialog.Hide()
self._openAfterImport(fits)
elif info != self.progressDialog.message and info is not None:
# New message, overwrite cached message and update
self.progressDialog.message = info
self.progressDialog.Pulse(info)
else:
# Simply Pulse() if we don't have anything else to do
self.progressDialog.Pulse()
def _openAfterImport(self, fits):
if len(fits) > 0:
if len(fits) == 1:
fit = fits[0]
wx.PostEvent(self, FitSelected(fitID=fit.ID))
wx.PostEvent(self.shipBrowser, Stage3Selected(shipID=fit.shipID, back=True))
else:
wx.PostEvent(self.shipBrowser, ImportSelected(fits=fits, back=True))
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())
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()
if '.' not in os.path.basename(filePath):
filePath += ".xml"
sFit = service.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)
sFit.backupFits(filePath, self.backupCallback)
self.progressDialog.ShowModal()
def backupCallback(self, info):
if info == -1:
self.progressDialog.Hide()
else:
self.progressDialog.Update(info)
def exportSkillsNeeded(self, event):
""" Exports skills needed for active fit and active character """
sCharacter = service.Character.getInstance()
@@ -680,12 +707,122 @@ class MainFrame(wx.Frame):
if '.' not in os.path.basename(filePath):
filePath += ".{0}".format(saveFmt)
self.waitDialog = animUtils.WaitDialog(self)
self.waitDialog = wx.BusyInfo("Exporting skills needed...")
sCharacter.backupSkills(filePath, saveFmt, self.getActiveFit(), self.closeWaitDialog)
self.waitDialog.ShowModal()
saveDialog.Destroy()
def fileImportDialog(self, event):
"""Handles importing single/multiple EVE XML / EFT cfg fit files"""
sFit = service.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)
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)
self.progressDialog.message = None
sFit.importFitsThreaded(dlg.GetPaths(), self.fileImportCallback)
self.progressDialog.ShowModal()
dlg.Destroy()
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())
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()
if '.' not in os.path.basename(filePath):
filePath += ".xml"
sFit = service.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)
sFit.backupFits(filePath, self.backupCallback)
self.progressDialog.ShowModal()
def exportHtml(self, event):
from gui.utils.exportHtml import exportHtml
sFit = service.Fit.getInstance()
settings = service.settings.HTMLExportSettings.getInstance()
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)
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)
exportHtml.getInstance().refreshFittingHtml(True, self.backupCallback)
self.progressDialog.ShowModal()
def backupCallback(self, info):
if info == -1:
self.closeProgressDialog()
else:
self.progressDialog.Update(info)
def fileImportCallback(self, info, fits=None):
"""
While importing fits from file, the logic calls back to this function to
update progress bar to show activity. XML files can contain multiple
ships with multiple fits, whereas EFT cfg files contain many fits of
a single ship. When iterating through the files, we update the message
when we start a new file, and then Pulse the progress bar with every fit
that is processed.
"""
if info == -1:
self.closeProgressDialog()
self._openAfterImport(fits)
elif info != self.progressDialog.message and info is not None:
# New message, overwrite cached message and update
self.progressDialog.message = info
self.progressDialog.Pulse(info)
else:
# Simply Pulse() if we don't have anything else to do
self.progressDialog.Pulse()
def _openAfterImport(self, fits):
if len(fits) > 0:
if len(fits) == 1:
fit = fits[0]
wx.PostEvent(self, FitSelected(fitID=fit.ID))
wx.PostEvent(self.shipBrowser, Stage3Selected(shipID=fit.shipID, back=True))
else:
wx.PostEvent(self.shipBrowser, ImportSelected(fits=fits, back=True))
def closeProgressDialog(self):
# Windows apparently handles ProgressDialogs differently. We can
# simply Destroy it here, but for other platforms we must Close it
if 'wxMSW' in wx.PlatformInfo:
self.progressDialog.Destroy()
else:
self.progressDialog.EndModal(wx.ID_OK)
self.progressDialog.Close()
def importCharacter(self, event):
""" Imports character XML file from EVE API """
dlg = wx.FileDialog(self, "Open One Or More Character Files",
@@ -694,33 +831,16 @@ class MainFrame(wx.Frame):
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE)
if dlg.ShowModal() == wx.ID_OK:
self.waitDialog = animUtils.WaitDialog(self, title="Importing Character")
self.waitDialog = wx.BusyInfo("Importing Character...")
sCharacter = service.Character.getInstance()
sCharacter.importCharacter(dlg.GetPaths(), self.importCharacterCallback)
dlg.Destroy()
self.waitDialog.ShowModal()
def importCharacterCallback(self):
self.waitDialog.Destroy()
self.closeWaitDialog()
wx.PostEvent(self, GE.CharListUpdated())
def exportHtml(self, event):
from gui.utils.exportHtml import exportHtml
sFit = service.Fit.getInstance()
settings = service.settings.HTMLExportSettings.getInstance()
max = sFit.countAllFits()
path = settings.getPath()
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()
def closeWaitDialog(self):
self.waitDialog.Destroy()
del self.waitDialog
def openGraphFrame(self, event):
if not self.graphFrame:

View File

@@ -19,12 +19,15 @@
import wx
import config
import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import gui.graphFrame
import gui.globalEvents as GE
import service
if not 'wxMac' 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()
@@ -40,9 +43,13 @@ class MainMenuBar(wx.MenuBar):
self.saveCharId = wx.NewId()
self.saveCharAsId = wx.NewId()
self.revertCharId = wx.NewId()
self.eveFittingsId = wx.NewId()
self.exportToEveId = wx.NewId()
self.ssoLoginId = wx.NewId()
self.attrEditorId = wx.NewId()
self.toggleOverridesId = wx.NewId()
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
wx.MenuBar.__init__(self)
# File menu
@@ -78,30 +85,56 @@ class MainMenuBar(wx.MenuBar):
editMenu.Append(self.saveCharId, "Save Character")
editMenu.Append(self.saveCharAsId, "Save Character As...")
editMenu.Append(self.revertCharId, "Revert Character")
# Character menu
windowMenu = wx.Menu()
self.Append(windowMenu, "&Window")
charEditItem = wx.MenuItem(windowMenu, self.characterEditorId, "&Character Editor\tCTRL+E")
charEditItem.SetBitmap(bitmapLoader.getBitmap("character_small", "icons"))
charEditItem.SetBitmap(BitmapLoader.getBitmap("character_small", "gui"))
windowMenu.AppendItem(charEditItem)
damagePatternEditItem = wx.MenuItem(windowMenu, self.damagePatternEditorId, "Damage Pattern Editor\tCTRL+D")
damagePatternEditItem.SetBitmap(bitmapLoader.getBitmap("damagePattern_small", "icons"))
damagePatternEditItem.SetBitmap(BitmapLoader.getBitmap("damagePattern_small", "gui"))
windowMenu.AppendItem(damagePatternEditItem)
targetResistsEditItem = wx.MenuItem(windowMenu, self.targetResistsEditorId, "Target Resists Editor\tCTRL+R")
targetResistsEditItem.SetBitmap(bitmapLoader.getBitmap("explosive_big", "icons"))
targetResistsEditItem.SetBitmap(BitmapLoader.getBitmap("explosive_big", "gui"))
windowMenu.AppendItem(targetResistsEditItem)
graphFrameItem = wx.MenuItem(windowMenu, self.graphFrameId, "Graphs\tCTRL+G")
graphFrameItem.SetBitmap(bitmapLoader.getBitmap("graphs_small", "icons"))
graphFrameItem.SetBitmap(BitmapLoader.getBitmap("graphs_small", "gui"))
windowMenu.AppendItem(graphFrameItem)
preferencesItem = wx.MenuItem(windowMenu, wx.ID_PREFERENCES, "Preferences\tCTRL+P")
preferencesItem.SetBitmap(bitmapLoader.getBitmap("preferences_small", "icons"))
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)):
self.sCrest = service.Crest.getInstance()
# CREST Menu
crestMenu = wx.Menu()
self.Append(crestMenu, "&CREST")
if self.sCrest.settings.get('mode') != CrestModes.IMPLICIT:
crestMenu.Append(self.ssoLoginId, "Manage Characters")
else:
crestMenu.Append(self.ssoLoginId, "Login to EVE")
crestMenu.Append(self.eveFittingsId, "Browse EVE Fittings")
crestMenu.Append(self.exportToEveId, "Export To EVE")
if self.sCrest.settings.get('mode') == CrestModes.IMPLICIT or len(self.sCrest.getCrestCharacters()) == 0:
self.Enable(self.eveFittingsId, False)
self.Enable(self.exportToEveId, False)
if not gui.mainFrame.disableOverrideEditor:
attrItem = wx.MenuItem(windowMenu, self.attrEditorId, "Attribute Overrides\tCTRL+B")
attrItem.SetBitmap(BitmapLoader.getBitmap("fit_rename_small", "gui"))
windowMenu.AppendItem(attrItem)
editMenu.AppendSeparator()
editMenu.Append(self.toggleOverridesId, "Turn Overrides On")
# Help menu
helpMenu = wx.Menu()
self.Append(helpMenu, "&Help")
@@ -131,3 +164,5 @@ class MainMenuBar(wx.MenuBar):
self.Enable(self.revertCharId, char.isDirty)
event.Skip()

View File

@@ -24,7 +24,7 @@ from gui.cachingImageList import CachingImageList
from gui.contextMenu import ContextMenu
import gui.PFSearchBox as SBox
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
ItemSelected, ITEM_SELECTED = wx.lib.newevent.NewEvent()
@@ -103,10 +103,10 @@ class MarketBrowser(wx.Panel):
self.marketView.jump(item)
class SearchBox(SBox.PFSearchBox):
def __init__(self, parent):
SBox.PFSearchBox.__init__(self, parent)
cancelBitmap = bitmapLoader.getBitmap("fit_delete_small","icons")
searchBitmap = bitmapLoader.getBitmap("fsearch_small","icons")
def __init__(self, parent, **kwargs):
SBox.PFSearchBox.__init__(self, parent, **kwargs)
cancelBitmap = BitmapLoader.getBitmap("fit_delete_small","gui")
searchBitmap = BitmapLoader.getBitmap("fsearch_small","gui")
self.SetSearchBitmap(searchBitmap)
self.SetCancelBitmap(cancelBitmap)
self.ShowSearchButton()
@@ -134,13 +134,13 @@ class MarketTree(wx.TreeCtrl):
self.SortChildren(self.root)
# Add recently used modules node
rumIconId = self.addImage("market_small", "icons")
rumIconId = self.addImage("market_small", "gui")
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)
def addImage(self, iconFile, location = "pack"):
def addImage(self, iconFile, location="icons"):
if iconFile is None:
return -1
return self.imageList.GetImageIndex(iconFile, location)

View File

@@ -18,7 +18,7 @@
#===============================================================================
import wx
import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import service
from wx.lib.intctrl import IntCtrl
from gui.utils.clipboard import toClipboard, fromClipboard
@@ -58,14 +58,10 @@ class DmgPatternEditorDlg(wx.Dialog):
self.namePicker.Bind(wx.EVT_TEXT_ENTER, self.processRename)
self.namePicker.Hide()
self.btnSave = wx.Button(self, wx.ID_SAVE)
self.btnSave.Hide()
self.btnSave.Bind(wx.EVT_BUTTON, self.processRename)
size = None
headerSizer.Add(self.ccDmgPattern, 1, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT|wx.LEFT, 3)
buttons = (("new", wx.ART_NEW),
("rename", bitmapLoader.getBitmap("rename", "icons")),
("rename", BitmapLoader.getBitmap("rename", "gui")),
("copy", wx.ART_COPY),
("delete", wx.ART_DELETE))
for name, art in buttons:
@@ -83,6 +79,10 @@ class DmgPatternEditorDlg(wx.Dialog):
btn.SetToolTipString("%s pattern" % name.capitalize())
headerSizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL)
self.btnSave = wx.Button(self, wx.ID_SAVE)
self.btnSave.Hide()
self.btnSave.Bind(wx.EVT_BUTTON, self.processRename)
self.headerSizer.Add(self.btnSave, 0, wx.ALIGN_CENTER)
mainSizer.Add(headerSizer, 0, wx.EXPAND | wx.ALL, 2)
@@ -90,10 +90,10 @@ class DmgPatternEditorDlg(wx.Dialog):
mainSizer.Add(self.sl, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
contentSizer = wx.BoxSizer(wx.VERTICAL)
self.embitmap = bitmapLoader.getBitmap("em_big", "icons")
self.thermbitmap = bitmapLoader.getBitmap("thermal_big", "icons")
self.kinbitmap = bitmapLoader.getBitmap("kinetic_big", "icons")
self.expbitmap = bitmapLoader.getBitmap("explosive_big", "icons")
self.embitmap = BitmapLoader.getBitmap("em_big", "gui")
self.thermbitmap = BitmapLoader.getBitmap("thermal_big", "gui")
self.kinbitmap = BitmapLoader.getBitmap("kinetic_big", "gui")
self.expbitmap = BitmapLoader.getBitmap("explosive_big", "gui")
dmgeditSizer = wx.FlexGridSizer(2, 6, 0, 2)
dmgeditSizer.AddGrowableCol(0)
@@ -105,7 +105,7 @@ class DmgPatternEditorDlg(wx.Dialog):
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, "icons"))
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 = 10
@@ -276,9 +276,7 @@ class DmgPatternEditorDlg(wx.Dialog):
for btn in (self.new, self.rename, self.delete, self.copy):
btn.Hide()
self.headerSizer.Remove(btn)
self.headerSizer.Add(self.btnSave, 0, wx.ALIGN_CENTER)
self.btnSave.Show()
self.headerSizer.Layout()
if event is not None:
@@ -311,9 +309,7 @@ class DmgPatternEditorDlg(wx.Dialog):
self.ccDmgPattern.Show()
self.namePicker.Hide()
self.btnSave.Hide()
self.headerSizer.Remove(self.btnSave)
for btn in (self.new, self.rename, self.delete, self.copy):
self.headerSizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL)
btn.Show()
sel = self.ccDmgPattern.GetSelection()

View File

@@ -19,22 +19,22 @@
import wx
from gui.preferenceView import PreferenceView
import bitmapLoader
from gui.bitmapLoader import BitmapLoader
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")
i = wx.IconFromBitmap(bitmapLoader.getBitmap("preferences_small", "icons"))
i = wx.IconFromBitmap(BitmapLoader.getBitmap("preferences_small", "gui"))
self.SetIcon(i)
mainSizer = wx.BoxSizer(wx.VERTICAL)
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.listbook.SetImageList(self.imageList)
@@ -77,4 +77,4 @@ class PreferenceDialog(wx.Dialog):
self.btnOK.Bind(wx.EVT_BUTTON, self.OnBtnOK)
def OnBtnOK(self, event):
self.Destroy()
self.Close()

View File

@@ -26,19 +26,29 @@ from gui.builtinViewColumns.state import State
from gui.contextMenu import ContextMenu
import eos.types
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 DummyItem:
def __init__(self, txt):
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 ProjectedView(d.Display):
DEFAULT_COLS = ["State",
@@ -96,8 +106,6 @@ class ProjectedView(d.Display):
sFit.removeProjected(fitID, self.get(row))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
event.Skip()
def handleDrag(self, type, fitID):
#Those are drags coming from pyfa sources, NOT builtin wx drags
if type == "fit":
@@ -180,11 +188,20 @@ class ProjectedView(d.Display):
self.EnsureVisible(item)
self.deselectItems()
if stuff == []:
stuff = [DummyEntry("Drag an item or fit, or use right-click menu for system effects")]
self.update(stuff)
def get(self, row):
numMods = len(self.modules)
numDrones = len(self.drones)
numFits = len(self.fits)
if (numMods + numDrones + numFits) == 0:
return None
if row < numMods:
stuff = self.modules[row]
elif row - numMods < numDrones:

271
gui/propertyEditor.py Normal file
View File

@@ -0,0 +1,271 @@
import wx
try:
import wx.propgrid as wxpg
except:
if wx.VERSION < (2, 9):
raise ImportError("wx.propgrid is only available in wxPython >= 2.9")
else:
raise
import gui.PFSearchBox as SBox
from gui.marketBrowser import SearchBox
import gui.display as d
import gui.globalEvents as GE
from gui.bitmapLoader import BitmapLoader
import service
import csv
import eos.db
import logging
logger = logging.getLogger(__name__)
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)
i = wx.IconFromBitmap(BitmapLoader.getBitmap("fit_rename_small", "gui"))
self.SetIcon(i)
self.mainFrame = parent
menubar = wx.MenuBar()
fileMenu = wx.Menu()
fileImport = fileMenu.Append(wx.ID_ANY, 'Import', 'Import overrides')
fileExport = fileMenu.Append(wx.ID_ANY, 'Export', 'Import overrides')
fileClear = fileMenu.Append(wx.ID_ANY, 'Clear All', 'Clear all overrides')
menubar.Append(fileMenu, '&File')
self.SetMenuBar(menubar)
self.Bind(wx.EVT_MENU, self.OnImport, fileImport)
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)
self.mainFrame = parent
self.panel = panel = wx.Panel(self, wx.ID_ANY)
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
leftSizer = wx.BoxSizer(wx.VERTICAL)
leftPanel = wx.Panel(panel, wx.ID_ANY, style=wx.DOUBLE_BORDER if 'wxMSW' in wx.PlatformInfo else wx.SIMPLE_BORDER)
self.searchBox = SearchBox(leftPanel)
self.itemView = ItemView(leftPanel)
leftSizer.Add(self.searchBox, 0, wx.EXPAND)
leftSizer.Add(self.itemView, 1, wx.EXPAND)
leftPanel.SetSizer(leftSizer)
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.pg = AttributeGrid(panel)
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)
mainSizer.Add(rightSizer, 1, wx.EXPAND)
panel.SetSizer(mainSizer)
mainSizer.SetSizeHints(panel)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(panel, 1, wx.EXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, event):
fitID = self.mainFrame.getActiveFit()
if fitID is not None:
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
self.Destroy()
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)
if (dlg.ShowModal() == wx.ID_OK):
path = dlg.GetPath()
with open(path, 'rb') as csvfile:
spamreader = csv.reader(csvfile)
for row in spamreader:
itemID, attrID, value = row
item = eos.db.getItem(int(itemID))
attr = eos.db.getAttributeInfo(int(attrID))
item.setOverride(attr, float(value))
self.itemView.updateItems(True)
def OnExport(self, event):
sMkt = service.Market.getInstance()
items = sMkt.getItemsWithOverrides()
defaultFile = "pyfa_overrides.csv"
dlg = wx.FileDialog(self, "Save Overrides As...",
wildcard = "pyfa overrides (*.csv)|*.csv",
style = wx.FD_SAVE,
defaultFile=defaultFile)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
with open(path, 'wb') as csvfile:
writer = csv.writer(csvfile)
for item in items:
for key, override in item.overrides.iteritems():
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)
if dlg.ShowModal() == wx.ID_YES:
sMkt = service.Market.getInstance()
items = sMkt.getItemsWithOverrides()
# We can't just delete overrides, as loaded items will still have
# them assigned. Deleting them from the database won't propagate
# them due to the eve/user database disconnect. We must loop through
# all items that have overrides and remove them
for item in items:
for _, x in item.overrides.items():
item.deleteOverride(x.attr)
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",
"Base Name",
"attr:power,,,True",
"attr:cpu,,,True"]
def __init__(self, parent):
d.Display.__init__(self, parent)
sMkt = service.Market.getInstance()
self.things = sMkt.getItemsWithOverrides()
self.items = self.things
self.searchBox = parent.Parent.Parent.searchBox
# Bind search actions
self.searchBox.Bind(SBox.EVT_TEXT_ENTER, self.scheduleSearch)
self.searchBox.Bind(SBox.EVT_SEARCH_BTN, self.scheduleSearch)
self.searchBox.Bind(SBox.EVT_CANCEL_BTN, self.clearSearch)
self.searchBox.Bind(SBox.EVT_TEXT, self.scheduleSearch)
self.update(self.items)
def clearSearch(self, event=None):
if event:
self.searchBox.Clear()
self.items = self.things
self.update(self.items)
def updateItems(self, updateDisplay=False):
sMkt = service.Market.getInstance()
self.things = sMkt.getItemsWithOverrides()
self.items = self.things
if updateDisplay:
self.update(self.things)
def scheduleSearch(self, event=None):
sMkt = service.Market.getInstance()
search = self.searchBox.GetLineText(0)
# Make sure we do not count wildcard as search symbol
realsearch = search.replace("*", "")
# Show nothing if query is too short
if len(realsearch) < 3:
self.clearSearch()
return
sMkt.searchItems(search, self.populateSearch, False)
def populateSearch(self, items):
self.items = list(items)
self.update(items)
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)
self.SetExtraStyle(wxpg.PG_EX_HELP_AS_TOOLTIPS)
self.item = None
self.itemView = parent.Parent.itemView
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.itemView.Bind(wx.EVT_LIST_ITEM_SELECTED, self.itemActivated)
self.itemView.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.itemActivated)
def itemActivated(self, event):
self.Clear()
self.btn.Enable(True)
sel = event.EventObject.GetFirstSelected()
self.item = item = self.itemView.items[sel]
for key in sorted(item.attributes.keys()):
override = item.overrides.get(key, None)
default = item.attributes[key].value
if override and override.value != default:
prop = wxpg.FloatProperty(key, value=override.value)
prop.SetModifiedStatus(True)
else:
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))
self.Append(prop)
def removeOverrides(self, event):
if self.item is None:
return
for _, x in self.item.overrides.items():
self.item.deleteOverride(x.attr)
self.itemView.updateItems(True)
self.ClearModifiedStatus()
self.itemView.Select(self.itemView.GetFirstSelected(), on=False)
self.Clear()
def Clear(self):
self.item = None
self.btn.Enable(False)
wxpg.PropertyGrid.Clear(self)
def OnPropGridChange(self, event):
p = event.GetProperty()
attr = p.GetClientData()
if p.GetValue() == attr.value:
self.item.deleteOverride(attr)
p.SetModifiedStatus(False)
else:
self.item.setOverride(attr, p.GetValue())
self.itemView.updateItems()
logger.debug('%s changed to "%s"' % (p.GetName(), p.GetValueAsString()))
def OnPropGridSelect(self, event):
pass
def OnPropGridRightClick(self, event):
pass

View File

@@ -24,7 +24,7 @@
###########################################################################
import wx
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
###########################################################################
## Class TogglePanel
@@ -54,8 +54,8 @@ class TogglePanel ( wx.Panel ):
# Load expanded/collapsed bitmaps from the icons folder
self.bmpExpanded = bitmapLoader.getBitmap("down-arrow2","icons")
self.bmpCollapsed = bitmapLoader.getBitmap("up-arrow2","icons")
self.bmpExpanded = BitmapLoader.getBitmap("down-arrow2","gui")
self.bmpCollapsed = BitmapLoader.getBitmap("up-arrow2","gui")
# Make the bitmaps have the same color as window text
@@ -146,7 +146,6 @@ class TogglePanel ( wx.Panel ):
else:
return True
def IsExpanded(self):
""" Returns ``True`` if the pane window is currently shown. """
if self._toggle == 1:
@@ -154,7 +153,6 @@ class TogglePanel ( wx.Panel ):
else:
return True
def OnStateChange(self, sz):
"""
Handles the status changes (collapsing/expanding).
@@ -168,9 +166,8 @@ class TogglePanel ( wx.Panel ):
self.parent.GetSizer().SetSizeHints(self.parent)
if self.IsCollapsed():
# expanded . collapsed transition
# expanded . collapsed transition
if self.parent.GetSizer():
# we have just set the size hints...
sz = self.parent.GetSizer().CalcMin()
@@ -178,39 +175,36 @@ class TogglePanel ( wx.Panel ):
# use SetClientSize() and not SetSize() otherwise the size for
# e.g. a wxFrame with a menubar wouldn't be correctly set
self.parent.SetClientSize(sz)
else:
self.parent.Layout()
else:
# collapsed . expanded transition
# force our parent to "fit", i.e. expand so that it can honour
# our minimal size
# collapsed . expanded transition
# force our parent to "fit", i.e. expand so that it can honour
# our minimal size
self.parent.Fit()
# Toggle the content panel (hide/show)
def toggleContent( self, event ):
def toggleContent(self, event):
self.Freeze()
if self._toggle == 1:
self.contentMinSize = self.contentPanel.GetSize()
self.contentPanel.SetMinSize(wx.Size(self.contentMinSize[0],0))
self.headerBmp.SetBitmap( self.bmpCollapsed)
self.contentPanel.Hide()
self.headerBmp.SetBitmap(self.bmpCollapsed)
else:
self.contentPanel.SetMinSize(self.contentMinSize)
self.headerBmp.SetBitmap( self.bmpExpanded)
self._toggle *=-1
self.contentPanel.Show()
self.headerBmp.SetBitmap(self.bmpExpanded)
self._toggle *= -1
self.Layout()
self.Thaw()
if self.forceLayout == -1:
self.OnStateChange(self.GetBestSize())
if wx.VERSION >= (3, 0):
x, y = self.GetBestSize()
y -= self.contentPanel.GetSize()[1]
else:
x, y = self.GetBestSize()
self.OnStateChange((x, y))
else:
self.parent.Layout()

View File

@@ -312,47 +312,53 @@ class PyGauge(wx.PyWindow):
r = copy.copy(rect)
r.width = w
if r.width > 0:
# If we draw it with zero width, GTK throws errors. This way,
# only draw it if the gauge will actually show something.
# We stick other calculations in this block to avoid wasting
# time on them if not needed. See GH issue #282
pv = value
xv=1
transition = 0
if pv <= 100:
xv = pv/100
pv = value
xv=1
transition = 0
elif pv <=101:
xv = pv -100
transition = 1
if pv <= 100:
xv = pv/100
transition = 0
elif pv <= 103:
xv = (pv -101)/2
transition = 2
elif pv <=101:
xv = pv -100
transition = 1
elif pv <= 105:
xv = (pv -103)/2
transition = 3
elif pv <= 103:
xv = (pv -101)/2
transition = 2
else:
pv = 106
xv = pv -100
transition = -1
elif pv <= 105:
xv = (pv -103)/2
transition = 3
if transition != -1:
colorS,colorE = self.transitionsColors[transition]
color = colorUtils.CalculateTransitionColor(colorS, colorE, xv)
else:
color = wx.Colour(191,48,48)
else:
pv = 106
xv = pv -100
transition = -1
if self.gradientEffect > 0:
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)
if transition != -1:
colorS,colorE = self.transitionsColors[transition]
color = colorUtils.CalculateTransitionColor(colorS, colorE, xv)
else:
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)
else:
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)
gBmp = drawUtils.DrawGradientBar(r.width, r.height, gMid, color, gcolor)
dc.DrawBitmap(gBmp,r.left, r.top)
else:
colour=self.GetBarColour()
dc.SetBrush(wx.Brush(colour))
@@ -397,7 +403,6 @@ class PyGauge(wx.PyWindow):
dc.SetTextForeground(wx.Colour(255,255,255))
dc.DrawLabel(formatStr.format(value), rect, wx.ALIGN_CENTER)
def OnTimer(self,event):
"""
Handles the ``wx.EVT_TIMER`` event for L{PyfaGauge}.

View File

@@ -18,7 +18,7 @@
#===============================================================================
import wx
import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import service
from gui.utils.clipboard import toClipboard, fromClipboard
from service.targetResists import ImportError
@@ -51,15 +51,11 @@ class ResistsEditorDlg(wx.Dialog):
self.namePicker.Bind(wx.EVT_TEXT_ENTER, self.processRename)
self.namePicker.Hide()
self.btnSave = wx.Button(self, wx.ID_SAVE)
self.btnSave.Hide()
self.btnSave.Bind(wx.EVT_BUTTON, self.processRename)
size = None
headerSizer.Add(self.ccResists, 1, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 3)
buttons = (("new", wx.ART_NEW),
("rename", bitmapLoader.getBitmap("rename", "icons")),
("rename", BitmapLoader.getBitmap("rename", "gui")),
("copy", wx.ART_COPY),
("delete", wx.ART_DELETE))
for name, art in buttons:
@@ -77,6 +73,12 @@ class ResistsEditorDlg(wx.Dialog):
btn.SetToolTipString("%s resist profile" % name.capitalize())
headerSizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL)
self.btnSave = wx.Button(self, wx.ID_SAVE)
self.btnSave.Hide()
self.btnSave.Bind(wx.EVT_BUTTON, self.processRename)
headerSizer.Add(self.btnSave, 0, wx.ALIGN_CENTER)
mainSizer.Add(headerSizer, 0, wx.EXPAND | wx.ALL, 2)
self.sl = wx.StaticLine(self)
@@ -101,7 +103,7 @@ class ResistsEditorDlg(wx.Dialog):
style = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT
border = 5
bmp = wx.StaticBitmap(self, wx.ID_ANY, bitmapLoader.getBitmap("%s_big"%type, "icons"))
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))
@@ -110,6 +112,9 @@ class ResistsEditorDlg(wx.Dialog):
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
self.colorReset = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT)
contentSizer.Add(resistEditSizer, 1, wx.EXPAND | wx.ALL, 5)
self.slfooter = wx.StaticLine(self)
contentSizer.Add(self.slfooter, 0, wx.EXPAND | wx.TOP, 5)
@@ -196,21 +201,21 @@ class ResistsEditorDlg(wx.Dialog):
# if everything checks out, set resist attribute
setattr(p, "%sAmount"%type, value/100)
editObj.SetForegroundColour(self.colorReset)
self.stNotice.SetLabel("")
self.totSizer.Layout()
if event is not None:
# If we get here, everything is normal. Reset color
event.EventObject.SetForegroundColour(wx.NullColor)
event.Skip()
service.TargetResists.getInstance().saveChanges(p)
except ValueError:
event.EventObject.SetForegroundColour(wx.RED)
editObj.SetForegroundColour(wx.RED)
self.stNotice.SetLabel("Incorrect Formatting (decimals only)")
except AssertionError:
event.EventObject.SetForegroundColour(wx.RED)
editObj.SetForegroundColour(wx.RED)
self.stNotice.SetLabel("Incorrect Range (must be 0-100)")
finally: # Refresh for color changes to take effect immediately
self.Refresh()
@@ -266,7 +271,7 @@ class ResistsEditorDlg(wx.Dialog):
for type in self.DAMAGE_TYPES:
editObj = getattr(self, "%sEdit"%type)
editObj.ChangeValue("0.0")
editObj.SetForegroundColour(wx.NullColor)
editObj.SetForegroundColour(self.colorReset)
self.Refresh()
self.renamePattern()
@@ -349,8 +354,6 @@ class ResistsEditorDlg(wx.Dialog):
self.namePicker.SetFocus()
for btn in (self.new, self.rename, self.delete, self.copy):
btn.Hide()
self.headerSizer.Remove(btn)
self.headerSizer.Add(self.btnSave, 0, wx.ALIGN_CENTER)
self.btnSave.Show()
self.restrict()
self.headerSizer.Layout()
@@ -359,12 +362,10 @@ class ResistsEditorDlg(wx.Dialog):
self.ccResists.Show()
self.namePicker.Hide()
self.btnSave.Hide()
self.headerSizer.Remove(self.btnSave)
for btn in (self.new, self.rename, self.delete, self.copy):
self.headerSizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL)
btn.Show()
self.unrestrict()
#self.headerSizer.Layout()
self.headerSizer.Layout()
def __del__( self ):

View File

@@ -325,7 +325,8 @@ class SFBrowserItem(wx.Window):
def OnLeftDown(self, event):
self.CaptureMouse()
if not self.HasCapture():
self.CaptureMouse()
btn = self.toolbar.MouseClick(event)

View File

@@ -1,6 +1,6 @@
import wx
import copy
from gui import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import gui.globalEvents as GE
import time
@@ -15,6 +15,7 @@ import gui.utils.animEffects as animEffects
import gui.sfBrowserItem as SFItem
from gui.contextMenu import ContextMenu
import gui.utils.fonts as fonts
import service
import gui.utils.fonts as fonts
@@ -106,9 +107,9 @@ class RaceSelector(wx.Window):
self.buttonsPadding = 4
if layout == wx.VERTICAL:
self.bmpArrow = bitmapLoader.getBitmap("down-arrow2","icons")
self.bmpArrow = BitmapLoader.getBitmap("down-arrow2","gui")
else:
self.bmpArrow = bitmapLoader.getBitmap("up-arrow2","icons")
self.bmpArrow = BitmapLoader.getBitmap("up-arrow2","gui")
# Make the bitmaps have the same color as window text
@@ -206,7 +207,7 @@ class RaceSelector(wx.Window):
self.raceBmps = []
for race in races:
if race:
self.raceBmps.append(bitmapLoader.getBitmap("race_%s_small" % race, "icons"))
self.raceBmps.append(BitmapLoader.getBitmap("race_%s_small" % race, "gui"))
self.raceNames = races
self.CalcButtonsBarPos()
self.Refresh()
@@ -327,14 +328,14 @@ class NavigationPanel(SFItem.SFBrowserItem):
def __init__(self,parent, size = (-1, 24)):
SFItem.SFBrowserItem.__init__(self,parent,size = size)
self.rewBmpH = bitmapLoader.getBitmap("frewind_small","icons")
self.forwBmp = bitmapLoader.getBitmap("fforward_small","icons")
self.searchBmpH = bitmapLoader.getBitmap("fsearch_small","icons")
self.newBmpH = bitmapLoader.getBitmap("fit_add_small","icons")
self.resetBmpH = bitmapLoader.getBitmap("freset_small","icons")
self.switchBmpH = bitmapLoader.getBitmap("fit_switch_view_mode_small","icons")
self.rewBmpH = BitmapLoader.getBitmap("frewind_small","gui")
self.forwBmp = BitmapLoader.getBitmap("fforward_small","gui")
self.searchBmpH = BitmapLoader.getBitmap("fsearch_small","gui")
self.newBmpH = BitmapLoader.getBitmap("fit_add_small","gui")
self.resetBmpH = BitmapLoader.getBitmap("freset_small","gui")
self.switchBmpH = BitmapLoader.getBitmap("fit_switch_view_mode_small","gui")
switchImg = bitmapLoader.getImage("fit_switch_view_mode_small","icons")
switchImg = BitmapLoader.getImage("fit_switch_view_mode_small","gui")
switchImg = switchImg.AdjustChannels(1,1,1,0.4)
self.switchBmpD = wx.BitmapFromImage(switchImg)
@@ -966,7 +967,7 @@ class CategoryItem(SFItem.SFBrowserItem):
SFItem.SFBrowserItem.__init__(self,parent,size = size)
if categoryID:
self.shipBmp = bitmapLoader.getBitmap("ship_small","icons")
self.shipBmp = BitmapLoader.getBitmap("ship_small","gui")
else:
self.shipBmp = wx.EmptyBitmap(16,16)
@@ -1098,26 +1099,26 @@ class ShipItem(SFItem.SFBrowserItem):
self.shipBmp = None
if shipID:
self.shipBmp = bitmapLoader.getBitmap(str(shipID),"ships")
self.shipBmp = BitmapLoader.getBitmap(str(shipID), "renders")
if not self.shipBmp:
self.shipBmp = bitmapLoader.getBitmap("ship_no_image_big","icons")
self.shipBmp = BitmapLoader.getBitmap("ship_no_image_big", "gui")
self.shipFittingInfo = shipFittingInfo
self.shipName, self.shipFits = shipFittingInfo
self.newBmp = bitmapLoader.getBitmap("fit_add_small", "icons")
self.acceptBmp = bitmapLoader.getBitmap("faccept_small", "icons")
self.newBmp = BitmapLoader.getBitmap("fit_add_small", "gui")
self.acceptBmp = BitmapLoader.getBitmap("faccept_small", "gui")
self.shipEffBk = bitmapLoader.getBitmap("fshipbk_big","icons")
self.shipEffBk = BitmapLoader.getBitmap("fshipbk_big","gui")
img = wx.ImageFromBitmap(self.shipEffBk)
img = img.Mirror(False)
self.shipEffBkMirrored = wx.BitmapFromImage(img)
self.raceBmp = bitmapLoader.getBitmap("race_%s_small" % self.shipRace, "icons")
self.raceBmp = BitmapLoader.getBitmap("race_%s_small" % self.shipRace, "gui")
if not self.raceBmp:
self.raceBmp = bitmapLoader.getBitmap("fit_delete_small","icons")
self.raceBmp = BitmapLoader.getBitmap("fit_delete_small","gui")
self.raceDropShadowBmp = drawUtils.CreateDropShadowBitmap(self.raceBmp, 0.2)
@@ -1340,7 +1341,7 @@ class ShipItem(SFItem.SFBrowserItem):
editCtl.SetPosition((fnEditPosX,fnEditPosY))
class PFBitmapFrame(wx.Frame):
def __init__ (self,parent, pos, bitmap):
def __init__ (self, parent, pos, bitmap):
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
@@ -1428,10 +1429,10 @@ class FitItem(SFItem.SFBrowserItem):
self.deleted = False
if shipID:
self.shipBmp = bitmapLoader.getBitmap(str(shipID),"ships")
self.shipBmp = BitmapLoader.getBitmap(str(shipID),"renders")
if not self.shipBmp:
self.shipBmp = bitmapLoader.getBitmap("ship_no_image_big","icons")
self.shipBmp = BitmapLoader.getBitmap("ship_no_image_big","gui")
self.shipFittingInfo = shipFittingInfo
self.shipName, self.fitName, self.fitBooster, self.timestamp = shipFittingInfo
@@ -1439,13 +1440,13 @@ class FitItem(SFItem.SFBrowserItem):
# see GH issue #62
if self.fitBooster is None: self.fitBooster = False
self.boosterBmp = bitmapLoader.getBitmap("fleet_fc_small", "icons")
self.copyBmp = bitmapLoader.getBitmap("fit_add_small", "icons")
self.renameBmp = bitmapLoader.getBitmap("fit_rename_small", "icons")
self.deleteBmp = bitmapLoader.getBitmap("fit_delete_small","icons")
self.acceptBmp = bitmapLoader.getBitmap("faccept_small", "icons")
self.boosterBmp = BitmapLoader.getBitmap("fleet_fc_small", "gui")
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.acceptBmp = BitmapLoader.getBitmap("faccept_small", "gui")
self.shipEffBk = bitmapLoader.getBitmap("fshipbk_big","icons")
self.shipEffBk = BitmapLoader.getBitmap("fshipbk_big","gui")
img = wx.ImageFromBitmap(self.shipEffBk)
img = img.Mirror(False)
@@ -1641,7 +1642,16 @@ class FitItem(SFItem.SFBrowserItem):
self.RestoreEditButton()
return
self.deleteFit()
# to prevent accidental deletion, give dialog confirmation unless shift is depressed
if wx.GetMouseState().ShiftDown() or wx.GetMouseState().MiddleDown():
self.deleteFit()
else:
dlg = wx.MessageDialog(self,
"Do you really want to delete this fit?",
"Confirm Delete", wx.YES | wx.NO | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
self.deleteFit()
def deleteFit(self, event=None):
if self.deleted:
@@ -1708,7 +1718,8 @@ class FitItem(SFItem.SFBrowserItem):
if self.dragging:
if not self.dragged:
if self.dragMotionTrigger < 0:
self.CaptureMouse()
if not self.HasCapture():
self.CaptureMouse()
self.dragWindow = PFBitmapFrame(self, pos, self.dragTLFBmp)
self.dragWindow.Show()
self.dragged = True
@@ -1808,7 +1819,7 @@ class FitItem(SFItem.SFBrowserItem):
self.AdjustControlSizePos(self.tcFitName, self.textStartx, self.toolbarx - self.editWidth - self.padding)
tdc = wx.MemoryDC()
self.dragTLFBmp = wx.EmptyBitmap((self.toolbarx if self.toolbarx < 200 else 200), rect.height)
self.dragTLFBmp = wx.EmptyBitmap((self.toolbarx if self.toolbarx < 200 else 200), rect.height, 24)
tdc.SelectObject(self.dragTLFBmp)
tdc.Blit(0, 0, (self.toolbarx if self.toolbarx < 200 else 200), rect.height, mdc, 0, 0, wx.COPY)
tdc.SelectObject(wx.NullBitmap)

View File

@@ -18,7 +18,7 @@
#===============================================================================
import wx
import bitmapLoader
from gui.bitmapLoader import BitmapLoader
import config
import service
import dateutil.parser
@@ -107,7 +107,7 @@ class UpdateDialog(wx.Dialog):
self.Centre( wx.BOTH )
def OnClose(self, e):
self.Destroy()
self.Close()
def SuppressChange(self, e):
if (self.supressCheckbox.IsChecked()):

View File

@@ -94,8 +94,5 @@ class WaitDialog(wx.Dialog):
mainSizer.Add( self.progress, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 0 )
self.SetSizer( mainSizer )
self.Layout()
self.Bind(wx.EVT_CLOSE,self.OnClose)
self.CenterOnParent()
def OnClose(self, event):
pass

View File

@@ -33,9 +33,10 @@ def DrawFilledBitmap(width, height, color):
return canvas
def DrawGradientBar(width, height, gStart, gEnd, gMid = None, fillRatio = 4):
# we need to have dimensions to draw
#assert width > 0 and height > 0
canvas = wx.EmptyBitmap(width,height)
mdc = wx.MemoryDC()
mdc.SelectObject(canvas)

View File

@@ -136,7 +136,7 @@ class exportHtmlThread(threading.Thread):
categoryList = list(sMkt.getShipRoot())
categoryList.sort(key=lambda ship: ship.name)
count = 1
count = 0
for group in categoryList:
# init market group string to give ships something to attach to
@@ -163,9 +163,9 @@ class exportHtmlThread(threading.Thread):
except:
pass
finally:
count += 1
if self.callback:
wx.CallAfter(self.callback, count)
count += 1
else:
# Ship group header
HTMLship = (
@@ -182,9 +182,9 @@ class exportHtmlThread(threading.Thread):
except:
continue
finally:
count += 1
if self.callback:
wx.CallAfter(self.callback, count)
count += 1
HTMLgroup += HTMLship + (' </ul>\n'
' </li>\n')

View File

@@ -1,3 +1,8 @@
'''
Font file to handle the differences in font calculations between
different wxPython versions
'''
import wx
if 'wxMac' in wx.PlatformInfo: