Files
pyfa/gui/fitCommands/fighter/abilityToggleState.py
2019-04-14 21:42:58 +03:00

32 lines
1.2 KiB
Python

import wx
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calcCommands.fighter.abilityToggleState import CalcToggleFighterAbilityStateCommand
from gui.fitCommands.helpers import InternalCommandHistory
from service.fit import Fit
class GuiToggleFighterAbilityCommand(wx.Command):
def __init__(self, fitID, position, effectID):
wx.Command.__init__(self, True, 'Toggle Fighter Ability State')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.position = position
self.effectID = effectID
def Do(self):
cmd = CalcToggleFighterAbilityStateCommand(fitID=self.fitID, projected=False, position=self.position, effectID=self.effectID)
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):
success = self.internalHistory.undoAll()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
return success