Some documentation

This commit is contained in:
blitzmann
2018-08-02 23:23:52 -04:00
parent fc153915b6
commit 36b158637c
6 changed files with 36 additions and 8 deletions

View File

@@ -12,23 +12,24 @@ pyfalog = Logger(__name__)
class FitAddModuleCommand(wx.Command):
""""
Fitting command that appends a module to a fit using the first available slot.
Fitting command that appends a module to a fit using the first available slot. In the case of a Subsystem, it checks
if there is already a subsystem with the same slot, and runs the replace command instead.
from sFit.appendModule
"""
def __init__(self, fitID, itemID, mutaplasmidID=None, baseID=None):
wx.Command.__init__(self, True, "Module Add")
wx.Command.__init__(self, True)
self.fitID = fitID
self.itemID = itemID
self.mutaplasmidID = mutaplasmidID
self.baseID = baseID
self.new_position = None
self.change = None
self.replace_cmd = None
def Do(self):
fitID = self.fitID
itemID = self.itemID
pyfalog.debug("Appending module for fit ({0}) using item: {1}", fitID, itemID)
fit = eos.db.getFit(fitID)
item = eos.db.getItem(itemID, eager=("attributes", "group.category"))
@@ -38,13 +39,19 @@ class FitAddModuleCommand(wx.Command):
try:
self.module = Module(item, bItem, mItem)
except ValueError:
pyfalog.warning("Invalid item: {0}", itemID)
pyfalog.warning("Invalid module: {}", item)
return False
# If subsystem and we need to replace, run the replace command instead and bypass the rest of this command
if self.module.item.category.name == "Subsystem":
fit.modules.freeSlot(self.module.getModifiedItemAttr("subSystemSlot"))
for mod in fit.modules:
if mod.getModifiedItemAttr("subSystemSlot") == self.module.getModifiedItemAttr("subSystemSlot"):
from .fitReplaceModule import FitReplaceModuleCommand
self.replace_cmd = FitReplaceModuleCommand(self.fitID, mod.modPosition, itemID)
return self.replace_cmd.Do()
if self.module.fits(fit):
pyfalog.debug("Adding {} as module for fit {}", self.module, fit)
self.module.owner = fit
numSlots = len(fit.modules)
fit.modules.append(self.module)
@@ -68,6 +75,10 @@ class FitAddModuleCommand(wx.Command):
return True
def Undo(self):
# We added a subsystem module, which actually ran the replace command. Run the undo for that guy instead
if self.replace_cmd:
return self.replace_cmd.Undo()
from .fitRemoveModule import FitRemoveModuleCommand # Avoid circular import
if self.new_position:
cmd = FitRemoveModuleCommand(self.fitID, [self.new_position])