Added new supported items in itemRemove item class.
Added the ability to remove charges and projected items using the itemRemove built in context menu. In this commit I fixed a minor bug in the projected view that caused the right clicked item not to be SHOWN as selected until after the context menu had been spawned and closed. I also removed all parent references from the ContextMenu class and sub classes. I am instead using the fit service to do all the work of removing the items in the itemRemove class.
This commit is contained in:
@@ -134,5 +134,5 @@ class BoosterView(d.Display):
|
||||
|
||||
srcContext = "boosterItem"
|
||||
itemContext = "Booster"
|
||||
menu = ContextMenu.getMenu(self, (item,), (srcContext, itemContext))
|
||||
menu = ContextMenu.getMenu( (item,), (srcContext, itemContext))
|
||||
self.PopupMenu(menu)
|
||||
|
||||
@@ -5,9 +5,8 @@ import wx
|
||||
import gui.globalEvents as GE
|
||||
|
||||
class AmmoPattern(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
|
||||
@@ -6,9 +6,8 @@ import wx
|
||||
from gui import bitmapLoader
|
||||
|
||||
class DamagePattern(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
return srcContext in ("resistancesViewFull",) and self.mainFrame.getActiveFit() is not None
|
||||
|
||||
@@ -6,9 +6,8 @@ import service
|
||||
import wx
|
||||
|
||||
class DroneSplit(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
return srcContext in ("droneItem", "projectedDrone") and selection[0].amount > 1
|
||||
@@ -27,8 +26,8 @@ DroneSplit.register()
|
||||
|
||||
class DroneSpinner(wx.Dialog):
|
||||
|
||||
def __init__(self, parent, drone, context):
|
||||
wx.Dialog.__init__(self, parent, title="Select Amount", size=wx.Size(220, 60))
|
||||
def __init__(self, drone, context):
|
||||
wx.Dialog.__init__(self, title="Select Amount", size=wx.Size(220, 60))
|
||||
self.drone = drone
|
||||
self.context = context
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@ import wx
|
||||
from gui import bitmapLoader
|
||||
|
||||
class FactorReload(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
return srcContext in ("firepowerViewFull",) and self.mainFrame.getActiveFit() is not None
|
||||
|
||||
@@ -1,31 +1,44 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import service
|
||||
import wx
|
||||
import gui.globalEvents as GE
|
||||
|
||||
class ItemRemove(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
return srcContext in ("fittingModule", "droneItem", "implantItem", "boosterItem")
|
||||
return srcContext in ("fittingModule", "fittingCharge", "droneItem", "implantItem", "boosterItem", "projectedModule", "projectedCharge",
|
||||
"projectedFit", "projectedDrone")
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Remove {0}".format(itmContext if itmContext is not None else "Item")
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
srcContext = fullContext[0]
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
cFit = sFit.getFit(fitID)
|
||||
|
||||
if srcContext == "fittingModule":
|
||||
for module in selection:
|
||||
if module is not None: self.parent.removeModule(module)
|
||||
if module is not None:
|
||||
sFit.removeModule(fitID,cFit.modules.index(module))
|
||||
elif srcContext in ("fittingCharge" , "projectedCharge"):
|
||||
sFit.setAmmo(fitID, None, selection)
|
||||
elif srcContext == "droneItem":
|
||||
for drone in selection:
|
||||
if drone is not None: self.parent.removeDrone(drone)
|
||||
sFit.removeDrone(fitID, cFit.drones.index(selection[0]))
|
||||
elif srcContext == "implantItem":
|
||||
for implant in selection:
|
||||
if implant is not None: self.parent.removeImplant(implant)
|
||||
sFit.removeImplant(fitID, cFit.implants.index(selection[0]))
|
||||
elif srcContext == "boosterItem":
|
||||
for booster in selection:
|
||||
if booster is not None: self.parent.removeBooster(booster)
|
||||
sFit.removeBooster(fitID, cFit.boosters.index(selection[0]))
|
||||
else:
|
||||
sFit.removeProjected(fitID, selection[0])
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
|
||||
|
||||
ItemRemove.register()
|
||||
|
||||
@@ -5,9 +5,8 @@ import service
|
||||
import wx
|
||||
|
||||
class ItemStats(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
return srcContext in ("marketItemGroup", "marketItemMisc", "fittingModule", "fittingCharge", "fittingShip", "baseShip",
|
||||
|
||||
@@ -4,9 +4,8 @@ import gui.mainFrame
|
||||
import service
|
||||
|
||||
class MarketJump(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
validContexts = ("marketItemMisc", "fittingModule", "fittingCharge", "droneItem", "implantItem",
|
||||
|
||||
@@ -7,9 +7,8 @@ from eos.types import Hardpoint
|
||||
import gui.globalEvents as GE
|
||||
|
||||
class ModuleAmmoPicker(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in ("fittingModule", "projectedModule"):
|
||||
|
||||
@@ -5,9 +5,8 @@ import gui.globalEvents as GE
|
||||
import wx
|
||||
|
||||
class Project(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
|
||||
|
||||
@@ -5,12 +5,11 @@ import service
|
||||
import wx
|
||||
|
||||
class WhProjector(ContextMenu):
|
||||
def __init__(self, parent):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
return srcContext in ("projectedDrone", "projectedModule", "projectedCharge", "projectedFit", "projectedNone")
|
||||
return srcContext == "projected"
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Add System Effects"
|
||||
|
||||
@@ -417,7 +417,7 @@ class FittingView(d.Display):
|
||||
|
||||
contexts.append(("fittingShip", "Ship"))
|
||||
|
||||
menu = ContextMenu.getMenu(self, selection, *contexts)
|
||||
menu = ContextMenu.getMenu( selection, *contexts)
|
||||
self.PopupMenu(menu)
|
||||
|
||||
def click(self, event):
|
||||
|
||||
@@ -304,8 +304,8 @@ class SkillTreeView (wx.Panel):
|
||||
srcContext = "skillItem"
|
||||
itemContext = "Skill"
|
||||
context = (srcContext, itemContext)
|
||||
self.statsMenu = ContextMenu.getMenu(self, None, context)
|
||||
self.levelChangeMenu = ContextMenu.getMenu(self, None, context) or wx.Menu()
|
||||
self.statsMenu = ContextMenu.getMenu( None, context)
|
||||
self.levelChangeMenu = ContextMenu.getMenu( None, context) or wx.Menu()
|
||||
self.levelChangeMenu.AppendSeparator()
|
||||
self.levelIds = {}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class ContextMenu(object):
|
||||
ContextMenu.menus.append(cls)
|
||||
|
||||
@classmethod
|
||||
def getMenu(cls, parent, selection, *fullContexts):
|
||||
def getMenu(cls, selection, *fullContexts):
|
||||
menu = wx.Menu()
|
||||
menu.info = {}
|
||||
menu.selection = selection
|
||||
@@ -40,7 +40,7 @@ class ContextMenu(object):
|
||||
except IndexError:
|
||||
itmContext = None
|
||||
for menuHandler in cls.menus:
|
||||
m = menuHandler(parent)
|
||||
m = menuHandler()
|
||||
if m.display(srcContext, selection):
|
||||
amount += 1
|
||||
texts = m.getText(itmContext, selection)
|
||||
|
||||
@@ -228,5 +228,5 @@ class DroneView(d.Display):
|
||||
sMkt = service.Market.getInstance()
|
||||
sourceContext = "droneItem"
|
||||
itemContext = sMkt.getCategoryByItem(drone.item).name
|
||||
menu = ContextMenu.getMenu(self, (drone,), (sourceContext, itemContext))
|
||||
menu = ContextMenu.getMenu( (drone,), (sourceContext, itemContext))
|
||||
self.PopupMenu(menu)
|
||||
|
||||
@@ -132,5 +132,5 @@ class ImplantView(d.Display):
|
||||
sourceContext = "implantItem"
|
||||
itemContext = sMkt.getCategoryByItem(implant.item).name
|
||||
|
||||
menu = ContextMenu.getMenu(self, (implant,), (sourceContext, itemContext))
|
||||
menu = ContextMenu.getMenu( (implant,), (sourceContext, itemContext))
|
||||
self.PopupMenu(menu)
|
||||
|
||||
@@ -397,7 +397,7 @@ class ItemView(d.Display):
|
||||
sourceContext = "marketItemGroup" if self.marketBrowser.searchMode is False else "marketItemMisc"
|
||||
itemContext = sMkt.getCategoryByItem(item).name
|
||||
|
||||
menu = ContextMenu.getMenu(self, (item,), (sourceContext, itemContext))
|
||||
menu = ContextMenu.getMenu( (item,), (sourceContext, itemContext))
|
||||
self.PopupMenu(menu)
|
||||
|
||||
def populate(self, items):
|
||||
|
||||
@@ -59,6 +59,11 @@ class ProjectedView(d.Display):
|
||||
self.Bind(wx.EVT_KEY_UP, self.kbEvent)
|
||||
|
||||
self.droneView = gui.droneView.DroneView
|
||||
|
||||
if "__WXGTK__" in wx.PlatformInfo:
|
||||
self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu)
|
||||
else:
|
||||
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
|
||||
|
||||
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag)
|
||||
self.SetDropTarget(ProjectedViewDrop(self.mergeDrones))
|
||||
@@ -182,36 +187,47 @@ class ProjectedView(d.Display):
|
||||
sFit = service.Fit.getInstance()
|
||||
sFit.toggleProjected(fitID, item, "right" if event.Button == 3 else "left")
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
elif event.Button == 3:
|
||||
sMkt = service.Market.getInstance()
|
||||
if isinstance(item, eos.types.Drone):
|
||||
srcContext = "projectedDrone"
|
||||
itemContext = sMkt.getCategoryByItem(item.item).name
|
||||
context = ((srcContext, itemContext),)
|
||||
elif isinstance(item, eos.types.Module):
|
||||
modSrcContext = "projectedModule"
|
||||
modItemContext = sMkt.getCategoryByItem(item.item).name
|
||||
modFullContext = (modSrcContext, modItemContext)
|
||||
if item.charge is not None:
|
||||
chgSrcContext = "projectedCharge"
|
||||
chgItemContext = sMkt.getCategoryByItem(item.charge).name
|
||||
chgFullContext = (chgSrcContext, chgItemContext)
|
||||
context = (modFullContext, chgFullContext)
|
||||
else:
|
||||
context = (modFullContext,)
|
||||
|
||||
def scheduleMenu(self, event):
|
||||
event.Skip()
|
||||
if self.getColumn(event.Position) != self.getColIndex(State):
|
||||
wx.CallAfter(self.spawnMenu)
|
||||
|
||||
def spawnMenu(self):
|
||||
sel = self.GetFirstSelected()
|
||||
menu = None
|
||||
if sel != -1:
|
||||
item = self.get(sel)
|
||||
sMkt = service.Market.getInstance()
|
||||
if isinstance(item, eos.types.Drone):
|
||||
srcContext = "projectedDrone"
|
||||
itemContext = sMkt.getCategoryByItem(item.item).name
|
||||
context = ((srcContext, itemContext),)
|
||||
elif isinstance(item, eos.types.Module):
|
||||
modSrcContext = "projectedModule"
|
||||
modItemContext = sMkt.getCategoryByItem(item.item).name
|
||||
modFullContext = (modSrcContext, modItemContext)
|
||||
if item.charge is not None:
|
||||
chgSrcContext = "projectedCharge"
|
||||
chgItemContext = sMkt.getCategoryByItem(item.charge).name
|
||||
chgFullContext = (chgSrcContext, chgItemContext)
|
||||
context = (modFullContext, chgFullContext)
|
||||
else:
|
||||
context = (("projectedFit",),)
|
||||
menu = ContextMenu.getMenu(self, (item,), *context)
|
||||
if menu is not None:
|
||||
self.PopupMenu(menu)
|
||||
elif row == -1 and event.Button == 3:
|
||||
context = (modFullContext,)
|
||||
else:
|
||||
fitSrcContext = "projectedFit"
|
||||
fitItemContext = item.name
|
||||
context = ((fitSrcContext,fitItemContext),)
|
||||
context = context + (("projected",),)
|
||||
menu = ContextMenu.getMenu((item,), *context)
|
||||
elif sel == -1:
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
if fitID is None:
|
||||
return
|
||||
context = (("projectedNone",),)
|
||||
menu = ContextMenu.getMenu(self, [], *context)
|
||||
if menu is not None:
|
||||
self.PopupMenu(menu)
|
||||
context = (("projected",),)
|
||||
menu = ContextMenu.getMenu([], *context)
|
||||
if menu is not None:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
def remove(self, event):
|
||||
row, _ = self.HitTest(event.Position)
|
||||
|
||||
@@ -1085,7 +1085,7 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
pos = self.ScreenToClient(pos)
|
||||
contexts = []
|
||||
contexts.append(("baseShip", "Ship Basic"))
|
||||
menu = ContextMenu.getMenu(self, self.baseItem, *contexts)
|
||||
menu = ContextMenu.getMenu( self.baseItem, *contexts)
|
||||
self.PopupMenu(menu, pos)
|
||||
|
||||
def OnTimer(self, event):
|
||||
|
||||
@@ -92,7 +92,7 @@ class StatsPane(wx.Panel):
|
||||
def contextHandler(self, contentPanel):
|
||||
viewName = contentPanel.viewName
|
||||
def handler(event):
|
||||
menu = ContextMenu.getMenu(self, None, (viewName,))
|
||||
menu = ContextMenu.getMenu( None, (viewName,))
|
||||
if menu is not None:
|
||||
contentPanel.PopupMenu(menu)
|
||||
|
||||
|
||||
BIN
icons/Thumbs.db
Normal file
BIN
icons/Thumbs.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user