def UpdateText(self): context = self.previewContainer.context if not hasattr(context, 'typeID'): return groupID = evetypes.GetGroupID(context.typeID) categoryID = evetypes.GetCategoryID(context.typeID) title = evetypes.GetName(context.typeID) if hasattr(context, 'itemID'): bp = sm.GetService('michelle').GetBallpark() if bp: slim = bp.GetInvItem(context.itemID) if slim: title = slim.name self.title.text = title subtitle = '' if categoryID != invconst.categoryApparel: scene = self.previewContainer.sceneContainer.scene model = first_or_default(getattr(scene, 'objects', []), None) if model: radius = round(model.GetBoundingSphereRadius() * 2, 0) if groupID in invconst.turretModuleGroups or groupID in invconst.turretAmmoGroups: subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabelNoRace', groupName=evetypes.GetGroupName(context.typeID), length=FmtDist(radius)) else: raceID = evetypes.GetRaceID(context.typeID) race = cfg.races.Get( raceID) if raceID in cfg.races else None if race is None: subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabelNoRace', groupName=evetypes.GetGroupName(context.typeID), length=FmtDist(radius)) else: raceName = localization.GetByMessageID(race.raceNameID) subtitle = localization.GetByLabel( 'UI/Preview/ShipSubLabel', raceName=raceName, groupName=evetypes.GetGroupName(context.typeID), length=FmtDist(radius)) self.subtitle.text = subtitle if categoryID == invconst.categoryApparel: self.descCont.Show() description = evetypes.GetDescription(context.typeID) or '' description = re.sub('<b>|</b>|\\r', '', description) description = re.sub('\\n', '<br>', description) self.desc.text = description
def CheckCanFitType(dogmaLocation, typeID, locationID): maxGroupFitted = dogmaLocation.dogmaStaticMgr.GetTypeAttribute( typeID, const.attributeMaxGroupFitted) if maxGroupFitted: groupID = evetypes.GetGroupID(typeID) modulesByGroup = dogmaLocation.GetModuleListByShipGroup( locationID, groupID) if len(modulesByGroup) >= maxGroupFitted: shipItem = dogmaLocation.dogmaItems[locationID] raise UserError( 'CantFitTooManyByGroup', { 'ship': shipItem.typeID, 'module': typeID, 'groupName': evetypes.GetGroupName(typeID), 'noOfModules': int(maxGroupFitted), 'noOfModulesFitted': len(modulesByGroup) }) maxTypeFitted = dogmaLocation.dogmaStaticMgr.GetTypeAttribute( typeID, const.attributeMaxTypeFitted) if maxTypeFitted: modulesByType = dogmaLocation.GetModuleListByShipType( locationID, typeID) if len(modulesByType) >= maxTypeFitted: shipItem = dogmaLocation.dogmaItems[locationID] raise UserError( 'CantFitTooManyByType', { 'ship': shipItem.typeID, 'module': typeID, 'noOfModules': int(maxTypeFitted), 'noOfModulesFitted': len(modulesByType) })
def AddLayout(self): pad = const.defaultPadding uicontrols.WndCaptionLabel(text=evetypes.GetGroupName(self.typeID), subcaption=localization.GetByLabel('UI/UpgradeWindow/TypeUpgradesTo', type1=self.typeID, type2=self.GetUpgradeTypeID()), parent=self.sr.topParent, align=uiconst.RELATIVE) uicontrols.Icon(parent=self.sr.topParent, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(0, 0, 64, 64), padding=(pad, pad, pad, pad), typeID=self.typeID) self.sr.footer = uiprimitives.Container(name='footer', parent=self.sr.main, align=uiconst.TOBOTTOM, pos=(0, 0, 0, 25), padding=(pad, pad, pad, pad)) uiprimitives.Line(align=uiconst.TOBOTTOM, parent=self.sr.main) self.sr.iconContainer = uiprimitives.Container(name='iconContainer', parent=self.sr.main, align=uiconst.TOALL, padding=(pad + 5, pad + 5, 0, 0), columns=4) self.sr.iconContainer.OnDropData = self.OnDropData self.sr.iconContainer.OnDragEnter = self.OnDragEnter self.sr.iconContainer.OnDragExit = self.OnDragExit btns = [(localization.GetByLabel('UI/UpgradeWindow/StartUpgrade'), self.InitiateUpgrade, (), None)] self.buttons = btns = uicontrols.ButtonGroup(btns=btns, parent=self.sr.footer, line=0) self.transferBtn = btns.GetBtnByIdx(0)
def GetShipsAndGroups(self, filterTextLower, fittings): fittingsByGroupID = defaultdict(list) fittingsByGroupAndRaceIDs = defaultdict(lambda: defaultdict(set)) if not fittings: shipGroups, shipsByGroupID, shipsByGroupAndRaceIDs = self.GetAllShipGroupsAndShipsByGroupID( filterTextLower) else: shipGroups = set() shipsByGroupID = defaultdict(set) shipsByGroupAndRaceIDs = defaultdict(lambda: defaultdict(set)) for fittingID, fitting in fittings.iteritems(): shipTypeID = fitting.shipTypeID if not evetypes.Exists(shipTypeID): log.LogError( 'Ship in stored fittings does not exist, shipID=%s, fittingID=%s' % (shipTypeID, fittingID)) continue groupID = evetypes.GetGroupID(shipTypeID) fittingsByGroupID[groupID].append(fitting) groupName = evetypes.GetGroupName(shipTypeID) shipGroups.add((groupName, groupID)) raceID = evetypes.GetRaceID(shipTypeID) shipsByGroupAndRaceIDs[groupID][raceID].add(shipTypeID) fittingsByGroupAndRaceIDs[groupID][raceID].add(fitting) return (fittingsByGroupID, shipsByGroupID, shipGroups, shipsByGroupAndRaceIDs, fittingsByGroupAndRaceIDs)
def ExportLootHistory(self): lootHistory = sm.GetService('fleet').GetLootHistory() rows = [] for kv in lootHistory: row = [ FmtDate(kv.time, 'ss'), cfg.eveowners.Get(kv.charID).name, evetypes.GetName(kv.typeID), kv.quantity, evetypes.GetGroupName(kv.typeID) ] rows.append(row) fileNameExtension = 'Loot' header = 'Time\tCharacter\tItem Type\tQuantity\tItem Group' self.ExportToDisk(header, rows, fileNameExtension)
def GetPlacesScrollList(self, places, groupID, sublevel): addressbook = sm.GetService('addressbook') bookmarkSvc = sm.GetService('bookmarkSvc') pathfinder = sm.GetService('clientPathfinderService') scrolllist = [] unreachabelText = localization.GetByLabel('UI/Common/unreachable') coordinateText = localization.GetByLabel( 'UI/PeopleAndPlaces/Coordinate') for bookmark in places: hint, comment = bookmarkSvc.UnzipMemo(bookmark.memo) sol, con, reg = addressbook.GetSolConReg(bookmark) typename = evetypes.GetGroupName(bookmark.typeID) date = util.FmtDate(bookmark.created, 'ls') if bookmark and (bookmark.itemID == bookmark.locationID or bookmark.typeID == const.typeSolarSystem) and bookmark.x: typename = coordinateText jumps = 0 if 40000000 > bookmark.itemID > 30000000: jumps = pathfinder.GetAutopilotJumpCount( session.solarsystemid2, bookmark.itemID) elif 40000000 > bookmark.locationID > 30000000: jumps = pathfinder.GetAutopilotJumpCount( session.solarsystemid2, bookmark.locationID) if IsUnreachableJumpCount(jumps): jumps = unreachabelText creatorID = getattr(bookmark, 'creatorID', None) if creatorID is not None: creatorName = cfg.eveowners.Get(creatorID).name else: creatorName = '' text = '<t>'.join((unicode(x) for x in (hint, typename, jumps, sol, con, reg, date, creatorName))) data = { 'bm': bookmark, 'DropData': lambda *args: self.DropOnBookmark(bookmark, *args), 'itemID': bookmark.bookmarkID, 'tabs': [], 'hint': hint, 'comment': comment, 'label': text, 'sublevel': sublevel, 'listGroupID': groupID } scrolllist.append(listentry.Get('PlaceEntry', data)) return scrolllist
def GetShipExposureTemplateData(self): if not eve.stationItem: return racialShips = { const.raceAmarr: [2006, 20183, 24696, 24692, 597, 1944, 624], const.raceCaldari: [621, 20185, 24698, 640, 602, 648, 623], const.raceGallente: [627, 20187, 24700, 641, 593, 650, 626], const.raceMinmatar: [629, 20189, 24702, 644, 587, 653, 622] } oreShipsList = [17478, 17476, 2998] racialIntroVideos = { const.raceAmarr: 'res:/video/cq/LOGO_AMARR.webm', const.raceCaldari: 'res:/video/cq/LOGO_CALDARI.webm', const.raceGallente: 'res:/video/cq/LOGO_GALLENTE.webm', const.raceMinmatar: 'res:/video/cq/LOGO_MINMATAR.webm' } data = util.KeyVal() if random.random() <= 0.3: data.introVideoPath = 'res:/video/cq/LOGO_ORE.webm' data.shipTypeID = random.choice(oreShipsList) else: stationRace = evetypes.GetRaceID(eve.stationItem.stationTypeID) if stationRace not in racialShips: stationRace = const.raceGallente data.introVideoPath = racialIntroVideos[stationRace] data.shipTypeID = random.choice(racialShips[stationRace]) data.shipName = evetypes.GetName(data.shipTypeID) data.shipGroupName = evetypes.GetGroupName(data.shipTypeID) data.buttonText = localization.GetByLabel( 'UI/Station/Holoscreen/Common/AvailableOnMarketNow') data.mainText = '<fontsize=30>' + localization.GetByLabel( 'UI/Station/Holoscreen/Ship/ShipDetailsTitle') data.mainText += '\n<fontsize=25>' + evetypes.GetDescription( data.shipTypeID) data.clickFunc = sm.GetService('marketutils').ShowMarketDetails data.clickArgs = (data.shipTypeID, None) data.clickFuncLabel = localization.GetByLabel( 'UI/Station/Holoscreen/Ship/OpenMarketForShip', ship=data.shipTypeID) return data
def GetAllShipGroupsAndShipsByGroupID(self, filterTextLower): shipGroups = set() shipsByGroupID = defaultdict(set) shipsByGroupAndRaceIDs = defaultdict(lambda: defaultdict(set)) grouplist = sm.GetService('marketutils').GetMarketGroups()[ const.marketCategoryShips] shipTypesIDsFromMarket = { i for i in itertools.chain.from_iterable( [x.types for x in grouplist]) } for shipTypeID in shipTypesIDsFromMarket: shipName = evetypes.GetName(shipTypeID) if filterTextLower and shipName.lower().find(filterTextLower) < 0: continue groupID = evetypes.GetGroupID(shipTypeID) groupName = evetypes.GetGroupName(shipTypeID) shipGroups.add((groupName, groupID)) shipsByGroupID[groupID].add(shipTypeID) raceID = evetypes.GetRaceID(shipTypeID) shipsByGroupAndRaceIDs[groupID][raceID].add(shipTypeID) return (shipGroups, shipsByGroupID, shipsByGroupAndRaceIDs)
def UpdateTable(self): layout = '%s<t>%s<t>%s<t>%s<t>%s<t>%s' headers = [ 'distance (m)', 'itemID', 'Type Name', 'Group Name', 'Explosion Bucket ID', 'Selected Explosion' ] content = [] ballpark = sm.GetService('michelle').GetBallpark() balls = ballpark.GetBallsInRange(session.shipid, SEARCH_DISTANCE) selectedEntries = [] for ballID in balls: ball = sm.GetService('michelle').GetBall(ballID) if not hasattr(ball, 'typeData') or getattr( ball, 'exploded', False): continue typeID = ball.typeData['typeID'] explosionBucketID = GetExplosionBucketIDByTypeID(typeID) if explosionBucketID is None: continue typeName = evetypes.GetName(typeID) groupName = evetypes.GetGroupName(typeID) explosionRes = 'Random' dist = util.FmtAmt(ballpark.DistanceBetween( session.shipid, ballID)) info = (dist, ballID, typeName, groupName, explosionBucketID, explosionRes) label = layout % info entry = uicontrols.ScrollEntryNode( decoClass=uicontrols.SE_GenericCore, label=label) if ballID in self.selectedBallsToExplosionBucketID: selectedEntries.append(entry) content.append(entry) self.scroll.Load(contentList=content, headers=headers, fixedEntryHeight=18) self.scroll.SelectNodes(selectedEntries)
def GetGroupName(self): typeID = self.GetProductOrBlueprintTypeID() return evetypes.GetGroupName(typeID)
def GetTypeName(self): categoryID = evetypes.GetCategoryID(self.typeID) if categoryID == const.categoryStation: return evetypes.GetCategoryNameByCategory(categoryID) else: return evetypes.GetGroupName(self.typeID)
def GetProductGroupAndCategory(self): typeID = self.GetProductOrBlueprintTypeID() return KeyVal(groupID=evetypes.GetGroupID(typeID), groupName=evetypes.GetGroupName(typeID), categoryID=evetypes.GetCategoryID(typeID), categoryName=evetypes.GetCategoryName(typeID))
def GetStandardLinkHint(self, url): if url.startswith('showinfo'): parsedArgs = BaseLink().ParseShowInfo(url[9:]) if not parsedArgs: return localization.GetByLabel('UI/Commands/ShowInfo') typeID, itemID, data = parsedArgs if evetypes.Exists(typeID): if evetypes.GetCategoryID(typeID) == const.categorySkill: hintText = localization.GetByLabel('UI/Common/ShowTypeInfo', groupName=evetypes.GetCategoryName(typeID)) else: hintText = localization.GetByLabel('UI/Common/ShowTypeInfo', groupName=evetypes.GetGroupName(typeID)) else: hintText = localization.GetByLabel('UI/Common/ShowInfo') return hintText if url.startswith('podGuideLink'): podGuideID = int(url[len('podGuideLink:'):]) return localization.GetByMessageID(GetTermShortText(podGuideID)) if url.startswith('accessGroup'): return '' for k, v in HINTLABELS.iteritems(): if url.startswith('%s:' % k): if v is None: return v return localization.GetByLabel(v) return url
def GetAttributeInfo(godmaService, typeID, attributes, instance, localization): attributeEntries = [ EntryData( 'Header', localization.GetByLabel( 'UI/Inflight/SpaceComponents/Deploy/InfoAttributesHeader') ), EntryData('LabelTextSides', localization.GetByLabel( 'UI/Inflight/SpaceComponents/Deploy/DeployAtRange'), FmtDist(attributes.deployAtRange), iconID=RANGE_ICON), EntryData( 'LabelTextSides', localization.GetByLabel( 'UI/Inflight/SpaceComponents/Deploy/MinDistanceFromOwnGroup', groupName=evetypes.GetGroupName(typeID)), FmtDist(attributes.minDistanceFromOwnGroup), iconID=RANGE_ICON), EntryData( 'LabelTextSides', localization.GetByLabel( 'UI/Inflight/SpaceComponents/Deploy/MinDistanceFromControlTower', groupName=evetypes.GetGroupNameByGroup(groupControlTower)), FmtDist(attributes.minDistanceFromControlTower), iconID=RANGE_ICON) ] if hasattr(attributes, 'maxDistanceFromControlTower'): attributeEntries.append( EntryData( 'LabelTextSides', localization.GetByLabel( 'UI/Inflight/SpaceComponents/Deploy/MaxDistanceFromControlTower', groupName=evetypes.GetGroupNameByGroup( groupControlTower)), FmtDist(attributes.maxDistanceFromControlTower), iconID=RANGE_ICON)) if hasattr(attributes, 'minDistanceFromStargatesAndStations'): attributeEntries.append( EntryData( 'LabelTextSides', localization.GetByLabel( 'UI/Inflight/SpaceComponents/Deploy/MinDistanceFromStargatesAndStations', stargateGroupName=evetypes.GetGroupNameByGroup( groupStargate), stationGroupName=evetypes.GetGroupNameByGroup( groupStation)), FmtDist(attributes.minDistanceFromStargatesAndStations), iconID=RANGE_ICON)) if hasattr(attributes, 'minDistanceFromWormhole'): attributeEntries.append( EntryData( 'LabelTextSides', localization.GetByLabel( 'UI/Inflight/SpaceComponents/Deploy/MinDistanceFromWormhole', wormholeGroupName=evetypes.GetGroupNameByGroup( groupWormhole)), FmtDist(attributes.minDistanceFromStargatesAndStations), iconID=RANGE_ICON)) if getattr(attributes, 'disallowInWormholeSpace', True): attributeEntries.append( EntryData( 'LabelTextSides', localization.GetByLabel( 'UI/Inflight/SpaceComponents/Deploy/DisallowedFromWormholeSpace' ), '', iconID=BANNED_ICON)) return attributeEntries
def ShowDirectionalSearchResult(self, *args): self.listtype = 'location' scrolllist = [] if self.scanresult and len(self.scanresult): myball = None ballpark = sm.GetService('michelle').GetBallpark() if ballpark: myball = ballpark.GetBall(eve.session.shipid) prime = [] for result in self.scanresult: slimItem, ball, celestialRec = result if not slimItem and celestialRec: prime.append(celestialRec.id) if prime: cfg.evelocations.Prime(prime) for slimItem, ball, celestialRec in self.scanresult: if self is None or self.destroyed: return if slimItem: typeName = evetypes.GetName(slimItem.typeID) entryname = GetSlimItemName(slimItem) itemID = slimItem.itemID typeID = slimItem.typeID if not entryname: entryname = evetypes.GetGroupName(slimItem.typeID) elif celestialRec: typeName = evetypes.GetName(celestialRec.typeID) if evetypes.GetGroupID(celestialRec.typeID ) == const.groupHarvestableCloud: entryname = GetByLabel( 'UI/Inventory/SlimItemNames/SlimHarvestableCloud', typeName) elif evetypes.GetCategoryID( celestialRec.typeID) == const.categoryAsteroid: entryname = GetByLabel( 'UI/Inventory/SlimItemNames/SlimAsteroid', typeName) else: entryname = cfg.evelocations.Get(celestialRec.id).name if not entryname: entryname = typeName itemID = celestialRec.id typeID = celestialRec.typeID else: continue if ball is not None: dist = ball.surfaceDist diststr = FmtDist(dist, maxdemicals=1) else: dist = 0 diststr = '-' groupID = evetypes.GetGroupID(typeID) if not eve.session.role & (service.ROLE_GML | service.ROLE_WORLDMOD): if groupID == const.groupCloud: continue data = KeyVal() data.label = '%s<t>%s<t>%s' % (entryname, typeName, diststr) data.entryName = entryname data.typeName = typeName data.Set('sort_%s' % GetByLabel('UI/Common/Distance'), dist) data.columnID = 'directionalResultGroupColumn' data.result = result data.itemID = itemID data.typeID = typeID data.GetMenu = self.DirectionalResultMenu scrolllist.append( listentry.Get('DirectionalScanResults', data=data)) blue.pyos.BeNice() if not len(scrolllist): data = KeyVal() data.label = GetByLabel('UI/Inflight/Scanner/DirectionalNoResult') data.hideLines = 1 scrolllist.append(listentry.Get('Generic', data=data)) headers = [] else: headers = [ GetByLabel('UI/Common/Name'), GetByLabel('UI/Common/Type'), GetByLabel('UI/Common/Distance') ] self.sr.dirscroll.Load(contentList=scrolllist, headers=headers)
def LoadComposition(self): fleetSvc = sm.GetService('fleet') if not fleetSvc.IsCommanderOrBoss(): raise UserError('FleetNotCommanderOrBoss') scrolllist = [] composition = fleetSvc.GetFleetComposition() fleetHierarchy = fleetSvc.GetFleetHierarchy() fleetPositionText = localization.GetByLabel( 'UI/Fleet/FleetWindow/FleetPosition') for kv in composition: blue.pyos.BeNice() member = fleetSvc.GetMemberInfo(kv.characterID, fleetHierarchy) if not fleetSvc.IsMySubordinate( kv.characterID) and not fleetSvc.IsBoss(): continue data = KeyVal() charName = localization.GetByLabel('UI/Common/CharacterNameLabel', charID=kv.characterID) locationName = localization.GetByLabel('UI/Common/LocationDynamic', location=kv.solarSystemID) if kv.stationID: locationName = '%s %s' % ( locationName, localization.GetByLabel('UI/Fleet/FleetComposition/Docked') ) if kv.shipTypeID is not None: shipTypeName = evetypes.GetName(kv.shipTypeID) shipGroupName = evetypes.GetGroupName(kv.shipTypeID) else: shipTypeName = '' shipGroupName = '' if kv.skills: skillLevels = localization.GetByLabel( 'UI/Fleet/FleetComposition/SkillLevels', skillLevelA=kv.skills[2], skillLevelB=kv.skills[1], skillLevelC=kv.skills[0]) data.hint = localization.GetByLabel( 'UI/Fleet/FleetComposition/SkillsHint', skillTypeA=kv.skillIDs[2], skillLevelA=kv.skills[2], skillTypeB=kv.skillIDs[1], skillLevelB=kv.skills[1], skillTypeC=kv.skillIDs[0], skillLevelC=kv.skills[0]) else: skillLevels = '' if not member.wingName: fleetPosition = '' positionSortValue = (None, None) elif not member.squadName: fleetPosition = member.wingName positionSortValue = (fleetPosition, None) else: fleetPosition = '%s / %s ' % (member.wingName, member.squadName) positionSortValue = (member.wingName, member.squadName) data.label = '<t>'.join([ charName, locationName, shipTypeName, shipGroupName, member.roleName, skillLevels, fleetPosition ]) data.GetMenu = self.OnCompositionEntryMenu data.cfgname = charName data.retval = None data.charID = kv.characterID data.shipTypeID = kv.shipTypeID data.solarSystemID = kv.solarSystemID data.info = cfg.eveowners.Get(kv.characterID) data.Set('sort_%s' % fleetPositionText, positionSortValue) scrolllist.append(listentry.Get('FleetCompositionEntry', data=data)) self.counterLabel.text = localization.GetByLabel( 'UI/Fleet/FleetComposition/PilotsSelected', numSelected=0, numTotalPilots=len(scrolllist)) self.sr.scrollBroadcasts.sr.id = 'scrollComposition' headers = [ localization.GetByLabel('UI/Common/Name'), localization.GetByLabel('UI/Common/Location'), localization.GetByLabel('UI/Fleet/FleetComposition/ShipType'), localization.GetByLabel('UI/Fleet/FleetComposition/ShipGroup'), localization.GetByLabel('UI/Fleet/FleetComposition/FleetRole'), localization.GetByLabel('UI/Fleet/FleetComposition/FleetSkills'), fleetPositionText ] self.sr.scrollBroadcasts.Load(headers=headers, contentList=scrolllist)