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: item = Market.getInstance().getItem(itemID, eager='group.category') if item is None: event.Skip() return batchOp = wx.GetMouseState( ).GetModifiers() == wx.MOD_ALT and getattr( event, 'allowBatch', None) is not False # If we've selected ammo, then apply to the selected module(s) if item.isCharge: positions = [] fit = Fit.getInstance().getFit(fitID) if batchOp: for position, mod in enumerate(fit.modules): if isinstance(mod, Module) and not mod.isEmpty: positions.append(position) else: for mod in self.getSelectedMods(): if mod.isEmpty or mod not in fit.modules: continue positions.append(fit.modules.index(mod)) if len(positions) > 0: self.mainFrame.command.Submit( cmd.GuiChangeLocalModuleChargesCommand( fitID=fitID, positions=positions, chargeItemID=itemID)) elif (item.isModule and not batchOp) or item.isSubsystem: self.mainFrame.command.Submit( cmd.GuiAddLocalModuleCommand(fitID=fitID, itemID=itemID)) elif item.isModule and batchOp: self.mainFrame.command.Submit( cmd.GuiFillWithNewLocalModulesCommand(fitID=fitID, itemID=itemID)) event.Skip()
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: item = Market.getInstance().getItem(itemID, eager='group.category') if item is None: event.Skip() return batchOp = wx.GetMouseState().GetModifiers() == wx.MOD_ALT and getattr(event, 'allowBatch', None) is not False if (item.isModule and not batchOp) or item.isSubsystem: self.mainFrame.command.Submit(cmd.GuiAddLocalModuleCommand(fitID=fitID, itemID=itemID)) elif item.isModule and batchOp: self.mainFrame.command.Submit(cmd.GuiFillWithNewLocalModulesCommand(fitID=fitID, itemID=itemID)) event.Skip()
def activate(self, callingWindow, fullContext, mainItem, i): self.mainFrame.command.Submit( cmd.GuiFillWithNewLocalModulesCommand( fitID=self.mainFrame.getActiveFit(), itemID=int(mainItem.ID)))
def addModule(self, x, y, itemID): """Add a module from the market browser (from dragging it)""" fitID = self.mainFrame.getActiveFit() item = Market.getInstance().getItem(itemID) fit = Fit.getInstance().getFit(fitID) dstRow, _ = self.HitTest((x, y)) if dstRow == -1 or dstRow in self.blanks: dstMod = None else: try: dstMod = self.mods[dstRow] except IndexError: dstMod = None if not isinstance(dstMod, Module): dstMod = None if dstMod not in fit.modules: dstMod = None dstPos = fit.modules.index(dstMod) if dstMod is not None else None mstate = wx.GetMouseState() # If we dropping on a module, try to replace, or add if replacement fails if item.isModule and dstMod is not None and not dstMod.isEmpty: positions = getSimilarModPositions( fit.modules, dstMod) if mstate.GetModifiers() == wx.MOD_ALT else [dstPos] command = cmd.GuiReplaceLocalModuleCommand(fitID=fitID, itemID=itemID, positions=positions) if not self.mainFrame.command.Submit(command): if mstate.GetModifiers() == wx.MOD_ALT: self.mainFrame.command.Submit( cmd.GuiFillWithNewLocalModulesCommand(fitID=fitID, itemID=itemID)) else: self.mainFrame.command.Submit( cmd.GuiAddLocalModuleCommand(fitID=fitID, itemID=itemID)) elif item.isModule: if mstate.GetModifiers() == wx.MOD_ALT: self.mainFrame.command.Submit( cmd.GuiFillWithNewLocalModulesCommand(fitID=fitID, itemID=itemID)) else: self.mainFrame.command.Submit( cmd.GuiAddLocalModuleCommand(fitID=fitID, itemID=itemID)) elif item.isSubsystem: self.mainFrame.command.Submit( cmd.GuiAddLocalModuleCommand(fitID=fitID, itemID=itemID)) elif item.isCharge: failoverToAll = False positionsAll = list(range(len(fit.modules))) if dstMod is None or dstMod.isEmpty: positions = positionsAll elif mstate.GetModifiers() == wx.MOD_ALT: positions = getSimilarModPositions(fit.modules, dstMod) failoverToAll = True else: positions = [fit.modules.index(dstMod)] if len(positions) > 0: command = cmd.GuiChangeLocalModuleChargesCommand( fitID=fitID, positions=positions, chargeItemID=itemID) if not self.mainFrame.command.Submit( command) and failoverToAll: self.mainFrame.command.Submit( cmd.GuiChangeLocalModuleChargesCommand( fitID=fitID, positions=positionsAll, chargeItemID=itemID))
def activate(self, fullContext, selection, i): self.mainFrame.command.Submit( cmd.GuiFillWithNewLocalModulesCommand( fitID=self.mainFrame.getActiveFit(), itemID=int(selection[0].ID))) self.mainFrame.additionsPane.select('Drones')