def GetMenu(self, *args): if isinstance(self.sr.node.invtype, tuple): typeID = self.sr.node.invtype[0] else: typeID = self.sr.node.invtype groupID = evetypes.GetGroupID(typeID) catID = evetypes.GetCategoryIDByGroup(groupID) graphicID = evetypes.GetGraphicID(typeID) graphicFileMenu = [] if evetypes.Exists(typeID) and evetypes.GetGraphicID( typeID) is not None: graphic = GetGraphic(evetypes.GetGraphicID(typeID)) if graphic is not None: graphicFile = GetGraphicFile(graphic) graphicFileMenu = [ [ 'Copy graphicID (%s)' % graphicID, lambda *x: blue.pyos.SetClipboardData(str(graphicID)), () ], [ 'Copy graphicFile (%s)' % graphicFile, lambda *x: blue.pyos.SetClipboardData(graphicFile), () ] ] averagePrice = inventorycommon.typeHelpers.GetAveragePrice(typeID) if averagePrice is None: averagePrice = 'n/a' else: averagePrice = util.FmtISK(averagePrice) menu = [[ 'Preview', lambda *x: uthread.new( sm.StartService('preview').PreviewType, typeID), () ]] menu += graphicFileMenu menu += [[ 'Copy typeID (%s)' % typeID, lambda *x: blue.pyos.SetClipboardData(str(typeID)), () ], [ 'Copy groupID (%s)' % groupID, lambda *x: blue.pyos.SetClipboardData(str(groupID)), () ], [ 'Copy categoryID (%s)' % catID, lambda *x: blue.pyos.SetClipboardData(str(catID)), () ], [ 'Average price: %s' % averagePrice, lambda *x: blue.pyos.SetClipboardData(averagePrice), () ], [ 'View market details', lambda *x: uthread.new( sm.StartService('marketutils').ShowMarketDetails, typeID, None), () ], None] menu += sm.GetService('menu').GetGMTypeMenu(typeID) return menu
def GetPlanetPhoto(self, itemID, typeID, size=512): graphicID = evetypes.GetGraphicID(typeID) outPath = GetCachePath(typeID, graphicID, size, itemID) planet = Planet() planet.GetPlanetByID(itemID, typeID) if planet.model is None or planet.model.highDetail is None: return NOT_AVAILABLE_PATH planetTransform = trinity.EveTransform() planetTransform.scaling = (100.0, 100.0, 100.0) planetTransform.children.append(planet.model.highDetail) scene = self.GetPlanetScene() try: planet.DoPreProcessEffectForPhotoSvc(size) except: del planetTransform.children[:] return NOT_AVAILABLE_PATH trinity.WaitForResourceLoads() scene.sunDirection = (-1.0, 0.0, 0.0) scene.sunDiffuseColor = (1.0, 1.0, 1.0, 1.0) scene.objects.append(planetTransform) view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere( boundingSphereRadius=130) bitmap = photo.RenderToSurface(view, projection, size, scene, transparent=False) bitmap.Save(outPath) del planetTransform.children[:] self._RemovePathFromNotAvailList(outPath) return outPath
def UpdateHardpoints(self, newModel = None): if newModel is None: newModel = self.GetSceneShip() if newModel is None: log.LogError('UpdateHardpoints - No model!') return factionName = GetSofFactionName(evetypes.GetGraphicID(self.controller.GetTypeID())) turretSet.TurretSet.FitTurrets(self.controller.GetItemID(), newModel, factionName)
def FitHardpoints(self): if not self.activeshipmodel or self.activeShipTypeID is None or self.refreshingfitting: return self.refreshingfitting = True activeShip = util.GetActiveShip() sofFactionName = GetSofFactionName( evetypes.GetGraphicID(self.activeShipTypeID)) turretSet.TurretSet.FitTurrets(activeShip, self.activeshipmodel, sofFactionName) self.refreshingfitting = False
def _getResourceFromTypeID(self, typeID): try: graphicID = evetypes.GetGraphicID(typeID) except evetypes.TypeNotFoundException: graphicID = None if graphicID is None: self._showMessage('Could not get graphicID from typeID ' + str(typeID)) return return self._getResourceFromGraphicID(graphicID)
def LoadSolarSystemMap(self): self.maxRadius = 0.0 solarsystemID = self.solarsystemID parent = self.systemMapTransform solarSystemData = self.systemMapSvc.GetSolarsystemData(solarsystemID) planets = [] childrenToParentByID = {} sunID = None maxRadius = 0.0 for celestialObject in solarSystemData: if celestialObject.groupID == const.groupPlanet: planets.append((celestialObject.itemID, geo2.Vector(celestialObject.x, celestialObject.y, celestialObject.z))) maxRadius = max(maxRadius, geo2.Vec3Length((celestialObject.x, celestialObject.y, celestialObject.z))) elif celestialObject.groupID == const.groupSun: sunID = celestialObject.itemID sunGraphicFilePath = GetGraphicFile(evetypes.GetGraphicID(celestialObject.typeID)) sunGraphicFile = trinity.Load(sunGraphicFilePath) self.CreateSun(sunGraphicFile) self.sunID = sunID objectPositions = {} for each in solarSystemData: objectPositions[each.itemID] = (each.x, each.y, each.z) if each.groupID in (const.groupPlanet, const.groupStargate): childrenToParentByID[each.itemID] = sunID continue closest = [] eachPosition = geo2.Vector(each.x, each.y, each.z) maxRadius = max(maxRadius, geo2.Vec3Length(eachPosition)) for planetID, planetPos in planets: diffPos = planetPos - eachPosition diffVector = geo2.Vec3Length(diffPos) closest.append((diffVector, planetID)) closest.sort() childrenToParentByID[each.itemID] = closest[0][1] self.maxRadius = maxRadius for each in solarSystemData: if each.itemID == each.locationID: continue if each.groupID == const.groupSecondarySun: continue if each.groupID == const.groupPlanet: self.CreatePlanet((each.x, each.y, each.z)) OrbitCircle(each.itemID, (each.x, each.y, each.z), objectPositions[sunID], self.systemMapTransform) elif each.groupID == const.groupMoon: parentID = childrenToParentByID.get(each.itemID, None) if parentID: self.CreatePlanet((each.x, each.y, each.z)) OrbitCircle(each.itemID, (each.x, each.y, each.z), objectPositions[parentID], self.systemMapTransform) self.solarSystemRadius = maxRadius cfg.evelocations.Prime(objectPositions.keys(), 0)
def BuildSOFDNAFromTypeID(typeID, materialSetID=None): if typeID is None: return if not evetypes.Exists(typeID): return if materialSetID is None: materialSetID = evetypes.GetSofMaterialSetIDOrNone(typeID) sofBuildClass = evetypes.GetSofBuildClassOrNone(typeID) return BuildSOFDNAFromGraphicID(evetypes.GetGraphicID(typeID), materialSetID=materialSetID, sofBuildClass=sofBuildClass)
def IsPreviewable(typeID): if not evetypes.Exists(typeID): return False else: if IsApparel(typeID): return True if IsShipSkin(typeID): return True if evetypes.GetGraphicID(typeID) is None: return False return evetypes.GetCategoryID( typeID) in const.previewCategories or evetypes.GetGroupID( typeID) in const.previewGroups
def ExistsInCacheOrRenders(self, typeID, size, itemID, blueprint): graphicID = evetypes.GetGraphicID(typeID) if evetypes.GetGroupID(typeID) == const.groupStation: npcStation = cfg.mapSolarSystemContentCache.npcStations.get( itemID, None) if npcStation: graphicID = npcStation.graphicID renderPath = GetRenderPath(graphicID, size, blueprint) if blue.paths.exists(renderPath): return renderPath cachePath = GetCachePath(typeID, graphicID, size, itemID, blueprint) if self.CheckAvail(cachePath) is not None: return cachePath
def _LoadModularShipModel(self, itemID, typeID): raceName = GetSofRaceName(evetypes.GetGraphicID(typeID)) dogmaItem = sm.GetService( 'clientDogmaIM').GetDogmaLocation().dogmaItems.get(itemID, None) if dogmaItem is None: self.log.error( '%s._LoadModularShip(itemID = %s, typeID = %s): Trying to show t3 ship which is not in dogma' % (self, itemID, typeID)) return fittedSubsystems = [ fittedItem for fittedItem in dogmaItem.GetFittedItems().itervalues() if fittedItem.categoryID == const.categorySubSystem ] subSystemIds = {item.groupID: item.typeID for item in fittedSubsystems} return sm.GetService('t3ShipSvc').GetTech3ShipFromDict( dogmaItem.typeID, subSystemIds, raceName)
def OnSlimItemUpdated(self, item): if item is None or self.unloaded: return if item.state and (item.state != self.state or item.timer != self.timer): if item.timer and item.state == structures.STATE_ANCHORING: start, end, paused = item.timer duration = (end - start) / const.SEC elapsed = duration - max(end - blue.os.GetWallclockTime(), 0L) / const.SEC else: duration = 0 elapsed = 0 self.state = item.state self.timer = item.timer self.GotoState(STATES[self.state], duration, elapsed) if set([ i[0] for i in item.modules or [] if evetypes.GetGraphicID(i[1]) is not None ]) != set(self.modules.keys()): uthread.new(self.ReloadHardpoints)
def FitTurret(model, turretTypeID, locatorID, turretFaction = None, count = 1, online = True, checkSettings = True): if not evetypes.Exists(turretTypeID): return if checkSettings and not gfxsettings.Get(gfxsettings.UI_TURRETS_ENABLED): return groupID = evetypes.GetGroupID(turretTypeID) if model is None: log.LogError('FitTurret() called with NoneType, so there is no model to fit the turret to!') return if groupID not in const.turretModuleGroups: return newTurretSet = None graphicID = evetypes.GetGraphicID(turretTypeID) if graphicID is not None: newTurretSet = TurretSet.AddTurretToModel(model, graphicID, turretFaction, locatorID, count) if newTurretSet is None: return if not online: newTurretSet.Offline() newTurretSet.turretTypeID = turretTypeID newTurretSet.turretGroupID = groupID return newTurretSet
def GetValidBlueprintPath(self, sprite, typeID, size=64, blueprint=BLUEPRINT_NORMAL): graphicID = evetypes.GetGraphicID(typeID) cachePath = GetCachePath(typeID, graphicID, size, None, blueprint) resFile = blue.ResFile() try: if resFile.Open(cachePath): self.LogInfo('GetValidBlueprintPath ', cachePath, ' exists') return cachePath finally: del resFile graphic = inventorycommon.typeHelpers.GetIcon(typeID) if graphic and graphic.iconFile: iconPath = graphic.iconFile.strip() iconPath = photo.GetIconFileFromSheet(iconPath) else: iconPath = sprite.texture.resPath if blueprint == BLUEPRINT_DUST: backgroundPath = BLUEPRINT_DUST_RESPATH overlayPath = None elif blueprint == BLUEPRINT_COPY: backgroundPath = BLUEPRINT_COPY_RESPATH overlayPath = BLUEPRINT_COPY_OVERLAY_PATH elif blueprint == BLUEPRINT_RELIC: backgroundPath = BLUEPRINT_RELIC_RESPATH overlayPath = BLUEPRINT_RELIC_OVERLAY_PATH else: backgroundPath = BLUEPRINT_RESPATH overlayPath = BLUEPRINT_OVERLAY_PATH uthread.new(self.RenderBlueprint, sprite, cachePath, size, iconPath, backgroundPath, overlayPath) self._RemovePathFromNotAvailList(cachePath) return cachePath
def GetGraphic(typeID): try: return fsdGraphicIDs.GetGraphic(evetypes.GetGraphicID(typeID)) except Exception: pass
def FitTurrets(self, itemID, typeID, model): sofFactionName = evetypes.GetSofFactionNameOrNone(typeID) if sofFactionName is None: sofFactionName = GetSofFactionName(evetypes.GetGraphicID(typeID)) TurretSet.FitTurrets(itemID, model, sofFactionName)
def GetExplosionBucketIDByTypeID(typeID): explosionBucketIdByGraphicID = GetExplosionBucketID(evetypes.GetGraphicID(typeID)) explosionBucketIdByGroup = evetypes.GetExplosionBucketIDByGroup(evetypes.GetGroupID(typeID)) return explosionBucketIdByGraphicID or explosionBucketIdByGroup
def LoadOrbitalObjects(self, scene): orbitalObjects = sm.GetService('planetInfo').GetOrbitalsForPlanet( self.planetID, const.groupPlanetaryCustomsOffices) park = sm.GetService('michelle').GetBallpark() addedObjects = [] for orbitalObjectID in orbitalObjects: invItem = park.GetInvItem(orbitalObjectID) fileName = None if evetypes.GetGraphicID(invItem.typeID) is not None: if type(evetypes.GetGraphicID(invItem.typeID)) != type(0): raise RuntimeError('NeedGraphicIDNotMoniker', invItem.itemID) if inventorycommon.typeHelpers.GetGraphic(invItem.typeID): fileName = inventorycommon.typeHelpers.GetGraphicFile( invItem.typeID) if not (fileName.lower().endswith('.red') or fileName.lower().endswith('.blue')): filenameAndTurretType = fileName.split(' ') fileName = filenameAndTurretType[0] if fileName is None: self.LogError( 'Error: Object type %s has invalid graphicFile, using graphicID: %s' % (invItem.typeID, evetypes.GetGraphicID(invItem.typeID))) continue tryFileName = fileName.replace(':/Model', ':/dx9/Model').replace( '.blue', '.red') tryFileName = tryFileName.replace('.red', '_UI.red') model = None if tryFileName is not None: try: model = blue.resMan.LoadObject(tryFileName) except: model = None if model is None: self.LogError('Was looking for:', tryFileName, 'but it does not exist!') if model is None: try: model = blue.resMan.LoadObject(fileName) except: model = None if not model: log.LogError( 'Could not load model for orbital object. FileName:', fileName, ' id:', invItem.itemID, ' typeID:', getattr(invItem, 'typeID', '?unknown?')) if invItem is not None and hasattr(invItem, 'typeID'): log.LogError('Type is:', evetypes.GetName(invItem.typeID)) continue model.name = '%s' % invItem.itemID model.display = 0 model.scaling = (0.002, 0.002, 0.002) addedObjects.append(model) orbitRoot = trinity.EveTransform() orbitRoot.children.append(model) inclinationRoot = trinity.EveTransform() inclinationRoot.children.append(orbitRoot) orbitalInclination = orbitalObjectID / math.pi % ( math.pi / 4.0) - math.pi / 8.0 if orbitalInclination <= 0.0: orbitalInclination -= math.pi / 8.0 else: orbitalInclination += math.pi / 8.0 inclinationRoot.rotation = geo2.QuaternionRotationSetYawPitchRoll( 0.0, orbitalInclination, 0.0) rotationCurveSet = trinity.TriCurveSet() rotationCurveSet.playOnLoad = False rotationCurveSet.Stop() rotationCurveSet.scaledTime = 0.0 rotationCurveSet.scale = 0.25 orbitRoot.curveSets.append(rotationCurveSet) ypr = trinity.TriYPRSequencer() ypr.YawCurve = trinity.TriScalarCurve() ypr.YawCurve.extrapolation = trinity.TRIEXT_CYCLE ypr.YawCurve.AddKey(0.0, 0.0, 0.0, 0.0, trinity.TRIINT_LINEAR) ypr.YawCurve.AddKey(200.0, 360.0, 0.0, 0.0, trinity.TRIINT_LINEAR) ypr.YawCurve.Sort() rotationCurveSet.curves.append(ypr) binding = trinity.TriValueBinding() binding.sourceObject = ypr binding.sourceAttribute = 'value' binding.destinationObject = orbitRoot binding.destinationAttribute = 'rotation' rotationCurveSet.bindings.append(binding) rotationCurveSet.Play() model.translation = (0.0, 0.0, 1500.0) model.rotation = geo2.QuaternionRotationSetYawPitchRoll( math.pi, 0.0, 0.0) scene.objects.append(inclinationRoot) ls = trinity.EveCurveLineSet() ls.scaling = (1.0, 1.0, 1.0) tex2D1 = trinity.TriTextureParameter() tex2D1.name = 'TexMap' tex2D1.resourcePath = 'res:/UI/Texture/Planet/link.dds' ls.lineEffect.resources.append(tex2D1) tex2D2 = trinity.TriTextureParameter() tex2D2.name = 'OverlayTexMap' tex2D2.resourcePath = 'res:/UI/Texture/Planet/link.dds' ls.lineEffect.resources.append(tex2D2) lineColor = (1.0, 1.0, 1.0, 0.05) p1 = SurfacePoint(0.0, 0.0, -1500.0, 1000.0) p2 = SurfacePoint(5.0, 0.0, 1498.0, 1000.0) l1 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor, p2.GetAsXYZTuple(), lineColor, (0.0, 0.0, 0.0), 3.0) p1 = SurfacePoint(0.0, 0.0, -1500.0, 1000.0) p2 = SurfacePoint(-5.0, 0.0, 1498.0, 1000.0) l2 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor, p2.GetAsXYZTuple(), lineColor, (0.0, 0.0, 0.0), 3.0) animationColor = (0.3, 0.3, 0.3, 0.5) ls.ChangeLineAnimation(l1, animationColor, 0.25, 1.0) ls.ChangeLineAnimation(l2, animationColor, -0.25, 1.0) ls.ChangeLineSegmentation(l1, 100) ls.ChangeLineSegmentation(l2, 100) ls.SubmitChanges() orbitRoot.children.append(ls) trinity.WaitForResourceLoads() for model in addedObjects: model.display = 1
def GetGraphicFile(typeID): return fsdGraphicIDs.GetGraphicFile(evetypes.GetGraphicID(typeID), '')
def GetAnimationStates(typeID): return fsdGraphicIDs.GetAnimationStates(evetypes.GetGraphicID(typeID), [])