Remove drone splitting / merging, and introduce drone change qty
This commit is contained in:
@@ -27,4 +27,5 @@ from .guiAddDrone import GuiAddDroneCommand
|
||||
from .guiRemoveDrone import GuiRemoveDroneCommand
|
||||
from .guiChangeFighterQty import GuiChangeFighterQty
|
||||
from .guiChangeCargoQty import GuiChangeCargoQty
|
||||
from .guiChangeProjectedFitQty import GuiChangeProjectedFitQty
|
||||
from .guiChangeProjectedFitQty import GuiChangeProjectedFitQty
|
||||
from .guiChangeDroneQty import GuiChangeDroneQty
|
||||
@@ -37,6 +37,8 @@ class FitAddProjectedDroneCommand(wx.Command):
|
||||
|
||||
if drone is None:
|
||||
drone = Drone(item)
|
||||
if not drone.item.isType("projected"):
|
||||
return False
|
||||
fit.projectedDrones.append(drone)
|
||||
|
||||
self.index = fit.projectedDrones.index(drone)
|
||||
|
||||
@@ -30,6 +30,8 @@ class FitAddProjectedModuleCommand(wx.Command):
|
||||
|
||||
try:
|
||||
module = Module(item)
|
||||
if not module.item.isType("projected"):
|
||||
return False
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
32
gui/fitCommands/calc/fitChangeDroneQty.py
Normal file
32
gui/fitCommands/calc/fitChangeDroneQty.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
#from .helpers import ModuleInfoCache
|
||||
from eos.saveddata.module import Module, State
|
||||
import eos.db
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
class FitChangeDroneQty(wx.Command):
|
||||
def __init__(self, fitID, position, amount=1):
|
||||
wx.Command.__init__(self, True, "Drone add")
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.amount = amount # add x amount. If this goes over amount, removes stack
|
||||
self.old_amount = None
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("Changing active fighters ({0}) for fit ({1}) to amount: {2}", self.position, self.fitID, self.amount)
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
drone = fit.drones[self.position]
|
||||
self.old_amount = drone.amount
|
||||
drone.amount = self.amount
|
||||
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
cmd = FitChangeDroneQty(self.fitID, self.position, self.old_amount)
|
||||
return cmd.Do()
|
||||
38
gui/fitCommands/guiChangeDroneQty.py
Normal file
38
gui/fitCommands/guiChangeDroneQty.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import wx
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from service.fit import Fit
|
||||
from gui import globalEvents as GE
|
||||
from .calc.fitAddModule import FitAddModuleCommand
|
||||
from .calc.fitReplaceModule import FitReplaceModuleCommand
|
||||
from .calc.fitChangeDroneQty import FitChangeDroneQty
|
||||
from service.fit import Fit
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class GuiChangeDroneQty(wx.Command):
|
||||
def __init__(self, fitID, position, amount=1):
|
||||
wx.Command.__init__(self, True, "")
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.sFit = Fit.getInstance()
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.amount = amount
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
|
||||
def Do(self):
|
||||
cmd = FitChangeDroneQty(self.fitID, self.position, self.amount)
|
||||
if self.internal_history.Submit(cmd):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
Reference in New Issue
Block a user