Exemple #1
0
    def handleModule(self, event):
        item, context = self.moduleLookup.get(event.Id, None)
        if item is None:
            event.Skip()
            return

        fitID = self.mainFrame.getActiveFit()
        fit = Fit.getInstance().getFit(fitID)
        if context == 'fittingModule':
            positions = []
            for position, mod in enumerate(fit.modules):
                if mod in self.selection:
                    positions.append(position)
            self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleMetasCommand(
                fitID=fitID, positions=positions, newItemID=item.ID))
        elif context == 'droneItem':
            drone = self.selection[0]
            if drone in fit.drones:
                position = fit.drones.index(drone)
                self.mainFrame.command.Submit(cmd.GuiChangeLocalDroneMetaCommand(
                    fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'fighterItem':
            fighter = self.selection[0]
            if fighter in fit.fighters:
                position = fit.fighters.index(fighter)
                self.mainFrame.command.Submit(cmd.GuiChangeLocalFighterMetaCommand(
                    fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'implantItem':
            implant = self.selection[0]
            if implant in fit.implants:
                position = fit.implants.index(implant)
                self.mainFrame.command.Submit(cmd.GuiChangeImplantMetaCommand(
                    fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'boosterItem':
            booster = self.selection[0]
            if booster in fit.boosters:
                position = fit.boosters.index(booster)
                self.mainFrame.command.Submit(cmd.GuiChangeBoosterMetaCommand(
                    fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'cargoItem':
            cargo = self.selection[0]
            self.mainFrame.command.Submit(cmd.GuiChangeCargoMetaCommand(
                fitID=fitID, itemID=cargo.itemID, newItemID=item.ID))
        elif context == 'projectedModule':
            mod = self.selection[0]
            if mod in fit.projectedModules:
                position = fit.projectedModules.index(mod)
                self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleMetaCommand(
                    fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'projectedDrone':
            drone = self.selection[0]
            self.mainFrame.command.Submit(cmd.GuiChangeProjectedDroneMetaCommand(
                fitID=fitID, itemID=drone.itemID, newItemID=item.ID))
        elif context == 'projectedFighter':
            fighter = self.selection[0]
            if fighter in fit.projectedFighters:
                position = fit.projectedFighters.index(fighter)
                self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterMetaCommand(
                    fitID=fitID, position=position, newItemID=item.ID))
    def handleModule(self, event):
        item, context = self.moduleLookup.get(event.Id, None)
        if item is None:
            event.Skip()
            return

        fitID = self.mainFrame.getActiveFit()
        fit = Fit.getInstance().getFit(fitID)
        if context == 'fittingModule':
            positions = [mod.modPosition for mod in self.selection]
            self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleMetasCommand(
                fitID=fitID, positions=positions, newItemID=item.ID))
        elif context == 'droneItem':
            position = fit.drones.index(self.selection[0])
            self.mainFrame.command.Submit(cmd.GuiChangeLocalDroneMetaCommand(
                fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'fighterItem':
            position = fit.fighters.index(self.selection[0])
            self.mainFrame.command.Submit(cmd.GuiChangeLocalFighterMetaCommand(
                fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'implantItem':
            position = fit.implants.index(self.selection[0])
            self.mainFrame.command.Submit(cmd.GuiChangeImplantMetaCommand(
                fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'boosterItem':
            position = fit.boosters.index(self.selection[0])
            self.mainFrame.command.Submit(cmd.GuiChangeBoosterMetaCommand(
                fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'cargoItem':
            self.mainFrame.command.Submit(cmd.GuiChangeCargoMetaCommand(
                fitID=fitID, itemID=self.selection[0].itemID, newItemID=item.ID))
        elif context == 'projectedModule':
            position = fit.projectedModules.index(self.selection[0])
            self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleMetaCommand(
                fitID=fitID, position=position, newItemID=item.ID))
        elif context == 'projectedDrone':
            self.mainFrame.command.Submit(cmd.GuiChangeProjectedDroneMetaCommand(
                fitID=fitID, itemID=self.selection[0].itemID, newItemID=item.ID))
        elif context == 'projectedFighter':
            position = fit.projectedFighters.index(self.selection[0])
            self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterMetaCommand(
                fitID=fitID, position=position, newItemID=item.ID))
Exemple #3
0
 def __handleModule(self, varItem):
     fitID = self.mainFrame.getActiveFit()
     fit = Fit.getInstance().getFit(fitID)
     if wx.GetMouseState().GetModifiers() == wx.MOD_ALT:
         positions = getSimilarModPositions(fit.modules, self.mainItem)
     else:
         sMkt = Market.getInstance()
         positions = []
         for mod in self.selection:
             if mod.isEmpty:
                 continue
             if mod is self.mainItem:
                 positions.append(fit.modules.index(mod))
                 continue
             if mod not in fit.modules:
                 continue
             modVariations = sMkt.getVariationsByItems((mod.item,))
             if modVariations == self.mainVariations:
                 positions.append(fit.modules.index(mod))
     self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleMetasCommand(
         fitID=fitID, positions=positions, newItemID=varItem.ID))