activateButton.py (2878B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\abyss\activateButton.py 2 import abyss 3 from carbonui import uiconst 4 from carbonui.uicore import uicore 5 from carbonui.util.color import Color 6 from eve.client.script.ui.control import eveLabel 7 from eve.client.script.ui.shared.industry.submitButton import PrimaryButton 8 from eve.client.script.ui.shared.industry.views.errorFrame import ErrorFrame 9 import localization 10 11 class ActivateButton(PrimaryButton): 12 13 def ApplyAttributes(self, attributes): 14 super(ActivateButton, self).ApplyAttributes(attributes) 15 self.controller = attributes.controller 16 self.UpdateState() 17 self.controller.onChange.connect(self.UpdateState) 18 19 def IsActive(self): 20 return self.controller.isReady or self.controller.isActivating 21 22 def IsBlinking(self): 23 return self.controller.isActivating 24 25 def IsErrorPresent(self): 26 return bool(self.controller.errors) and not self.controller.isReady 27 28 def GetColor(self): 29 if self.IsErrorPresent(): 30 return Color.RED 31 else: 32 return sm.GetService('uiColor').GetUIColor(uiconst.COLORTYPE_UIHILIGHT) 33 34 def UpdateBlinkByState(self): 35 pass 36 37 def UpdateIsEnabledByState(self): 38 if self.controller.isReady: 39 self.Enable() 40 else: 41 self.Disable() 42 43 def UpdateState(self): 44 super(ActivateButton, self).UpdateState() 45 super(ActivateButton, self).UpdateBlinkByState() 46 uicore.uilib.tooltipHandler.RefreshTooltipForOwner(self) 47 48 def ClickFunc(self, *args): 49 self.controller.Activate() 50 51 def LoadTooltipPanel(self, panel, *args): 52 errors = self.controller.errors 53 ActivateButtonTooltipPanel(errors=errors, panel=panel) 54 55 def GetText(self): 56 return self.controller.GetText() 57 58 59 class ActivateButtonTooltipPanel(object): 60 61 def __init__(self, errors, panel): 62 self.panel = panel 63 self.Reconstruct(errors) 64 65 def Reconstruct(self, errors): 66 if self.panel.destroyed: 67 return 68 self.panel.margin = (8, 8, 8, 0) 69 self.panel.columns = 2 70 self.panel.Flush() 71 if not errors: 72 return 73 self.panel.cellSpacing = (0, 4) 74 for error, errorArgs in errors: 75 self.AddErrorRow(error, errorArgs) 76 77 self.panel.AddSpacer(width=0, height=4, colSpan=2) 78 79 def AddErrorRow(self, error, args): 80 text = abyss.get_error_label(localization.GetByLabel, error, *args) 81 description = eveLabel.EveLabelMedium(text=text, align=uiconst.TOPLEFT) 82 description.width = min(description.textwidth, 320) 83 cell = self.panel.AddCell(description, colSpan=2, cellPadding=(8, 4, 8, 4)) 84 frame = ErrorFrame(bgParent=cell, opacityLow=0.15, opacityHigh=0.25) 85 frame.Show()