omega_frame.py (6251B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\omega\upsell\components\omega_frame.py 2 import math 3 from carbonui import Align, PickState, uiconst 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.frame import Frame 6 from carbonui.primitives.gradientSprite import GradientSprite 7 from carbonui.primitives.sprite import Sprite 8 from carbonui.primitives.transform import Transform 9 from carbonui.uianimations import animations 10 from eve.client.script.ui import eveColor 11 from itertoolsext.Enum import Enum 12 13 class FrameDecoration(Frame): 14 default_texturePath = 'res:/UI/Texture/classes/OmegaUpsell/frame_decoration.png' 15 default_color = eveColor.OMEGA_ACCENT 16 default_opacity = 0.5 17 default_cornerSize = 5 18 19 20 class FrameDecorationBestDeal(FrameDecoration): 21 default_color = eveColor.CRYO_BLUE 22 23 24 class FrameHighlight(FrameDecoration): 25 default_color = eveColor.WHITE 26 default_opacity = 1.0 27 default_glowBrightness = 0.3 28 default_outputMode = uiconst.OutputMode.COLOR_AND_GLOW 29 30 31 class BaseBackgroundHighlight(Sprite): 32 default_align = Align.TOALL 33 default_state = uiconst.UI_DISABLED 34 default_texturePath = 'res:/UI/Texture/classes/OmegaUpsell/highlights/280x528.png' 35 default_color = eveColor.OMEGA_ACCENT 36 default_opacity = 0.25 37 idle_opacity = 0.0 38 hover_opacity = 0.25 39 40 41 class OfferBackgroundHighlight(BaseBackgroundHighlight): 42 default_color = eveColor.LED_GREY 43 44 45 class OfferBackgroundHighlightBestDeal(BaseBackgroundHighlight): 46 idle_opacity = 0.125 47 default_color = eveColor.CRYO_BLUE 48 49 50 class BenefitBackgroundHighlight(BaseBackgroundHighlight): 51 default_texturePath = 'res:/UI/Texture/classes/OmegaUpsell/highlights/256x112.png' 52 53 54 class DefaultOfferBackgroundHighlight(BaseBackgroundHighlight): 55 default_texturePath = 'res:/UI/Texture/classes/OmegaUpsell/highlights/960x140.png' 56 57 58 @Enum 59 60 class OmegaFrameState(object): 61 IDLE = 0 62 HOVER = 1 63 64 65 class BaseOmegaOfferBackground(Container): 66 highlight_class = BaseBackgroundHighlight 67 hover_rgb_data = eveColor.OMEGA_SECONDARY_GRADIENT_RGB_DATA 68 idle_rgb_data = eveColor.OMEGA_PRIMARY_GRADIENT_RGB_DATA 69 70 def __init__(self, *args, **kwargs): 71 super(BaseOmegaOfferBackground, self).__init__(*args, **kwargs) 72 self.construct_layout() 73 74 def construct_layout(self): 75 self.highlight = self.highlight_class(name='highlight', parent=self, opacity=self.highlight_class.idle_opacity) 76 self.hover = GradientSprite(name='hover', parent=self, align=Align.TOALL, pickState=PickState.OFF, rgbData=self.hover_rgb_data, rotation=-math.pi / 2, opacity=0.0) 77 self.idle = GradientSprite(name='idle', parent=self, align=Align.TOALL, pickState=PickState.OFF, rgbData=self.idle_rgb_data, rotation=-math.pi / 2) 78 79 def set_state(self, state, duration = 0.4): 80 if state == OmegaFrameState.IDLE: 81 animations.FadeIn(self.idle, duration=duration) 82 animations.FadeOut(self.hover, duration=duration) 83 animations.FadeTo(obj=self.highlight, startVal=self.highlight.opacity, endVal=self.highlight_class.idle_opacity, duration=duration) 84 return 85 if state == OmegaFrameState.HOVER: 86 animations.FadeOut(self.idle, duration=duration) 87 animations.FadeIn(self.hover, duration=duration) 88 animations.FadeTo(obj=self.highlight, startVal=self.highlight.opacity, endVal=self.highlight_class.hover_opacity, duration=duration) 89 return 90 91 92 class OmegaOfferBackground(BaseOmegaOfferBackground): 93 highlight_class = OfferBackgroundHighlight 94 hover_rgb_data = eveColor.OMEGA_PRIMARY_GRADIENT_RGB_DATA 95 96 97 class OmegaOfferBackgroundBestDeal(OmegaOfferBackground): 98 highlight_class = OfferBackgroundHighlightBestDeal 99 100 101 class OmegaBenefitBackground(BaseOmegaOfferBackground): 102 highlight_class = BenefitBackgroundHighlight 103 104 105 class OmegaDefaultOfferBackground(BaseOmegaOfferBackground): 106 highlight_class = DefaultOfferBackgroundHighlight 107 108 109 class BaseOmegaOfferFrame(Container): 110 background_class = OmegaOfferBackground 111 top_decoration_class = FrameDecoration 112 113 def __init__(self, *args, **kwargs): 114 super(BaseOmegaOfferFrame, self).__init__(*args, **kwargs) 115 self.construct_layout() 116 117 def construct_layout(self): 118 self.construct_containers() 119 self.construct_background() 120 self.construct_frame() 121 122 def construct_containers(self): 123 self.frame_container = Container(name='frame_container', parent=self) 124 self.background_container = Container(name='background_container', parent=self) 125 126 def construct_background(self): 127 self.container_background = self.background_class(name='container_background', parent=self.background_container) 128 129 def construct_frame(self): 130 self.top_highlight = FrameHighlight(name='top_highlight', parent=self.frame_container, opacity=0.0) 131 self.top_decoration_class(name='top_decoration', parent=self.frame_container) 132 self.construct_bottom_frame_decoration() 133 Frame(name='frame', parent=self.frame_container, color=eveColor.OMEGA_TERTIARY) 134 135 def construct_bottom_frame_decoration(self): 136 bottom_container = Transform(name='bottom_container', parent=self.frame_container, align=Align.TOALL, rotation=math.pi) 137 FrameDecoration(name='bottom_decoration', parent=bottom_container) 138 139 def set_state(self, state, duration = 0.4): 140 self.container_background.set_state(state, duration) 141 if state == OmegaFrameState.IDLE: 142 animations.FadeOut(self.top_highlight, duration=duration) 143 return 144 if state == OmegaFrameState.HOVER: 145 animations.FadeIn(self.top_highlight, duration=duration) 146 return 147 148 149 class OmegaOfferFrame(BaseOmegaOfferFrame): 150 151 def set_state(self, state, duration = 0.4): 152 self.container_background.set_state(state, duration) 153 154 155 class OmegaOfferFrameBestDeal(OmegaOfferFrame): 156 background_class = OmegaOfferBackgroundBestDeal 157 top_decoration_class = FrameDecorationBestDeal 158 159 160 class OmegaBenefitFrame(BaseOmegaOfferFrame): 161 background_class = OmegaBenefitBackground 162 163 def construct_bottom_frame_decoration(self): 164 pass