mutationBar.py (2490B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\dynamicItem\mutationBar.py 2 from carbonui import uiconst 3 from carbonui.primitives.container import Container 4 from carbonui.primitives.containerAutoSize import ContainerAutoSize 5 from carbonui.primitives.fill import Fill 6 from carbonui.primitives.sprite import Sprite 7 from carbonui.util import color 8 from eve.client.script.ui.control.eveLabel import EveLabelMedium 9 from eve.client.script.ui.shared.dynamicItem.const import COLOR_NEGATIVE, COLOR_POSITIVE 10 import math 11 COLOR_BAR_BACKGROUND = color.Color.GRAY2 12 COLOR_PIP = color.Color.WHITE 13 14 class MutationBar(ContainerAutoSize): 15 default_height = 24 16 default_barWidth = 50 17 18 def ApplyAttributes(self, attributes): 19 super(MutationBar, self).ApplyAttributes(attributes) 20 self.attribute = attributes.attribute 21 self.barWidth = attributes.get('barWidth', self.default_barWidth) 22 self.Layout() 23 24 def Layout(self): 25 EveLabelMedium(parent=self, align=uiconst.TOLEFT, text=self.attribute.displayMutationLow) 26 barCont = Container(parent=self, align=uiconst.TOLEFT, left=8, width=self.barWidth) 27 EveLabelMedium(parent=self, align=uiconst.TOLEFT, left=8, text=self.attribute.displayMutationHigh) 28 Fill(parent=barCont, align=uiconst.TOTOP_NOPUSH, top=6, height=4, color=COLOR_BAR_BACKGROUND) 29 a = self.attribute 30 mutationRangeWidth = a.mutationMax - a.mutationMin 31 value = getattr(a, 'baseValue', a.value) 32 if a.highIsGood: 33 left = max((min(value, a.sourceValue) - a.mutationMin) / mutationRangeWidth, 0.0) 34 else: 35 left = max((a.mutationMax - max(value, a.sourceValue)) / mutationRangeWidth, 0.0) 36 width = abs((value - max(a.sourceValue, a.mutationMin)) / mutationRangeWidth) 37 if a.isMutationPositive: 38 changeColor = COLOR_POSITIVE 39 rotation = 0.0 40 else: 41 changeColor = COLOR_NEGATIVE 42 rotation = math.pi 43 Sprite(parent=barCont, align=uiconst.TOPLEFT, top=6, height=4, left=left * self.barWidth, width=width * self.barWidth, texturePath='res:/UI/Texture/Classes/DynamicItem/arrows.png', tileX=True, rotation=rotation, color=changeColor, idx=0) 44 left = max(abs(value - a.mutationLow) / mutationRangeWidth, 0.0) 45 Fill(parent=barCont, align=uiconst.TOPLEFT, top=6, height=4, left=math.floor(left * self.barWidth), width=1, color=COLOR_PIP, idx=0)