backgroundDeco.py (14555B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\factionalWarfare\enlistmentFlow\backgroundDeco.py 2 from __future__ import print_function 3 import math 4 import random 5 from carbonui.primitives.transform import Transform 6 from carbon.common.script.sys.serviceConst import ROLE_PROGRAMMER 7 from carbon.common.script.util.mathCommon import FloatCloseEnough 8 from carbonui.control.button import Button 9 from carbonui.control.window import Window 10 from carbonui.primitives.container import Container 11 from carbonui import const as uiconst 12 from carbonui.text.custom import TextCustom 13 from carbonui.primitives.sprite import Sprite 14 from carbonui.primitives.vectorlinetrace import DashedCircle 15 from carbonui.uianimations import animations 16 from carbonui.util.dpi import ScaleDpi 17 from eve.client.script.ui import eveColor 18 19 class BackgroundDeco(Container): 20 default_align = uiconst.TOPLEFT 21 default_width = 470 22 default_height = 470 23 default_state = uiconst.UI_NORMAL 24 25 def ApplyAttributes(self, attributes): 26 super(BackgroundDeco, self).ApplyAttributes(attributes) 27 self.colorSprites = [] 28 self.ConstructCentralDeco() 29 self.ConstructedCircles() 30 self.ConstuctInnerElements() 31 self.ConstructResizingElements() 32 self.ColorSprites(eveColor.CRYO_BLUE) 33 34 def ColorSprites(self, color): 35 for sprite in self.colorSprites: 36 sprite.SetRGBA(*color) 37 38 def ConstructSides(self): 39 self.sides = Sprite(name='sides', parent=self, align=uiconst.CENTER, pos=(0, 0, 1259, 340), opacity=1.0, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/circle/sides.png') 40 self.sidesDashes = Sprite(name='sidesDashes', parent=self, align=uiconst.CENTER, pos=(0, 0, 1257, 340), opacity=1.0, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/circle/sideDashes.png', color=eveColor.CRYO_BLUE) 41 42 def ConstructOutCircles(self): 43 self.outerCircle1 = Sprite(name='outerCircle1', parent=self, align=uiconst.CENTER, pos=(0, 0, 1036, 1056), opacity=3.0, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/circle/outeCircle1.png') 44 self.outerCircle2 = Sprite(name='outerCircle2', parent=self, align=uiconst.CENTER, pos=(0, 0, 1006, 1026), opacity=3.0, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/circle/outerCircle2.png', color=eveColor.CRYO_BLUE) 45 self.ellipse720 = Sprite(name='ellipse720', parent=self, align=uiconst.CENTER, pos=(0, 0, 834, 834), opacity=3.0, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/circle/ellipse720.png', color=eveColor.CRYO_BLUE) 46 47 def SetMainCircleSize(self, isBig, animate = True): 48 if isBig: 49 newScale = (1.0, 1.0) 50 else: 51 newScale = (0.75, 0.75) 52 if animate: 53 animations.MorphVector2(self.resizingTransform, 'scale', self.resizingTransform.scale, newScale) 54 else: 55 self.resizingTransform.scale = newScale 56 57 def Animate(self, sleep = False): 58 pass 59 60 def ConstructCentralDeco(self): 61 self.Construct_central_deco_1a() 62 self.Construct_central_deco_1a_color() 63 self.Construct_central_deco_1b() 64 self.Construct_central_deco_1b_color() 65 self.Construct_central_deco_2a() 66 self.Construct_central_deco_2a_color() 67 self.Construct_central_deco_2b() 68 self.Construct_central_deco_2b_color() 69 70 def Construct_central_deco_1a(self): 71 self.central_deco_1_a = Sprite(name='central_deco_1_a', parent=self, align=uiconst.CENTER, pos=(0, 0, 198, 340), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Central_decoration_1_A.png') 72 73 def Construct_central_deco_1a_color(self): 74 self.central_deco_1a_color = Sprite(name='central_deco_1a_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 198, 340), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Central_decoration_1_A_Colour.png') 75 self.colorSprites.append(self.central_deco_1a_color) 76 77 def Construct_central_deco_1b(self): 78 self.central_deco_ab = Sprite(name='central_deco_ab', parent=self, align=uiconst.CENTER, pos=(0, 0, 198, 340), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Central_decoration_1_B.png') 79 80 def Construct_central_deco_1b_color(self): 81 self.central_deco_1b_color = Sprite(name='central_deco_1b_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 198, 340), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Central_decoration_1_B_Colour.png') 82 self.colorSprites.append(self.central_deco_1b_color) 83 84 def Construct_central_deco_2a(self): 85 self.central_deco_2a = Sprite(name='central_deco_2a', parent=self, align=uiconst.CENTER, pos=(0, 0, 198, 340), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Central_decoration_2_A.png') 86 87 def Construct_central_deco_2a_color(self): 88 self.central_deco_2a_color = Sprite(name='central_deco_2a_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 198, 340), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Central_decoration_2_A_Colour.png') 89 self.colorSprites.append(self.central_deco_2a_color) 90 91 def Construct_central_deco_2b(self): 92 self.central_deco_2b = Sprite(name='central_deco_2b', parent=self, align=uiconst.CENTER, pos=(0, 0, 198, 340), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Central_decoration_2_B.png') 93 94 def Construct_central_deco_2b_color(self): 95 self.central_deco_2b_color = Sprite(name='central_deco_2b_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 198, 340), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Central_decoration_2_B_colour.png') 96 self.colorSprites.append(self.central_deco_2b_color) 97 98 def ConstructedCircles(self): 99 self.Construct_dashed_large_circle_outer() 100 self.Construct_dashed_large_circle_color() 101 self.Construct_dashed_large_circle_inner_ring() 102 self.Construct_external_deco() 103 self.Construct_external_deco_lights_color() 104 105 def Construct_dashed_large_circle_outer(self): 106 self.dashed_large_circle_outer = Sprite(name='dashed_large_circle_outer', parent=self, align=uiconst.CENTER, pos=(0, 0, 1034, 1056), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Dashed_large_circles_Outer_ring.png') 107 108 def Construct_dashed_large_circle_color(self): 109 self.dashed_large_circle_color = Sprite(name='dashed_large_circle_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 834, 474), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Dashed_large_circles_Colour.png') 110 self.colorSprites.append(self.dashed_large_circle_color) 111 112 def Construct_dashed_large_circle_inner_ring(self): 113 self.dashed_large_circle_inner_ring = Sprite(name='dashed_large_circle_inner_ring', parent=self, align=uiconst.CENTER, pos=(0, 0, 642, 641), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Dashed_large_circles_Inner_ring.png') 114 115 def Construct_ellipse_dashes_color(self): 116 self.dashed_large_circle_inner_ring = Sprite(name='Construct_ellipse_dashes_color', parent=self.resizingTransform, align=uiconst.CENTER, pos=(0, 0, 418, 420), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Ellipse_dashes_Colour.png') 117 self.colorSprites.append(self.dashed_large_circle_inner_ring) 118 119 def Construct_external_deco(self): 120 self.external_deco = Sprite(name='external_deco', parent=self, align=uiconst.CENTER, pos=(0, 0, 1131, 666), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/External_decorations.png') 121 122 def Construct_external_deco_lights_color(self): 123 self.external_deco_lights_color = Sprite(name='external_deco_lights_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 939, 654), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/External_decorations_lights_Colour.png') 124 self.colorSprites.append(self.external_deco_lights_color) 125 126 def ConstructHorizontal(self): 127 self.Construct_horizontal_deco_bottom_row() 128 self.Construct_horizontal_deco_bottom_row_detail_color() 129 self.Construct_horizontal_deco_top_row() 130 self.Construct_horizontal_deco_top_row_detail_color() 131 132 def Construct_horizontal_deco_bottom_row(self): 133 self.horizontal_deco_bottom_row = Sprite(name='horizontal_deco_bottom_row', parent=self, align=uiconst.CENTER, pos=(0, 0, 1260, 339), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Horizontal_decoration_BottomRow.png') 134 135 def Construct_horizontal_deco_bottom_row_detail_color(self): 136 self.external_deco_lights_color = Sprite(name='Construct_horizontal_deco_bottom_row_detail_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 1260, 339), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Horizontal_decoration_BottomRow_Detail_Colour.png') 137 self.colorSprites.append(self.external_deco_lights_color) 138 139 def Construct_horizontal_deco_top_row(self): 140 self.horizontal_deco_top_row = Sprite(name='horizontal_deco_top_row', parent=self, align=uiconst.CENTER, pos=(0, 0, 1260, 339), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Horizontal_decoration_TopRow.png') 141 142 def Construct_horizontal_deco_top_row_detail_color(self): 143 self.horizontal_deco_top_row_detail_color = Sprite(name='horizontal_deco_top_row_detail_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 1260, 339), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Horizontal_decoration_TopRow_Detail_Colour.png') 144 self.colorSprites.append(self.horizontal_deco_top_row_detail_color) 145 146 def ConstuctInnerElements(self): 147 self.Construct_inner_elements() 148 self.Construct_inner_elements_lights_color() 149 self.Construct_middle_edge_elements() 150 151 def ConstructResizingElements(self): 152 self.resizingTransform = Transform(parent=self, pos=(0, 0, 496, 496), align=uiconst.CENTER, scalingCenter=(0.5, 0.5)) 153 self.Construct_inner_dashed_ring() 154 self.Construct_inner_solid_ring() 155 self.Construct_radial_inner_glow() 156 self.Construct_radial_outer_glow_color() 157 self.Construct_ellipse_dashes_color() 158 159 def Construct_inner_dashed_ring(self): 160 self.inner_dashed_ring = Sprite(name='inner_dashed_ring', parent=self.resizingTransform, align=uiconst.CENTER, pos=(0, 0, 496, 496), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Inner_dashed_ring.png') 161 162 def Construct_inner_elements(self): 163 self.inner_elements = Sprite(name='inner_elements', parent=self, align=uiconst.CENTER, pos=(0, 0, 752, 688), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Inner_elements.png') 164 165 def Construct_inner_elements_lights_color(self): 166 self.inner_elements_lights_color = Sprite(name='inner_elements_lights_color', parent=self, align=uiconst.CENTER, pos=(0, 0, 691, 402), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Inner_elements_lights_Colour.png') 167 self.colorSprites.append(self.inner_elements_lights_color) 168 169 def Construct_inner_solid_ring(self): 170 self.inner_solid_ring = Sprite(name='inner_solid_ring', parent=self.resizingTransform, align=uiconst.CENTER, pos=(0, 0, 496, 496), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Inner_solid_ring.png') 171 172 def Construct_middle_edge_elements(self): 173 self.middle_edge_elements = Sprite(name='middle_edge_elements', parent=self, align=uiconst.CENTER, pos=(0, 0, 1209, 206), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Middle_edge_elements.png') 174 175 def Construct_radial_inner_glow(self): 176 self.radial_inner_glow = Sprite(name='radial_inner_glow', parent=self.resizingTransform, align=uiconst.CENTER, pos=(0, 0, 475, 492), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Radia_inner_glow.png') 177 178 def Construct_radial_outer_glow_color(self): 179 self.radial_outer_glow_color = Sprite(name='radial_outer_glow_color', parent=self.resizingTransform, align=uiconst.CENTER, pos=(0, 0, 599, 681), state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/Classes/Enlistment/deco/Radial_outer_glow_Colour.png') 180 self.colorSprites.append(self.radial_outer_glow_color) 181 182 183 class TestBgDeco(Window): 184 default_width = 1280 185 default_height = 720 186 default_windowID = 'testBgDeco' 187 default_minSize = (1280, 720) 188 default_fixedWidth = 1280 189 default_fixedHeight = 720 190 191 def DebugReload(self, *args): 192 self.Reload(self) 193 194 def ApplyAttributes(self, attributes): 195 super(TestBgDeco, self).ApplyAttributes(attributes) 196 bcgDeco = BackgroundDeco(parent=self.content, align=uiconst.CENTER) 197 reloadBtn = Button(parent=self.content, label='Reload', align=uiconst.TOPLEFT, func=self.DebugReload, top=0, idx=0) 198 199 def RotateDeco(deco): 200 print('deco.rotation = ', end=' ') 201 if FloatCloseEnough(deco.rotation, 0): 202 change = math.radians(22.5) 203 newValue = deco.rotation + change 204 else: 205 newValue = 0 206 animations.MorphScalar(deco, 'rotation', deco.rotation, newValue, duration=0.2) 207 208 Button(parent=self.content, label='elllipses', align=uiconst.TOPLEFT, func=lambda *args: RotateDeco(bcgDeco.ellipse720), top=30, idx=0) 209 Button(parent=self.content, label='outeCircle1', align=uiconst.TOPLEFT, func=lambda *args: RotateDeco(bcgDeco.outerCircle1), top=60, idx=0) 210 Button(parent=self.content, label='outeCircle2', align=uiconst.TOPLEFT, func=lambda *args: RotateDeco(bcgDeco.outerCircle2), top=90, idx=0) 211 Button(parent=self.content, label='change Color', align=uiconst.TOPLEFT, func=lambda *args: self.ChangeColor(bcgDeco), top=120, idx=0) 212 213 def ChangeColor(self, bgDeco): 214 colors = [eveColor.HOT_RED, eveColor.CRYO_BLUE, eveColor.WARNING_ORANGE] 215 color = random.choice(colors) 216 for sprite in bgDeco.colorSprites: 217 sprite.SetRGBA(*color)