Merge branch 'master' into market_metagroups

This commit is contained in:
DarkPhoenix
2019-03-25 13:21:20 +03:00
2015 changed files with 35785 additions and 24201 deletions

View File

@@ -27,7 +27,8 @@ from logbook import Logger
import config
logging = Logger(__name__)
pyfalog = Logger(__name__)
class BitmapLoader(object):
@@ -38,7 +39,7 @@ class BitmapLoader(object):
# logging.info("Using local image files.")
# archive = None
logging.info("Using local image files.")
pyfalog.info("Using local image files.")
archive = None
cached_bitmaps = OrderedDict()
@@ -93,7 +94,7 @@ class BitmapLoader(object):
filename, img = cls.loadScaledBitmap(name, location, scale)
if img is None:
print(("Missing icon file: {0}/{1}".format(location, filename)))
pyfalog.warning("Missing icon file: {0}/{1}".format(location, filename))
return None
bmp: wx.Bitmap = img.ConvertToBitmap()
@@ -130,7 +131,7 @@ class BitmapLoader(object):
sbuf = io.StringIO(img_data)
return wx.ImageFromStream(sbuf)
except KeyError:
print(("Missing icon file from zip: {0}".format(path)))
pyfalog.warning("Missing icon file from zip: {0}".format(path))
else:
path = os.path.join(config.pyfaPath, 'imgs' + os.sep + location + os.sep + filename)

View File

@@ -108,10 +108,10 @@ class BoosterView(d.Display):
event.Skip()
return
self.origional = fit.boosters if fit is not None else None
self.boosters = stuff = fit.boosters[:] if fit is not None else None
if stuff is not None:
stuff.sort(key=lambda booster: booster.slot or 0)
self.original = fit.boosters if fit is not None else None
self.boosters = fit.boosters[:] if fit is not None else None
if self.boosters is not None:
self.boosters.sort(key=lambda booster: booster.slot or 0)
if event.fitID != self.lastFitId:
@@ -124,8 +124,8 @@ class BoosterView(d.Display):
self.deselectItems()
self.populate(stuff)
self.refresh(stuff)
self.populate(self.boosters)
self.refresh(self.boosters)
event.Skip()
def addItem(self, event):
@@ -152,7 +152,7 @@ class BoosterView(d.Display):
def removeBooster(self, booster):
fitID = self.mainFrame.getActiveFit()
self.mainFrame.command.Submit(cmd.GuiRemoveBoosterCommand(fitID, self.origional.index(booster)))
self.mainFrame.command.Submit(cmd.GuiRemoveBoosterCommand(fitID, self.original.index(booster)))
def click(self, event):
event.Skip()
@@ -172,8 +172,7 @@ class BoosterView(d.Display):
sel = self.GetFirstSelected()
if sel != -1:
sFit = Fit.getInstance()
fit = sFit.getFit(self.mainFrame.getActiveFit())
item = fit.boosters[sel]
item = self.boosters[sel]
srcContext = "boosterItem"
itemContext = "Booster"

View File

@@ -162,8 +162,7 @@ class DroneView(Display):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
DRONE_ORDER = ('Light Scout Drones', 'Medium Scout Drones',
'Heavy Attack Drones', 'Sentry Drones', 'Fighters',
'Fighter Bombers', 'Combat Utility Drones',
'Heavy Attack Drones', 'Sentry Drones', 'Combat Utility Drones',
'Electronic Warfare Drones', 'Logistic Drones', 'Mining Drones', 'Salvage Drones')
def droneKey(self, drone):

View File

@@ -220,20 +220,12 @@ class FighterDisplay(d.Display):
def _merge(src, dst):
return
'''
DRONE_ORDER = ('Light Scout Drones', 'Medium Scout Drones',
'Heavy Attack Drones', 'Sentry Drones', 'Fighters',
'Fighter Bombers', 'Combat Utility Drones',
'Electronic Warfare Drones', 'Logistic Drones', 'Mining Drones', 'Salvage Drones',
'Light Fighters', 'Heavy Fighters', 'Support Fighters')
def droneKey(self, drone):
sMkt = Market.getInstance()
FIGHTER_ORDER = ('Heavy Fighter', 'Light Fighter', 'Support Fighter')
groupName = sMkt.getMarketGroupByItem(drone.item).name
print groupName
return (self.DRONE_ORDER.index(groupName),
drone.item.name)
'''
def fighterKey(self, fighter):
sMkt = Market.getInstance()
groupName = sMkt.getGroupByItem(fighter.item).name
return (self.FIGHTER_ORDER.index(groupName), fighter.item.name)
def fitChanged(self, event):
sFit = Fit.getInstance()
@@ -249,12 +241,10 @@ class FighterDisplay(d.Display):
return
self.original = fit.fighters if fit is not None else None
self.fighters = stuff = fit.fighters[:] if fit is not None else None
self.fighters = fit.fighters[:] if fit is not None else None
'''
if stuff is not None:
stuff.sort(key=self.droneKey)
'''
if self.fighters is not None:
self.fighters.sort(key=self.fighterKey)
if event.fitID != self.lastFitId:
self.lastFitId = event.fitID
@@ -266,7 +256,7 @@ class FighterDisplay(d.Display):
self.deselectItems()
self.update(stuff)
self.update(self.fighters)
event.Skip()
def addItem(self, event):

View File

@@ -129,8 +129,10 @@ class ProjectedView(d.Display):
sFit = Fit.getInstance()
row = self.GetFirstSelected()
if row != -1:
sFit.removeProjected(fitID, self.get(row))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
thing = self.get(row)
if thing:
sFit.removeProjected(fitID, self.get(row))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
def handleDrag(self, type, fitID):
# Those are drags coming from pyfa sources, NOT builtin wx drags

View File

@@ -29,12 +29,9 @@ class FactorReload(ContextMenu):
sFit.refreshFit(fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
def getBitmap(self, context, selection):
@property
def checked(self):
sFit = Fit.getInstance()
if sFit.serviceFittingOptions["useGlobalForceReload"]:
return BitmapLoader.getBitmap("state_active_small", "gui")
else:
return None
return sFit.serviceFittingOptions["useGlobalForceReload"]
FactorReload.register()

View File

@@ -117,11 +117,12 @@ class MetaSwap(ContextMenu):
id = ContextMenu.nextID()
mitem = wx.MenuItem(rootMenu, id, item.name)
mitem.Enable(fit.canFit(item))
bindmenu.Bind(wx.EVT_MENU, self.handleModule, mitem)
self.moduleLookup[id] = item, context
m.Append(mitem)
mitem.Enable(fit.canFit(item))
return m
def handleModule(self, event):

View File

@@ -207,8 +207,15 @@ AttrGroupDict = {
"fighterSquadronOrbitRange",
]
},
GuiAttrGroup.SHIP_GROUP : {
"label" : "Can Fit To",
"attributes": []
},
}
AttrGroupDict[GuiAttrGroup.SHIP_GROUP]["attributes"].extend([("canFitShipGroup{:02d}".format(i+1), "Group") for i in range(20)])
AttrGroupDict[GuiAttrGroup.SHIP_GROUP]["attributes"].extend([("canFitShipType{:01d}".format(i+1), "Ship") for i in range(20)])
Group1 = [
GuiAttrGroup.FITTING,
GuiAttrGroup.STRUCTURE,
@@ -222,6 +229,7 @@ Group1 = [
GuiAttrGroup.ON_DEATH,
GuiAttrGroup.JUMP_SYSTEMS,
GuiAttrGroup.PROPULSIONS,
GuiAttrGroup.SHIP_GROUP
]
CategoryGroups = {

View File

@@ -173,9 +173,15 @@ class ItemParams(wx.Panel):
self.paramList.AssignImageList(self.imageList)
def AddAttribute(self, parent, attr):
display = None
if isinstance(attr, tuple):
display = attr[1]
attr = attr[0]
if attr in self.attrValues and attr not in self.processed_attribs:
data = self.GetData(attr)
data = self.GetData(attr, display)
if data is None:
return
@@ -203,7 +209,7 @@ class ItemParams(wx.Panel):
misc_parent = root
# We must first deet4ermine if it's categorey already has defined groupings set for it. Otherwise, we default to just using the fitting group
order = CategoryGroups.get(self.item.category.categoryName, [GuiAttrGroup.FITTING])
order = CategoryGroups.get(self.item.category.categoryName, [GuiAttrGroup.FITTING, GuiAttrGroup.SHIP_GROUP])
# start building out the tree
for data in [AttrGroupDict[o] for o in order]:
heading = data.get("label")
@@ -256,7 +262,7 @@ class ItemParams(wx.Panel):
for i in range(self.paramList.GetMainWindow().GetColumnCount()):
self.paramList.SetColumnWidth(i, wx.LIST_AUTOSIZE)
def GetData(self, attr):
def GetData(self, attr, displayOveride = None):
info = self.attrInfo.get(attr)
att = self.attrValues[attr]
@@ -275,7 +281,7 @@ class ItemParams(wx.Panel):
return None
if info and info.displayName and self.toggleView == AttributeView.NORMAL:
attrName = info.displayName
attrName = displayOveride or info.displayName
else:
attrName = attr

View File

@@ -21,8 +21,6 @@ class ItemEffects(wx.Panel):
self.SetSizer(mainSizer)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick, self.effectList)
if config.debug:
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick, self.effectList)
self.PopulateList()
@@ -100,26 +98,6 @@ class ItemEffects(wx.Panel):
self.RefreshValues(event)
def OnRightClick(self, event):
"""
Debug use: open effect file with default application.
If effect file does not exist, create it
"""
effect = self.effects[event.GetText()]
file_ = os.path.join(config.pyfaPath, "eos", "effects", "%s.py" % effect.handlerName)
if not os.path.isfile(file_):
open(file_, 'a').close()
if 'wxMSW' in wx.PlatformInfo:
os.startfile(file_)
elif 'wxMac' in wx.PlatformInfo:
os.system("open " + file_)
else:
subprocess.call(["xdg-open", file_])
def RefreshValues(self, event):
self.Freeze()
self.effectList.ClearAll()

View File

@@ -202,7 +202,7 @@ class ItemView(Display):
mktgrpid = sMkt.getMarketGroupByItem(item).ID
except AttributeError:
mktgrpid = -1
print(("unable to find market group for", item.name))
pyfalog.warning("unable to find market group for {}".format(item.name))
parentname = sMkt.getParentItemByItem(item).name
# Get position of market group
metagrpid = sMkt.getMetaGroupIdByItem(item)

View File

@@ -82,7 +82,7 @@ class FitSpawner(gui.multiSwitch.TabSpawner):
if not isinstance(view, FittingView):
view = FittingView(self.multiSwitch)
print("###################### Created new view:" + repr(view))
pyfalog.debug("###################### Created new view:" + repr(view))
self.multiSwitch.ReplaceActivePage(view)
view.fitSelected(event)
@@ -174,8 +174,8 @@ class FittingView(d.Display):
self.Bind(wx.EVT_MOTION, self.OnMouseMove)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
self.parent.Bind(EVT_NOTEBOOK_PAGE_CHANGED, self.pageChanged)
print("------------------ new fitting view -------------------")
print(self)
pyfalog.debug("------------------ new fitting view -------------------")
pyfalog.debug(self)
def OnLeaveWindow(self, event):
self.SetToolTip(None)
@@ -224,16 +224,7 @@ class FittingView(d.Display):
wx.PostEvent(self.mainFrame, FitSelected(fitID=fitID))
def Destroy(self):
# @todo: when wxPython 4.0.2 is release, https://github.com/pyfa-org/Pyfa/issues/1586#issuecomment-390074915
# Make sure to remove the shitty checks that I have to put in place for these handlers to ignore when self is None
print("+++++ Destroy " + repr(self))
# print(self.parent.Unbind(EVT_NOTEBOOK_PAGE_CHANGED))
# print(self.mainFrame.Unbind(GE.FIT_CHANGED, handler=self.fitChanged))
# print(self.mainFrame.Unbind(EVT_FIT_RENAMED, handler=self.fitRenamed ))
# print(self.mainFrame.Unbind(EVT_FIT_REMOVED, handler=self.fitRemoved))
# print(self.mainFrame.Unbind(ITEM_SELECTED, handler=self.appendItem))
pyfalog.debug("+++++ Destroy " + repr(self))
d.Display.Destroy(self)
def pageChanged(self, event):
@@ -296,7 +287,6 @@ class FittingView(d.Display):
delete fit caused change in stats (projected)
todo: move this to the notebook, not the page. We don't want the page being responsible for deleting itself
"""
print('_+_+_+_+_+_ Fit Removed: {} {} activeFitID: {}, eventFitID: {}'.format(repr(self), str(bool(self)), self.activeFitID, event.fitID))
pyfalog.debug("FittingView::fitRemoved")
if not self:
event.Skip()
@@ -331,7 +321,7 @@ class FittingView(d.Display):
event.Skip()
def fitSelected(self, event):
print('====== Fit Selected: ' + repr(self) + str(bool(self)))
pyfalog.debug('====== Fit Selected: ' + repr(self) + str(bool(self)))
if self.parent.IsActive(self):
fitID = event.fitID

View File

@@ -79,7 +79,8 @@ class ContextMenu(object):
multiple = not isinstance(bitmap, wx.Bitmap)
for it, text in enumerate(texts):
id = cls.nextID()
rootItem = wx.MenuItem(rootMenu, id, text)
check = m.checked
rootItem = wx.MenuItem(rootMenu, id, text, kind=wx.ITEM_NORMAL if m.checked is None else wx.ITEM_CHECK)
rootMenu.info[id] = (m, fullContext, it)
sub = m.getSubMenu(srcContext, selection, rootMenu, it, rootItem)
@@ -114,6 +115,9 @@ class ContextMenu(object):
rootMenu.Append(rootItem)
if check is not None:
rootItem.Check(check)
empty = False
if display_amount > 0 and i != len(fullContexts) - 1:
@@ -177,6 +181,10 @@ class ContextMenu(object):
def getBitmap(self, context, selection):
return None
@property
def checked(self):
'''If menu item is toggleable, this should return bool value'''
return None
# noinspection PyUnresolvedReferences
from gui.builtinContextMenus import ( # noqa: E402,F401

View File

@@ -174,7 +174,7 @@ class CopySelectDialog(wx.Dialog):
def exportXml(self, options, callback):
fit = getFit(self.mainFrame.getActiveFit())
Port.exportXml(None, fit, callback)
Port.exportXml([fit], None, callback)
def exportMultiBuy(self, options, callback):
fit = getFit(self.mainFrame.getActiveFit())
@@ -182,4 +182,4 @@ class CopySelectDialog(wx.Dialog):
def exportEfs(self, options, callback):
fit = getFit(self.mainFrame.getActiveFit())
EfsPort.exportEfs(fit, 0, callback)
EfsPort.exportEfs(fit, 0, callback)

View File

@@ -93,8 +93,8 @@ class GraphFrame(wx.Frame):
graphFrame_enabled = True
if int(mpl.__version__[0]) < 1:
print(("pyfa: Found matplotlib version ", mpl.__version__, " - activating OVER9000 workarounds"))
print("pyfa: Recommended minimum matplotlib version is 1.0.0")
pyfalog.warning("pyfa: Found matplotlib version {} - activating OVER9000 workarounds".format(mpl.__version__))
pyfalog.warning("pyfa: Recommended minimum matplotlib version is 1.0.0")
self.legendFix = True
mplImported = True

View File

@@ -73,17 +73,18 @@ from service.settings import HTMLExportSettings, SettingsProvider
from service.update import Update
import gui.fitCommands as cmd
pyfalog = Logger(__name__)
disableOverrideEditor = False
try:
from gui.propertyEditor import AttributeEditor
except ImportError as e:
AttributeEditor = None
print(("Error loading Attribute Editor: %s.\nAccess to Attribute Editor is disabled." % e.message))
pyfalog.warning("Error loading Attribute Editor: %s.\nAccess to Attribute Editor is disabled." % e.message)
disableOverrideEditor = True
pyfalog = Logger(__name__)
pyfalog.debug("Done loading mainframe imports")
@@ -417,11 +418,11 @@ class MainFrame(wx.Frame):
format_ = dlg.GetFilterIndex()
path = dlg.GetPath()
if format_ == 0:
output = Port.exportXml(None, fit)
output = Port.exportXml([fit], None)
if '.' not in os.path.basename(path):
path += ".xml"
else:
print(("oops, invalid fit format %d" % format_))
pyfalog.warning("oops, invalid fit format %d" % format_)
try:
dlg.Destroy()
except RuntimeError:

View File

@@ -68,7 +68,7 @@ class exportHtmlThread(threading.Thread):
FILE.write(HTML)
FILE.close()
except IOError as ex:
print(("Failed to write to " + settings.getPath()))
pyfalog.warning("Failed to write to " + settings.getPath())
pass
except Exception as ex:
pass