feedbackLabelCont.py (3971B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fittingScreen\feedbackLabelCont.py 2 import uthread2 3 from carbonui import const as uiconst 4 from carbonui.primitives.container import Container 5 from eve.client.script.ui.control.eveLabel import EveCaptionMedium 6 import shipfitting.errorConst as errorConst 7 from localization import GetByLabel 8 from carbonui.uicore import uicore 9 10 class FeedbackLabelCont(Container): 11 default_width = 100 12 default_height = 30 13 default_align = uiconst.CENTER 14 __notifyevents__ = ['OnFeedbackTextChanged'] 15 16 def ApplyAttributes(self, attributes): 17 Container.ApplyAttributes(self, attributes) 18 self.timeoutThread = None 19 self.currentErrorKey = None 20 self.feedbackLabel = EveCaptionMedium(name='feedbackLabel', parent=self, text='', idx=0, align=uiconst.CENTER, width=300) 21 self.feedbackLabel.SetRGB(220 / 255.0, 240 / 255.0, 255 / 255.0) 22 self.CreateErrorDict() 23 self.fallbackMsg = GetByLabel('UI/Fitting/FittingWindow/WarningModuleCouldntBeFitted') 24 sm.RegisterNotify(self) 25 26 def CreateErrorDict(self): 27 self.errorDict = {errorConst.MODULE_NOT_APPROPRIATE_FOR_CATEGORY: GetByLabel('UI/Fitting/FittingWindow/WarningNotForThisHullCategory'), 28 errorConst.CANT_FIT_MODULE_TO_SHIP: GetByLabel('UI/Fitting/FittingWindow/WarningHullCantFitThisModule'), 29 errorConst.MODULE_TOO_BIG: GetByLabel('UI/Fitting/FittingWindow/WarningModuleTooBig'), 30 errorConst.NOT_ENOUGH_LAUNCHER_SLOTS: GetByLabel('UI/Fitting/FittingWindow/WarningNotEnoughLauncherSlots'), 31 errorConst.NOT_ENOUGH_TURRET_SLOTS: GetByLabel('UI/Fitting/FittingWindow/WarningNotEnoughTurretSlotsFree'), 32 errorConst.NOT_ENOUGH_RIG_SLOTS: GetByLabel('UI/Fitting/FittingWindow/WarningNotEnoughRigSlots'), 33 errorConst.RIG_WRONG_SIZE: GetByLabel('UI/Fitting/FittingWindow/WarningRigNotRightSize'), 34 errorConst.SLOT_NOT_PRESENT: GetByLabel('UI/Fitting/FittingWindow/WarningNotEnoughFreeSlots'), 35 errorConst.WRONG_SLOT: GetByLabel('UI/Fitting/FittingWindow/WarningIncorrectSlotForModule'), 36 errorConst.SLOT_IN_USE: GetByLabel('UI/Fitting/FittingWindow/WarningModuleSlotInUse')} 37 self.errorLabelPathDictWithVariables = {errorConst.CANT_FIT_TOO_MANY_BY_GROUP: 'UI/Fitting/FittingWindow/WarningMaxGroupFitted', 38 errorConst.CANT_FIT_TOO_MANY_BY_TYPE: 'UI/Fitting/FittingWindow/WarningMaxTypeFitted'} 39 40 def SetText(self, errorInfo): 41 if self.timeoutThread: 42 self.timeoutThread.kill() 43 self.timeoutThread = None 44 errorKey = errorInfo.errorKey if errorInfo else None 45 textChanging = self.currentErrorKey in self.errorLabelPathDictWithVariables or self.currentErrorKey != errorKey 46 if textChanging: 47 if errorKey is None: 48 text = '' 49 elif errorKey in self.errorLabelPathDictWithVariables: 50 labelPath = self.errorLabelPathDictWithVariables.get(errorKey) 51 text = GetByLabel(labelPath, extraInfo=errorInfo.extraInfo) 52 else: 53 text = self.errorDict.get(errorKey, self.fallbackMsg) 54 self.feedbackLabel.text = '<center>%s</center>' % text 55 self.currentErrorKey = errorKey 56 if textChanging: 57 uicore.animations.MorphScalar(self.feedbackLabel, 'opacity', startVal=0, endVal=1.0, duration=0.2, loops=1, curveType=uiconst.ANIM_OVERSHOT) 58 else: 59 uicore.animations.MorphScalar(self.feedbackLabel, 'opacity', startVal=self.feedbackLabel.opacity, endVal=1.5, duration=0.2, loops=1, curveType=uiconst.ANIM_BOUNCE) 60 61 def OnFeedbackTextChanged(self, errorInfo, timeout = False): 62 self.SetText(errorInfo) 63 if errorInfo and timeout: 64 self.timeoutThread = uthread2.call_after_wallclocktime_delay(self.TimeOutLabel, 1.5) 65 66 def TimeOutLabel(self): 67 self.feedbackLabel.text = ''