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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user