Add projection range commands to projected fighters
This commit is contained in:
@@ -68,7 +68,8 @@ class ChangeItemProjectionRange(ContextMenuSingle):
|
||||
elif isinstance(mainItem, Fighter):
|
||||
if mainItem in fit.projectedFighters:
|
||||
position = fit.projectedFighters.index(mainItem)
|
||||
pass
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterProjectionRangeCommand(
|
||||
fitID=fitID, position=position, projectionRange=newRange))
|
||||
|
||||
|
||||
ChangeItemProjectionRange.register()
|
||||
|
||||
@@ -65,6 +65,7 @@ from .gui.projectedFighter.abilityToggleState import GuiToggleProjectedFighterAb
|
||||
from .gui.projectedFighter.add import GuiAddProjectedFighterCommand
|
||||
from .gui.projectedFighter.changeAmount import GuiChangeProjectedFighterAmountCommand
|
||||
from .gui.projectedFighter.changeMetas import GuiChangeProjectedFighterMetasCommand
|
||||
from .gui.projectedFighter.changeProjectionRange import GuiChangeProjectedFighterProjectionRangeCommand
|
||||
from .gui.projectedFit.add import GuiAddProjectedFitsCommand
|
||||
from .gui.projectedFit.changeAmount import GuiChangeProjectedFitAmountCommand
|
||||
from .gui.projectedFit.changeProjectionRange import GuiChangeProjectedFitProjectionRangeCommand
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import wx
|
||||
from logbook import Logger
|
||||
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class CalcChangeProjectedFighterProjectionRangeCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, projectionRange):
|
||||
wx.Command.__init__(self, True, 'Change Projected Fighter Projection Range')
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.projectionRange = projectionRange
|
||||
self.savedProjectionRange = None
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug('Doing changing of projected fighter projection range to {} at position {} for fit {}'.format(
|
||||
self.projectionRange, self.position, self.fitID))
|
||||
fit = Fit.getInstance().getFit(self.fitID)
|
||||
fighter = fit.projectedFighters[self.position]
|
||||
if fighter.projectionRange == self.projectionRange:
|
||||
return False
|
||||
self.savedProjectionRange = fighter.projectionRange
|
||||
fighter.projectionRange = self.projectionRange
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
pyfalog.debug('Undoing changing of projected fighter projection range to {} at position {} for fit {}'.format(
|
||||
self.projectionRange, self.position, self.fitID))
|
||||
cmd = CalcChangeProjectedFighterProjectionRangeCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.position,
|
||||
projectionRange=self.savedProjectionRange)
|
||||
return cmd.Do()
|
||||
@@ -0,0 +1,42 @@
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from gui.fitCommands.calc.fighter.projectedChangeProjectionRange import CalcChangeProjectedFighterProjectionRangeCommand
|
||||
from gui.fitCommands.helpers import InternalCommandHistory
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class GuiChangeProjectedFighterProjectionRangeCommand(wx.Command):
|
||||
|
||||
def __init__(self, fitID, position, projectionRange):
|
||||
wx.Command.__init__(self, True, 'Change Projected Fighter Projection Range')
|
||||
self.internalHistory = InternalCommandHistory()
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
self.projectionRange = projectionRange
|
||||
|
||||
def Do(self):
|
||||
cmd = CalcChangeProjectedFighterProjectionRangeCommand(
|
||||
fitID=self.fitID,
|
||||
position=self.position,
|
||||
projectionRange=self.projectionRange)
|
||||
success = self.internalHistory.submit(cmd)
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitIDs=(self.fitID,)))
|
||||
return success
|
||||
|
||||
def Undo(self):
|
||||
success = self.internalHistory.undoAll()
|
||||
eos.db.flush()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.recalc(self.fitID)
|
||||
sFit.fill(self.fitID)
|
||||
eos.db.commit()
|
||||
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitIDs=(self.fitID,)))
|
||||
return success
|
||||
Reference in New Issue
Block a user