Exemple #1
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     oldModMap = self._getPositionMap(fit)
     results = []
     self.replacedItemIDs = set()
     lastSuccessfulCmd = None
     for position in self.positions:
         module = fit.modules[position]
         if module.isEmpty:
             continue
         if module.itemID == self.newItemID:
             continue
         info = ModuleInfo.fromModule(module)
         info.itemID = self.newItemID
         cmd = CalcReplaceLocalModuleCommand(fitID=self.fitID,
                                             position=position,
                                             newModInfo=info,
                                             unloadInvalidCharges=True)
         result = self.internalHistory.submit(cmd)
         results.append(result)
         if result:
             self.replacedItemIDs.add(module.itemID)
             lastSuccessfulCmd = cmd
     success = any(results)
     if lastSuccessfulCmd is not None and lastSuccessfulCmd.needsGuiRecalc:
         eos.db.flush()
         sFit.recalc(self.fitID)
     self.savedRemovedDummies = sFit.fill(self.fitID)
     eos.db.commit()
     newModMap = self._getPositionMap(fit)
     events = []
     if success and self.replacedItemIDs:
         events.append(
             GE.FitChanged(fitIDs=(self.fitID, ),
                           action='moddel',
                           typeID=self.replacedItemIDs))
     if success:
         events.append(
             GE.FitChanged(fitIDs=(self.fitID, ),
                           action='modadd',
                           typeID=self.newItemID))
     if not events:
         events.append(GE.FitChanged(fitIDs=(self.fitID, )))
     if success:
         for position in self.positions:
             oldMod = oldModMap.get(position)
             newMod = newModMap.get(position)
             if oldMod is not newMod:
                 events.append(GE.ItemChangedInplace(old=oldMod,
                                                     new=newMod))
     for event in events:
         wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), event)
     return success
Exemple #2
0
 def Undo(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     oldBooster = fit.boosters[self.newPosition]
     success = self.internalHistory.undoAll()
     eos.db.flush()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     eos.db.commit()
     newBooster = fit.boosters[self.position]
     mainFrame = gui.mainFrame.MainFrame.getInstance()
     wx.PostEvent(mainFrame, GE.FitChanged(fitIDs=(self.fitID, )))
     wx.PostEvent(mainFrame,
                  GE.ItemChangedInplace(old=oldBooster, new=newBooster))
     return success
Exemple #3
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     implant = fit.implants[self.position]
     if implant.itemID == self.newItemID:
         return False
     info = ImplantInfo.fromImplant(implant)
     info.itemID = self.newItemID
     cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=info)
     success = self.internalHistory.submit(cmd)
     eos.db.flush()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     eos.db.commit()
     self.newPosition = cmd.newPosition
     newImplant = fit.implants[self.newPosition]
     mainFrame = gui.mainFrame.MainFrame.getInstance()
     wx.PostEvent(mainFrame, GE.FitChanged(fitIDs=(self.fitID, )))
     wx.PostEvent(mainFrame,
                  GE.ItemChangedInplace(old=implant, new=newImplant))
     return success
Exemple #4
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     booster = fit.boosters[self.position]
     if booster.itemID == self.newItemID:
         return False
     info = BoosterInfo.fromBooster(booster)
     info.itemID = self.newItemID
     cmd = CalcAddBoosterCommand(fitID=self.fitID, boosterInfo=info)
     success = self.internalHistory.submit(cmd)
     eos.db.flush()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     eos.db.commit()
     self.newPosition = cmd.newPosition
     newBooster = fit.boosters[self.newPosition]
     mainFrame = gui.mainFrame.MainFrame.getInstance()
     wx.PostEvent(mainFrame, GE.FitChanged(fitIDs=(self.fitID, )))
     wx.PostEvent(mainFrame,
                  GE.ItemChangedInplace(old=booster, new=newBooster))
     return success
Exemple #5
0
 def Undo(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     oldModMap = self._getPositionMap(fit)
     for position in self.positions:
         oldModMap[position] = fit.modules[position]
     restoreRemovedDummies(fit, self.savedRemovedDummies)
     success = self.internalHistory.undoAll()
     eos.db.flush()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     eos.db.commit()
     newModMap = self._getPositionMap(fit)
     events = []
     if success:
         events.append(
             GE.FitChanged(fitIDs=(self.fitID, ),
                           action='moddel',
                           typeID=self.newItemID))
     if success and self.replacedItemIDs:
         events.append(
             GE.FitChanged(fitIDs=(self.fitID, ),
                           action='modadd',
                           typeID=self.replacedItemIDs))
     if not events:
         events.append(GE.FitChanged(fitIDs=(self.fitID, )))
     if success:
         for position in self.positions:
             oldMod = oldModMap.get(position)
             newMod = newModMap.get(position)
             if oldMod is not newMod:
                 events.append(
                     GE.ItemChangedInplace(fitID=self.fitID,
                                           old=oldMod,
                                           new=newMod))
     for event in events:
         wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), event)
     return success