(self, callingWindow, fullContext, mainItem, selection, i)
| 36 | return _t("Change {0} Quantity").format(itmContext) |
| 37 | |
| 38 | def activate(self, callingWindow, fullContext, mainItem, selection, i): |
| 39 | fitID = self.mainFrame.getActiveFit() |
| 40 | srcContext = fullContext[0] |
| 41 | if isinstance(mainItem, es_Fit): |
| 42 | try: |
| 43 | value = mainItem.getProjectionInfo(fitID).amount |
| 44 | except AttributeError: |
| 45 | return |
| 46 | else: |
| 47 | value = mainItem.amount |
| 48 | |
| 49 | limits = (0, 20) if isinstance(mainItem, es_Fit) else None |
| 50 | with AmountChanger(self.mainFrame, value, limits) as dlg: |
| 51 | if dlg.ShowModal() == wx.ID_OK: |
| 52 | |
| 53 | if dlg.input.GetLineText(0).strip() == '': |
| 54 | return |
| 55 | |
| 56 | sFit = Fit.getInstance() |
| 57 | fit = sFit.getFit(fitID) |
| 58 | cleanInput = int(float(re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip()))) |
| 59 | |
| 60 | if isinstance(mainItem, es_Cargo): |
| 61 | itemIDs = [] |
| 62 | for cargo in selection: |
| 63 | if cargo in fit.cargo: |
| 64 | itemIDs.append(cargo.itemID) |
| 65 | self.mainFrame.command.Submit(cmd.GuiChangeCargosAmountCommand( |
| 66 | fitID=fitID, itemIDs=itemIDs, amount=cleanInput)) |
| 67 | elif isinstance(mainItem, Drone): |
| 68 | if srcContext == "projectedDrone": |
| 69 | self.mainFrame.command.Submit(cmd.GuiChangeProjectedDroneAmountCommand( |
| 70 | fitID=fitID, itemID=mainItem.itemID, amount=cleanInput)) |
| 71 | else: |
| 72 | if mainItem in fit.drones: |
| 73 | position = fit.drones.index(mainItem) |
| 74 | self.mainFrame.command.Submit(cmd.GuiChangeLocalDroneAmountCommand( |
| 75 | fitID=fitID, position=position, amount=cleanInput)) |
| 76 | elif isinstance(mainItem, es_Fit): |
| 77 | self.mainFrame.command.Submit(cmd.GuiChangeProjectedFitAmountCommand( |
| 78 | fitID=fitID, projectedFitID=mainItem.ID, amount=cleanInput)) |
| 79 | elif isinstance(mainItem, es_Fighter): |
| 80 | if srcContext == "projectedFighter": |
| 81 | if mainItem in fit.projectedFighters: |
| 82 | position = fit.projectedFighters.index(mainItem) |
| 83 | self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterAmountCommand( |
| 84 | fitID=fitID, position=position, amount=cleanInput)) |
| 85 | else: |
| 86 | if mainItem in fit.fighters: |
| 87 | position = fit.fighters.index(mainItem) |
| 88 | self.mainFrame.command.Submit(cmd.GuiChangeLocalFighterAmountCommand( |
| 89 | fitID=fitID, position=position, amount=cleanInput)) |
| 90 | |
| 91 | |
| 92 | ChangeItemAmount.register() |
nothing calls this directly
no test coverage detected