Improved on drag/drop for cargo and fitting views. Can now copy rather than swap

This commit is contained in:
blitzmann
2014-05-07 17:12:52 -04:00
parent 0c42848d52
commit d9e61a3305
4 changed files with 48 additions and 26 deletions

View File

@@ -24,7 +24,7 @@ class Cargo(ContextMenu):
fitID = self.mainFrame.getActiveFit()
typeID = int(selection[0].ID)
sFit.addCargo(fitID, typeID, 1)
sFit.addCargo(fitID, typeID)
self.mainFrame.additionsPane.select("Cargo")
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))

View File

@@ -346,13 +346,14 @@ class FittingView(d.Display):
def swapCargo(self, x, y, srcIdx):
'''Swap a module from cargo to fitting window'''
mstate = wx.GetMouseState()
dstRow, _ = self.HitTest((x, y))
if dstRow != -1 and dstRow not in self.blanks:
module = self.mods[dstRow]
cFit = service.Fit.getInstance()
cFit.swapModuleWithCargo(self.mainFrame.getActiveFit(), module.position, srcIdx)
cFit.moveCargoToModule(self.mainFrame.getActiveFit(), module.position, srcIdx, mstate.CmdDown() and module.isEmpty)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))

View File

@@ -102,17 +102,26 @@ class CargoView(d.Display):
def swapModule(self, x, y, modIdx):
'''Swap a module from fitting window with cargo'''
sFit = service.Fit.getInstance()
fit = sFit.getFit(self.mainFrame.getActiveFit())
dstRow, _ = self.HitTest((x, y))
if dstRow != -1:
# Gather module information to get position
sFit = service.Fit.getInstance()
fit = sFit.getFit(self.mainFrame.getActiveFit())
module = fit.modules[modIdx]
mstate = wx.GetMouseState()
sFit.swapModuleWithCargo(self.mainFrame.getActiveFit(), module.position, dstRow)
# Gather module information to get position
module = fit.modules[modIdx]
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
if dstRow != -1: # we're swapping with cargo
if mstate.CmdDown(): # if copying, append to cargo
sFit.addCargo(self.mainFrame.getActiveFit(), module.item.ID)
else: # else, move / swap
sFit.moveCargoToModule(self.mainFrame.getActiveFit(), module.position, dstRow)
else: # dragging to blank spot, append
sFit.addCargo(self.mainFrame.getActiveFit(), module.item.ID)
if not mstate.CmdDown(): # if not copying, remove module
sFit.removeModule(self.mainFrame.getActiveFit(), module.position)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
def fitChanged(self, event):
#Clear list and get out if current fitId is None