Do command fit toggle. Still need to settle on the logic for how to handle deleted fits - seems there's an issue with the queue.

This commit is contained in:
blitzmann
2018-08-03 22:30:09 -04:00
parent 3c7f0258df
commit 425c7f657c
5 changed files with 76 additions and 3 deletions

View File

@@ -186,9 +186,7 @@ class CommandView(d.Display):
col = self.getColumn(event.Position)
if col == self.getColIndex(State):
fitID = self.mainFrame.getActiveFit()
sFit = Fit.getInstance()
sFit.toggleCommandFit(fitID, item)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
self.mainFrame.command.Submit(cmd.GuiToggleCommandCommand(fitID, item.ID))
def scheduleMenu(self, event):
event.Skip()

View File

@@ -12,3 +12,4 @@ from .guiRemoveBooster import GuiRemoveBoosterCommand
from .guiAddCommand import GuiAddCommandCommand
from .guiRemoveCommand import GuiRemoveCommandCommand
from .guiSetMode import GuiSetModeCommand
from .guiToggleCommand import GuiToggleCommandCommand

View File

@@ -0,0 +1,42 @@
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 FitToggleCommandCommand(wx.Command):
""""
from sFit.toggleCommandFit
"""
def __init__(self, fitID, commandFitId):
wx.Command.__init__(self, True, "Cargo add")
self.fitID = fitID
self.commandFitID = commandFitId
def Do(self):
pyfalog.debug("Toggle command fit ({0}) for: {1}", self.commandFitID, self.fitID)
commandFit = eos.db.getFit(self.commandFitID)
if not commandFit:
pyfalog.debug(" -- Command fit not found, deleted?")
return False
commandInfo = commandFit.getCommandInfo(self.fitID)
if not commandInfo:
pyfalog.debug(" -- Command fit info not found, deleted?")
return False
commandInfo.active = not commandInfo.active
eos.db.commit()
return True
def Undo(self):
cmd = FitToggleCommandCommand(self.fitID, self.commandFitID)
return cmd.Do()

View File

@@ -0,0 +1,31 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
from .calc.fitToggleCommand import FitToggleCommandCommand
class GuiToggleCommandCommand(wx.Command):
def __init__(self, fitID, commandFitID):
wx.Command.__init__(self, True, "")
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 = FitToggleCommandCommand(fitID, commandFitID)
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

View File

@@ -496,6 +496,7 @@ class Fit(object):
eos.db.commit()
self.recalc(fit)
@deprecated
def toggleCommandFit(self, fitID, thing):
pyfalog.debug("Toggle command fit ({0}) for: {1}", fitID, thing)
fit = eos.db.getFit(fitID)