Merge branch 'master' of evefit.org:pyfa
This commit is contained in:
@@ -26,6 +26,20 @@ from gui.builtinViewColumns.projectedState import ProjectedState
|
||||
from gui.contextMenu import ContextMenu
|
||||
import eos.types
|
||||
|
||||
|
||||
class ProjectedViewDrop(wx.PyDropTarget):
|
||||
def __init__(self, dropFn):
|
||||
wx.PyDropTarget.__init__(self)
|
||||
self.dropFn = dropFn
|
||||
# this is really transferring an EvE itemID
|
||||
self.dropData = wx.PyTextDataObject()
|
||||
self.SetDataObject(self.dropData)
|
||||
|
||||
def OnData(self, x, y, t):
|
||||
if self.GetData():
|
||||
self.dropFn(x, y, int(self.dropData.GetText()))
|
||||
return t
|
||||
|
||||
class ProjectedView(d.Display):
|
||||
DEFAULT_COLS = ["Projected State",
|
||||
"Projected Ammo Icon",
|
||||
@@ -40,6 +54,34 @@ class ProjectedView(d.Display):
|
||||
self.Bind(wx.EVT_LEFT_DCLICK, self.remove)
|
||||
self.droneView = gui.droneView.DroneView
|
||||
|
||||
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag)
|
||||
self.SetDropTarget(ProjectedViewDrop(self.mergeDrones))
|
||||
|
||||
def startDrag(self, event):
|
||||
row = event.GetIndex()
|
||||
if row != -1 and isinstance(self.get(row), eos.types.Drone):
|
||||
data = wx.PyTextDataObject()
|
||||
data.SetText(str(self.GetItemData(row)))
|
||||
|
||||
dropSource = wx.DropSource(self)
|
||||
dropSource.SetData(data)
|
||||
dropSource.DoDragDrop()
|
||||
|
||||
def mergeDrones(self, x, y, itemID):
|
||||
srcRow = self.FindItemData(-1,itemID)
|
||||
dstRow, _ = self.HitTest((x, y))
|
||||
if srcRow != -1 and dstRow != -1:
|
||||
self._merge(srcRow, dstRow)
|
||||
|
||||
def _merge(self, src, dst):
|
||||
dstDrone = self.get(dst)
|
||||
if isinstance(dstDrone, eos.types.Drone):
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
if sFit.mergeDrones(fitID, self.get(src), dstDrone, True):
|
||||
wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
def moduleSort(self, module):
|
||||
return module.item.name
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ class Fit(object):
|
||||
else:
|
||||
return False
|
||||
|
||||
def mergeDrones(self, fitID, d1, d2):
|
||||
def mergeDrones(self, fitID, d1, d2, projected=False):
|
||||
if fitID == None:
|
||||
return False
|
||||
|
||||
@@ -329,7 +329,11 @@ class Fit(object):
|
||||
if d1.item != d2.item:
|
||||
return False
|
||||
|
||||
fit.drones.remove(d1)
|
||||
if projected:
|
||||
fit.projectedDrones.remove(d1)
|
||||
else:
|
||||
fit.drones.remove(d1)
|
||||
|
||||
d2.amount += d1.amount
|
||||
d2.amountActive += d1.amountActive if d1.amountActive > 0 else -d2.amountActive
|
||||
eos.db.commit()
|
||||
|
||||
Reference in New Issue
Block a user