Remove drone splitting / merging, and introduce drone change qty

This commit is contained in:
blitzmann
2018-08-18 00:39:05 -04:00
parent a37fdf48c8
commit fd83a4b709
9 changed files with 91 additions and 9 deletions

View File

@@ -144,10 +144,12 @@ class DroneView(Display):
data[1] is typeID or index of data we want to manipulate
"""
if data[0] == "drone": # we want to merge drones
srcRow = int(data[1])
dstRow, _ = self.HitTest((x, y))
if srcRow != -1 and dstRow != -1:
self._merge(srcRow, dstRow)
pass
# remove merge functionality, if people complain in the next while, can add it back
# srcRow = int(data[1])
# dstRow, _ = self.HitTest((x, y))
# if srcRow != -1 and dstRow != -1:
# self._merge(srcRow, dstRow)
elif data[0] == "market":
wx.PostEvent(self.mainFrame, ItemSelected(itemID=int(data[1])))

View File

@@ -106,7 +106,9 @@ class ProjectedView(d.Display):
if data[0] == "projected":
# if source is coming from projected, we are trying to combine drones.
self.mergeDrones(x, y, int(data[1]))
pass
# removing merge functionality - if people complain about it, can add it back as a command
# self.mergeDrones(x, y, int(data[1]))
elif data[0] == "fitting":
dstRow, _ = self.HitTest((x, y))
# Gather module information to get position

View File

@@ -6,6 +6,7 @@ import gui.globalEvents as GE
import wx
import re
from service.fit import Fit
from eos.saveddata.drone import Drone
from eos.saveddata.cargo import Cargo as es_Cargo
from eos.saveddata.fighter import Fighter as es_Fighter
from service.settings import ContextMenuSettings
@@ -20,7 +21,7 @@ class ChangeAmount(ContextMenu):
if not self.settings.get('amount'):
return False
return srcContext in ("cargoItem", "projectedFit", "fighterItem", "projectedFighter")
return srcContext in ("droneItem", "cargoItem", "projectedFit", "fighterItem", "projectedFighter")
def getText(self, itmContext, selection):
return u"Change {0} Quantity".format(itmContext)
@@ -48,6 +49,8 @@ class ChangeAmount(ContextMenu):
if isinstance(thing, es_Cargo):
self.mainFrame.command.Submit(cmd.GuiChangeCargoQty(fitID, fit.cargo.index(thing), int(float(cleanInput))))
return # no need for post event here
elif isinstance(thing, Drone):
self.mainFrame.command.Submit(cmd.GuiChangeDroneQty(fitID, fit.drones.index(thing), int(float(cleanInput))))
elif isinstance(thing, es_Fit):
self.mainFrame.command.Submit(cmd.GuiChangeProjectedFitQty(fitID, thing.ID, int(float(cleanInput))))
return

View File

@@ -186,7 +186,7 @@ from gui.builtinContextMenus import ( # noqa: E402,F401
itemStats,
damagePattern,
marketJump,
droneSplit,
#droneSplit,
itemRemove,
droneRemoveStack,
ammoPattern,
@@ -202,7 +202,7 @@ from gui.builtinContextMenus import ( # noqa: E402,F401
priceOptions,
amount,
cargoAmmo,
droneStack,
#droneStack,
metaSwap,
implantSets,
fighterAbilities,

View File

@@ -27,4 +27,5 @@ from .guiAddDrone import GuiAddDroneCommand
from .guiRemoveDrone import GuiRemoveDroneCommand
from .guiChangeFighterQty import GuiChangeFighterQty
from .guiChangeCargoQty import GuiChangeCargoQty
from .guiChangeProjectedFitQty import GuiChangeProjectedFitQty
from .guiChangeProjectedFitQty import GuiChangeProjectedFitQty
from .guiChangeDroneQty import GuiChangeDroneQty

View File

@@ -37,6 +37,8 @@ class FitAddProjectedDroneCommand(wx.Command):
if drone is None:
drone = Drone(item)
if not drone.item.isType("projected"):
return False
fit.projectedDrones.append(drone)
self.index = fit.projectedDrones.index(drone)

View File

@@ -30,6 +30,8 @@ class FitAddProjectedModuleCommand(wx.Command):
try:
module = Module(item)
if not module.item.isType("projected"):
return False
except ValueError:
return False

View File

@@ -0,0 +1,32 @@
import wx
from service.fit import Fit
import gui.mainFrame
from gui import globalEvents as GE
#from .helpers import ModuleInfoCache
from eos.saveddata.module import Module, State
import eos.db
from logbook import Logger
pyfalog = Logger(__name__)
class FitChangeDroneQty(wx.Command):
def __init__(self, fitID, position, amount=1):
wx.Command.__init__(self, True, "Drone add")
self.fitID = fitID
self.position = position
self.amount = amount # add x amount. If this goes over amount, removes stack
self.old_amount = None
def Do(self):
pyfalog.debug("Changing active fighters ({0}) for fit ({1}) to amount: {2}", self.position, self.fitID, self.amount)
fit = eos.db.getFit(self.fitID)
drone = fit.drones[self.position]
self.old_amount = drone.amount
drone.amount = self.amount
eos.db.commit()
return True
def Undo(self):
cmd = FitChangeDroneQty(self.fitID, self.position, self.old_amount)
return cmd.Do()

View File

@@ -0,0 +1,38 @@
import wx
import eos.db
import gui.mainFrame
from service.fit import Fit
from gui import globalEvents as GE
from .calc.fitAddModule import FitAddModuleCommand
from .calc.fitReplaceModule import FitReplaceModuleCommand
from .calc.fitChangeDroneQty import FitChangeDroneQty
from service.fit import Fit
from logbook import Logger
pyfalog = Logger(__name__)
class GuiChangeDroneQty(wx.Command):
def __init__(self, fitID, position, amount=1):
wx.Command.__init__(self, True, "")
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.sFit = Fit.getInstance()
self.fitID = fitID
self.position = position
self.amount = amount
self.internal_history = wx.CommandProcessor()
def Do(self):
cmd = FitChangeDroneQty(self.fitID, self.position, self.amount)
if self.internal_history.Submit(cmd):
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