Make sure drones to not merge on meta change

This commit is contained in:
DarkPhoenix
2019-04-15 18:57:00 +03:00
parent 3fa5ac7858
commit 8b0f5f871c
3 changed files with 5 additions and 4 deletions

View File

@@ -13,12 +13,13 @@ pyfalog = Logger(__name__)
class CalcAddLocalDroneCommand(wx.Command):
def __init__(self, fitID, droneInfo):
def __init__(self, fitID, droneInfo, forceNewStack=False):
wx.Command.__init__(self, True, 'Add Drone')
self.fitID = fitID
self.droneInfo = droneInfo
self.savedDroneInfo = None
self.savedPosition = None
self.forceNewStack = forceNewStack
def Do(self):
pyfalog.debug('Doing addition of local drone {} to fit {}'.format(self.droneInfo, self.fitID))
@@ -26,7 +27,7 @@ class CalcAddLocalDroneCommand(wx.Command):
item = Market.getInstance().getItem(self.droneInfo.itemID, eager=("attributes", "group.category"))
# If we're not adding any active drones, check if there's an inactive stack
# with enough space for new drones and use it
if self.droneInfo.amountActive == 0:
if not self.forceNewStack and self.droneInfo.amountActive == 0:
for drone in fit.drones.find(item):
if (
drone is not None and drone.amountActive == 0 and

View File

@@ -27,7 +27,7 @@ class GuiChangeDroneMetaCommand(wx.Command):
info = DroneInfo.fromDrone(drone)
info.itemID = self.newItemID
cmdRemove = CalcRemoveLocalDroneCommand(fitID=self.fitID, position=self.position, amount=math.inf)
cmdAdd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=info)
cmdAdd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=info, forceNewStack=True)
success = self.internalHistory.submitBatch(cmdRemove, cmdAdd)
sFit.recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))

View File

@@ -17,7 +17,7 @@ class GuiRemoveLocalFighterCommand(wx.Command):
def Do(self):
cmd = CalcRemoveLocalFighterCommand(fitID=self.fitID, position=self.position)
success = self.internalHistory.submit()
success = self.internalHistory.submit(cmd)
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success