Merge branch 'charImplants' into singularity
# Conflicts: # eos/db/saveddata/fit.py # gui/builtinContextMenus/itemStats.py
This commit is contained in:
@@ -20,4 +20,5 @@ __all__ = [
|
||||
"priceClear",
|
||||
"amount",
|
||||
"metaSwap",
|
||||
"implantSets",
|
||||
]
|
||||
|
||||
78
gui/builtinContextMenus/implantSets.py
Normal file
78
gui/builtinContextMenus/implantSets.py
Normal file
@@ -0,0 +1,78 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import service
|
||||
import gui.globalEvents as GE
|
||||
import wx
|
||||
|
||||
class ImplantSets(ContextMenu):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
return srcContext in ("implantView", "implantEditor")
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Add Implant Set"
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
"""
|
||||
A note on the selection here: Most context menus act on a fit, so it's easy enough to get the active fit from
|
||||
the MainFrame instance. There's never been a reason to get info from another window, so there's not common
|
||||
way of doing this. However, we use this context menu within the Character Editor to apply implant sets to a
|
||||
character, so we need to access the character editor.
|
||||
|
||||
It is for these reasons that I hijack the selection parameter when calling the menu and pass a pointer to the
|
||||
Character Editor. This way we can use it to get current editing character ID and apply the implants.
|
||||
|
||||
It would probably be better to have a function on the MainFrame to get the currently open Character Editor (as
|
||||
we do with the item stats window). Eventually... Until then, this long ass note will remain to remind me why
|
||||
stupid shit like this is even happening.
|
||||
"""
|
||||
|
||||
m = wx.Menu()
|
||||
bindmenu = rootMenu if "wxMSW" in wx.PlatformInfo else m
|
||||
|
||||
sIS = service.ImplantSets.getInstance()
|
||||
implantSets = sIS.getImplantSetList()
|
||||
|
||||
self.context = context
|
||||
if len(selection) == 1:
|
||||
self.selection = selection[0] # dirty hack here
|
||||
|
||||
self.idmap = {}
|
||||
|
||||
for set in implantSets:
|
||||
id = wx.NewId()
|
||||
mitem = wx.MenuItem(rootMenu, id, set.name)
|
||||
bindmenu.Bind(wx.EVT_MENU, self.handleSelection, mitem)
|
||||
self.idmap[id] = set
|
||||
m.AppendItem(mitem)
|
||||
|
||||
return m
|
||||
|
||||
def handleSelection(self, event):
|
||||
set = self.idmap.get(event.Id, None)
|
||||
|
||||
if set is None:
|
||||
event.Skip()
|
||||
return
|
||||
|
||||
if self.context == "implantEditor":
|
||||
# we are calling from character editor, the implant source is different
|
||||
sChar = service.Character.getInstance()
|
||||
charID = self.selection.getActiveCharacter()
|
||||
|
||||
for implant in set.implants:
|
||||
sChar.addImplant(charID, implant.item.ID)
|
||||
|
||||
wx.PostEvent(self.selection, GE.CharChanged())
|
||||
else:
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
for implant in set.implants:
|
||||
sFit.addImplant(fitID, implant.item.ID, recalc=implant == set.implants[-1])
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
ImplantSets.register()
|
||||
@@ -9,6 +9,7 @@ class ItemStats(ContextMenu):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
|
||||
return srcContext in ("marketItemGroup", "marketItemMisc",
|
||||
"fittingModule", "fittingCharge",
|
||||
"fittingShip", "baseShip",
|
||||
@@ -16,7 +17,7 @@ class ItemStats(ContextMenu):
|
||||
"implantItem", "boosterItem",
|
||||
"skillItem", "projectedModule",
|
||||
"projectedDrone", "projectedCharge",
|
||||
"itemStats", "fighterItem")
|
||||
"itemStats", "fighterItem", "implantItemChar")
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "{0} Stats".format(itmContext if itmContext is not None else "Item")
|
||||
|
||||
@@ -12,7 +12,8 @@ class MarketJump(ContextMenu):
|
||||
"fittingCharge", "droneItem",
|
||||
"implantItem", "boosterItem",
|
||||
"projectedModule", "projectedDrone",
|
||||
"projectedCharge", "cargoItem")
|
||||
"projectedCharge", "cargoItem",
|
||||
"implantItemChar")
|
||||
|
||||
if not srcContext in validContexts or selection is None or len(selection) < 1:
|
||||
return False
|
||||
@@ -33,12 +34,10 @@ class MarketJump(ContextMenu):
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
srcContext = fullContext[0]
|
||||
if srcContext in ("fittingModule", "droneItem", "implantItem",
|
||||
"boosterItem", "projectedModule", "projectedDrone",
|
||||
"cargoItem"):
|
||||
item = selection[0].item
|
||||
elif srcContext in ("fittingCharge", "projectedCharge"):
|
||||
if srcContext in ("fittingCharge", "projectedCharge"):
|
||||
item = selection[0].charge
|
||||
elif hasattr(selection[0], "item"):
|
||||
item = selection[0].item
|
||||
else:
|
||||
item = selection[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user