Rework cargo-related GUI commands and use command when deleting item from cargo with delete key
This commit is contained in:
@@ -2,7 +2,9 @@ from .booster.add import GuiAddBoosterCommand
|
||||
from .booster.remove import GuiRemoveBoosterCommand
|
||||
from .booster.sideEffectToggleState import GuiToggleBoosterSideEffectStateCommand
|
||||
from .booster.toggleState import GuiToggleBoosterStateCommand
|
||||
from .guiAddCargo import GuiAddCargoCommand
|
||||
from .cargo.add import GuiAddCargoCommand
|
||||
from .cargo.changeAmount import GuiChangeCargoAmount
|
||||
from .cargo.remove import GuiRemoveCargoCommand
|
||||
from .guiAddCharge import GuiModuleAddChargeCommand
|
||||
from .guiAddCommand import GuiAddCommandCommand
|
||||
from .guiAddDrone import GuiAddDroneCommand
|
||||
@@ -10,7 +12,6 @@ from .guiAddFighter import GuiAddFighterCommand
|
||||
from .guiAddModule import GuiModuleAddCommand
|
||||
from .guiAddProjected import GuiAddProjectedCommand
|
||||
from .guiCargoToModule import GuiCargoToModuleCommand
|
||||
from .guiChangeCargoQty import GuiChangeCargoQty
|
||||
from .guiChangeDroneQty import GuiChangeDroneQty
|
||||
from .guiChangeFighterQty import GuiChangeFighterQty
|
||||
from .guiChangeProjectedDroneQty import GuiChangeProjectedDroneQty
|
||||
@@ -24,7 +25,6 @@ from .guiModuleToCargo import GuiModuleToCargoCommand
|
||||
from .guiMutaConvert import GuiMutaConvertCommand
|
||||
from .guiMutaRevert import GuiMutaRevertCommand
|
||||
from .guiRebaseItems import GuiRebaseItemsCommand
|
||||
from .guiRemoveCargo import GuiRemoveCargoCommand
|
||||
from .guiRemoveCommand import GuiRemoveCommandCommand
|
||||
from .guiRemoveDrone import GuiRemoveDroneCommand
|
||||
from .guiRemoveFighter import GuiRemoveFighterCommand
|
||||
|
||||
0
gui/fitCommands/cargo/__init__.py
Normal file
0
gui/fitCommands/cargo/__init__.py
Normal file
@@ -1,29 +1,27 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.helpers import CargoInfo
|
||||
from .calcCommands.cargo.add import CalcAddCargoCommand
|
||||
from gui.fitCommands.calcCommands.cargo.add import CalcAddCargoCommand
|
||||
from gui.fitCommands.helpers import CargoInfo, InternalCommandHistory
|
||||
|
||||
|
||||
class GuiAddCargoCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, itemID, amount=1):
|
||||
wx.Command.__init__(self, True, "Cargo Add")
|
||||
self.internalHistory = wx.CommandProcessor()
|
||||
def __init__(self, fitID, itemID, amount):
|
||||
wx.Command.__init__(self, True, 'Add Cargo')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.amount = amount
|
||||
|
||||
def Do(self):
|
||||
if self.internalHistory.Submit(CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))):
|
||||
if self.internalHistory.submit(CalcAddCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))):
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internalHistory.Commands:
|
||||
self.internalHistory.Undo()
|
||||
success = self.internalHistory.undoAll()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return success
|
||||
35
gui/fitCommands/cargo/changeAmount.py
Normal file
35
gui/fitCommands/cargo/changeAmount.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import math
|
||||
|
||||
import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calcCommands.cargo.changeAmount import CalcChangeCargoAmountCommand
|
||||
from gui.fitCommands.calcCommands.cargo.remove import CalcRemoveCargoCommand
|
||||
from gui.fitCommands.helpers import CargoInfo, InternalCommandHistory
|
||||
|
||||
|
||||
class GuiChangeCargoAmount(wx.Command):
|
||||
|
||||
def __init__(self, fitID, itemID, amount):
|
||||
wx.Command.__init__(self, True, 'Change Cargo Amount')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.amount = amount
|
||||
|
||||
def Do(self):
|
||||
if self.amount > 0:
|
||||
if self.internalHistory.submit(CalcChangeCargoAmountCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=self.amount))):
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
else:
|
||||
if self.internalHistory.submit(CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))):
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
@@ -1,29 +1,28 @@
|
||||
import math
|
||||
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.helpers import CargoInfo
|
||||
from .calcCommands.cargo.remove import CalcRemoveCargoCommand
|
||||
from gui.fitCommands.calcCommands.cargo.remove import CalcRemoveCargoCommand
|
||||
from gui.fitCommands.helpers import CargoInfo, InternalCommandHistory
|
||||
|
||||
|
||||
class GuiRemoveCargoCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, itemID):
|
||||
wx.Command.__init__(self, True, "Cargo Remove")
|
||||
self.internalHistory = wx.CommandProcessor()
|
||||
wx.Command.__init__(self, True, 'Remove Cargo')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
|
||||
def Do(self):
|
||||
if self.internalHistory.Submit(CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))):
|
||||
if self.internalHistory.submit(CalcRemoveCargoCommand(fitID=self.fitID, cargoInfo=CargoInfo(itemID=self.itemID, amount=math.inf))):
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internalHistory.GetCommands():
|
||||
self.internalHistory.Undo()
|
||||
success = self.internalHistory.undoAll()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return success
|
||||
@@ -1,33 +0,0 @@
|
||||
import wx
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calcCommands.cargo.changeAmount import CalcChangeCargoAmountCommand
|
||||
from service.fit import Fit
|
||||
from gui.fitCommands.helpers import CargoInfo
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class GuiChangeCargoQty(wx.Command):
|
||||
|
||||
def __init__(self, fitID, itemID, amount):
|
||||
wx.Command.__init__(self, True, "")
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.amount = amount
|
||||
self.internalHistory = wx.CommandProcessor()
|
||||
|
||||
def Do(self):
|
||||
cmd = CalcChangeCargoAmountCommand(self.fitID, CargoInfo(itemID=self.itemID, amount=self.amount))
|
||||
if self.internalHistory.Submit(cmd):
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internalHistory.Commands:
|
||||
self.internalHistory.Undo()
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
Reference in New Issue
Block a user