Change cargo removal command to be able to accept multiple typeIDs
This commit is contained in:
@@ -109,7 +109,7 @@ class CargoView(d.Display):
|
||||
cargo = self.cargo[self.GetItemData(row)]
|
||||
except IndexError:
|
||||
return
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCargoCommand(fitID=fitID, itemID=cargo.itemID))
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCargosCommand(fitID=fitID, itemIDs=[cargo.itemID]))
|
||||
event.Skip()
|
||||
|
||||
def swapModule(self, x, y, modIdx):
|
||||
@@ -174,7 +174,7 @@ class CargoView(d.Display):
|
||||
cargo = self.cargo[self.GetItemData(row)]
|
||||
except IndexError:
|
||||
return
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCargoCommand(fitID=fitID, itemID=cargo.itemID))
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCargosCommand(fitID=fitID, itemIDs=[cargo.itemID]))
|
||||
|
||||
def spawnMenu(self, event):
|
||||
sel = self.GetFirstSelected()
|
||||
|
||||
@@ -82,8 +82,8 @@ class RemoveItem(ContextMenuCombined):
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveBoosterCommand(
|
||||
fitID=fitID, position=position))
|
||||
elif srcContext == "cargoItem":
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCargoCommand(
|
||||
fitID=fitID, itemID=mainItem.itemID))
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveCargosCommand(
|
||||
fitID=fitID, itemIDs=[mainItem.itemID]))
|
||||
elif srcContext == "projectedFit":
|
||||
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedFitCommand(
|
||||
fitID=fitID, projectedFitID=mainItem.ID, amount=math.inf))
|
||||
|
||||
@@ -6,7 +6,7 @@ from .gui.booster.toggleState import GuiToggleBoosterStateCommand
|
||||
from .gui.cargo.add import GuiAddCargoCommand
|
||||
from .gui.cargo.changeAmount import GuiChangeCargoAmountCommand
|
||||
from .gui.cargo.changeMeta import GuiChangeCargoMetaCommand
|
||||
from .gui.cargo.remove import GuiRemoveCargoCommand
|
||||
from .gui.cargo.remove import GuiRemoveCargosCommand
|
||||
from .gui.commandFit.add import GuiAddCommandFitCommand
|
||||
from .gui.commandFit.remove import GuiRemoveCommandFitCommand
|
||||
from .gui.commandFit.toggleState import GuiToggleCommandFitStateCommand
|
||||
|
||||
@@ -2,27 +2,36 @@ import math
|
||||
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.cargo.remove import CalcRemoveCargoCommand
|
||||
from gui.fitCommands.helpers import CargoInfo, InternalCommandHistory
|
||||
|
||||
|
||||
class GuiRemoveCargoCommand(wx.Command):
|
||||
class GuiRemoveCargosCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, itemID):
|
||||
wx.Command.__init__(self, True, 'Remove Cargo')
|
||||
def __init__(self, fitID, itemIDs):
|
||||
wx.Command.__init__(self, True, 'Remove Cargos')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.itemIDs = itemIDs
|
||||
|
||||
def Do(self):
|
||||
cmd = CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))
|
||||
success = self.internalHistory.submit(cmd)
|
||||
result = []
|
||||
for itemID in self.itemIDs:
|
||||
cmd = CalcRemoveCargoCommand(
|
||||
fitID=self.fitID,
|
||||
cargoInfo=CargoInfo(itemID=itemID, amount=math.inf),
|
||||
commit=False)
|
||||
result.append(self.internalHistory.submit(cmd))
|
||||
success = any(result)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
|
||||
Reference in New Issue
Block a user