Convert implant location change to a command
This commit is contained in:
@@ -77,10 +77,7 @@ class ImplantView(wx.Panel):
|
||||
def OnRadioSelect(self, event):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
if fitID is not None:
|
||||
sFit = Fit.getInstance()
|
||||
sFit.toggleImplantSource(fitID, ImplantLocation.FIT if self.rbFit.GetValue() else ImplantLocation.CHARACTER)
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
self.mainFrame.command.Submit(cmd.GuiChangeImplantLocation(fitID, ImplantLocation.FIT if self.rbFit.GetValue() else ImplantLocation.CHARACTER))
|
||||
|
||||
|
||||
class ImplantDisplay(d.Display):
|
||||
|
||||
@@ -31,4 +31,5 @@ from .guiChangeProjectedFitQty import GuiChangeProjectedFitQty
|
||||
from .guiChangeDroneQty import GuiChangeDroneQty
|
||||
from .guiChangeProjectedDroneQty import GuiChangeProjectedDroneQty
|
||||
from .guiToggleDrone import GuiToggleDroneCommand
|
||||
from .guiFitRename import GuiFitRenameCommand
|
||||
from .guiFitRename import GuiFitRenameCommand
|
||||
from .guiChangeImplantLocation import GuiChangeImplantLocation
|
||||
25
gui/fitCommands/calc/fitChangeImplantLocation.py
Normal file
25
gui/fitCommands/calc/fitChangeImplantLocation.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import wx
|
||||
import eos.db
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class FitChangeImplantLocation(wx.Command):
|
||||
def __init__(self, fitID, source):
|
||||
wx.Command.__init__(self, True, "Drone add")
|
||||
self.fitID = fitID
|
||||
self.source = source
|
||||
self.old_source = None
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("Toggling implant source for fit ID: {0}", self.fitID)
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
self.old_source = fit.implantSource
|
||||
fit.implantSource = self.source
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
|
||||
def Undo(self):
|
||||
cmd = FitChangeImplantLocation(self.fitID, self.old_source)
|
||||
return cmd.Do()
|
||||
@@ -3,7 +3,9 @@ from service.fit import Fit
|
||||
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from eos.saveddata.fit import ImplantLocation
|
||||
from .calc.fitAddImplant import FitAddImplantCommand
|
||||
from .calc.fitChangeImplantLocation import FitChangeImplantLocation
|
||||
|
||||
|
||||
class GuiAddImplantCommand(wx.Command):
|
||||
@@ -16,7 +18,7 @@ class GuiAddImplantCommand(wx.Command):
|
||||
self.itemID = itemID
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(FitAddImplantCommand(self.fitID, self.itemID)):
|
||||
if self.internal_history.Submit(FitAddImplantCommand(self.fitID, self.itemID)) and self.internal_history.Submit(FitChangeImplantLocation(self.fitID, ImplantLocation.FIT)):
|
||||
self.sFit.recalc(self.fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
|
||||
return True
|
||||
|
||||
30
gui/fitCommands/guiChangeImplantLocation.py
Normal file
30
gui/fitCommands/guiChangeImplantLocation.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.fitChangeImplantLocation import FitChangeImplantLocation
|
||||
|
||||
|
||||
class GuiChangeImplantLocation(wx.Command):
|
||||
def __init__(self, fitID, source):
|
||||
wx.Command.__init__(self, True, "Implant Source Change")
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.sFit = Fit.getInstance()
|
||||
self.internal_history = wx.CommandProcessor()
|
||||
self.fitID = fitID
|
||||
self.source = source
|
||||
|
||||
def Do(self):
|
||||
if self.internal_history.Submit(FitChangeImplantLocation(self.fitID, self.source)):
|
||||
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
|
||||
@@ -424,15 +424,6 @@ class Fit(FitDeprecated):
|
||||
else:
|
||||
return False
|
||||
|
||||
def toggleImplantSource(self, fitID, source):
|
||||
pyfalog.debug("Toggling implant source for fit ID: {0}", fitID)
|
||||
fit = eos.db.getFit(fitID)
|
||||
fit.implantSource = source
|
||||
|
||||
eos.db.commit()
|
||||
self.recalc(fit)
|
||||
return True
|
||||
|
||||
def toggleRestrictionIgnore(self, fitID):
|
||||
pyfalog.debug("Toggling restriction ignore for fit ID: {0}", fitID)
|
||||
fit = eos.db.getFit(fitID)
|
||||
|
||||
@@ -46,6 +46,16 @@ class FitDeprecated(object):
|
||||
eos.db.commit()
|
||||
return old_name, newName
|
||||
|
||||
@deprecated
|
||||
def toggleImplantSource(self, fitID, source):
|
||||
pyfalog.debug("Toggling implant source for fit ID: {0}", fitID)
|
||||
fit = eos.db.getFit(fitID)
|
||||
fit.implantSource = source
|
||||
|
||||
eos.db.commit()
|
||||
self.recalc(fit)
|
||||
return True
|
||||
|
||||
@deprecated
|
||||
def toggleDrone(self, fitID, i):
|
||||
pyfalog.debug("Toggling drones for fit ID: {0}", fitID)
|
||||
|
||||
Reference in New Issue
Block a user