def GetFighterTubesForShip(): myShip = GetActiveShip() dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation() LoadShipIfNecessary(dogmaLocation, myShip) numOfTubes = int( dogmaLocation.GetAttributeValue(myShip, const.attributeFighterTubes)) return numOfTubes
def GetGeneralActions(hasExtraOptions=True, itemID=None, bookmarkInfo=None, siteData=None): if itemID == GetActiveShip(): generalActions = [ SimpleRadialMenuAction(option1='UI/Inflight/StopMyShip', option2='UI/Inflight/StopMyCapsule'), GetOrbitOption(itemID, isMyShip=True), SecondLevelRadialMenuAction(hasExtraOptions=hasExtraOptions), GetKeepAtRangeOption(itemID, isMyShip=True), SimpleRadialMenuAction(option1='UI/Commands/OpenCargoHold'), SimpleRadialMenuAction(), SimpleRadialMenuAction(option1='UI/Commands/ShowInfo'), GetWarpToOption(itemID, bookmarkInfo=None, isMyShip=True) ] else: if siteData is not None: itemID = siteData.siteID generalActions = [ GetOrbitOption(itemID), SecondLevelRadialMenuAction(hasExtraOptions=hasExtraOptions), GetKeepAtRangeOption(itemID), SimpleRadialMenuAction(option1='UI/Inflight/LockTarget', option2='UI/Inflight/UnlockTarget'), GetApproachOption(bookmarkInfo, siteData), SimpleRadialMenuAction(option1='UI/Commands/ShowInfo'), GetWarpToOption(itemID, bookmarkInfo, siteData=siteData) ] return generalActions
def IsSellable(self, item): sellable = True if item.itemID in self.itemDict.keys(): self.itemAlreadyInList.append(item) sellable = False elif item.singleton: self.itemsNeedRepackaging.append(item) sellable = False elif IsStation(item.itemID): self.cannotSellItemList.append(item) sellable = False elif cfg.invtypes.Get(item.typeID).marketGroupID is None: self.cannotSellItemList.append(item) sellable = False elif item.ownerID not in [session.corpid, session.charid]: self.cannotSellItemList.append(item) sellable = False elif item.itemID == GetActiveShip(): self.cannotSellItemList.append(item) sellable = False elif bool( item.singleton) and item.categoryID == const.categoryBlueprint: self.cannotSellItemList.append(item) sellable = False elif not CheckIfInHangarOrCorpHangarAndCanTake(item): self.cannotSellItemList.append(item) sellable = False return sellable
def GetObjectsActions(categoryID, groupID, typeID=None, itemID=None, bookmarkInfo=None, siteData=None, *args): secondaryActions = GetObjectsSecondaryActions(categoryID, groupID, typeID=typeID, itemID=itemID, bookmarkInfo=bookmarkInfo, siteData=siteData) generalActions = GetGeneralActions(hasExtraOptions=bool(secondaryActions), itemID=itemID, bookmarkInfo=bookmarkInfo, siteData=siteData) myActions = generalActions[:] if itemID == GetActiveShip(): return myActions primaryComponentActions = GetSpaceComponentPrimaryActionsForTypeID(typeID) groupActions = primaryGroupActions.get(groupID, None) categoryActions = primaryCategoryActions.get(categoryID, None) siteActions = siteData.GetSiteActions() if siteData else None if primaryComponentActions: primaryActions = primaryComponentActions elif siteActions: primaryActions = siteActions elif groupActions: primaryActions = groupActions elif categoryActions: primaryActions = categoryActions else: primaryActions = [SimpleRadialMenuAction()] return primaryActions + myActions
def OnClick(self, *args): LeftSideButton.OnClick(self) shipID = GetActiveShip() if shipID is None: return uicore.layer.shipui.fighterCont.SelectAll() sm.GetService('fighters').RecallAllFightersToTubes()
def CreateCurrentShipCont(self): self.shipCont.Flush() Frame(parent=self.shipCont, color=(1, 1, 1, 0.1)) activeShip = GetActiveShip() clientDogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation() shipDogmaItem = clientDogmaLocation.GetShip() shipTypeID = shipDogmaItem.typeID icon = Icon(parent=self.shipCont, pos=(0, 0, 40, 40), ignoreSize=True, state=uiconst.UI_DISABLED) if self.fittingSvc.IsShipSimulated(): self.shipCont.OnClick = self.ExitSimulation icon.LoadIconByTypeID(shipTypeID) else: self.shipCont.OnClick = self.LoadCurrentShip hologramTexture = inventorycommon.typeHelpers.GetHoloIconPath( shipTypeID) icon.LoadTexture(hologramTexture) shipName = cfg.evelocations.Get(activeShip).name text = '%s<br>%s' % (evetypes.GetName(shipTypeID), shipName) self.shipnametext = EveLabelMedium(text=text, parent=self.shipCont, align=uiconst.TOTOP, top=2, padLeft=48)
def GetObjectsSecondaryActions(categoryID, groupID, typeID=None, itemID=None, bookmarkInfo=None, siteData=None): """ this function returns all the secondary options we want for this category/group. It's different from GetObjectsActions in the sense that it will collect all the options, while GetObjectsActions only retuns the action from a group OR category """ myActions = [] categoryActions = secondaryCategoryActions.get(categoryID, None) if categoryActions: myActions += categoryActions groupActions = secondaryGroupActions.get(groupID, None) if groupActions: myActions += groupActions if itemID == GetActiveShip() and session.solarsystemid: myActions += GetMyShipSpecialCaseSecondLevel(typeID=typeID, itemID=itemID) secondaryComponentActions = GetSpaceComponentSecondaryActions(typeID) if secondaryComponentActions: myActions += secondaryComponentActions if siteData: myActions.extend(siteData.GetSecondaryActions()) if myActions: myActions = [SecondLevelRadialMenuAction(hasExtraOptions=False) ] + myActions return myActions
def GetGeneralActions(hasExtraOptions=True, itemID=None, bookmarkInfo=None, siteData=None): """ defaults, and range could have changed since this was generated, so we always make this list again This returns actions for slots 2-8 (the first one is base don group/category/type) """ if itemID == GetActiveShip(): generalActions = [ SimpleRadialMenuAction(option1='UI/Inflight/StopMyShip', option2='UI/Inflight/StopMyCapsule'), GetOrbitOption(itemID, isMyShip=True), SecondLevelRadialMenuAction(hasExtraOptions=hasExtraOptions), GetKeepAtRangeOption(itemID, isMyShip=True), SimpleRadialMenuAction(option1='UI/Commands/OpenCargoHold'), SimpleRadialMenuAction(), SimpleRadialMenuAction(option1='UI/Commands/ShowInfo'), GetWarpToOption(itemID, bookmarkInfo=None, isMyShip=True) ] else: if siteData is not None: itemID = siteData.siteID generalActions = [ GetOrbitOption(itemID), SecondLevelRadialMenuAction(hasExtraOptions=hasExtraOptions), GetKeepAtRangeOption(itemID), SimpleRadialMenuAction(option1='UI/Inflight/LockTarget', option2='UI/Inflight/UnlockTarget'), GetApproachOption(bookmarkInfo, siteData), SimpleRadialMenuAction(option1='UI/Commands/ShowInfo'), GetWarpToOption(itemID, bookmarkInfo, siteData=siteData) ] return generalActions
def GetObjectsSecondaryActions(categoryID, groupID, typeID=None, itemID=None, bookmarkInfo=None, siteData=None): myActions = [] categoryActions = secondaryCategoryActions.get(categoryID, None) if categoryActions: myActions += categoryActions groupActions = secondaryGroupActions.get(groupID, None) if groupActions: myActions += groupActions if itemID == GetActiveShip() and session.solarsystemid: myActions += GetMyShipSpecialCaseSecondLevel(typeID=typeID, itemID=itemID) secondaryComponentActions = GetSpaceComponentSecondaryActions(typeID) if secondaryComponentActions: myActions += secondaryComponentActions if siteData: myActions.extend(siteData.GetSecondaryActions()) if myActions: myActions = [SecondLevelRadialMenuAction(hasExtraOptions=False) ] + myActions return myActions
def GetLightSupportHeavySlotsForShip(): myShip = GetActiveShip() dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation() LoadShipIfNecessary(dogmaLocation, myShip) lightSlots = GetShipLightSlots(dogmaLocation, myShip) supportSlots = GetShipSupportSlots(dogmaLocation, myShip) heavySlots = GetShipHeavySlots(dogmaLocation, myShip) return (lightSlots, supportSlots, heavySlots)
def OnClick(self, *args): LeftSideButton.OnClick(self) shipID = GetActiveShip() if shipID is None: return Inventory.OpenOrShow((self.invIDText, shipID), usePrimary=False, toggle=True)
def IsValid(self, item): activeShipID = GetActiveShip() if item.flagID == const.flagReward: return False if item.groupID == const.groupMineral: return False if item.itemID in (activeShipID, session.charid): return False return True
def GetFittingDragData(): fittingSvc = sm.StartService('fittingSvc') fitting = KeyVal() fitting.shipTypeID, fitting.fitData = fittingSvc.GetFittingDictForCurrentFittingWindowShip( ) fitting.fittingID = None fitting.description = '' fitting.name = cfg.evelocations.Get(GetActiveShip()).locationName fitting.ownerID = 0 if fittingSvc.IsShipSimulated(): fitting.name = '.simulated %s' % evetypes.GetName(fitting.shipTypeID) else: fitting.name = cfg.evelocations.Get(GetActiveShip()).locationName entry = KeyVal() entry.fitting = fitting entry.label = fitting.name entry.displayText = fitting.name entry.__guid__ = 'listentry.FittingEntry' return [entry]
def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.MakeUnResizeable() self.HideHeaderFill() self.windowReady = False self.controller = None self._layoutLock = locks.Lock() shipID = attributes.shipID or GetActiveShip() self.LoadController(shipID) self.LoadWnd()
def GetNumberOfSlaves(self, moduleInfoItem, ownerGuid): myShip = GetActiveShip() if ownerGuid in ('xtriui.FittingSlot2', 'xtriui.FittingSlotGhost'): return 0 else: slaves = self.dogmaLocation.GetSlaveModules( moduleInfoItem.itemID, myShip) if slaves: numSlaves = len(slaves) + 1 else: numSlaves = 0 return numSlaves
def GetFittingForCurrentInWnd(self, putModuleAmmoInHangar = True): fitting = KeyVal() fitting.shipTypeID, fitting.fitData = self.GetFittingDictForCurrentFittingWindowShip(putModuleAmmoInHangar=putModuleAmmoInHangar) fitting.fittingID = None fitting.description = '' fitting.ownerID = 0 typeName = evetypes.GetName(fitting.shipTypeID) if self.inSimulation: shipName = name = 'simulated %s' % typeName else: shipName = cfg.evelocations.Get(GetActiveShip()).locationName fitting.name = shipName return fitting
def AddCurrentShip(self): activeShipID = GetActiveShip() if not activeShipID: return inv = sm.GetService('invCache').GetInventoryFromId(activeShipID) item = inv.GetItem() shipName = GetShowInfoLink(item.typeID, cfg.evelocations.Get(activeShipID).name, itemID=activeShipID) self.ownerLabel = EveLabelMedium(name='ownerLabel', parent=self.sr.main, text=shipName, padLeft=10, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) texturePath = evetypes.inventorycommon.typeHelpers.GetHoloIconPath(item.typeID) cont = Container(parent=self.sr.main, name='shipCont', align=uiconst.TOTOP, height=128) sprite = Sprite(name='shipSprite', parent=cont, pos=(0, 0, 128, 128), align=uiconst.CENTER, texturePath=texturePath) sprite.GetMenu = (self.GetShipMenu, item) sprite.OnDblClick = self.DoubleClickShip
def AddPropulsionModuleInfo(self, itemID, chargeInfoItem): myShip = GetActiveShip() myMaxVelocity = self.dogmaLocation.GetAttributeValue( myShip, const.attributeMaxVelocity) speedFactor = self.GetEffectiveAttributeValue( itemID, const.attributeSpeedFactor) speedBoostFactor = self.GetEffectiveAttributeValue( itemID, const.attributeSpeedBoostFactor) mass = self.dogmaLocation.GetAttributeValue(myShip, const.attributeMass) massAddition = self.dogmaLocation.GetAttributeValue( itemID, const.attributeMassAddition) maxVelocityWithBonus = myMaxVelocity * ( 1 + speedBoostFactor * speedFactor * 0.01 / (massAddition + mass)) text = localization.GetByLabel( 'UI/Inflight/ModuleRacks/Tooltips/MaxVelocityWithAndWithoutPropulsion', maxVelocity=myMaxVelocity, maxVelocityWithBonus=maxVelocityWithBonus) iconID = cfg.dgmattribs.Get(const.attributeMaxVelocity).iconID self.AddRowWithIconAndText(text=text, iconID=iconID)
def GetModuleShortcut(self, moduleInfoItem): moduleShortcut = None masterModuleID = self.dogmaLocation.GetMasterModuleID( GetActiveShip(), moduleInfoItem.itemID) if masterModuleID is not None: masterModuleInfoItem = self.dogmaLocation.GetDogmaItem( masterModuleID) flagID = masterModuleInfoItem.flagID else: flagID = moduleInfoItem.flagID slotOrder = shipHud.GetSlotOrder() if flagID not in slotOrder: return pos = slotOrder.index(flagID) if pos is not None: row = pos / 8 hiMedLo = ('High', 'Medium', 'Low')[row] loc = pos % 8 slotno = loc + 1 shortcut = uicore.cmd.GetShortcutStringByFuncName( 'CmdActivate%sPowerSlot%i' % (hiMedLo, slotno)) if shortcut: moduleShortcut = shortcut return moduleShortcut
def ToggleGhostFitting(self, *args): fittingSvc = sm.GetService('fittingSvc') ghostFittingSvc = sm.GetService('ghostFittingSvc') isSimulated = fittingSvc.IsShipSimulated() self.ghostFittingSwitch.state = uiconst.UI_DISABLED if isSimulated: fittingSvc.SetSimulationState(False) shipID = GetActiveShip() newTypeID = GetTypeIDForController(shipID) ghostFittingSvc.SendOnSimulatedShipLoadedEvent(shipID, newTypeID) self.ChangeSimulateUIstate(False) else: fittingDL = sm.GetService( 'clientDogmaIM').GetFittingDogmaLocation() shipItem = fittingDL.GetShip() if shipItem: fittingSvc.SetSimulationState(True) ghostFittingSvc.SendOnSimulatedShipLoadedEvent( shipItem.itemID, shipItem.typeID) else: ghostFittingSvc.LoadCurrentShip() newState = not isSimulated self.ChangeSimulateUIstate(newState) self.controller.OnSimulationStateChanged(newState)
def TryFit(invItems, shipID=None): if not shipID: shipID = GetActiveShip() if not shipID: return godma = sm.services['godma'] invCache = sm.GetService('invCache') shipInv = invCache.GetInventoryFromId(shipID, locationID=session.stationid2) godmaSM = godma.GetStateManager() useRigs = None charges = set() drones = [] subSystemGroupIDs = set() for invItem in invItems[:]: if IsFittingModule(invItem.categoryID): moduleEffects = cfg.dgmtypeeffects.get(invItem.typeID, []) for mEff in moduleEffects: if mEff.effectID == const.effectRigSlot: if useRigs is None: useRigs = True if RigFittingCheck(invItem) else False if not useRigs: invItems.remove(invItem) invCache.UnlockItem(invItem.itemID) break if invItem.categoryID == const.categorySubSystem: if invItem.groupID in subSystemGroupIDs: invItems.remove(invItem) else: subSystemGroupIDs.add(invItem.groupID) elif invItem.categoryID == const.categoryCharge: charges.add(invItem) invItems.remove(invItem) elif invItem.categoryID == const.categoryDrone: drones.append(invItem) invItems.remove(invItem) if len(invItems) > 0: shipInv.moniker.MultiAdd([invItem.itemID for invItem in invItems], invItems[0].locationID, flag=const.flagAutoFit) if charges: shipStuff = shipInv.List() shipStuff.sort(key=lambda r: (r.flagID, isinstance(r.itemID, tuple))) loadedSlots = set() if drones: invCtrl.ShipDroneBay(shipID or GetActiveShip()).AddItems(drones) dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation() shipDogmaItem = dogmaLocation.dogmaItems.get(shipID, None) loadedSomething = False for DBRowInvItem in charges: invItem = KeyVal(DBRowInvItem) chargeDgmType = godmaSM.GetType(invItem.typeID) isCrystalOrScript = invItem.groupID in cfg.GetCrystalGroups() for row in shipStuff: if row in loadedSlots: continue if not IsShipFittingFlag(row.flagID): continue if dogmaLocation.IsInWeaponBank( row.locationID, row.itemID) and dogmaLocation.IsModuleSlave( row.itemID, row.locationID): continue if row.categoryID == const.categoryCharge: continue moduleDgmType = godmaSM.GetType(row.typeID) desiredSize = getattr(moduleDgmType, 'chargeSize', None) for x in xrange(1, 5): chargeGroup = getattr(moduleDgmType, 'chargeGroup%d' % x, False) if not chargeGroup: continue if chargeDgmType.groupID != chargeGroup: continue if desiredSize and getattr(chargeDgmType, 'chargeSize', -1) != desiredSize: continue for i, squatter in enumerate( [i for i in shipStuff if i.flagID == row.flagID]): if isCrystalOrScript and i > 0: break if shipDogmaItem is None: continue subLocation = dogmaLocation.GetSubLocation( shipID, squatter.flagID) if subLocation is None: continue chargeVolume = chargeDgmType.volume * dogmaLocation.GetAttributeValue( subLocation, const.attributeQuantity) if godmaSM.GetType(row.typeID).capacity <= chargeVolume: break else: moduleCapacity = godmaSM.GetType(row.typeID).capacity numCharges = moduleCapacity / chargeDgmType.volume subLocation = dogmaLocation.GetSubLocation( shipID, row.flagID) if subLocation: numCharges -= dogmaLocation.GetAttributeValue( subLocation, const.attributeQuantity) dogmaLocation.LoadAmmoToModules(shipID, [row.itemID], invItem.typeID, invItem.itemID, invItem.locationID) loadedSomething = True invItem.stacksize -= numCharges loadedSlots.add(row) blue.pyos.synchro.SleepWallclock(100) break else: continue if invItem.stacksize <= 0: break else: if not loadedSomething: uicore.Message('NoSuitableModules')
def ReloadFittingDogmaLocation(self): sm.GetService('ghostFittingSvc').ResetFittingDomaLocation(force=True) sm.GetService('fittingSvc').SetSimulationState(simulationOn=False) itemID = GetActiveShip() self.OnControllerChanging(itemID)
def LoadController(self, attributes): itemID = attributes.shipID or GetActiveShip() return GetFittingController(itemID)
def ExitSimulation(self, *args): sm.GetService('fittingSvc').SetSimulationState(False) shipID = GetActiveShip() sm.GetService('ghostFittingSvc').SendOnSimulatedShipLoadedEvent( shipID, None)
def GetItemID(self): return GetActiveShip()
def LoadTypeRequirements(self, typeID): if self.typeID is not None: self.Flush() self.typeID = typeID if typeID is None: return invType = cfg.invtypes.Get(typeID) isSkill = invType.categoryID == invconst.categorySkill haveSkill = sm.GetService('skills').GetMySkillsFromTypeID( typeID) is not None requiredSkills = sm.GetService( 'clientDogmaStaticSvc').GetRequiredSkills(typeID) if isSkill and haveSkill: SkillLevels(parent=self, align=uiconst.NOALIGN, typeID=typeID, groupID=invType.groupID) elif requiredSkills: texturePath, hint = sm.GetService( 'skills').GetRequiredSkillsLevelTexturePathAndHint( requiredSkills.items(), typeID=typeID) skillIcon = Sprite(name='skillIcon', parent=self, align=uiconst.NOALIGN, width=ICON_SIZE, height=ICON_SIZE, texturePath=texturePath, hint=hint, useSizeFromTexture=False) skillSvc = sm.GetService('skills') if any((skillSvc.IsTrialRestricted(typeID) for typeID in requiredSkills.keys())): def OpenSubscriptionPage(): reasonCategory = { invconst.categoryShip: 'ship', invconst.categorySkill: 'skill' }.get(types.GetCategoryID(typeID), 'item') reason = ':'.join([reasonCategory, str(typeID)]) uicore.cmd.OpenSubscriptionPage(origin=ORIGIN_MARKET, reason=reason) skillIcon.OnClick = OpenSubscriptionPage else: def OpenRequirementsInfoTab(): info = sm.GetService('info') info.ShowInfo(typeID, selectTabType=infoConst.TAB_REQUIREMENTS) skillIcon.OnClick = OpenRequirementsInfoTab isModule = invType.categoryID == invconst.categoryModule if isModule: godma = sm.GetService('godma') dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation() shipID = GetActiveShip() powerContainer = ContainerAutoSize(parent=self, align=uiconst.NOALIGN) modulePowerLoad = godma.GetTypeAttribute(typeID, dconst.attributePower, 0) powerOutput = dogmaLocation.GetAttributeValue( shipID, dconst.attributePowerOutput) - dogmaLocation.GetAttributeValue( shipID, dconst.attributePowerLoad) havePower = shipID is not None and powerOutput > modulePowerLoad icon = [ 'res:/UI/Texture/classes/Market/powerRequirementNotMet.png', 'res:/UI/Texture/classes/Market/powerRequirementMet.png' ][havePower] hint = [ 'UI/Market/Marketbase/PowerRequirementNotMet', 'UI/Market/Marketbase/PowerRequirementMet' ][havePower] powerIcon = Sprite(parent=powerContainer, align=uiconst.CENTERTOP, texturePath=icon, width=ICON_SIZE, height=ICON_SIZE, ignoreSize=True, hint=localization.GetByLabel(hint)) powerLabel = EveLabelSmallBold(parent=powerContainer, align=uiconst.CENTERTOP, top=ICON_SIZE + 2, text=int(modulePowerLoad)) cpuContainer = ContainerAutoSize(parent=self, align=uiconst.NOALIGN) moduleCpuLoad = godma.GetTypeAttribute(typeID, dconst.attributeCpu, 0) cpuOutput = dogmaLocation.GetAttributeValue( shipID, dconst.attributeCpuOutput) - dogmaLocation.GetAttributeValue( shipID, dconst.attributeCpuLoad) haveCpu = shipID is not None and cpuOutput > moduleCpuLoad icon = [ 'res:/UI/Texture/classes/Market/cpuRequirementNotMet.png', 'res:/UI/Texture/classes/Market/cpuRequirementMet.png' ][haveCpu] hint = [ 'UI/Market/Marketbase/CpuRequirementNotMet', 'UI/Market/Marketbase/CpuRequirementMet' ][haveCpu] cpuIcon = Sprite(parent=cpuContainer, align=uiconst.CENTERTOP, texturePath=icon, ignoreSize=True, width=ICON_SIZE, height=ICON_SIZE, hint=localization.GetByLabel(hint)) cpuLabel = EveLabelSmallBold(parent=cpuContainer, align=uiconst.CENTERTOP, top=ICON_SIZE + 2, text=int(moduleCpuLoad))