hexes.py (10035B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation_new\hexes.py 2 import carbonui.const as uiconst 3 from carbon.client.script.environment.AudioUtil import PlaySound 4 from carbonui.loggers.buttonLogger import log_button_clicked 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.sprite import Sprite 7 from carbonui.uianimations import animations 8 from eve.client.script.ui import eveColor 9 10 class CCHexButtonMedium(Container): 11 texture_0 = 'res:/UI/Texture/CharacterCreation/hexes/bloodlines.dds' 12 textureInv_0 = 'res:/UI/Texture/CharacterCreation/hexes/bloodlinesInverted.dds' 13 frameTexture = 'res:/UI/Texture/CharacterCreation/hexes/mediumHexFrame.dds' 14 bgTexture = 'res:/UI/Texture/CharacterCreation/hexes/mediumHexBg.dds' 15 bevelTexture = 'res:/UI/Texture/CharacterCreation/hexes/mediumHexBevel.dds' 16 shawdowTexture = 'res:/UI/Texture/CharacterCreation/hexes/mediumHexShadow.dds' 17 numColumns = 4 18 hexPadWidth = 0 19 hexPadHeight = 0 20 wInterval = 64 21 hInterval = 64 22 rectW = 64 23 rectH = 64 24 shadowOffset = 1 25 default_analyticID = '' 26 27 def ApplyAttributes(self, attributes): 28 Container.ApplyAttributes(self, attributes) 29 self.hint = self.hexName = attributes.hexName or '' 30 self.info = attributes.info 31 self.func = attributes.func 32 self.id = attributes.id 33 self.iconNum = attributes.iconNum 34 self.showIcon = attributes.get('showIcon', 1) 35 self.clickable = attributes.get('clickable', 1) 36 self.showBg = self.clickable 37 self.analyticID = attributes.get('analyticID', self.default_analyticID) 38 self.SetupHex() 39 40 def SetupHex(self, *args): 41 textureNum, logoLocation = self.GetLogoLocation() 42 normalCont = Container(name='normal', parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED) 43 if self.showBg: 44 sprite = Sprite(name='normalBg', parent=normalCont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=self.bgTexture, padding=(-self.hexPadWidth, 45 -self.hexPadHeight, 46 -self.hexPadWidth, 47 -self.hexPadHeight)) 48 sprite.SetRGBA(0.35, 0.35, 0.35, 0.3) 49 sprite = Sprite(name='normalBevel', parent=normalCont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=self.bevelTexture, padding=(-self.hexPadWidth, 50 -self.hexPadHeight, 51 -self.hexPadWidth, 52 -self.hexPadHeight)) 53 sprite.SetAlpha(0.2) 54 self.bevel = sprite 55 if self.showIcon: 56 sprite = Sprite(name='normalIcon', parent=normalCont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=getattr(self, 'texture_%s' % textureNum, '')) 57 sprite.rectLeft, sprite.rectTop, sprite.rectWidth, sprite.rectHeight = logoLocation 58 sprite.SetAlpha(1.0) 59 self.logo = sprite 60 shadowOffset = getattr(self, 'shadowOffset', 3) 61 sprite = Sprite(name='normalShadow', parent=normalCont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=getattr(self, 'texture_%s' % textureNum, ''), padding=(shadowOffset, 62 shadowOffset, 63 -shadowOffset, 64 -shadowOffset)) 65 sprite.rectLeft, sprite.rectTop, sprite.rectWidth, sprite.rectHeight = logoLocation 66 sprite.SetRGBA(0.0, 0.0, 0.0, 0.3) 67 self.normalCont = normalCont 68 name = '%sFrame' % self.hexName 69 sprite = Sprite(name=name, parent=self, align=uiconst.TOALL, state=uiconst.UI_HIDDEN, texturePath=self.frameTexture, padding=(-self.hexPadWidth, 70 -self.hexPadHeight, 71 -self.hexPadWidth, 72 -self.hexPadHeight)) 73 sprite.SetAlpha(0.2) 74 self.frame = sprite 75 name = '%sSelection' % self.hexName 76 selectionCont = Container(name='selectionCont', parent=self, align=uiconst.TOALL, state=uiconst.UI_HIDDEN) 77 sprite = Sprite(name=name, parent=selectionCont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=getattr(self, 'textureInv_%s' % textureNum, '')) 78 sprite.rectLeft, sprite.rectTop, sprite.rectWidth, sprite.rectHeight = logoLocation 79 sprite = Sprite(name=name, parent=selectionCont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=getattr(self, 'textureInv_%s' % textureNum, ''), padding=(2, 2, -2, -2)) 80 sprite.rectLeft, sprite.rectTop, sprite.rectWidth, sprite.rectHeight = logoLocation 81 sprite.SetRGBA(0.0, 0.0, 0.0, 0.3) 82 self.selection = selectionCont 83 if self.showBg: 84 sprite = Sprite(name='shadow', parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath=self.shawdowTexture, padding=(-self.hexPadWidth, 85 -self.hexPadHeight, 86 -self.hexPadWidth, 87 -self.hexPadHeight)) 88 sprite.SetAlpha(0.5) 89 90 def OnClick(self, *args): 91 if not self.clickable: 92 return 93 log_button_clicked(self) 94 if self.func: 95 self.func(self) 96 97 def OnMouseEnter(self, *args): 98 if not self.clickable: 99 return 100 PlaySound('ui_icc_button_mouse_over_play') 101 if getattr(self, 'frame', None) is not None: 102 self.frame.state = uiconst.UI_DISABLED 103 if getattr(self, 'bevel', None) is not None: 104 self.bevel.SetAlpha(0.5) 105 106 def OnMouseExit(self, *args): 107 if not self.clickable: 108 return 109 if getattr(self, 'frame', None) is not None: 110 self.frame.state = uiconst.UI_HIDDEN 111 if getattr(self, 'bevel', None) is not None: 112 self.bevel.SetAlpha(0.2) 113 114 def SelectHex(self, allConts = []): 115 PlaySound('ui_icc_button_mouse_down_play') 116 for c in allConts: 117 c.normalCont.state = uiconst.UI_DISABLED 118 c.frame.state = uiconst.UI_HIDDEN 119 c.selection.state = uiconst.UI_HIDDEN 120 121 self.normalCont.state = uiconst.UI_HIDDEN 122 self.selection.state = uiconst.UI_DISABLED 123 124 def GetLogoLocation(self, *args): 125 iconNum = self.iconNum 126 numInFile = pow(self.numColumns, 2) 127 textureNum = iconNum / numInFile 128 newIconNum = iconNum - numInFile * textureNum 129 j = newIconNum / self.numColumns 130 i = newIconNum % self.numColumns 131 leftOffset = getattr(self, 'leftOffset', 0) 132 topOffset = getattr(self, 'topOffset', 0) 133 top = topOffset + j * self.hInterval 134 left = leftOffset + i * self.wInterval 135 return (textureNum, (left, 136 top, 137 self.rectW, 138 self.rectH)) 139 140 141 class CCHexButtonRace2(CCHexButtonMedium): 142 __guid__ = 'uicls.CCHexButtonRace2' 143 texture_0 = 'res:/UI/Texture/CharacterCreation/hexes/smallRaceGenderHexes.dds' 144 textureInv_0 = 'res:/UI/Texture/CharacterCreation/hexes/smallRaceGenderHexesInverted.dds' 145 frameTexture = 'res:/UI/Texture/CharacterCreation/hexes/mediumHexFrame.dds' 146 bgTexture = 'res:/UI/Texture/CharacterCreation/hexes/mediumHexBg.dds' 147 topOffset = 64 148 149 150 class CCHexButtonGender2(CCHexButtonMedium): 151 __guid__ = 'uicls.CCHexButtonGender2' 152 texture_0 = 'res:/UI/Texture/CharacterCreation/hexes/smallRaceGenderHexes.dds' 153 textureInv_0 = 'res:/UI/Texture/CharacterCreation/hexes/smallRaceGenderHexesInverted.dds' 154 155 156 class CCHexButtonAncestry(CCHexButtonMedium): 157 __guid__ = 'uicls.CCHexButtonAncestry' 158 texture_0 = 'res:/UI/Texture/CharacterCreation/hexes/ancestries1.dds' 159 textureInv_0 = 'res:/UI/Texture/CharacterCreation/hexes/ancestriesInverted1.dds' 160 texture_1 = 'res:/UI/Texture/CharacterCreation/hexes/ancestries2.dds' 161 textureInv_1 = 'res:/UI/Texture/CharacterCreation/hexes/ancestriesInverted2.dds' 162 texture_2 = 'res:/UI/Texture/CharacterCreation/hexes/ancestries3.dds' 163 textureInv_2 = 'res:/UI/Texture/CharacterCreation/hexes/ancestriesInverted3.dds' 164 165 166 class CCHexButtonSchool(CCHexButtonMedium): 167 __guid__ = 'uicls.CCHexButtonSchool' 168 texture_0 = 'res:/UI/Texture/CharacterCreation/hexes/ancestries3.dds' 169 textureInv_0 = 'res:/UI/Texture/CharacterCreation/hexes/ancestriesInverted3.dds' 170 topOffset = 192 171 leftOffset = 64 172 173 174 class CCHexButtonHead(CCHexButtonMedium): 175 __guid__ = 'uicls.CCHexButtonHead' 176 texture_0 = '' 177 textureInv_0 = 'res:/UI/Texture/CharacterCreation/headPickerBG.dds' 178 frameTexture = 'res:/UI/Texture/CharacterCreation/headPickerFrame.dds' 179 bgTexture = 'res:/UI/Texture/CharacterCreation/headPickerBG.dds' 180 bevelTexture = 'res:/UI/Texture/CharacterCreation/headPickerBevel.dds' 181 shawdowTexture = 'res:/UI/Texture/CharacterCreation/headPickerShadow.dds' 182 numColumns = 1 183 shadowOffset = 0 184 default_analyticID = 'CCHexButtonHead' 185 186 187 class CCHexButtonBody(CCHexButtonMedium): 188 __guid__ = 'uicls.CCHexButtonBody' 189 texture_0 = '' 190 textureInv_0 = 'res:/UI/Texture/CharacterCreation/bodyPickerBG.dds' 191 frameTexture = 'res:/UI/Texture/CharacterCreation/bodyPickerFrame.dds' 192 bgTexture = 'res:/UI/Texture/CharacterCreation/bodyPickerBG.dds' 193 bevelTexture = 'res:/UI/Texture/CharacterCreation/bodyPickerBevel.dds' 194 shawdowTexture = 'res:/UI/Texture/CharacterCreation/bodyPickerShadow.dds' 195 numColumns = 1 196 shadowOffset = 0 197 wInterval = 128 198 hInterval = 128 199 rectW = 128 200 rectH = 128 201 default_analyticID = 'CCHexButtonBody' 202 203 204 class CCHexButtonRandomize(CCHexButtonMedium): 205 __guid__ = 'uicls.CCHexButtonRandomize' 206 texture_0 = 'res:/UI/Texture/CharacterCreation/randomize_arrows.png' 207 numColumns = 1 208 default_analyticID = 'CCHexButtonRandomize' 209 210 def ApplyAttributes(self, attributes): 211 super(CCHexButtonRandomize, self).ApplyAttributes(attributes) 212 self.logo.padding = 5 213 self.logo.SetRGBA(*eveColor.PRIMARY_BLUE) 214 215 def StartBlinking(self): 216 animations.BlinkIn(self.logo, startVal=0.5, endVal=1.2, duration=1.2, loops=-1, curveType=uiconst.ANIM_WAVE) 217 218 def StopBlinking(self): 219 self.logo.StopAnimations() 220 self.logo.opacity = 1.0