nebulaBackground.py (2831B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\studio\nebulaBackground.py 2 from carbonui import Align, uiconst 3 from carbonui.primitives.container import Container 4 from carbonui.primitives.sprite import Sprite 5 from carbonui.uianimations import animations 6 from eve.client.script.ui.cosmetics.ship.pages.studio import nebulaConsts 7 8 class SkinrBackgroundContainer(Container): 9 background_opacity = 0.5 10 background_fade_duration = 0.4 11 asset_size_offset = 100 12 13 def __init__(self, *args, **kwargs): 14 super(SkinrBackgroundContainer, self).__init__(*args, **kwargs) 15 self.connect_signals() 16 self.top_container = Container(name='top_container', parent=self, align=Align.TOTOP, pickState=uiconst.TR2_SPS_OFF, bgColor=(0, 0, 0)) 17 self.bottom_container = Container(name='bottom_container', parent=self, align=Align.TOBOTTOM, pickState=uiconst.TR2_SPS_OFF, bgColor=(0, 0, 0)) 18 self.left_container = Container(name='left_container', parent=self, align=Align.TOLEFT, pickState=uiconst.TR2_SPS_OFF, bgColor=(0, 0, 0)) 19 self.right_container = Container(name='right_container', parent=self, align=Align.TORIGHT, pickState=uiconst.TR2_SPS_OFF, bgColor=(0, 0, 0)) 20 self.mid_container = Container(name='mid_container', parent=self, align=Align.TOALL, pickState=uiconst.TR2_SPS_OFF) 21 self.bg_circle = Sprite(parent=self.mid_container, name='bg_cutout', texturePath='res:/UI/Texture/classes/Cosmetics/Ship/nebula_bg_fade.png', align=Align.TOALL) 22 self.on_nebula_changed(nebulaConsts.SELECTED_SKINR_BACKGROUND.get()) 23 24 def connect_signals(self): 25 nebulaConsts.SELECTED_SKINR_BACKGROUND.on_change.connect(self.on_nebula_changed) 26 27 def disconnect_signals(self): 28 nebulaConsts.SELECTED_SKINR_BACKGROUND.on_change.disconnect(self.on_nebula_changed) 29 30 def Close(self): 31 try: 32 self.disconnect_signals() 33 finally: 34 super(SkinrBackgroundContainer, self).Close() 35 36 def on_nebula_changed(self, value): 37 self.fade_to_opacity(0.0) if value is nebulaConsts.BackgroundEnum.Empty else self.fade_to_opacity(self.background_opacity) 38 39 def fade_to_opacity(self, target_opacity): 40 if not nebulaConsts.skinr_nebula_backgrounds_enabled(): 41 target_opacity = 0.0 42 animations.FadeTo(self, self.opacity, target_opacity, duration=self.background_fade_duration) 43 44 def adjust_size(self, width_available, height_available): 45 self.left_container.width = width_available - self.asset_size_offset 46 self.right_container.width = width_available - self.asset_size_offset 47 self.top_container.height = height_available - self.asset_size_offset 48 self.bottom_container.height = height_available - self.asset_size_offset