Convert tactical mode switching
This commit is contained in:
@@ -6,7 +6,7 @@ import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
from service.fit import Fit
|
||||
from service.settings import ContextMenuSettings
|
||||
|
||||
import gui.fitCommands as cmd
|
||||
|
||||
class TacticalMode(ContextMenu):
|
||||
def __init__(self):
|
||||
@@ -60,10 +60,8 @@ class TacticalMode(ContextMenu):
|
||||
event.Skip()
|
||||
return
|
||||
|
||||
sFit = Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
sFit.setMode(fitID, self.modeIds[event.Id])
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
self.mainFrame.command.Submit(cmd.GuiSetModeCommand(fitID, self.modeIds[event.Id]))
|
||||
|
||||
|
||||
TacticalMode.register()
|
||||
|
||||
@@ -7,3 +7,4 @@ from .guiRemoveCargo import GuiRemoveCargoCommand
|
||||
from .guiAddCargo import GuiAddCargoCommand
|
||||
from .guiRemoveImplant import GuiRemoveImplantCommand
|
||||
from .guiAddImplant import GuiAddImplantCommand
|
||||
from .guiSetMode import GuiSetModeCommand
|
||||
34
gui/fitCommands/calc/fitSetMode.py
Normal file
34
gui/fitCommands/calc/fitSetMode.py
Normal file
@@ -0,0 +1,34 @@
|
||||
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 FitSetModeCommand(wx.Command):
|
||||
""""
|
||||
from sFit.setMode
|
||||
"""
|
||||
def __init__(self, fitID, mode):
|
||||
wx.Command.__init__(self, True, "Cargo add")
|
||||
self.fitID = fitID
|
||||
self.mode = mode
|
||||
self.old_mode = None
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("Set mode for fit ID: {0}", self.fitID)
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
self.old_mode = fit.mode
|
||||
fit.mode = self.mode
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
cmd = FitSetModeCommand(self.fitID, self.old_mode)
|
||||
cmd.Do()
|
||||
return True
|
||||
31
gui/fitCommands/guiSetMode.py
Normal file
31
gui/fitCommands/guiSetMode.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calc.fitSetMode import FitSetModeCommand
|
||||
|
||||
class GuiSetModeCommand(wx.Command):
|
||||
def __init__(self, fitID, mode):
|
||||
wx.Command.__init__(self, True, "Cargo Add")
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
# can set his up no to not have to set variables on our object
|
||||
self.cmd = FitSetModeCommand(fitID, mode)
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(self.cmd):
|
||||
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
|
||||
|
||||
@@ -1155,6 +1155,7 @@ class Fit(object):
|
||||
|
||||
self.recalc(fit)
|
||||
|
||||
@deprecated
|
||||
def setMode(self, fitID, mode):
|
||||
pyfalog.debug("Set mode for fit ID: {0}", fitID)
|
||||
if fitID is None:
|
||||
|
||||
Reference in New Issue
Block a user