assetMenu.py (12619B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation_new\assetMenu.py 2 import types 3 import carbonui.const as uiconst 4 import uthread 5 import charactercreator.const as ccConst 6 import localization 7 from carbonui.primitives.container import Container 8 from carbonui.primitives.fill import Fill 9 from carbonui.primitives.frame import Frame 10 from carbonui.primitives.sprite import Sprite 11 from carbonui.uicore import uicore 12 from eve.client.script.ui.login.charcreation_new.charCreationUtils import CCLabel 13 from eve.client.script.ui.login.charcreation_new.colorPalette import CCColorPalette 14 from eve.client.script.ui.login.charcreation_new.assetPicker import CharCreationAssetPicker, femaleModifierDisplayNames, maleModifierDisplayNames 15 GROUPNAMES = {ccConst.SKINGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Complexion', 16 ccConst.HAIRGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Hair', 17 ccConst.EYESGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Eyes', 18 ccConst.MAKEUPGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Makeup', 19 ccConst.SKINDETAILSGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/SkinDetails', 20 ccConst.CLOTHESGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Clothes', 21 ccConst.BODYGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Shape', 22 ccConst.BACKGROUNDGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Backgrounds', 23 ccConst.POSESGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Poses', 24 ccConst.LIGHTSGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Lights', 25 ccConst.PIERCINGGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Piercings', 26 ccConst.TATTOOGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Tattoos', 27 ccConst.SCARSGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Scars', 28 ccConst.PROSTHETICS: 'UI/Login/CharacterCreation/AssetMenu/Groups/Prosthetics', 29 ccConst.AUGMENTATIONS: 'UI/Login/CharacterCreation/AssetMenu/Groups/Augmentations', 30 ccConst.ARCHETYPESGROUP: 'UI/Login/CharacterCreation/AssetMenu/Groups/Archetypes'} 31 32 class CharCreationAssetMenu(Container): 33 34 def ApplyAttributes(self, attributes): 35 Container.ApplyAttributes(self, attributes) 36 self.name = attributes.menuType or 'CharCreationAssetMenu' 37 sm.GetService('cc').LogInfo('CharCreationAssetMenu::ApplyAttributes:: name = ', self.name) 38 if attributes.genderID == 0: 39 modifierNames = femaleModifierDisplayNames 40 else: 41 modifierNames = maleModifierDisplayNames 42 self.mainContainter = Container(parent=self, name='mainAssetMenuCont', align=uiconst.TOALL, state=uiconst.UI_PICKCHILDREN) 43 self.mainContainter.clipChildren = 1 44 self.togglerIdx = None 45 self.toggleFunc = attributes.toggleFunc 46 if self.toggleFunc: 47 self.togglerIdx = idx = attributes.get('togglerIdx', -1) 48 if idx == -1: 49 padTop = 16 50 padBottom = 4 51 else: 52 padTop = 4 53 padBottom = 16 54 self.menuToggler = CharCreationMenuToggler(parent=self.mainContainter, caption=localization.GetByLabel('UI/Login/CharacterCreation/AssetMenu/BodyModifications'), padTop=padTop, padBottom=padBottom, menuType=attributes.menuType, func=self.ToggleMenu, idx=idx) 55 for groupID, modifiers in attributes.groups: 56 if self._AreAllModifiersEmpty(modifiers): 57 continue 58 if type(groupID) == types.IntType: 59 caption = localization.GetByLabel(GROUPNAMES.get(groupID, 'UI/Login/CharacterCreation/AssetMenu/MissingCaption')) 60 else: 61 caption = localization.GetByLabel(modifierNames.get(groupID, 'UI/Login/CharacterCreation/AssetMenu/MissingCaption')) 62 CharCreationAssetPicker(parent=self.mainContainter, modifier=groupID, caption=caption, padTop=4, padBottom=4, genderID=attributes.genderID, bloodlineID=attributes.bloodlineID, charID=attributes.charID, isSubmenu=False, groupID=groupID) 63 for modifier in modifiers: 64 if self._IsModifierEmpty(modifier): 65 continue 66 caption = localization.GetByLabel(modifierNames.get(modifier, 'UI/Login/CharacterCreation/AssetMenu/MissingCaption')) 67 CharCreationAssetPicker(parent=self.mainContainter, modifier=modifier, caption=caption, padTop=-2, padBottom=4, genderID=attributes.genderID, bloodlineID=attributes.bloodlineID, isSubmenu=True, groupID=groupID) 68 69 menuState = settings.user.ui.Get('assetMenuState', {ccConst.BODYGROUP: True}) 70 for pickerContainer in self.mainContainter.children: 71 if isinstance(pickerContainer, CharCreationMenuToggler): 72 continue 73 key = pickerContainer.modifier or 'group_%s' % getattr(pickerContainer, 'groupID', '') 74 if not pickerContainer.isSubmenu and menuState.get(key, 0): 75 pickerContainer.Expand(initing=True) 76 77 if self.togglerIdx and self.menuToggler: 78 self.menuToggler.SetOrder(self.togglerIdx) 79 80 def _AreAllModifiersEmpty(self, modifiers): 81 return modifiers and not any([ not self._IsModifierEmpty(modifier) for modifier in modifiers ]) 82 83 def _IsModifierEmpty(self, modifier): 84 if type(modifier) is types.IntType: 85 return False 86 itemTypes, _ = uicore.layer.charactercreation.controller.GetAvailableStyles(modifier) 87 if itemTypes: 88 return False 89 return True 90 91 def ToggleMenu(self, *args): 92 if self.toggleFunc: 93 self.toggleFunc() 94 95 def CheckIfOversize(self, currentPicker = None): 96 canCollapse = [] 97 totalExpandedHeight = 0 98 for each in self.mainContainter.children: 99 if not isinstance(each, CharCreationAssetPicker): 100 continue 101 if each.state == uiconst.UI_HIDDEN: 102 continue 103 if each.IsExpanded(): 104 if not each.isSubmenu: 105 subs = each.GetMySubmenus() 106 totalExpandedHeight += each.padTop + each.GetExpandedHeight() + each.padBottom 107 if each is not currentPicker and currentPicker not in each.GetMySubmenus(): 108 canCollapse.append((each._expandTime, each)) 109 else: 110 totalExpandedHeight += each.padTop + each.GetExpandedHeight() + each.padBottom 111 if each is not currentPicker and each.isSubmenu: 112 canCollapse.append((each._expandTime, each)) 113 else: 114 totalExpandedHeight += each.padTop + each.GetCollapsedHeight() + each.padBottom 115 116 canCollapse.sort() 117 availableSpace = uicore.desktop.height - 150 - ccConst.BUTTON_AREA_HEIGHT 118 if totalExpandedHeight > availableSpace: 119 diff = totalExpandedHeight - availableSpace 120 for expandTime, each in canCollapse: 121 if each.IsExpanded(): 122 uthread.new(each.Collapse) 123 diff -= each.GetExpandedHeight() - each.GetCollapsedHeight() 124 if diff <= 0: 125 break 126 127 128 class CharCreationMenuToggler(Container): 129 __guid__ = 'uicls.CharCreationMenuToggler' 130 __notifyevents__ = ['OnColorPaletteChanged'] 131 FULLHEIGHT = 22 132 COLLAPSEHEIGHT = 22 133 default_align = uiconst.TOTOP 134 default_left = 0 135 default_top = 0 136 default_width = 0 137 default_height = COLLAPSEHEIGHT 138 default_pos = None 139 default_name = 'CharCreationMenuToggler' 140 default_state = uiconst.UI_PICKCHILDREN 141 142 def ApplyAttributes(self, attributes): 143 for each in uicore.layer.main.children: 144 if each.name == self.default_name: 145 each.Close() 146 147 info = uicore.layer.charactercreation.controller.GetInfo() 148 Container.ApplyAttributes(self, attributes) 149 if attributes.parent is None: 150 uicore.layer.main.children.append(self) 151 self.colorPaletteParent = Container(parent=self, align=uiconst.TOLEFT, width=CCColorPalette.COLORPALETTEWIDTH, name='colorPaletteParent', state=uiconst.UI_DISABLED) 152 self.captionParent = Container(parent=self, align=uiconst.TOTOP, height=self.COLLAPSEHEIGHT, name='captionParent', state=uiconst.UI_NORMAL) 153 self.func = attributes.func 154 self.captionParent.OnClick = self.Toggle 155 self.captionParent.OnMouseEnter = self.OnCaptionEnter 156 self.captionParent.OnMouseExit = self.OnCaptionExit 157 self.menuType = attributes.menuType 158 self.caption = CCLabel(parent=self.captionParent, align=uiconst.CENTERLEFT, left=10, letterspace=3, shadowOffset=(0, 0), text=attributes.caption, uppercase=1, color=ccConst.COLOR, fontsize=13) 159 if self.menuType != 'tattooMenu': 160 self.caption.SetAlpha(0.5) 161 self.keepColor = 0 162 self.AddRadioButton() 163 Fill(parent=self.captionParent, color=(0.4, 0.4, 0.4, 0.5)) 164 self.bevel = bevel = Frame(parent=self.captionParent, color=(1.0, 1.0, 1.0, 0.2), frameConst=ccConst.FILL_BEVEL, state=uiconst.UI_HIDDEN) 165 frame = Frame(parent=self.captionParent, frameConst=ccConst.FRAME_SOFTSHADE, color=(1.0, 1.0, 1.0, 0.5)) 166 frame.padding = (-12, -5, -12, -15) 167 self.height = self.captionParent.height 168 sm.RegisterNotify(self) 169 170 def AddRadioButton(self, *args): 171 self.shadowIcon = Sprite(parent=self.captionParent, name='shadowIcon', align=uiconst.CENTERRIGHT, state=uiconst.UI_DISABLED, pos=(0, 0, 32, 32), texturePath='res:/UI/Texture/CharacterCreation/radiobuttonShadow.dds', color=(0.4, 0.4, 0.4, 0.6)) 172 self.backIcon = Sprite(parent=self.captionParent, name='backIcon', align=uiconst.CENTERRIGHT, state=uiconst.UI_DISABLED, pos=(0, 0, 32, 32), texturePath='res:/UI/Texture/CharacterCreation/radiobuttonBack.dds') 173 self.radioBtnFill = Container(parent=self.captionParent, state=uiconst.UI_HIDDEN, align=uiconst.CENTERRIGHT, pos=(0, 0, 32, 32), idx=0) 174 self.radioBtnHilite = Sprite(parent=self.radioBtnFill, name='radioBtnHilite', align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(0, 0, 32, 32), texturePath='res:/UI/Texture/CharacterCreation/radiobuttonWhite.dds') 175 self.radioBtnColor = Sprite(parent=self.radioBtnFill, name='radioBtnColor', align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(0, 0, 32, 32), texturePath='res:/UI/Texture/CharacterCreation/radiobuttonColor.dds') 176 if self.menuType == 'tattooMenu': 177 self.SetRadioBtnColor(color='green') 178 179 def OnCaptionEnter(self, *args): 180 uicore.layer.charactercreation.controller.SetHintText(None, localization.GetByLabel('UI/Login/CharacterCreation/AssetMenu/BodyModHelp')) 181 sm.StartService('audio').SendUIEvent(unicode('ui_icc_menu_mouse_over_play')) 182 if not self.keepColor: 183 self.caption.SetAlpha(1.0) 184 if self.menuType == 'tattooMenu': 185 self.SetRadioBtnColor(color='red') 186 elif self.menuType == 'assetMenu': 187 self.SetRadioBtnColor(color='green') 188 if self.bevel: 189 self.bevel.state = uiconst.UI_DISABLED 190 191 def OnCaptionExit(self, *args): 192 uicore.layer.charactercreation.controller.SetHintText(None) 193 if self.menuType != 'tattooMenu': 194 self.caption.SetAlpha(0.5) 195 if not self.keepColor: 196 if self.menuType == 'tattooMenu': 197 self.SetRadioBtnColor(color='green') 198 else: 199 self.radioBtnFill.state = uiconst.UI_HIDDEN 200 if self.bevel: 201 self.bevel.state = uiconst.UI_HIDDEN 202 203 def Toggle(self, *args): 204 sm.StartService('audio').SendUIEvent(unicode('ui_icc_button_mouse_down_play')) 205 self.keepColor = 1 206 if self.func: 207 self.func() 208 self.ResetRadioButton() 209 210 def ResetRadioButton(self, *args): 211 self.keepColor = 0 212 if self.menuType != 'tattooMenu': 213 self.caption.SetAlpha(0.5) 214 if self.menuType == 'tattooMenu': 215 self.SetRadioBtnColor(color='green') 216 else: 217 self.radioBtnFill.state = uiconst.UI_HIDDEN 218 219 def OnColorPaletteChanged(self, width): 220 self.colorPaletteParent.width = width 221 222 def SetRadioBtnColor(self, color = 'green', *args): 223 if color == 'green': 224 self.radioBtnFill.state = uiconst.UI_DISABLED 225 self.radioBtnColor.SetRGB(0, 1, 0) 226 self.radioBtnHilite.SetAlpha(0.7) 227 elif color == 'red': 228 self.radioBtnFill.state = uiconst.UI_DISABLED 229 self.radioBtnColor.SetRGB(1, 0, 0) 230 self.radioBtnHilite.SetAlpha(0.3)