first_party_skins.py (7458B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\cosmetics\client\ships\skins\static_data\first_party_skins.py 2 import blue 3 import localization 4 import evetypes 5 import fsdBuiltData.common.graphicMaterialSets as materialSets 6 from cosmetics.common.ships.skins.static_data.skin_type import ShipSkinType 7 from localization.formatters.timeIntervalFormatters import FormatTimeIntervalShortWritten, TIME_CATEGORY_DAY, TIME_CATEGORY_MINUTE 8 9 class FirstPartyStaticLicense(object): 10 11 def __init__(self, static, license): 12 self._static = static 13 self._license = license 14 15 @property 16 def typeID(self): 17 return self._license.licenseTypeID 18 19 @property 20 def name(self): 21 return evetypes.GetName(self._license.licenseTypeID) 22 23 @property 24 def duration(self): 25 return self._license.duration 26 27 @property 28 def durationLabel(self): 29 if self.is_single_use and self.duration != -1: 30 return localization.GetByLabel('UI/Skins/SkinDurationSingleUseWithDuration', days=self.duration) 31 if self.is_single_use: 32 return localization.GetByLabel('UI/Skins/SkinDurationSingleUse') 33 if self.duration == -1: 34 return localization.GetByLabel('UI/Skins/SkinDurationPermanent') 35 return localization.GetByLabel('UI/Skins/SkinDurationLimited', days=self.duration) 36 37 @property 38 def is_permanent(self): 39 return self._license.duration == -1 40 41 @property 42 def is_single_use(self): 43 return getattr(self._license, 'isSingleUse', False) 44 45 @property 46 def iconTexturePath(self): 47 return _skin_icon_texture_path(self.skin.materialID) 48 49 @property 50 def skin(self): 51 if not getattr(self, '_cached_skin', None): 52 self._cached_skin = self._static.GetSkinByID(self._license.skinID) 53 return FirstPartyStaticSkin(self._static, self._cached_skin) 54 55 @property 56 def material(self): 57 return self.skin.material 58 59 60 class FirstPartyStaticSkin(object): 61 62 def __init__(self, static, skin): 63 self._static = static 64 self._skin = skin 65 66 @property 67 def skinID(self): 68 return self._skin.skinID 69 70 @property 71 def materialID(self): 72 return self._skin.skinMaterialID 73 74 @property 75 def material(self): 76 if not getattr(self, '_cached_material', None): 77 self._cached_material = self._static.GetMaterialByID(self._skin.skinMaterialID) 78 return FirstPartyStaticMaterial(self._static, self._cached_material) 79 80 @property 81 def types(self): 82 return self._skin.types 83 84 @property 85 def licenses(self): 86 licenses = self._static.GetLicencesForSkinID(self._skin.skinID) 87 return [ FirstPartyStaticLicense(self._static, license) for license in licenses ] 88 89 @property 90 def isStructureSkin(self): 91 return self._skin.isStructureSkin 92 93 94 class FirstPartyStaticMaterial(object): 95 96 def __init__(self, static, material): 97 self._static = static 98 self._material = material 99 100 @property 101 def iconTexturePath(self): 102 return _skin_icon_texture_path(self._material.skinMaterialID) 103 104 @property 105 def materialID(self): 106 return self._material.skinMaterialID 107 108 @property 109 def materialSetID(self): 110 return self._material.materialSetID 111 112 @property 113 def name(self): 114 messageID = int(self._material.displayNameID) 115 return localization.GetByMessageID(messageID) 116 117 @property 118 def skins(self): 119 skins = self._static.GetSkinsForMaterialID(self._material.skinMaterialID) 120 return [ FirstPartyStaticSkin(self._static, skin) for skin in skins ] 121 122 123 class FirstPartySkin(object): 124 125 def __init__(self, material, skin = None, licensed = False, expires = None, isSingleUse = False, isStructureSkin = False): 126 self._skin = skin 127 self._material = material 128 self._materialSet = materialSets.GetGraphicMaterialSet(self._material.materialSetID) 129 self.licensed = licensed 130 self.expires = expires 131 self.isSingleUse = isSingleUse 132 self.isStructureSkin = isStructureSkin 133 134 @property 135 def skinID(self): 136 if self._skin: 137 return self._skin.skinID 138 else: 139 return None 140 141 @property 142 def expired(self): 143 return self.expires is not None and self.expires < blue.os.GetWallclockTime() 144 145 @property 146 def permanent(self): 147 return self.expires is None 148 149 def GetExpiresLabel(self): 150 if not self.licensed: 151 return 152 if self.isSingleUse and self.expires: 153 if self.expired: 154 return localization.GetByLabel('UI/Skins/SkinDurationSingleUseLicenseExpired') 155 else: 156 duration = self.expires - blue.os.GetWallclockTime() 157 expires = FormatTimeIntervalShortWritten(duration, showFrom=TIME_CATEGORY_DAY, showTo=TIME_CATEGORY_MINUTE) 158 return localization.GetByLabel('UI/Skins/SkinDurationSingleUseLicenseExpiresIn', expires=expires) 159 if self.isSingleUse: 160 return localization.GetByLabel('UI/Skins/SkinDurationSingleUse') 161 if self.expires is None: 162 return localization.GetByLabel('UI/Skins/SkinDurationPermanent') 163 duration = self.expires - blue.os.GetWallclockTime() 164 if duration < 0: 165 return localization.GetByLabel('UI/Skins/ExpiredLicense') 166 expires = FormatTimeIntervalShortWritten(duration, showFrom=TIME_CATEGORY_DAY, showTo=TIME_CATEGORY_MINUTE) 167 return localization.GetByLabel('UI/Skins/LicenseExpiresIn', expires=expires) 168 169 @property 170 def materialSetID(self): 171 return self._material.materialSetID 172 173 @property 174 def materialID(self): 175 return self._material.skinMaterialID 176 177 @property 178 def name(self): 179 messageID = int(self._material.displayNameID) 180 return localization.GetByMessageID(messageID) 181 182 @property 183 def types(self): 184 return self._skin.types 185 186 @property 187 def iconTexturePath(self): 188 return _skin_icon_texture_path(self._material.skinMaterialID) 189 190 @property 191 def colorPrimary(self): 192 return materialSets.GetColorPrimary(self._materialSet) 193 194 @property 195 def colorSecondary(self): 196 return materialSets.GetColorSecondary(self._materialSet) 197 198 @property 199 def colorHull(self): 200 return materialSets.GetColorHull(self._materialSet) 201 202 @property 203 def colorWindows(self): 204 return materialSets.GetColorWindows(self._materialSet) 205 206 @property 207 def skin_type(self): 208 return ShipSkinType.FIRST_PARTY_SKIN 209 210 def __eq__(self, other): 211 if other is None: 212 return False 213 if not hasattr(other, 'skinID'): 214 return False 215 if not hasattr(other, 'materialID'): 216 return False 217 if not hasattr(other, 'licensed'): 218 return False 219 if not hasattr(other, 'expires'): 220 return False 221 return self.skinID == other.skinID and self.materialID == other.materialID and self.licensed == other.licensed and self.expires == other.expires 222 223 def __repr__(self): 224 return "<%s material='%s' skinID=%s licensed=%s expires='%s'>" % (self.__class__.__name__, 225 self._material, 226 self.skinID, 227 self.licensed, 228 self.expires) 229 230 231 def _skin_icon_texture_path(materialID): 232 return 'res:/UI/Texture/classes/skins/icons/%s.png' % materialID