示例#1
0
 def Do(self):
     pyfalog.debug('Doing addition of local drone {} to fit {}'.format(self.droneInfo, self.fitID))
     fit = Fit.getInstance().getFit(self.fitID)
     item = Market.getInstance().getItem(self.droneInfo.itemID, eager=("attributes", "group.category"))
     # If we're not adding any active drones, check if there's an inactive stack
     # with enough space for new drones and use it
     if not self.forceNewStack and self.droneInfo.amountActive == 0:
         maxStack = droneStackLimit(fit, item)
         for drone in fit.drones.find(item):
             if (
                 drone is not None and drone.amountActive == 0 and
                 drone.amount + self.droneInfo.amount <= maxStack
             ):
                 self.savedDroneInfo = DroneInfo.fromDrone(drone)
                 self.savedPosition = fit.drones.index(drone)
                 drone.amount += self.droneInfo.amount
                 return True
     # Do new stack otherwise
     drone = self.droneInfo.toDrone()
     if drone is None:
         return False
     if not self.ignoreRestrictions and not drone.fits(fit):
         pyfalog.warning('Drone does not fit')
         return False
     fit.drones.append(drone)
     if drone not in fit.drones:
         pyfalog.warning('Failed to append to list')
         return False
     self.savedPosition = fit.drones.index(drone)
     return True
示例#2
0
    def addItem(self, event):
        item = Market.getInstance().getItem(event.itemID, eager='group.category')
        if item is None or not item.isDrone:
            event.Skip()
            return

        fitID = self.mainFrame.getActiveFit()
        fit = Fit.getInstance().getFit(fitID)
        if not fit or fit.isStructure:
            event.Skip()
            return

        amount = droneStackLimit(fit, event.itemID) if wx.GetMouseState().GetModifiers() == wx.MOD_ALT else 1
        if self.mainFrame.command.Submit(cmd.GuiAddLocalDroneCommand(fitID=fitID, itemID=event.itemID, amount=amount)):
            self.mainFrame.additionsPane.select('Drones')

        event.Skip()
示例#3
0
    def display(self, srcContext, selection):
        if srcContext not in ('marketItemGroup', 'marketItemMisc'):
            return False

        if self.mainFrame.getActiveFit() is None:
            return False

        item = selection[0]
        if item.category.name != 'Drone':
            return False

        fitID = self.mainFrame.getActiveFit()
        fit = Fit.getInstance().getFit(fitID)
        amount = droneStackLimit(fit, item)
        if amount < 1:
            return False

        self.amount = amount
        return True
示例#4
0
    def display(self, srcContext, mainItem):
        if srcContext not in ('marketItemGroup', 'marketItemMisc'):
            return False

        if self.mainFrame.getActiveFit() is None:
            return False

        if mainItem is None:
            return False

        if mainItem.category.name != 'Drone':
            return False

        fitID = self.mainFrame.getActiveFit()
        fit = Fit.getInstance().getFit(fitID)
        amount = droneStackLimit(fit, mainItem)
        if amount < 1:
            return False

        self.amount = amount
        return True