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.
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
from gui.contextMenu import ContextMenu
|
|
from gui.itemStats import ItemStatsDialog
|
|
import gui.mainFrame
|
|
import service
|
|
import wx
|
|
|
|
class ItemStats(ContextMenu):
|
|
def __init__(self):
|
|
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
|
|
|
def display(self, srcContext, selection):
|
|
return srcContext in ("marketItemGroup", "marketItemMisc", "fittingModule", "fittingCharge", "fittingShip", "baseShip",
|
|
"droneItem", "implantItem", "boosterItem", "skillItem", "projectedModule", "projectedDrone", "projectedCharge")
|
|
|
|
def getText(self, itmContext, selection):
|
|
return "{0} Stats".format(itmContext if itmContext is not None else "Item")
|
|
|
|
def activate(self, fullContext, selection, i):
|
|
srcContext = fullContext[0]
|
|
if srcContext == "fittingShip":
|
|
fitID = self.mainFrame.getActiveFit()
|
|
cFit = service.Fit.getInstance()
|
|
stuff = cFit.getFit(fitID).ship
|
|
else:
|
|
stuff = selection[0]
|
|
|
|
if srcContext == "fittingModule" and stuff.isEmpty:
|
|
return
|
|
|
|
mstate = wx.GetMouseState()
|
|
reuse = False
|
|
|
|
if mstate.CmdDown():
|
|
reuse = True
|
|
|
|
if self.mainFrame.GetActiveStatsWindow() == None and reuse:
|
|
ItemStatsDialog(stuff, fullContext)
|
|
|
|
elif reuse:
|
|
lastWnd = self.mainFrame.GetActiveStatsWindow()
|
|
pos = lastWnd.GetPosition()
|
|
maximized = lastWnd.IsMaximized()
|
|
if not maximized:
|
|
size = lastWnd.GetSize()
|
|
else:
|
|
size = wx.DefaultSize
|
|
pos = wx.DefaultPosition
|
|
ItemStatsDialog(stuff, fullContext, pos, size, maximized)
|
|
lastWnd.closeEvent(None)
|
|
|
|
else:
|
|
ItemStatsDialog(stuff, fullContext)
|
|
|
|
ItemStats.register()
|