Allow imports of separate mutated drones from clipboard

This commit is contained in:
DarkPhoenix
2021-10-26 10:19:10 +03:00
parent acab787a7b
commit 85f63e237d
4 changed files with 51 additions and 2 deletions

View File

@@ -52,7 +52,6 @@ class MutatedMixin:
# Note: there may be a better way of doing this, such as a metho on this classe to convert(mutaplamid). This
# will require a bit more research though, considering there has never been a need to "swap" out the item of a Module
# before, and there may be assumptions taken with regards to the item never changing (pre-calculated / cached results, for example)
print('muta init', self, self._item.ID, self.baseItemID)
self._item = eos.db.getItemWithBaseItemAttribute(self._item.ID, self.baseItemID)
self.__baseItem = baseItem
self.__mutaplasmid = mutaplasmid

View File

@@ -30,6 +30,7 @@ from .gui.localDrone.changeMutation import GuiChangeLocalDroneMutationCommand
from .gui.localDrone.clone import GuiCloneLocalDroneCommand
from .gui.localDrone.imprt import GuiImportLocalDronesCommand
from .gui.localDrone.mutatedConvert import GuiConvertMutatedLocalDroneCommand
from .gui.localDrone.mutatedImport import GuiImportLocalMutatedDroneCommand
from .gui.localDrone.mutatedRevert import GuiRevertMutatedLocalDroneCommand
from .gui.localDrone.remove import GuiRemoveLocalDronesCommand
from .gui.localDrone.stackSplit import GuiSplitLocalDroneStackCommand

View File

@@ -0,0 +1,44 @@
import wx
import eos.db
import gui.mainFrame
from gui import globalEvents as GE
from gui.fitCommands.calc.drone.localAdd import CalcAddLocalDroneCommand
from gui.fitCommands.helpers import InternalCommandHistory, DroneInfo
from service.fit import Fit
class GuiImportLocalMutatedDroneCommand(wx.Command):
def __init__(self, fitID, baseItem, mutaplasmid, mutations, amount):
wx.Command.__init__(self, True, 'Import Local Mutated Drone')
self.internalHistory = InternalCommandHistory()
self.fitID = fitID
self.newDroneInfo = DroneInfo(
amount=amount,
amountActive=0,
itemID=mutaplasmid.resultingItem.ID,
baseItemID=baseItem.ID,
mutaplasmidID=mutaplasmid.ID,
mutations=mutations)
def Do(self):
cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=self.newDroneInfo, forceNewStack=True)
success = self.internalHistory.submit(cmd)
eos.db.flush()
sFit = Fit.getInstance()
sFit.recalc(self.fitID)
sFit.fill(self.fitID)
eos.db.commit()
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitIDs=(self.fitID,)))
return success
def Undo(self):
success = self.internalHistory.undoAll()
eos.db.flush()
sFit = Fit.getInstance()
sFit.recalc(self.fitID)
sFit.fill(self.fitID)
eos.db.commit()
wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitIDs=(self.fitID,)))
return success

View File

@@ -762,7 +762,12 @@ class MainFrame(wx.Frame):
if importType == "FittingItem":
baseItem, mutaplasmidItem, mutations = importData[0]
if mutaplasmidItem:
self.command.Submit(cmd.GuiImportLocalMutatedModuleCommand(activeFit, baseItem, mutaplasmidItem, mutations))
if baseItem.isDrone:
self.command.Submit(cmd.GuiImportLocalMutatedDroneCommand(
activeFit, baseItem, mutaplasmidItem, mutations, amount=1))
else:
self.command.Submit(cmd.GuiImportLocalMutatedModuleCommand(
activeFit, baseItem, mutaplasmidItem, mutations))
else:
self.command.Submit(cmd.GuiAddLocalModuleCommand(activeFit, baseItem.ID))
return