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 __handleBooster(self, varItem): fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) booster = self.mainItem if booster in fit.boosters: position = fit.boosters.index(booster) self.mainFrame.command.Submit(cmd.GuiChangeBoosterMetaCommand( fitID=fitID, position=position, newItemID=varItem.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))