omegaCloneIcon.py (3210B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\cloneGrade\omegaCloneIcon.py 2 from carbon.client.script.environment.AudioUtil import PlaySound 3 from carbonui.primitives.container import Container 4 from carbonui.primitives.sprite import Sprite 5 import carbonui.const as uiconst 6 from clonegrade import COLOR_OMEGA_GOLD 7 from clonegrade.const import TEXTUREPATH_OMEGA_64, TEXTUREPATH_OMEGA_32, TEXTUREPATH_OMEGA_24, TEXTUREPATH_OMEGA_18 8 from eve.client.script.ui import eveColor 9 from eve.client.script.ui.shared.cloneGrade import cloneStateUtil 10 import expertSystems.client 11 from localization import GetByLabel 12 from carbonui.uicore import uicore 13 from omega.client.clone_grade_svc import get_clone_grade_svc 14 15 class OmegaCloneIcon(Container): 16 default_name = 'OmegaCloneIcon' 17 default_state = uiconst.UI_NORMAL 18 default_align = uiconst.TOPLEFT 19 20 def ApplyAttributes(self, attributes): 21 Container.ApplyAttributes(self, attributes) 22 self.baseOpacity = attributes.get('opacity', self.default_opacity) 23 self.tooltipText = attributes.get('tooltipText', None) 24 self.unlockedWithExpertSystems = attributes.get('unlockedWithExpertSystems') 25 self.origin = attributes.origin 26 self.reason = attributes.reason 27 self.construct_layout() 28 self.UpdateIcon() 29 30 def construct_layout(self): 31 self.icon = Sprite(name='icon', bgParent=self) 32 33 def UpdateIcon(self): 34 if self.width <= 18: 35 self.icon.texturePath = TEXTUREPATH_OMEGA_18 36 elif self.width <= 24: 37 self.icon.texturePath = TEXTUREPATH_OMEGA_24 38 elif self.width <= 32: 39 self.icon.texturePath = TEXTUREPATH_OMEGA_32 40 else: 41 self.icon.texturePath = TEXTUREPATH_OMEGA_64 42 self.icon.rgba = COLOR_OMEGA_GOLD if self.width <= 18 else eveColor.WHITE 43 44 def OnClick(self, *args): 45 PlaySound(uiconst.SOUND_BUTTON_CLICK) 46 uicore.cmd.OpenCloneUpgradeWindow(self.origin, self.reason) 47 48 def OnMouseEnter(self, *args): 49 self.FadeIn() 50 PlaySound(uiconst.SOUND_BUTTON_HOVER) 51 sm.ScatterEvent('OnOmegaIconMouseEnter') 52 53 def OnMouseExit(self, *args): 54 self.FadeOut() 55 sm.ScatterEvent('OnOmegaIconMouseExit') 56 57 def FadeIn(self): 58 uicore.animations.FadeTo(self, self.opacity, 1.5 * self.baseOpacity, duration=0.3) 59 60 def FadeOut(self): 61 uicore.animations.FadeTo(self, self.opacity, self.baseOpacity, duration=0.3) 62 63 def GetTooltipText(self): 64 if self.tooltipText: 65 return self.tooltipText 66 elif get_clone_grade_svc().is_omega_with_grace_period(): 67 return GetByLabel('UI/CloneState/RequiresOmegaCloneIsOmega') 68 else: 69 return GetByLabel('UI/CloneState/RequiresOmegaClone') 70 71 def LoadTooltipPanel(self, tooltipPanel, *args): 72 text = self.GetTooltipText() 73 if self.unlockedWithExpertSystems: 74 tooltipPanel.LoadGeneric1ColumnTemplate() 75 expertSystems.add_generic_unlocked_by_expert_systems(tooltipPanel) 76 else: 77 cloneStateUtil.LoadTooltipPanel(tooltipPanel, text, origin=self.origin, reason=self.reason)