NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

urlSprite.py (1099B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\primitives\urlSprite.py
      2 from carbonui.primitives.sprite import Sprite
      3 from evephotosvc.const import NONE_PATH
      4 DEFAULT_IMAGE = 'res:/UI/Texture/Vgs/missing_image.png'
      5 
      6 class UrlSprite(Sprite):
      7 
      8     def ApplyAttributes(self, attributes):
      9         super(UrlSprite, self).ApplyAttributes(attributes)
     10         self.url = attributes.get('url')
     11         self._load_texture_from_url()
     12 
     13     def _load_texture_from_url(self):
     14         if not self.url:
     15             raise AttributeError('UrlSprite requires image URL as a parameter')
     16         photo_service = sm.GetService('photo')
     17         texture, width, height = photo_service.GetTextureFromURL(self.url, retry=False)
     18         if not self._is_valid_texture(texture):
     19             texture, width, height = sm.GetService('photo').GetTextureFromURL(DEFAULT_IMAGE, retry=False)
     20         self.texture = texture
     21         self.width = width
     22         self.height = height
     23 
     24     def _is_valid_texture(self, texture):
     25         return texture is not None and texture.resPath != NONE_PATH