Move booster and implant meta swap out of meta swap command
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from .gui.booster.add import GuiAddBoosterCommand
|
||||
from .gui.booster.metaSwap import GuiSwapBoosterMetaCommand
|
||||
from .gui.booster.remove import GuiRemoveBoosterCommand
|
||||
from .gui.booster.sideEffectToggleState import GuiToggleBoosterSideEffectStateCommand
|
||||
from .gui.booster.toggleState import GuiToggleBoosterStateCommand
|
||||
@@ -15,6 +16,7 @@ from .gui.guiModuleToCargo import GuiModuleToCargoCommand
|
||||
from .gui.guiSwapCloneModule import GuiModuleSwapOrCloneCommand
|
||||
from .gui.implant.add import GuiAddImplantCommand
|
||||
from .gui.implant.changeLocation import GuiChangeImplantLocationCommand
|
||||
from .gui.implant.metaSwap import GuiSwapImplantMetaCommand
|
||||
from .gui.implant.remove import GuiRemoveImplantCommand
|
||||
from .gui.implant.toggleState import GuiToggleImplantStateCommand
|
||||
from .gui.itemsRebase import GuiRebaseItemsCommand
|
||||
|
||||
40
gui/fitCommands/gui/booster/metaSwap.py
Normal file
40
gui/fitCommands/gui/booster/metaSwap.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.booster.add import CalcAddBoosterCommand
|
||||
from gui.fitCommands.helpers import BoosterInfo, InternalCommandHistory
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class GuiSwapBoosterMetaCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, itemID):
|
||||
wx.Command.__init__(self, True, 'Swap Booster Meta')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.itemID = itemID
|
||||
|
||||
def Do(self):
|
||||
sFit = Fit.getInstance()
|
||||
booster = sFit.getFit(self.fitID).boosters[self.position]
|
||||
if booster.itemID == self.itemID:
|
||||
return False
|
||||
cmd = CalcAddBoosterCommand(
|
||||
fitID=self.fitID,
|
||||
boosterInfo=BoosterInfo(
|
||||
itemID=self.itemID,
|
||||
state=booster.active,
|
||||
sideEffects={se.effectID: se.active for se in booster.sideEffects}))
|
||||
if self.internalHistory.submit(cmd):
|
||||
sFit.recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
35
gui/fitCommands/gui/implant/metaSwap.py
Normal file
35
gui/fitCommands/gui/implant/metaSwap.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import wx
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.implant.add import CalcAddImplantCommand
|
||||
from gui.fitCommands.helpers import ImplantInfo, InternalCommandHistory
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class GuiSwapImplantMetaCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, itemID):
|
||||
wx.Command.__init__(self, True, 'Swap Implant Meta')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.itemID = itemID
|
||||
|
||||
def Do(self):
|
||||
sFit = Fit.getInstance()
|
||||
implant = sFit.getFit(self.fitID).implants[self.position]
|
||||
if implant.itemID == self.itemID:
|
||||
return False
|
||||
cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=self.itemID, state=implant.active))
|
||||
if self.internalHistory.submit(cmd):
|
||||
sFit.recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
Fit.getInstance().recalc(self.fitID)
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
|
||||
return success
|
||||
Reference in New Issue
Block a user