Add code for drone splitting, lacking a little amount selection popup
atm
This commit is contained in:
@@ -1 +1 @@
|
||||
__all__ = ["moduleAmmoPicker", "itemStats", "damagePattern", "marketJump"]
|
||||
__all__ = ["moduleAmmoPicker", "itemStats", "damagePattern", "marketJump", "droneSplit"]
|
||||
|
||||
24
gui/builtinContextMenus/droneSplit.py
Executable file
24
gui/builtinContextMenus/droneSplit.py
Executable file
@@ -0,0 +1,24 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.itemStats import ItemStatsDialog
|
||||
import gui.mainFrame
|
||||
import gui.fittingView
|
||||
import service
|
||||
import wx
|
||||
|
||||
class DroneSplit(ContextMenu):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, context, selection):
|
||||
return context in ("drone") and selection[0].amount > 1
|
||||
|
||||
def getText(self, context, selection):
|
||||
return "Split stack"
|
||||
|
||||
def activate(self, context, selection, i):
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
sFit.splitDroneStack(fitID, selection[0], 1)
|
||||
wx.PostEvent(self.mainFrame, gui.fittingView.FitChanged(fitID=fitID))
|
||||
|
||||
DroneSplit.register()
|
||||
@@ -49,9 +49,10 @@ class DroneView(d.Display):
|
||||
cFit = service.Fit.getInstance()
|
||||
fit = cFit.getFit(event.fitID)
|
||||
|
||||
stuff = fit.drones if fit is not None else None
|
||||
self.populate(stuff)
|
||||
self.refresh(stuff)
|
||||
stuff = fit.drones[:] if fit is not None else None
|
||||
if stuff is not None:
|
||||
stuff.sort(key=lambda d: d.item.name)
|
||||
self.update(stuff)
|
||||
event.Skip()
|
||||
|
||||
def addItem(self, event):
|
||||
|
||||
@@ -206,6 +206,23 @@ class Fit(object):
|
||||
else:
|
||||
return False
|
||||
|
||||
def splitDroneStack(self, fitID, d, amount):
|
||||
if fitID == None:
|
||||
return False
|
||||
|
||||
fit = eos.db.getFit(fitID)
|
||||
|
||||
total = d.amount
|
||||
active = d.amountActive > 0
|
||||
d.amount = amount
|
||||
d.amountActive = amount if active else 0
|
||||
|
||||
newD = eos.types.Drone(d.item)
|
||||
newD.amount = total - amount
|
||||
newD.amountActive = newD.amount if active else 0
|
||||
fit.drones.append(newD)
|
||||
eos.db.commit()
|
||||
|
||||
def removeDrone(self, fitID, i):
|
||||
fit = eos.db.getFit(fitID)
|
||||
d = fit.drones[i]
|
||||
|
||||
Reference in New Issue
Block a user