Implement some various toggles as commands
This commit is contained in:
@@ -157,9 +157,7 @@ class BoosterView(d.Display):
|
||||
col = self.getColumn(event.Position)
|
||||
if col == self.getColIndex(State):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.toggleBooster(fitID, row)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
self.mainFrame.command.Submit(cmd.GuiToggleImplantCommand(fitID, row))
|
||||
|
||||
def scheduleMenu(self, event):
|
||||
event.Skip()
|
||||
|
||||
@@ -296,10 +296,8 @@ class FighterDisplay(d.Display):
|
||||
col = self.getColumn(event.Position)
|
||||
if col == self.getColIndex(State):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
sFit = Fit.getInstance()
|
||||
fighter = self.fighters[row]
|
||||
sFit.toggleFighter(fitID, self.original.index(fighter))
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
self.mainFrame.command.Submit(cmd.GuiToggleFighterCommand(fitID, self.original.index(fighter)))
|
||||
|
||||
def scheduleMenu(self, event):
|
||||
event.Skip()
|
||||
|
||||
@@ -187,9 +187,7 @@ class ImplantDisplay(d.Display):
|
||||
col = self.getColumn(event.Position)
|
||||
if col == self.getColIndex(State):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
sFit = Fit.getInstance()
|
||||
sFit.toggleImplant(fitID, row)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
self.mainFrame.command.Submit(cmd.GuiToggleImplantCommand(fitID, row))
|
||||
|
||||
def scheduleMenu(self, event):
|
||||
event.Skip()
|
||||
|
||||
@@ -19,4 +19,7 @@ from .guiCargoToModule import GuiCargoToModuleCommand
|
||||
from .guiModuleToCargo import GuiModuleToCargoCommand
|
||||
from .guiAddFighter import GuiAddFighterCommand
|
||||
from .guiRemoveFighter import GuiRemoveFighterCommand
|
||||
from .guiMetaSwap import GuiMetaSwapCommand
|
||||
from .guiMetaSwap import GuiMetaSwapCommand
|
||||
from .guiToggleFighter import GuiToggleFighterCommand
|
||||
from .guiToggleImplant import GuiToggleImplantCommand
|
||||
from .guiToggleBooster import GuiToggleImplantCommand
|
||||
32
gui/fitCommands/calc/fitToggleBooster.py
Normal file
32
gui/fitCommands/calc/fitToggleBooster.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
#from .helpers import ModuleInfoCache
|
||||
from eos.saveddata.module import Module, State
|
||||
import eos.db
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
class FitToggleBoosterCommand(wx.Command):
|
||||
""""
|
||||
from sFit.toggleBooster
|
||||
"""
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, "Cargo add")
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("Toggling booster for fit ID: {0}", self.fitID)
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
booster = fit.boosters[self.position]
|
||||
booster.active = not booster.active
|
||||
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
cmd = FitToggleBoosterCommand(self.fitID, self.position)
|
||||
return cmd.Do()
|
||||
33
gui/fitCommands/calc/fitToggleFighter.py
Normal file
33
gui/fitCommands/calc/fitToggleFighter.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
#from .helpers import ModuleInfoCache
|
||||
from eos.saveddata.module import Module, State
|
||||
import eos.db
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
from eos.saveddata.implant import Implant
|
||||
|
||||
class FitToggleFighterCommand(wx.Command):
|
||||
""""
|
||||
from sFit.toggleFighter
|
||||
"""
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, "Cargo add")
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("Toggling fighters for fit ID: {0}", self.fitID)
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
f = fit.fighters[self.position]
|
||||
f.active = not f.active
|
||||
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
cmd = FitToggleFighterCommand(self.fitID, self.position)
|
||||
return cmd.Do()
|
||||
33
gui/fitCommands/calc/fitToggleImplant.py
Normal file
33
gui/fitCommands/calc/fitToggleImplant.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
#from .helpers import ModuleInfoCache
|
||||
from eos.saveddata.module import Module, State
|
||||
import eos.db
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
from eos.saveddata.implant import Implant
|
||||
|
||||
class FitToggleImplantCommand(wx.Command):
|
||||
""""
|
||||
from sFit.toggleImplant
|
||||
"""
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, "Cargo add")
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("Toggling implant for fit ID: {0}", self.fitID)
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
implant = fit.implants[self.position]
|
||||
implant.active = not implant.active
|
||||
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
cmd = FitToggleImplantCommand(self.fitID, self.position)
|
||||
return cmd.Do()
|
||||
@@ -13,6 +13,7 @@ from .calc.fitReplaceModule import FitReplaceModuleCommand
|
||||
from .calc.fitAddFighter import FitAddFighterCommand
|
||||
from .calc.fitRemoveFighter import FitRemoveFighterCommand
|
||||
|
||||
|
||||
class GuiMetaSwapCommand(wx.Command):
|
||||
def __init__(self, fitID, context, itemID, selection: list):
|
||||
wx.Command.__init__(self, True, "Meta Swap")
|
||||
|
||||
30
gui/fitCommands/guiToggleBooster.py
Normal file
30
gui/fitCommands/guiToggleBooster.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calc.fitToggleBooster import FitToggleBoosterCommand
|
||||
|
||||
class GuiToggleImplantCommand(wx.Command):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, "")
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(FitToggleBoosterCommand(self.fitID, self.position)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
30
gui/fitCommands/guiToggleFighter.py
Normal file
30
gui/fitCommands/guiToggleFighter.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calc.fitToggleFighter import FitToggleFighterCommand
|
||||
|
||||
class GuiToggleFighterCommand(wx.Command):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, "")
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(FitToggleFighterCommand(self.fitID, self.position)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
30
gui/fitCommands/guiToggleImplant.py
Normal file
30
gui/fitCommands/guiToggleImplant.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calc.fitToggleImplant import FitToggleImplantCommand
|
||||
|
||||
class GuiToggleImplantCommand(wx.Command):
|
||||
def __init__(self, fitID, position):
|
||||
wx.Command.__init__(self, True, "")
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
self.position = position
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(FitToggleImplantCommand(self.fitID, self.position)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
return False
|
||||
|
||||
def Undo(self):
|
||||
for _ in self.internal_history.Commands:
|
||||
self.internal_history.Undo()
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
@@ -1022,6 +1022,7 @@ class Fit(object):
|
||||
self.recalc(fit)
|
||||
return True
|
||||
|
||||
@deprecated
|
||||
def toggleFighter(self, fitID, i):
|
||||
pyfalog.debug("Toggling fighters for fit ID: {0}", fitID)
|
||||
fit = eos.db.getFit(fitID)
|
||||
@@ -1032,6 +1033,7 @@ class Fit(object):
|
||||
self.recalc(fit)
|
||||
return True
|
||||
|
||||
@deprecated
|
||||
def toggleImplant(self, fitID, i):
|
||||
pyfalog.debug("Toggling implant for fit ID: {0}", fitID)
|
||||
fit = eos.db.getFit(fitID)
|
||||
@@ -1066,6 +1068,7 @@ class Fit(object):
|
||||
self.recalc(fit)
|
||||
return True
|
||||
|
||||
@deprecated
|
||||
def toggleBooster(self, fitID, i):
|
||||
pyfalog.debug("Toggling booster for fit ID: {0}", fitID)
|
||||
fit = eos.db.getFit(fitID)
|
||||
|
||||
Reference in New Issue
Block a user