Support undo/redo module add
This commit is contained in:
@@ -382,14 +382,12 @@ class FittingView(d.Display):
|
|||||||
sFit.setAmmo(fitID, itemID, modules)
|
sFit.setAmmo(fitID, itemID, modules)
|
||||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||||
else:
|
else:
|
||||||
populate = sFit.appendModule(fitID, itemID)
|
self.mainFrame.command.Submit(cmd.FitModuleAddCommand(fitID, itemID))
|
||||||
if populate is not None:
|
|
||||||
self.slotsChanged()
|
|
||||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID, action="modadd", typeID=itemID))
|
|
||||||
|
|
||||||
event.Skip()
|
event.Skip()
|
||||||
|
|
||||||
def removeItem(self, event):
|
def removeItem(self, event):
|
||||||
|
'''Double Left Click - remove module'''
|
||||||
if event.CmdDown():
|
if event.CmdDown():
|
||||||
return
|
return
|
||||||
row, _ = self.HitTest(event.Position)
|
row, _ = self.HitTest(event.Position)
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
from .moduleStateChange import FitModuleStateChangeCommand
|
from .moduleStateChange import FitModuleStateChangeCommand
|
||||||
|
from.moduleAdd import FitModuleAddCommand
|
||||||
29
gui/fitCommands/moduleAdd.py
Normal file
29
gui/fitCommands/moduleAdd.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import wx
|
||||||
|
from service.fit import Fit
|
||||||
|
|
||||||
|
import gui.mainFrame
|
||||||
|
from gui import globalEvents as GE
|
||||||
|
|
||||||
|
|
||||||
|
class FitModuleAddCommand(wx.Command):
|
||||||
|
def __init__(self, fitID, itemID):
|
||||||
|
# todo: instead of modules, needs to be positions. Dead objects are a thing
|
||||||
|
wx.Command.__init__(self, True, "Module Add")
|
||||||
|
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||||
|
self.sFit = Fit.getInstance()
|
||||||
|
self.fitID = fitID
|
||||||
|
self.itemID = itemID
|
||||||
|
self.new_position = None
|
||||||
|
|
||||||
|
def Do(self):
|
||||||
|
populate, self.new_position = self.sFit.appendModule(self.fitID, self.itemID)
|
||||||
|
if populate is not None:
|
||||||
|
# self.slotsChanged() # unsure how to handle this right now? Perhaps move this to the event itself?
|
||||||
|
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID, action="modadd", typeID=self.itemID))
|
||||||
|
return True
|
||||||
|
|
||||||
|
def Undo(self):
|
||||||
|
# todo: self.slotsChanged()
|
||||||
|
result = self.sFit.removeModule(self.fitID, [self.new_position])
|
||||||
|
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID, action="moddel", typeID=self.itemID))
|
||||||
|
return True
|
||||||
@@ -566,7 +566,7 @@ class Fit(object):
|
|||||||
fit.fill()
|
fit.fill()
|
||||||
eos.db.commit()
|
eos.db.commit()
|
||||||
|
|
||||||
return numSlots != len(fit.modules)
|
return numSlots != len(fit.modules), m.modPosition
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user