diff --git a/gui/fitCommands/calc/drone/localAdd.py b/gui/fitCommands/calc/drone/localAdd.py index 88c96be2c..9122fb059 100644 --- a/gui/fitCommands/calc/drone/localAdd.py +++ b/gui/fitCommands/calc/drone/localAdd.py @@ -14,11 +14,12 @@ pyfalog = Logger(__name__) class CalcAddLocalDroneCommand(wx.Command): - def __init__(self, fitID, droneInfo, forceNewStack=False, commit=True): + def __init__(self, fitID, droneInfo, forceNewStack=False, ignoreRestrictions=False, commit=True): wx.Command.__init__(self, True, 'Add Local Drone') self.fitID = fitID self.droneInfo = droneInfo self.forceNewStack = forceNewStack + self.ignoreRestrictions = ignoreRestrictions self.commit = commit self.savedDroneInfo = None self.savedPosition = None @@ -46,7 +47,7 @@ class CalcAddLocalDroneCommand(wx.Command): drone = self.droneInfo.toDrone() if drone is None: return False - if not drone.fits(fit): + if not self.ignoreRestrictions and not drone.fits(fit): pyfalog.warning('Drone does not fit') return False try: diff --git a/gui/fitCommands/calc/drone/localRemove.py b/gui/fitCommands/calc/drone/localRemove.py index bebcb0c60..e3fb2e359 100644 --- a/gui/fitCommands/calc/drone/localRemove.py +++ b/gui/fitCommands/calc/drone/localRemove.py @@ -48,8 +48,6 @@ class CalcRemoveLocalDroneCommand(wx.Command): drone = self.savedDroneInfo.toDrone() if drone is None: return False - if not drone.fits(fit): - return False try: fit.drones.insert(self.position, drone) except HandledListActionError: diff --git a/gui/fitCommands/calc/fighter/localAdd.py b/gui/fitCommands/calc/fighter/localAdd.py index 6fab4c39b..f336282f2 100644 --- a/gui/fitCommands/calc/fighter/localAdd.py +++ b/gui/fitCommands/calc/fighter/localAdd.py @@ -11,11 +11,12 @@ pyfalog = Logger(__name__) class CalcAddLocalFighterCommand(wx.Command): - def __init__(self, fitID, fighterInfo, position=None, commit=True): + def __init__(self, fitID, fighterInfo, position=None, ignoreRestrictions=False, commit=True): wx.Command.__init__(self, True, 'Add Fighter') self.fitID = fitID self.fighterInfo = fighterInfo self.position = position + self.ignoreRestrictions = ignoreRestrictions self.commit = commit def Do(self): @@ -25,7 +26,7 @@ class CalcAddLocalFighterCommand(wx.Command): return False fit = Fit.getInstance().getFit(self.fitID) - if not fighter.fits(fit): + if not self.ignoreRestrictions and not fighter.fits(fit): pyfalog.warning('Fighter does not fit') return False diff --git a/gui/fitCommands/calc/fighter/localRemove.py b/gui/fitCommands/calc/fighter/localRemove.py index 4af640447..c3c1a0c5d 100644 --- a/gui/fitCommands/calc/fighter/localRemove.py +++ b/gui/fitCommands/calc/fighter/localRemove.py @@ -35,5 +35,6 @@ class CalcRemoveLocalFighterCommand(wx.Command): fitID=self.fitID, fighterInfo=self.savedFighterInfo, position=self.position, + ignoreRestrictions=True, commit=self.commit) return cmd.Do() diff --git a/gui/fitCommands/calc/module/changeCharges.py b/gui/fitCommands/calc/module/changeCharges.py index 66ed04fec..7bf720798 100644 --- a/gui/fitCommands/calc/module/changeCharges.py +++ b/gui/fitCommands/calc/module/changeCharges.py @@ -12,11 +12,12 @@ pyfalog = Logger(__name__) class CalcChangeModuleChargesCommand(wx.Command): - def __init__(self, fitID, projected, chargeMap, commit=True): + def __init__(self, fitID, projected, chargeMap, ignoreRestriction=False, commit=True): wx.Command.__init__(self, True, 'Change Module Charges') self.fitID = fitID self.projected = projected self.chargeMap = chargeMap + self.ignoreRestriction = ignoreRestriction self.commit = commit self.savedChargeMap = None self.savedStateCheckChanges = None @@ -40,7 +41,7 @@ class CalcChangeModuleChargesCommand(wx.Command): chargeItem = sMkt.getItem(chargeItemID) if chargeItemID is not None else None if chargeItem is not None and not chargeItem.isCharge: continue - if not mod.isValidCharge(chargeItem): + if not self.ignoreRestriction and not mod.isValidCharge(chargeItem): pyfalog.warning('Invalid charge {} for {}'.format(chargeItem, mod)) continue pyfalog.debug('Setting charge {} for {} on fit {}'.format(chargeItem, mod, self.fitID)) @@ -61,6 +62,7 @@ class CalcChangeModuleChargesCommand(wx.Command): fitID=self.fitID, projected=self.projected, chargeMap=self.savedChargeMap, + ignoreRestriction=True, commit=self.commit) if not cmd.Do(): return False diff --git a/gui/fitCommands/calc/module/localRemove.py b/gui/fitCommands/calc/module/localRemove.py index 211f6f0e7..f477529cf 100644 --- a/gui/fitCommands/calc/module/localRemove.py +++ b/gui/fitCommands/calc/module/localRemove.py @@ -60,12 +60,20 @@ class CalcRemoveLocalModulesCommand(wx.Command): if len(self.savedSubInfos) > 0: for position, modInfo in self.savedSubInfos.items(): cmd = CalcReplaceLocalModuleCommand( - fitID=self.fitID, position=position, newModInfo=modInfo, commit=False) + fitID=self.fitID, + position=position, + newModInfo=modInfo, + ignoreRestrictions=True, + commit=False) results.append(cmd.Do()) sFit.recalc(fit) for position, modInfo in self.savedModInfos.items(): cmd = CalcReplaceLocalModuleCommand( - fitID=self.fitID, position=position, newModInfo=modInfo, commit=False) + fitID=self.fitID, + position=position, + newModInfo=modInfo, + ignoreRestrictions=True, + commit=False) results.append(cmd.Do()) if not any(results): return False diff --git a/gui/fitCommands/calc/module/localReplace.py b/gui/fitCommands/calc/module/localReplace.py index bac71c0c2..dbdc30b6f 100644 --- a/gui/fitCommands/calc/module/localReplace.py +++ b/gui/fitCommands/calc/module/localReplace.py @@ -12,13 +12,14 @@ pyfalog = Logger(__name__) class CalcReplaceLocalModuleCommand(wx.Command): - def __init__(self, fitID, position, newModInfo, unloadInvalidCharges=False, commit=True): + def __init__(self, fitID, position, newModInfo, unloadInvalidCharges=False, ignoreRestrictions=False, commit=True): wx.Command.__init__(self, True, 'Replace Module') self.fitID = fitID self.position = position self.newModInfo = newModInfo self.oldModInfo = None self.unloadInvalidCharges = unloadInvalidCharges + self.ignoreRestrictions = ignoreRestrictions self.commit = commit self.savedStateCheckChanges = None self.unloadedCharge = None @@ -40,11 +41,11 @@ class CalcReplaceLocalModuleCommand(wx.Command): return False # Dummy it out in case the next bit fails fit.modules.free(self.position) - if not newMod.fits(fit): + if not self.ignoreRestrictions and not newMod.fits(fit): pyfalog.warning('Module does not fit') self.Undo() return False - if not newMod.isValidCharge(newMod.charge): + if not not self.ignoreRestrictions and not newMod.isValidCharge(newMod.charge): if self.unloadInvalidCharges: newMod.charge = None self.unloadedCharge = True @@ -86,10 +87,6 @@ class CalcReplaceLocalModuleCommand(wx.Command): if oldMod is None: return False fit.modules.free(self.position) - if not oldMod.fits(fit): - pyfalog.warning('Module does not fit') - self.Do() - return False try: fit.modules.replace(self.position, oldMod) except HandledListActionError: diff --git a/gui/fitCommands/calc/module/projectedAdd.py b/gui/fitCommands/calc/module/projectedAdd.py index 8bca163c2..15c5aaac6 100644 --- a/gui/fitCommands/calc/module/projectedAdd.py +++ b/gui/fitCommands/calc/module/projectedAdd.py @@ -13,11 +13,12 @@ pyfalog = Logger(__name__) class CalcAddProjectedModuleCommand(wx.Command): - def __init__(self, fitID, modInfo, position=None, commit=True): + def __init__(self, fitID, modInfo, position=None, ignoreRestrictions=False, commit=True): wx.Command.__init__(self, True) self.fitID = fitID self.newModInfo = modInfo self.newPosition = position + self.ignoreRestrictions = ignoreRestrictions self.commit = commit self.oldModInfo = None self.oldPosition = None @@ -33,7 +34,7 @@ class CalcAddProjectedModuleCommand(wx.Command): fit = sFit.getFit(self.fitID) if not newMod.canHaveState(newMod.state, projectedOnto=fit): newMod.state = FittingModuleState.OFFLINE - if not newMod.isValidCharge(newMod.charge): + if not self.ignoreRestrictions and not newMod.isValidCharge(newMod.charge): newMod.charge = None self.oldPosition, self.oldModInfo = fit.projectedModules.makeRoom(newMod) @@ -69,6 +70,7 @@ class CalcAddProjectedModuleCommand(wx.Command): fitID=self.fitID, modInfo=self.oldModInfo, position=self.oldPosition, + ignoreRestrictions=True, commit=False) if not cmd.Do(): return False diff --git a/gui/fitCommands/calc/module/projectedRemove.py b/gui/fitCommands/calc/module/projectedRemove.py index 16786003f..8740d5101 100644 --- a/gui/fitCommands/calc/module/projectedRemove.py +++ b/gui/fitCommands/calc/module/projectedRemove.py @@ -43,6 +43,7 @@ class CalcRemoveProjectedModuleCommand(wx.Command): fitID=self.fitID, modInfo=self.savedModInfo, position=self.position, + ignoreRestrictions=True, commit=False) if not cmd.Do(): return False diff --git a/gui/fitCommands/gui/localDrone/changeMetas.py b/gui/fitCommands/gui/localDrone/changeMetas.py index 0127b7e87..4fc06ca99 100644 --- a/gui/fitCommands/gui/localDrone/changeMetas.py +++ b/gui/fitCommands/gui/localDrone/changeMetas.py @@ -39,6 +39,7 @@ class GuiChangeLocalDroneMetasCommand(wx.Command): fitID=self.fitID, droneInfo=info, forceNewStack=True, + ignoreRestrictions=True, commit=False) results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd)) success = any(results) diff --git a/gui/fitCommands/gui/localDrone/stackSplit.py b/gui/fitCommands/gui/localDrone/stackSplit.py index 5062ad020..dd1a42893 100644 --- a/gui/fitCommands/gui/localDrone/stackSplit.py +++ b/gui/fitCommands/gui/localDrone/stackSplit.py @@ -37,6 +37,7 @@ class GuiSplitLocalDroneStackCommand(wx.Command): fitID=self.fitID, droneInfo=info, forceNewStack=True, + ignoreRestrictions=True, commit=False)) success = self.internalHistory.submitBatch(*commands) eos.db.commit() diff --git a/gui/fitCommands/gui/localFighter/changeMetas.py b/gui/fitCommands/gui/localFighter/changeMetas.py index ef4016ddf..b91030edc 100644 --- a/gui/fitCommands/gui/localFighter/changeMetas.py +++ b/gui/fitCommands/gui/localFighter/changeMetas.py @@ -35,6 +35,7 @@ class GuiChangeLocalFighterMetasCommand(wx.Command): cmdAdd = CalcAddLocalFighterCommand( fitID=self.fitID, fighterInfo=info, + ignoreRestrictions=True, commit=False) results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd)) success = any(results) diff --git a/gui/fitCommands/gui/localModule/replace.py b/gui/fitCommands/gui/localModule/replace.py index 9484228d2..d006d89cb 100644 --- a/gui/fitCommands/gui/localModule/replace.py +++ b/gui/fitCommands/gui/localModule/replace.py @@ -21,7 +21,11 @@ class GuiReplaceLocalModuleCommand(wx.Command): def Do(self): results = [] for position in self.positions: - cmd = CalcReplaceLocalModuleCommand(fitID=self.fitID, position=position, newModInfo=ModuleInfo(itemID=self.itemID), commit=False) + cmd = CalcReplaceLocalModuleCommand( + fitID=self.fitID, + position=position, + newModInfo=ModuleInfo(itemID=self.itemID), + commit=False) results.append(self.internalHistory.submit(cmd)) success = any(results) eos.db.commit()