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.
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from gui.contextMenu import ContextMenu
|
|
import gui.mainFrame
|
|
import service
|
|
import gui.globalEvents as GE
|
|
import wx
|
|
from gui import bitmapLoader
|
|
|
|
class FactorReload(ContextMenu):
|
|
def __init__(self):
|
|
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
|
|
|
def display(self, srcContext, selection):
|
|
return srcContext in ("firepowerViewFull",) and self.mainFrame.getActiveFit() is not None
|
|
|
|
def getText(self, itmContext, selection):
|
|
return "Factor in Reload Time"
|
|
|
|
def activate(self, fullContext, selection, i):
|
|
sFit = service.Fit.getInstance()
|
|
sFit.serviceFittingOptions["useGlobalForceReload"] = not sFit.serviceFittingOptions["useGlobalForceReload"]
|
|
fitID = self.mainFrame.getActiveFit()
|
|
sFit.refreshFit(fitID)
|
|
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
|
|
|
def getBitmap(self, context, selection):
|
|
sFit = service.Fit.getInstance()
|
|
fitID = self.mainFrame.getActiveFit()
|
|
fit = sFit.getFit(fitID)
|
|
if fit.factorReload:
|
|
return bitmapLoader.getBitmap("state_active_small", "icons")
|
|
else:
|
|
return None
|
|
|
|
|
|
FactorReload.register()
|