@@ -432,7 +432,149 @@ function private.AddOns.Blizzard_UIWidgets()
432432 ---- ====####$$$$%%%%%%%%%%%%%%%%%%%$$$$####====----
433433 -- Blizzard_UIWidgetTemplateHorizontalCurrencies --
434434 ---- ====####$$$$%%%%%%%%%%%%%%%%%%%$$$$####====----
435+ -- Mirrors Blizzard's local GetTextColorForEnabledState
436+ local function SafeGetTextColorForEnabledState (enabledState , overrideNormalFontColor )
437+ if enabledState == _G .Enum .WidgetEnabledState .Disabled then
438+ return _G .DISABLED_FONT_COLOR
439+ elseif enabledState == _G .Enum .WidgetEnabledState .Red then
440+ return _G .RED_FONT_COLOR
441+ elseif enabledState == _G .Enum .WidgetEnabledState .White then
442+ return _G .HIGHLIGHT_FONT_COLOR
443+ elseif enabledState == _G .Enum .WidgetEnabledState .Green then
444+ return _G .GREEN_FONT_COLOR
445+ elseif enabledState == _G .Enum .WidgetEnabledState .Artifact then
446+ return _G .ARTIFACT_GOLD_COLOR
447+ elseif enabledState == _G .Enum .WidgetEnabledState .Black then
448+ return _G .BLACK_FONT_COLOR
449+ elseif enabledState == _G .Enum .WidgetEnabledState .BrightBlue then
450+ return _G .BRIGHTBLUE_FONT_COLOR
451+ else
452+ return overrideNormalFontColor or _G .NORMAL_FONT_COLOR
453+ end
454+ end
455+
456+ -- Mirrors Blizzard's local currencyIconSizes / GetCurrencyIconSize
457+ local currencyIconSizeLookup = {
458+ [_G .Enum .WidgetIconSizeType .Small ] = 16 ,
459+ [_G .Enum .WidgetIconSizeType .Medium ] = 20 ,
460+ [_G .Enum .WidgetIconSizeType .Large ] = 22 ,
461+ [_G .Enum .WidgetIconSizeType .Standard ] = 18 ,
462+ }
463+ local function SafeGetCurrencyIconSize (iconSizeType )
464+ return currencyIconSizeLookup [iconSizeType ] or currencyIconSizeLookup [_G .Enum .WidgetIconSizeType .Small ]
465+ end
466+
467+ -- Replace UIWidgetBaseCurrencyTemplateMixin.Setup to avoid taint: font objects
468+ -- modified by Aurora cause GetWidth()/GetHeight() to return secret numbers,
469+ -- breaking arithmetic in the original Blizzard code.
470+ if _G .UIWidgetBaseCurrencyTemplateMixin and _G .UIWidgetBaseCurrencyTemplateMixin .Setup then
471+ _G .UIWidgetBaseCurrencyTemplateMixin .Setup = function (self , widgetContainer , currencyInfo , enabledState , tooltipEnabledState , hideIcon , customFont , overrideFontColor , tooltipLoc )
472+ if _G .UIWidgetTemplateTooltipFrameMixin and _G .UIWidgetTemplateTooltipFrameMixin .Setup then
473+ _G .UIWidgetTemplateTooltipFrameMixin .Setup (self , widgetContainer , tooltipLoc )
474+ end
475+ self :SetOverrideNormalFontColor (overrideFontColor )
476+
477+ local function SetUpFontString (fontstring , text )
478+ if customFont then
479+ fontstring :SetText (text )
480+ fontstring :SetFontObject (customFont )
481+ else
482+ local hAlignType = _G .Enum .WidgetTextHorizontalAlignmentType .Left
483+ fontstring :Setup (text , currencyInfo .textFontType , currencyInfo .textSizeType , enabledState , hAlignType )
484+ end
485+ end
486+
487+ _G .WidgetUtil .UpdateTextWithAnimation (self , _G .GenerateClosure (SetUpFontString , self .Text ), currencyInfo .updateAnimType , currencyInfo .text )
488+
489+ local tooltip = currencyInfo .tooltip
490+ if IsSecret (tooltip ) then tooltip = " " end
491+ self :SetTooltip (tooltip , SafeGetTextColorForEnabledState (tooltipEnabledState or enabledState ))
492+
493+ self .Icon :SetTexture (currencyInfo .iconFileID )
494+ self .Icon :SetDesaturated (enabledState == _G .Enum .WidgetEnabledState .Disabled )
495+
496+ local iconSize = SafeGetCurrencyIconSize (currencyInfo .iconSizeType )
497+ self .Icon :SetSize (iconSize , iconSize )
498+
499+ self :SetEnabledState (enabledState )
500+
501+ local totalWidth = SafeNumber (self .Text :GetWidth (), 0 )
502+ local widgetHeight = SafeNumber (self .Text :GetHeight (), 0 )
503+
504+ if currencyInfo .leadingText ~= " " then
505+ SetUpFontString (self .LeadingText , currencyInfo .leadingText )
506+
507+ self .LeadingText :Show ()
508+ self .Icon :SetPoint (" LEFT" , self .LeadingText , " RIGHT" , 5 , 0 )
509+ totalWidth = totalWidth + SafeNumber (self .LeadingText :GetWidth (), 0 ) + 5
510+ widgetHeight = _G .math .max (widgetHeight , SafeNumber (self .LeadingText :GetHeight (), 0 ))
511+ else
512+ self .LeadingText :Hide ()
513+ self .Icon :SetPoint (" LEFT" , self , " LEFT" , 0 , 0 )
514+ end
515+
516+ if hideIcon then
517+ self .Icon :Hide ()
518+ self .Text :SetPoint (" LEFT" , self .Icon , " LEFT" , 0 , 0 )
519+ else
520+ self .Icon :Show ()
521+ self .Text :SetPoint (" LEFT" , self .Icon , " RIGHT" , 5 , 0 )
522+ totalWidth = totalWidth + SafeNumber (self .Icon :GetWidth (), 0 ) + 5
523+ end
435524
525+ self :SetWidth (totalWidth )
526+ self :SetHeight (widgetHeight )
527+ end
528+ end
529+
530+ -- Replace UIWidgetTemplateHorizontalCurrenciesMixin.Setup to avoid taint:
531+ -- currency frame dimensions (set by the replaced Setup above) return secret
532+ -- numbers, breaking comparisons and arithmetic in the original Blizzard code.
533+ if _G .UIWidgetTemplateHorizontalCurrenciesMixin and _G .UIWidgetTemplateHorizontalCurrenciesMixin .Setup then
534+ _G .UIWidgetTemplateHorizontalCurrenciesMixin .Setup = function (self , widgetInfo , widgetContainer )
535+ if _G .UIWidgetBaseTemplateMixin and _G .UIWidgetBaseTemplateMixin .Setup then
536+ _G .UIWidgetBaseTemplateMixin .Setup (self , widgetInfo , widgetContainer )
537+ end
538+ self .currencyPool :ReleaseAll ()
539+
540+ local previousCurrencyFrame
541+ local biggestHeight = 0
542+ local totalWidth = 0
543+
544+ for index , currencyInfo in _G .ipairs (widgetInfo .currencies ) do
545+ local currencyFrame = self .currencyPool :Acquire ()
546+ currencyFrame :Show ()
547+
548+ local tooltipEnabledState = currencyInfo .isCurrencyMaxed and _G .Enum .WidgetEnabledState .Red or _G .Enum .WidgetEnabledState .White
549+
550+ currencyFrame :Setup (widgetContainer , currencyInfo , _G .Enum .WidgetEnabledState .Yellow , tooltipEnabledState , nil , nil , nil , widgetInfo .tooltipLoc )
551+
552+ if previousCurrencyFrame then
553+ currencyFrame :SetPoint (" TOPLEFT" , previousCurrencyFrame , " TOPRIGHT" , 10 , 0 )
554+ totalWidth = totalWidth + SafeNumber (currencyFrame :GetWidth (), 0 ) + 10
555+ else
556+ currencyFrame :SetPoint (" TOPLEFT" , self , " TOPLEFT" , 0 , 0 )
557+ totalWidth = SafeNumber (currencyFrame :GetWidth (), 0 )
558+ end
559+
560+ currencyFrame :SetOverrideNormalFontColor (self .fontColor )
561+
562+ previousCurrencyFrame = currencyFrame
563+
564+ local currencyHeight = SafeNumber (currencyFrame :GetHeight (), 0 )
565+ if currencyHeight > biggestHeight then
566+ biggestHeight = currencyHeight
567+ end
568+ end
569+
570+ local widgetSizeSetting = SafeNumber (widgetInfo .widgetSizeSetting , 0 )
571+ local useSizeSetting = widgetSizeSetting > totalWidth
572+
573+ local width = useSizeSetting and (totalWidth + ((widgetSizeSetting - totalWidth ) / 2 )) or totalWidth
574+ self :SetWidth (width )
575+ self :SetHeight (biggestHeight )
576+ end
577+ end
436578
437579 ---- ====####$$$$%%%%%%%%%%%%%$$$$####====----
438580 -- Blizzard_UIWidgetTemplateBulletTextList --
0 commit comments