Working commit for adding / removing projected modules / environments

This commit is contained in:
Ryan Holmes
2018-08-09 15:52:34 -04:00
parent 56ebb2926d
commit d6b280d3cc
6 changed files with 19 additions and 15 deletions

View File

@@ -236,12 +236,7 @@ class HandledProjectedModList(HandledList):
isSystemEffect = proj.item.group.name == "Effect Beacon"
if isSystemEffect:
# remove other system effects - only 1 per fit plz
oldEffect = next((m for m in self if m.item.group.name == "Effect Beacon"), None)
if oldEffect:
pyfalog.info("System effect occupied with {0}, replacing with {1}", oldEffect.item.name, proj.item.name)
self.remove(oldEffect)
self.makeRoom(proj)
HandledList.append(self, proj)
@@ -249,6 +244,15 @@ class HandledProjectedModList(HandledList):
if not proj.item.isType("projected") and not isSystemEffect:
self.remove(proj)
def makeRoom(self, proj):
# remove other system effects - only 1 per fit plz
oldEffect = next((m for m in self if m.item.group.name == "Effect Beacon"), None)
if oldEffect:
pyfalog.info("System effect occupied with {0}, replacing with {1}", oldEffect.item.name, proj.item.name)
self.remove(oldEffect)
return oldEffect.itemID
return None
class HandledProjectedDroneList(HandledDroneCargoList):
def append(self, proj):

View File

@@ -323,5 +323,4 @@ class ProjectedView(d.Display):
sFit = Fit.getInstance()
thing = self.get(row)
if thing: # thing doesn't exist if it's the dummy value
sFit.removeProjected(fitID, thing)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedCommand(fitID, thing))

View File

@@ -54,10 +54,11 @@ class ItemRemove(ContextMenu):
self.mainFrame.command.Submit(cmd.GuiRemoveCargoCommand(fitID, selection[0].itemID))
return # the command takes care of the PostEvent
elif srcContext in ("projectedFit", "projectedModule", "projectedDrone", "projectedFighter"):
sFit.removeProjected(fitID, selection[0])
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedCommand(fitID, selection[0]))
return # the command takes care of the PostEvent
elif srcContext == "commandFit":
self.mainFrame.command.Submit(cmd.GuiRemoveCommandCommand(fitID, selection[0].ID))
return
return # the command takes care of the PostEvent
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))

View File

@@ -13,4 +13,5 @@ from .guiAddCommand import GuiAddCommandCommand
from .guiRemoveCommand import GuiRemoveCommandCommand
from .guiSetMode import GuiSetModeCommand
from .guiToggleCommand import GuiToggleCommandCommand
from .guiAddProjected import GuiAddProjectedCommand
from .guiAddProjected import GuiAddProjectedCommand
from .guiRemoveProjected import GuiRemoveProjectedCommand

View File

@@ -5,6 +5,7 @@ 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 logbook import Logger
import eos.db
pyfalog = Logger(__name__)
@@ -46,10 +47,7 @@ class GuiAddProjectedCommand(wx.Command):
# fighter = Fighter(item)
# fit.projectedFighters.append(fighter)
elif item.group.name in Module.SYSTEM_GROUPS:
pyfalog.warn("WH PROJECTION NOT IMPLEMENTED")
# module = Module(item)
# module.state = State.ONLINE
# fit.projectedModules.append(module)
result = self.internal_history.Submit(FitAddProjectedEnvCommand(self.fitID, self.id))
else:
# attempt a regular module projection
result = self.internal_history.Submit(FitAddProjectedModuleCommand(self.fitID, self.id))

View File

@@ -528,6 +528,7 @@ class Fit(object):
eos.db.commit()
self.recalc(fit)
@deprecated
def removeProjected(self, fitID, thing):
pyfalog.debug("Removing projection on fit ({0}) from: {1}", fitID, thing)
fit = eos.db.getFit(fitID)