def handleMode(self, event): ability = self.abilityIds[event.Id] if ability is False or ability not in self.fighter.abilities: event.Skip() return fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if self.isProjected: container = fit.projectedFighters command = cmd.GuiToggleProjectedFighterAbilityStateCommand else: container = fit.fighters command = cmd.GuiToggleLocalFighterAbilityStateCommand if self.fighter in container: mainPosition = container.index(self.fighter) if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fighters = getSimilarFighters(container, self.fighter) else: fighters = self.selection positions = [] for fighter in fighters: if fighter in container: positions.append(container.index(fighter)) self.mainFrame.command.Submit(command( fitID=fitID, mainPosition=mainPosition, positions=positions, effectID=ability.effectID))
def click(self, event): mainRow, _ = self.HitTest(event.Position) if mainRow != -1: col = self.getColumn(event.Position) if col == self.getColIndex(State): mainItem = self.get(mainRow) if mainItem is None: return selection = self.getSelectedProjectors() if mainItem not in selection: selection = [mainItem] modPressed = wx.GetMouseState().GetModifiers() == wx.MOD_ALT fitID = self.mainFrame.getActiveFit() if isinstance(mainItem, EosModule) and modPressed: fit = Fit.getInstance().getFit(fitID) positions = getSimilarModPositions(fit.projectedModules, mainItem) selection = [fit.projectedModules[p] for p in positions] elif isinstance(mainItem, EosFighter) and modPressed: fit = Fit.getInstance().getFit(fitID) selection = getSimilarFighters(fit.projectedFighters, mainItem) self.mainFrame.command.Submit(cmd.GuiChangeProjectedItemStatesCommand( fitID=fitID, mainItem=mainItem, items=selection, click='right' if event.GetButton() == 3 else 'left')) return event.Skip()
def click(self, event): mainRow, _ = self.HitTest(event.Position) if mainRow != -1: col = self.getColumn(event.Position) if col == self.getColIndex(State): fitID = self.mainFrame.getActiveFit() try: mainFighter = self.fighters[mainRow] except IndexError: return if mainFighter in self.original: mainPosition = self.original.index(mainFighter) positions = [] if event.GetModifiers() == wx.MOD_ALT: for fighter in getSimilarFighters(self.original, mainFighter): positions.append(self.original.index(fighter)) else: for row in self.getSelectedRows(): try: fighter = self.fighters[row] except IndexError: continue if fighter in self.original: positions.append(self.original.index(fighter)) if mainPosition not in positions: positions = [mainPosition] self.mainFrame.command.Submit(cmd.GuiToggleLocalFighterStatesCommand( fitID=fitID, mainPosition=mainPosition, positions=positions)) return event.Skip()
def __handleProjectedItem(self, mainItem, selection): fitID = self.mainFrame.getActiveFit() if isinstance(mainItem, EosFit): self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=selection, amount=math.inf)) elif isinstance(mainItem, EosModule): if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fit = Fit.getInstance().getFit(fitID) positions = getSimilarModPositions(fit.projectedModules, mainItem) items = [fit.projectedModules[p] for p in positions] else: items = selection self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=items, amount=math.inf)) elif isinstance(mainItem, EosDrone): self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=selection, amount=math.inf)) elif isinstance(mainItem, EosFighter): if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fit = Fit.getInstance().getFit(fitID) items = getSimilarFighters(fit.projectedFighters, mainItem) else: items = selection self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=items, amount=math.inf)) else: self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=selection, amount=math.inf))
def __handleFighter(self, mainItem, selection): fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fighters = getSimilarFighters(fit.fighters, mainItem) else: fighters = selection positions = [] for fighter in fighters: if fighter in fit.fighters: positions.append(fit.fighters.index(fighter)) self.mainFrame.command.Submit(cmd.GuiRemoveLocalFightersCommand( fitID=fitID, positions=positions))
def onLeftDoubleClick(self, event): row, _ = self.HitTest(event.Position) if row != -1: col = self.getColumn(event.Position) if col != self.getColIndex(State): mstate = wx.GetMouseState() try: fighter = self.fighters[row] except IndexError: return if mstate.GetModifiers() == wx.MOD_ALT: fighters = getSimilarFighters(self.original, fighter) else: fighters = [fighter] self.removeFighters(fighters)
def __handleProjectedFighter(self, varItem): fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fighters = getSimilarFighters(fit.projectedFighters, self.mainItem) else: fighters = self.selection sMkt = Market.getInstance() positions = [] for fighter in fighters: if fighter not in fit.projectedFighters: continue if fighter is self.mainItem: positions.append(fit.projectedFighters.index(fighter)) continue fighterVariations = sMkt.getVariationsByItems((fighter.item,)) if fighterVariations == self.mainVariations: positions.append(fit.projectedFighters.index(fighter)) self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterMetasCommand( fitID=fitID, positions=positions, newItemID=varItem.ID))
def __handleProjectedFighter(self, varItem): fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fighters = getSimilarFighters(fit.projectedFighters, self.mainItem) else: fighters = self.selection sMkt = Market.getInstance() positions = [] for fighter in fighters: if fighter not in fit.projectedFighters: continue if fighter is self.mainItem: positions.append(fit.projectedFighters.index(fighter)) continue fighterVariations = sMkt.getVariationsByItems((fighter.item, )) if fighterVariations == self.mainVariations: positions.append(fit.projectedFighters.index(fighter)) self.mainFrame.command.Submit( cmd.GuiChangeProjectedFighterMetasCommand(fitID=fitID, positions=positions, newItemID=varItem.ID))
def __handleProjectedItem(self, callingWindow, mainItem, selection): fitID = self.mainFrame.getActiveFit() if isinstance(mainItem, EosFit): self.mainFrame.command.Submit( cmd.GuiRemoveProjectedItemsCommand(fitID=fitID, items=selection, amount=math.inf)) elif isinstance(mainItem, EosModule): if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fit = Fit.getInstance().getFit(fitID) positions = getSimilarModPositions(fit.projectedModules, mainItem) items = [fit.projectedModules[p] for p in positions] else: items = selection self.mainFrame.command.Submit( cmd.GuiRemoveProjectedItemsCommand(fitID=fitID, items=items, amount=math.inf)) elif isinstance(mainItem, EosDrone): self.mainFrame.command.Submit( cmd.GuiRemoveProjectedItemsCommand(fitID=fitID, items=selection, amount=math.inf)) elif isinstance(mainItem, EosFighter): if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fit = Fit.getInstance().getFit(fitID) items = getSimilarFighters(fit.projectedFighters, mainItem) else: items = selection self.mainFrame.command.Submit( cmd.GuiRemoveProjectedItemsCommand(fitID=fitID, items=items, amount=math.inf)) else: self.mainFrame.command.Submit( cmd.GuiRemoveProjectedItemsCommand(fitID=fitID, items=selection, amount=math.inf))
def activate(self, callingWindow, fullContext, mainItem, selection, i): fitID = self.mainFrame.getActiveFit() if isinstance(mainItem, EosFit): try: value = mainItem.getProjectionInfo(fitID).projectionRange except AttributeError: return else: value = mainItem.projectionRange if value is not None: value /= 1000 with RangeChanger(self.mainFrame, value) as dlg: if dlg.ShowModal() == wx.ID_OK: cleanInput = re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip()) if cleanInput: try: cleanInputFloat = float(cleanInput) except ValueError: return newRange = cleanInputFloat * 1000 else: newRange = None fitID = self.mainFrame.getActiveFit() items = selection if wx.GetMouseState().GetModifiers() in (wx.MOD_ALT, wx.MOD_CONTROL): if isinstance(mainItem, EosModule): fit = Fit.getInstance().getFit(fitID) positions = getSimilarModPositions( fit.projectedModules, mainItem) items = [fit.projectedModules[p] for p in positions] elif isinstance(mainItem, EosFighter): fit = Fit.getInstance().getFit(fitID) items = getSimilarFighters(fit.projectedFighters, mainItem) self.mainFrame.command.Submit( cmd.GuiChangeProjectedItemsProjectionRangeCommand( fitID=fitID, items=items, projectionRange=newRange))
def onLeftDoubleClick(self, event): row, _ = self.HitTest(event.Position) if row != -1: col = self.getColumn(event.Position) if col != self.getColIndex(State): mainItem = self.get(row) if mainItem is None: return fitID = self.mainFrame.getActiveFit() modPressed = wx.GetMouseState().GetModifiers() == wx.MOD_ALT if isinstance(mainItem, EosFit): self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=[mainItem], amount=math.inf if modPressed else 1)) elif isinstance(mainItem, EosModule): if modPressed: fit = Fit.getInstance().getFit(fitID) positions = getSimilarModPositions(fit.projectedModules, mainItem) items = [fit.projectedModules[p] for p in positions] else: items = [mainItem] self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=items, amount=1)) elif isinstance(mainItem, EosDrone): self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=[mainItem], amount=math.inf if modPressed else 1)) elif isinstance(mainItem, EosFighter): if modPressed: fit = Fit.getInstance().getFit(fitID) items = getSimilarFighters(fit.projectedFighters, mainItem) else: items = [mainItem] self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=items, amount=1)) else: self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand( fitID=fitID, items=[mainItem], amount=math.inf if modPressed else 1))