Merge branch 'singularity'
This commit is contained in:
@@ -15,6 +15,7 @@ __all__ = [
|
||||
"cargo",
|
||||
"shipJump",
|
||||
#"changeAffectingSkills",
|
||||
"tacticalMode",
|
||||
"targetResists",
|
||||
"priceClear"
|
||||
]
|
||||
|
||||
@@ -65,6 +65,7 @@ class ChangeAffectingSkills(ContextMenu):
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.skillIds = {}
|
||||
sub = wx.Menu()
|
||||
|
||||
@@ -78,7 +79,7 @@ class ChangeAffectingSkills(ContextMenu):
|
||||
skillItem.SetBitmap(bitmap)
|
||||
|
||||
for i in xrange(-1, 6):
|
||||
levelItem = self.addSkill(rootMenu, skill, i)
|
||||
levelItem = self.addSkill(rootMenu if msw else grandSub, skill, i)
|
||||
grandSub.AppendItem(levelItem)
|
||||
#@ todo: add check to current level. Need to fix #109 first
|
||||
sub.AppendItem(skillItem)
|
||||
|
||||
@@ -70,6 +70,7 @@ class DamagePattern(ContextMenu):
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
rootMenu.Bind(wx.EVT_MENU, self.handlePatternSwitch) # this bit is required for some reason
|
||||
|
||||
if self.m[i] not in self.subMenus:
|
||||
@@ -87,7 +88,7 @@ class DamagePattern(ContextMenu):
|
||||
|
||||
# Items that have a parent
|
||||
for pattern in self.subMenus[self.m[i]]:
|
||||
sub.AppendItem(self.addPattern(rootMenu, pattern))
|
||||
sub.AppendItem(self.addPattern(rootMenu if msw else sub, pattern))
|
||||
|
||||
return sub
|
||||
|
||||
|
||||
@@ -97,12 +97,12 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
parts = charge.name.split(" ")
|
||||
return map(self.numericConverter, parts)
|
||||
|
||||
def addCharge(self, rootMenu, charge):
|
||||
def addCharge(self, menu, charge):
|
||||
id = wx.NewId()
|
||||
name = charge.name if charge is not None else "Empty"
|
||||
self.chargeIds[id] = charge
|
||||
item = wx.MenuItem(rootMenu, id, name)
|
||||
rootMenu.Bind(wx.EVT_MENU, self.handleAmmoSwitch, item)
|
||||
item = wx.MenuItem(menu, id, name)
|
||||
menu.Bind(wx.EVT_MENU, self.handleAmmoSwitch, item)
|
||||
item.charge = charge
|
||||
if charge is not None and charge.icon is not None:
|
||||
bitmap = bitmapLoader.getBitmap(charge.icon.iconFile, "pack")
|
||||
@@ -117,6 +117,7 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
m.Enable(id, False)
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
m = wx.Menu()
|
||||
self.chargeIds = {}
|
||||
hardpoint = self.module.hardpoint
|
||||
@@ -147,7 +148,7 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
base = charge
|
||||
nameBase = currBase
|
||||
range = currRange
|
||||
item = self.addCharge(rootMenu, charge)
|
||||
item = self.addCharge(rootMenu if msw else m, charge)
|
||||
items.append(item)
|
||||
else:
|
||||
if sub is None:
|
||||
@@ -155,9 +156,9 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
sub.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
|
||||
self.addSeperator(sub, "Less Damage")
|
||||
item.SetSubMenu(sub)
|
||||
sub.AppendItem(self.addCharge(rootMenu, base))
|
||||
sub.AppendItem(self.addCharge(rootMenu if msw else sub, base))
|
||||
|
||||
sub.AppendItem(self.addCharge(rootMenu, charge))
|
||||
sub.AppendItem(self.addCharge(rootMenu if msw else sub, charge))
|
||||
|
||||
if sub is not None:
|
||||
self.addSeperator(sub, "More Damage")
|
||||
@@ -191,20 +192,20 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
m.AppendItem(item)
|
||||
|
||||
if charge.name not in ("Light Defender Missile I", "Heavy Defender Missile I"):
|
||||
sub.AppendItem(self.addCharge(rootMenu, charge))
|
||||
sub.AppendItem(self.addCharge(rootMenu if msw else sub, charge))
|
||||
else:
|
||||
defender = charge
|
||||
|
||||
if defender is not None:
|
||||
m.AppendItem(self.addCharge(rootMenu, defender))
|
||||
m.AppendItem(self.addCharge(rootMenu if msw else m, defender))
|
||||
if sub is not None:
|
||||
self.addSeperator(sub, "More Damage")
|
||||
else:
|
||||
self.charges.sort(key=self.nameSorter)
|
||||
for charge in self.charges:
|
||||
m.AppendItem(self.addCharge(rootMenu, charge))
|
||||
m.AppendItem(self.addCharge(rootMenu if msw else m, charge))
|
||||
|
||||
m.AppendItem(self.addCharge(rootMenu, None))
|
||||
m.AppendItem(self.addCharge(rootMenu if msw else m, None))
|
||||
return m
|
||||
|
||||
def handleAmmoSwitch(self, event):
|
||||
|
||||
60
gui/builtinContextMenus/tacticalMode.py
Normal file
60
gui/builtinContextMenus/tacticalMode.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import wx
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import service
|
||||
import gui.globalEvents as GE
|
||||
|
||||
class TacticalMode(ContextMenu):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext != "fittingShip":
|
||||
return False
|
||||
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = sFit.getFit(fitID)
|
||||
|
||||
self.modes = fit.ship.getModes()
|
||||
self.currMode = fit.mode
|
||||
|
||||
return srcContext == "fittingShip" and self.modes is not None
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Tactical Mode"
|
||||
|
||||
def addMode(self, menu, mode):
|
||||
label = mode.item.name.rsplit()[-2]
|
||||
id = wx.NewId()
|
||||
self.modeIds[id] = mode
|
||||
menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_RADIO)
|
||||
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.context = context
|
||||
self.modeIds = {}
|
||||
|
||||
sub = wx.Menu()
|
||||
|
||||
for mode in self.modes:
|
||||
menuItem = self.addMode(rootMenu if msw else sub, mode)
|
||||
sub.AppendItem(menuItem)
|
||||
menuItem.Check(self.currMode.item == mode.item)
|
||||
|
||||
return sub
|
||||
|
||||
def handleMode(self, event):
|
||||
item = self.modeIds[event.Id]
|
||||
if item is False or item not in self.modes:
|
||||
event.Skip()
|
||||
return
|
||||
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
sFit.setMode(fitID, self.modeIds[event.Id])
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
TacticalMode.register()
|
||||
@@ -61,6 +61,7 @@ class TargetResists(ContextMenu):
|
||||
return item
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.patternIds = {}
|
||||
self.subMenus = OrderedDict()
|
||||
self.singles = []
|
||||
@@ -78,12 +79,12 @@ class TargetResists(ContextMenu):
|
||||
else:
|
||||
self.singles.append(pattern)
|
||||
|
||||
sub.AppendItem(self.addPattern(rootMenu, None)) # Add reset
|
||||
sub.AppendItem(self.addPattern(rootMenu if msw else sub, None)) # Add reset
|
||||
sub.AppendSeparator()
|
||||
|
||||
# Single items, no parent
|
||||
for pattern in self.singles:
|
||||
sub.AppendItem(self.addPattern(rootMenu, pattern))
|
||||
sub.AppendItem(self.addPattern(rootMenu if msw else sub, pattern))
|
||||
|
||||
# Items that have a parent
|
||||
for menuName, patterns in self.subMenus.items():
|
||||
@@ -99,7 +100,7 @@ class TargetResists(ContextMenu):
|
||||
|
||||
# Append child items to child menu
|
||||
for pattern in patterns:
|
||||
grandSub.AppendItem(self.addPattern(rootMenu, pattern))
|
||||
grandSub.AppendItem(self.addPattern(rootMenu if msw else grandSub, pattern))
|
||||
sub.AppendItem(item) #finally, append parent item to root menu
|
||||
|
||||
return sub
|
||||
|
||||
@@ -15,6 +15,7 @@ class WhProjector(ContextMenu):
|
||||
return "Add System Effects"
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
sMkt = service.Market.getInstance()
|
||||
effdata = sMkt.getSystemWideEffects()
|
||||
|
||||
@@ -32,7 +33,10 @@ class WhProjector(ContextMenu):
|
||||
swObj, swName, swClass = swData
|
||||
self.idmap[wxid] = (swObj, swName)
|
||||
grandSubItem = wx.MenuItem(grandSub, wxid, swClass)
|
||||
rootMenu.Bind(wx.EVT_MENU, self.handleSelection, grandSubItem)
|
||||
if msw:
|
||||
rootMenu.Bind(wx.EVT_MENU, self.handleSelection, grandSubItem)
|
||||
else:
|
||||
grandSub.Bind(wx.EVT_MENU, self.handleSelection, grandSubItem)
|
||||
grandSub.AppendItem(grandSubItem)
|
||||
return sub
|
||||
|
||||
|
||||
@@ -42,7 +42,10 @@ class BaseName(ViewColumn):
|
||||
return "%s (%s)" % (stuff.name, stuff.ship.item.name)
|
||||
elif isinstance(stuff, Rack):
|
||||
if service.Fit.getInstance().serviceFittingOptions["rackLabels"]:
|
||||
return u'─ {} Slots ─'.format(Slot.getName(stuff.slot).capitalize())
|
||||
if stuff.slot == Slot.MODE:
|
||||
return u'─ Tactical Mode ─'
|
||||
else:
|
||||
return u'─ {} Slots ─'.format(Slot.getName(stuff.slot).capitalize())
|
||||
else:
|
||||
return ""
|
||||
elif isinstance(stuff, Module):
|
||||
|
||||
@@ -23,6 +23,7 @@ import service
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
from gui.viewColumn import ViewColumn
|
||||
from gui import bitmapLoader
|
||||
from eos.types import Mode
|
||||
|
||||
class CapacitorUse(ViewColumn):
|
||||
name = "Capacitor Usage"
|
||||
@@ -38,6 +39,9 @@ class CapacitorUse(ViewColumn):
|
||||
|
||||
|
||||
def getText(self, mod):
|
||||
if isinstance(mod, Mode):
|
||||
return ""
|
||||
|
||||
capUse = mod.capUse
|
||||
if capUse:
|
||||
return "%s%s" % ("+" if capUse < 0 else "", (formatAmount(-capUse, 3, 0, 3)))
|
||||
|
||||
@@ -23,6 +23,7 @@ from gui import bitmapLoader
|
||||
import service
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
import wx
|
||||
from eos.types import Mode
|
||||
|
||||
class MaxRange(ViewColumn):
|
||||
name = "Max Range"
|
||||
@@ -51,6 +52,9 @@ class MaxRange(ViewColumn):
|
||||
self.mask |= wx.LIST_MASK_TEXT
|
||||
|
||||
def getText(self, stuff):
|
||||
if isinstance(stuff, Mode):
|
||||
return ""
|
||||
|
||||
maxRange = stuff.maxRange if hasattr(stuff, "maxRange") else stuff.getModifiedItemAttr("maxRange")
|
||||
falloff = stuff.falloff
|
||||
if falloff:
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import builtinViewColumns
|
||||
from gui.viewColumn import ViewColumn
|
||||
from gui import bitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
@@ -69,7 +68,9 @@ class Miscellanea(ViewColumn):
|
||||
itemGroup = item.group.name
|
||||
itemCategory = item.category.name
|
||||
|
||||
if itemGroup in ("Energy Weapon", "Hybrid Weapon", "Projectile Weapon", "Combat Drone", "Fighter Drone"):
|
||||
if itemGroup == "Ship Modifiers":
|
||||
return "", None
|
||||
elif itemGroup in ("Energy Weapon", "Hybrid Weapon", "Projectile Weapon", "Combat Drone", "Fighter Drone"):
|
||||
trackingSpeed = stuff.getModifiedItemAttr("trackingSpeed")
|
||||
if not trackingSpeed:
|
||||
return "", None
|
||||
|
||||
@@ -403,6 +403,10 @@ class FittingView(d.Display):
|
||||
self.mods = fit.modules[:]
|
||||
self.mods.sort(key=lambda mod: (slotOrder.index(mod.slot), mod.position))
|
||||
|
||||
# Blanks is a list of indexes that mark non-module positions (such
|
||||
# as Racks and tactical Modes. This allows us to skip over common
|
||||
# module operations such as swapping, removing, copying, etc. that
|
||||
# would otherwise cause complications
|
||||
self.blanks = [] # preliminary markers where blanks will be inserted
|
||||
|
||||
if sFit.serviceFittingOptions["rackSlots"]:
|
||||
@@ -419,6 +423,15 @@ class FittingView(d.Display):
|
||||
for i, (x, slot) in enumerate(self.blanks):
|
||||
self.blanks[i] = x+i # modify blanks with actual index
|
||||
self.mods.insert(x+i, Rack.buildRack(slot))
|
||||
|
||||
if fit.mode:
|
||||
# Modes are special snowflakes and need a little manual loving
|
||||
# We basically append the Mode rack and Mode to the modules
|
||||
# while also marking their positions in the Blanks list
|
||||
self.blanks.append(len(self.mods))
|
||||
self.mods.append(Rack.buildRack(Slot.MODE))
|
||||
self.blanks.append(len(self.mods))
|
||||
self.mods.append(fit.mode)
|
||||
else:
|
||||
self.mods = None
|
||||
|
||||
@@ -457,7 +470,7 @@ class FittingView(d.Display):
|
||||
sel = self.GetFirstSelected()
|
||||
contexts = []
|
||||
|
||||
while sel != -1:
|
||||
while sel != -1 and sel not in self.blanks:
|
||||
mod = self.mods[self.GetItemData(sel)]
|
||||
if not mod.isEmpty:
|
||||
srcContext = "fittingModule"
|
||||
@@ -544,14 +557,17 @@ class FittingView(d.Display):
|
||||
|
||||
font = (self.GetClassDefaultAttributes()).font
|
||||
for i, mod in enumerate(self.mods):
|
||||
if slotMap[mod.slot]:
|
||||
if hasattr(mod,"slot") and slotMap[mod.slot]:
|
||||
self.SetItemBackgroundColour(i, wx.Colour(204, 51, 51))
|
||||
elif sFit.serviceFittingOptions["colorFitBySlot"] and not isinstance(mod, Rack):
|
||||
self.SetItemBackgroundColour(i, self.slotColour(mod.slot))
|
||||
else:
|
||||
self.SetItemBackgroundColour(i, self.GetBackgroundColour())
|
||||
|
||||
if i in self.blanks and sFit.serviceFittingOptions["rackSlots"] and sFit.serviceFittingOptions["rackLabels"]:
|
||||
# Set rack face to bold
|
||||
if isinstance(mod, Rack) and \
|
||||
sFit.serviceFittingOptions["rackSlots"] and \
|
||||
sFit.serviceFittingOptions["rackLabels"]:
|
||||
font.SetWeight(wx.FONTWEIGHT_BOLD)
|
||||
self.SetItemFont(i, font)
|
||||
else:
|
||||
|
||||
@@ -22,9 +22,9 @@ import re
|
||||
import gui.mainFrame
|
||||
import bitmapLoader
|
||||
import sys
|
||||
import wx.lib.mixins.listctrl as listmix
|
||||
import wx.lib.mixins.listctrl as listmix
|
||||
import wx.html
|
||||
from eos.types import Ship, Module, Skill, Booster, Implant, Drone
|
||||
from eos.types import Ship, Module, Skill, Booster, Implant, Drone, Mode
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
import service
|
||||
import config
|
||||
@@ -535,7 +535,7 @@ class ItemEffects (wx.Panel):
|
||||
|
||||
|
||||
class ItemAffectedBy (wx.Panel):
|
||||
ORDER = [Ship, Module, Drone, Implant, Booster, Skill]
|
||||
ORDER = [Ship, Mode, Module, Drone, Implant, Booster, Skill]
|
||||
def __init__(self, parent, stuff, item):
|
||||
wx.Panel.__init__ (self, parent)
|
||||
self.stuff = stuff
|
||||
|
||||
@@ -290,6 +290,7 @@ class MainFrame(wx.Frame):
|
||||
event.Skip()
|
||||
|
||||
def ShowAboutBox(self, evt):
|
||||
import eos.config
|
||||
info = wx.AboutDialogInfo()
|
||||
info.Name = "pyfa"
|
||||
info.Version = gui.aboutData.versionString
|
||||
@@ -299,7 +300,8 @@ class MainFrame(wx.Frame):
|
||||
"\n\t".join(gui.aboutData.credits) +
|
||||
"\n\nLicenses:\n\t" +
|
||||
"\n\t".join(gui.aboutData.licenses) +
|
||||
"\n\nPython: \t" + sys.version +
|
||||
"\n\nEVE Data: \t" + eos.config.gamedata_version +
|
||||
"\nPython: \t" + sys.version +
|
||||
"\nwxPython: \t" + wx.__version__ +
|
||||
"\nSQLAlchemy: \t" + sqlalchemy.__version__,
|
||||
700, wx.ClientDC(self))
|
||||
|
||||
Reference in New Issue
Block a user