Merge pull request #1885 from pyfa-org/issue1870
Implement fixes for #1870 - undo the Module.toDummy that happens when…
This commit is contained in:
@@ -8,6 +8,7 @@ import gui.mainFrame
|
||||
from gui.contextMenu import ContextMenu
|
||||
from service.market import Market
|
||||
from service.settings import ContextMenuSettings
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class MetaSwap(ContextMenu):
|
||||
@@ -53,6 +54,8 @@ class MetaSwap(ContextMenu):
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
self.moduleLookup = {}
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.mainFrame.getActiveFit())
|
||||
|
||||
def get_metalevel(x):
|
||||
if "metaLevel" not in x.attributes:
|
||||
@@ -114,6 +117,7 @@ class MetaSwap(ContextMenu):
|
||||
|
||||
id = ContextMenu.nextID()
|
||||
mitem = wx.MenuItem(rootMenu, id, item.name)
|
||||
mitem.Enable(fit.canFit(item))
|
||||
bindmenu.Bind(wx.EVT_MENU, self.handleModule, mitem)
|
||||
|
||||
self.moduleLookup[id] = item, context
|
||||
|
||||
@@ -73,19 +73,21 @@ class FitReplaceModuleCommand(wx.Command):
|
||||
# Dummy it out in case the next bit fails
|
||||
fit.modules.toDummy(self.position)
|
||||
|
||||
if self.module.fits(fit):
|
||||
self.module.owner = fit
|
||||
fit.modules.toModule(self.position, self.module)
|
||||
if self.module.isValidState(FittingModuleState.ACTIVE):
|
||||
self.module.state = FittingModuleState.ACTIVE
|
||||
if not self.module.fits(fit):
|
||||
self.Undo()
|
||||
return False
|
||||
|
||||
if self.old_module and self.old_module.charge and self.module.isValidCharge(self.old_module.charge):
|
||||
self.module.charge = self.old_module.charge
|
||||
self.module.owner = fit
|
||||
fit.modules.toModule(self.position, self.module)
|
||||
if self.module.isValidState(FittingModuleState.ACTIVE):
|
||||
self.module.state = FittingModuleState.ACTIVE
|
||||
|
||||
# Then, check states of all modules and change where needed. This will recalc if needed
|
||||
# self.checkStates(fit, m)
|
||||
if self.old_module and self.old_module.charge and self.module.isValidCharge(self.old_module.charge):
|
||||
self.module.charge = self.old_module.charge
|
||||
|
||||
# fit.fill()
|
||||
eos.db.commit()
|
||||
return True
|
||||
return False
|
||||
# Then, check states of all modules and change where needed. This will recalc if needed
|
||||
# self.checkStates(fit, m)
|
||||
|
||||
# fit.fill()
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user