def appendItem(self, event): """ Adds items that are double clicks from the market browser. We handle both modules and ammo """ if not self: event.Skip() return if self.parent.IsActive(self): itemID = event.itemID fitID = self.activeFitID if fitID is not None: sFit = Fit.getInstance() if sFit.isAmmo(itemID): # If we've selected ammo, then apply to the selected module(s) modules = [] sel = self.GetFirstSelected() while sel != -1 and sel not in self.blanks: mod = self.mods[self.GetItemData(sel)] if isinstance(mod, Module) and not mod.isEmpty: modules.append(self.mods[self.GetItemData(sel)]) sel = self.GetNextSelected(sel) if len(modules) > 0: self.mainFrame.command.Submit(cmd.GuiModuleAddChargeCommand(fitID, itemID, modules)) else: self.mainFrame.command.Submit(cmd.GuiModuleAddCommand(fitID, itemID)) event.Skip()
def handleAmmoSwitch(self, event): charge = self.chargeIds.get(event.Id, False) if charge is False: event.Skip() return fitID = self.mainFrame.getActiveFit() self.mainFrame.command.Submit(cmd.GuiModuleAddChargeCommand(fitID, charge.ID if charge is not None else None, self.modules))
def activate(self, fullContext, selection, i): srcContext = fullContext[0] sFit = Fit.getInstance() fitID = self.mainFrame.getActiveFit() fit = sFit.getFit(fitID) if srcContext == "fittingModule": modules = [module for module in selection if module is not None] self.mainFrame.command.Submit( cmd.GuiModuleRemoveCommand(fitID, modules)) return # the command takes care of the PostEvent elif srcContext in ("fittingCharge", "projectedCharge"): self.mainFrame.command.Submit( cmd.GuiModuleAddChargeCommand(fitID, None, selection)) return elif srcContext == "droneItem": self.mainFrame.command.Submit( cmd.GuiRemoveDroneCommand(fitID, fit.drones.index(selection[0]))) return elif srcContext == "fighterItem": self.mainFrame.command.Submit( cmd.GuiRemoveFighterCommand(fitID, fit.fighters.index(selection[0]))) return # the command takes care of the PostEvent elif srcContext == "implantItem": self.mainFrame.command.Submit( cmd.GuiRemoveImplantCommand(fitID, fit.implants.index(selection[0]))) return # the command takes care of the PostEvent elif srcContext == "boosterItem": self.mainFrame.command.Submit( cmd.GuiRemoveBoosterCommand(fitID, fit.boosters.index(selection[0]))) return # the command takes care of the PostEvent elif srcContext == "cargoItem": self.mainFrame.command.Submit( cmd.GuiRemoveCargoCommand(fitID, selection[0].itemID)) return # the command takes care of the PostEvent elif srcContext in ("projectedFit", "projectedModule", "projectedDrone", "projectedFighter"): self.mainFrame.command.Submit( cmd.GuiRemoveProjectedCommand(fitID, selection[0])) return # the command takes care of the PostEvent elif srcContext == "commandFit": self.mainFrame.command.Submit( cmd.GuiRemoveCommandCommand(fitID, selection[0].ID)) return # the command takes care of the PostEvent wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
def handleAmmoSwitch(self, event): if len(self.modules) != 1: event.Skip() return charge = self.chargeIds.get(event.Id, False) if charge is False: event.Skip() return fitID = self.mainFrame.getActiveFit() fit = db_getFit(fitID) selectedModule = self.modules[0] source = fit.modules if not selectedModule.isProjected else fit.projectedModules allModules = [] for mod in source: if mod.itemID is None: continue if mod.itemID == selectedModule.itemID: allModules.append(mod) self.mainFrame.command.Submit(cmd.GuiModuleAddChargeCommand(fitID, charge.ID if charge is not None else None, allModules))