As wormhole effects are still modules and we now fully support reverting modules even in case they were overwritten, consider them as modules in commands too
This commit is contained in:
@@ -43,8 +43,7 @@ class FitAddImplantCommand(wx.Command):
|
||||
if self.oldItemID:
|
||||
# If we had an item in the slot previously, add it back.
|
||||
cmd = FitAddImplantCommand(self.fitID, self.oldItemID, self.oldState)
|
||||
cmd.Do()
|
||||
return True
|
||||
return cmd.Do()
|
||||
|
||||
from .fitRemoveImplant import FitRemoveImplantCommand # Avoid circular import
|
||||
cmd = FitRemoveImplantCommand(self.fitID, self.newIndex)
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import wx
|
||||
from eos.saveddata.module import Module
|
||||
from eos.const import FittingModuleState
|
||||
import eos.db
|
||||
from logbook import Logger
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class FitAddProjectedEnvCommand(wx.Command):
|
||||
""""
|
||||
from sFit.project
|
||||
"""
|
||||
def __init__(self, fitID, itemID):
|
||||
wx.Command.__init__(self, True)
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.new_index = None
|
||||
self.old_item = None
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("Projecting fit ({0}) onto: {1}", self.fitID, self.itemID)
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
item = eos.db.getItem(self.itemID, eager=("attributes", "group.category"))
|
||||
|
||||
try:
|
||||
module = Module(item)
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
# todo: thing to check for existing environmental effects
|
||||
|
||||
module.state = FittingModuleState.ONLINE
|
||||
if module.isExclusiveSystemEffect:
|
||||
# if this is an exclusive system effect, we need to cache the old one. We make room for the new one here, which returns the old one
|
||||
self.old_item = fit.projectedModules.makeRoom(module)
|
||||
|
||||
fit.projectedModules.append(module)
|
||||
eos.db.commit()
|
||||
self.new_index = fit.projectedModules.index(module)
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
if self.old_item:
|
||||
# If we had an item in the slot previously, add it back.
|
||||
cmd = FitAddProjectedEnvCommand(self.fitID, self.old_item)
|
||||
cmd.Do()
|
||||
return True
|
||||
from gui.fitCommands.calc.fitRemoveProjectedEnv import FitRemoveProjectedEnvCommand # avoids circular import
|
||||
cmd = FitRemoveProjectedEnvCommand(self.fitID, self.itemID)
|
||||
cmd.Do()
|
||||
|
||||
return True
|
||||
@@ -52,6 +52,17 @@ class FitAddProjectedModuleCommand(wx.Command):
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
if self.oldModuleInfo is not None:
|
||||
cmd = FitAddProjectedModuleCommand(
|
||||
fitID=self.fitID,
|
||||
newItemID=self.oldModuleInfo.itemID,
|
||||
newBaseItemID=self.oldModuleInfo.baseID,
|
||||
newMutaplasmidID=self.oldModuleInfo.mutaplasmidID,
|
||||
newMutations=self.oldModuleInfo.mutations,
|
||||
newState=self.oldModuleInfo.state,
|
||||
newChargeID=self.oldModuleInfo.chargeID,
|
||||
newPosition=self.oldModuleInfo.modPosition)
|
||||
return cmd.Do()
|
||||
from gui.fitCommands.calc.fitRemoveProjectedModule import FitRemoveProjectedModuleCommand # avoids circular import
|
||||
cmd = FitRemoveProjectedModuleCommand(self.fitID, self.newPosition)
|
||||
cmd.Do()
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import wx
|
||||
import eos.db
|
||||
from logbook import Logger
|
||||
from .fitRemoveProjectedModule import FitRemoveProjectedModuleCommand
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
# this has the same exact definition that regular rpojected modules, besides the undo
|
||||
class FitRemoveProjectedEnvCommand(FitRemoveProjectedModuleCommand):
|
||||
""""
|
||||
from sFit.project
|
||||
"""
|
||||
|
||||
def __init__(self, fitID, itemID):
|
||||
wx.Command.__init__(self, True)
|
||||
self.fitID = fitID
|
||||
self.itemID = itemID
|
||||
self.removed_item = None
|
||||
|
||||
def Do(self):
|
||||
pyfalog.debug("Removing ({0}) onto: {1}", self.fitID, self.itemID)
|
||||
fit = eos.db.getFit(self.fitID)
|
||||
|
||||
item = next((x for x in fit.projectedModules if x.itemID == self.itemID), None)
|
||||
self.removed_item = item.itemID
|
||||
fit.projectedModules.remove(item)
|
||||
|
||||
eos.db.commit()
|
||||
return True
|
||||
|
||||
def Undo(self):
|
||||
from gui.fitCommands.calc.fitAddProjectedEnv import FitAddProjectedEnvCommand
|
||||
cmd = FitAddProjectedEnvCommand(self.fitID, self.removed_item)
|
||||
cmd.Do()
|
||||
return True
|
||||
@@ -5,7 +5,6 @@ import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from eos.saveddata.module import Module
|
||||
from .calc.fitAddProjectedModule import FitAddProjectedModuleCommand
|
||||
from .calc.fitAddProjectedEnv import FitAddProjectedEnvCommand
|
||||
from .calc.fitAddProjectedFit import FitAddProjectedFitCommand
|
||||
from .calc.fitAddProjectedFighter import FitAddProjectedFighterCommand
|
||||
from .calc.fitAddProjectedDrone import FitAddProjectedDroneCommand
|
||||
@@ -35,8 +34,6 @@ class GuiAddProjectedCommand(wx.Command):
|
||||
result = self.internal_history.Submit(FitAddProjectedDroneCommand(self.fitID, self.id))
|
||||
elif item.category.name == "Fighter":
|
||||
result = self.internal_history.Submit(FitAddProjectedFighterCommand(self.fitID, self.id))
|
||||
elif item.group.name in Module.SYSTEM_GROUPS:
|
||||
result = self.internal_history.Submit(FitAddProjectedEnvCommand(self.fitID, self.id))
|
||||
else:
|
||||
result = self.internal_history.Submit(FitAddProjectedModuleCommand(self.fitID, self.id, None, None, None, None, None, None))
|
||||
elif self.type == 'fit':
|
||||
|
||||
@@ -4,7 +4,6 @@ from service.fit import Fit
|
||||
import gui.mainFrame
|
||||
from gui import globalEvents as GE
|
||||
from .calc.fitRemoveProjectedModule import FitRemoveProjectedModuleCommand
|
||||
from .calc.fitRemoveProjectedEnv import FitRemoveProjectedEnvCommand
|
||||
from .calc.fitRemoveProjectedFit import FitRemoveProjectedFitCommand
|
||||
from .calc.fitRemoveProjectedFighter import FitRemoveProjectedFighterCommand
|
||||
from logbook import Logger
|
||||
@@ -22,7 +21,6 @@ class GuiRemoveProjectedCommand(wx.Command):
|
||||
'fit': FitRemoveProjectedFitCommand,
|
||||
'module': FitRemoveProjectedModuleCommand,
|
||||
'fighter': FitRemoveProjectedFighterCommand,
|
||||
'env': FitRemoveProjectedEnvCommand,
|
||||
'drone': FitRemoveProjectedDroneCommand
|
||||
}
|
||||
|
||||
@@ -38,13 +36,8 @@ class GuiRemoveProjectedCommand(wx.Command):
|
||||
self.data = fit.projectedDrones.index(thing)
|
||||
self.type = 'drone'
|
||||
elif isinstance(thing, Module):
|
||||
# todo: projected stuff should be wrapped in a projected class wrapper for easier maintainence
|
||||
if thing.item.group.name in Module.SYSTEM_GROUPS:
|
||||
self.type = 'env'
|
||||
self.data = thing.itemID
|
||||
else:
|
||||
self.type = 'module'
|
||||
self.data = fit.projectedModules.index(thing)
|
||||
self.type = 'module'
|
||||
self.data = fit.projectedModules.index(thing)
|
||||
elif isinstance(thing, Fighter):
|
||||
self.data = fit.projectedFighters.index(thing)
|
||||
self.type = 'fighter'
|
||||
|
||||
Reference in New Issue
Block a user