skinrInSceneContainer.py (4086B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\studio\skinrInSceneContainer.py 2 import geo2 3 import math 4 from carbonui import Align, uiconst 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.sprite import Sprite 7 from carbonui.ui3d import InSceneContainer 8 from carbonui.uianimations import animations 9 from cosmetics.client.ships import ship_skin_signals 10 from cosmetics.client.ships.skins.live_data import current_skin_design 11 from cosmetics.common.ships.skins.static_data.skin_type import ShipSkinType 12 from eve.client.script.ui import eveColor 13 from eve.client.script.ui.cosmetics.ship import shipUtil 14 from eve.client.script.ui.cosmetics.ship.pages.collection import collectionSignals 15 16 class SkinrInSceneContainer(InSceneContainer): 17 default_isFullscreen = False 18 default_width = 1638 19 default_height = 1638 20 21 def __init__(self, *args, **kwargs): 22 super(SkinrInSceneContainer, self).__init__(*args, **kwargs) 23 self.scale_offset = 0.0 24 self._is_expanded = False 25 self.content = Container(name='content', parent=self) 26 self.bg_sprite = Sprite(parent=self.content, texturePath='res:/UI/Texture/classes/Cosmetics/Ship/scene_bg.png', align=Align.CENTER, pos=(0, 0, 1340, 1316), color=eveColor.TUNGSTEN_GREY, opacity=0.15) 27 animations.FadeTo(self.content, 0.0, 1.0, duration=2.4) 28 self.connect_signals() 29 30 def connect_signals(self): 31 self._camera.on_update.connect(self.on_camera_update) 32 self._camera.on_orbit.connect(self.on_orbit) 33 collectionSignals.on_activated_skin_license_selected.connect(self.on_activated_skin_license_selected) 34 ship_skin_signals.on_skin_state_set.connect(self.on_skin_state_set) 35 36 def update(self): 37 self.update_bg_color() 38 39 def on_skin_state_set(self, ship_id, skin_state): 40 self.update_bg_color() 41 42 def update_bg_color(self): 43 ship_skin_state = shipUtil.get_active_ship_skin_state() 44 if ship_skin_state is None or ship_skin_state.skin_type != ShipSkinType.THIRD_PARTY_SKIN: 45 is_applied = False 46 else: 47 is_applied = ship_skin_state.skin_data.skin_id == current_skin_design.get().design_hex 48 self._update_bg_color(is_applied) 49 50 def _update_bg_color(self, is_applied): 51 color = self.get_bg_color(is_applied) 52 animations.SpColorMorphTo(self.bg_sprite, self.bg_sprite.rgba, color, duration=0.3) 53 54 def on_activated_skin_license_selected(self, skin_license): 55 is_applied = shipUtil.is_currently_applied_skin(skin_license.skin_hex) 56 self._update_bg_color(is_applied) 57 58 def get_bg_color(self, is_applied): 59 if is_applied: 60 return list(eveColor.CRYO_BLUE[:3]) + [0.3] 61 else: 62 return list(eveColor.TUNGSTEN_GREY[:3]) + [0.15] 63 64 def on_orbit(self): 65 if self._is_expanded: 66 return 67 self._is_expanded = True 68 animations.FadeTo(self.content, self.content.opacity, 0.75, duration=0.6) 69 70 def on_mouse_up(self, button): 71 if button not in (uiconst.MOUSELEFT, uiconst.MOUSERIGHT): 72 return 73 self._is_expanded = False 74 animations.FadeTo(self.content, self.content.opacity, 1.0, duration=0.6) 75 animations.MorphScalar(self, 'scale_offset', self.scale_offset, 0.0, duration=0.6) 76 77 def on_camera_update(self): 78 translation = geo2.Vec3Add(self._camera.eyePosition, geo2.Vec3Scale(self._camera.GetLookAtDirection(), -1000)) 79 self.transform.translation = translation 80 self.transform.rotation = geo2.QuaternionRotationSetYawPitchRoll(self._camera.yaw, math.pi / 2 - self._camera.pitch, 0.25 * self.scale_offset + self._camera.centerOffset) 81 self.scaling = (1.0 - 0.1 * self._camera.zoom + self.scale_offset) * self.width 82 83 def disable_render_steps(self): 84 pass 85 86 @property 87 def scaling(self): 88 return self.transform.scaling[0] 89 90 @scaling.setter 91 def scaling(self, value): 92 self.transform.scaling = (value, value, 1.0)