@@ -33,11 +33,7 @@ local DEFAULTS = {
3333 progressColor = " white" , -- "white", "gold", "green", "kind" (same colour as the icon) or "progress" (red to green)
3434 progressFormat = " slash" , -- "slash" 8/12, "spaced" 8 / 12, "both" 8/12 (67%), "percent" 67%, "left" 4 left
3535 progressShadow = false , -- drop shadow behind the text
36- progressBadge = true , -- the text sits in a badge -- experiment
37- badgeShape = " rounded" , -- "square", "rounded" or "pill"
38- badgeBorderSize = 1 , -- border thickness in pixels (0 = none)
39- badgeColor = { 0.05 , 0.04 , 0.02 , 0.85 }, -- fill (r, g, b, a); replaced, never changed in place
40- badgeBorderColor = { 1 , 0.82 , 0 , 0.9 }, -- border
36+ progressBadge = true , -- the text sits in a badge (dark pill, gold border) -- experiment
4137 progressX = 36 , -- its X
4238 progressY = 0 , -- its Y
4339 bounce = true , -- floating up/down animation
@@ -112,63 +108,9 @@ local KIND_TINT = { daily = { 0.55, 0.8, 1 }, group = { 1, 0.5, 0.45 } }
112108local TEXT_FONTS = { friz = " Fonts\\ FRIZQT__.TTF" , arial = " Fonts\\ ARIALN.TTF" , skurri = " Fonts\\ skurri.ttf" , morpheus = " Fonts\\ MORPHEUS.TTF" }
113109local TEXT_FONT_ORDER = { " friz" , " arial" , " skurri" , " morpheus" }
114110local PROGRESS_FORMATS = { " slash" , " spaced" , " both" , " percent" , " left" }
115- -- Badge behind the progress text: a border shape with the fill shape inset by the border
116- -- thickness. Rounded and pill ends are white cap textures (left end; the right end is the same
117- -- texture mirrored), tinted and stretched to the badge height; the middle is a plain colour.
118- local BADGE_PAD_X , BADGE_PAD_Y = 8 , 4
119- local BADGE_SHAPES = { " square" , " rounded" , " pill" }
120- local BADGE_CAPS = {
121- rounded = { file = " badge\\ rounded" , ratio = 16 / 64 }, -- cap width / height
122- pill = { file = " badge\\ pill" , ratio = 32 / 64 },
123- }
124-
125- local function BadgeLayer (text , layer , sublevel )
126- local left = text :CreateTexture (nil , layer , nil , sublevel )
127- local middle = text :CreateTexture (nil , layer , nil , sublevel )
128- local right = text :CreateTexture (nil , layer , nil , sublevel )
129- return { left = left , middle = middle , right = right }
130- end
131-
132- -- Lays out one layer (border or fill) inside the text frame, inset by `inset` pixels.
133- local function ShapeLayer (parts , text , shape , inset , width , height , color )
134- local r , g , b , a = color [1 ], color [2 ], color [3 ], color [4 ] or 1
135- local h = height - inset * 2
136- local cap = BADGE_CAPS [shape ]
137- parts .middle :ClearAllPoints ()
138- parts .middle :SetColorTexture (r , g , b , a )
139- if not cap or h <= 0 then
140- parts .left :Hide (); parts .right :Hide ()
141- parts .middle :SetPoint (" TOPLEFT" , text , " TOPLEFT" , inset , - inset )
142- parts .middle :SetPoint (" BOTTOMRIGHT" , text , " BOTTOMRIGHT" , - inset , inset )
143- parts .middle :SetShown (h > 0 )
144- return
145- end
146- local capWidth = math.min (h * cap .ratio , (width - inset * 2 ) / 2 )
147- for _ , side in ipairs ({ " left" , " right" }) do
148- local tex = parts [side ]
149- tex :SetTexture (IconPath (cap .file ))
150- tex :SetVertexColor (r , g , b , a )
151- tex :SetSize (capWidth , h )
152- tex :ClearAllPoints ()
153- if side == " left" then
154- tex :SetTexCoord (0 , 1 , 0 , 1 )
155- tex :SetPoint (" LEFT" , text , " LEFT" , inset , 0 )
156- else
157- tex :SetTexCoord (1 , 0 , 0 , 1 )
158- tex :SetPoint (" RIGHT" , text , " RIGHT" , - inset , 0 )
159- end
160- tex :Show ()
161- end
162- parts .middle :SetPoint (" TOPLEFT" , parts .left , " TOPRIGHT" )
163- parts .middle :SetPoint (" BOTTOMRIGHT" , parts .right , " BOTTOMLEFT" )
164- parts .middle :Show ()
165- end
166-
167- local function ShowBadge (text , show )
168- for _ , layer in ipairs ({ text .badgeBorder , text .badgeFill }) do
169- for _ , tex in pairs (layer ) do tex :SetShown (show ) end
170- end
171- end
111+ local BADGE_BACKDROP = { bgFile = " Interface\\ ChatFrame\\ ChatFrameBackground" , edgeFile = " Interface\\ Tooltips\\ UI-Tooltip-Border" ,
112+ tile = true , tileSize = 16 , edgeSize = 10 , insets = { left = 2 , right = 2 , top = 2 , bottom = 2 } }
113+ local BADGE_PAD_X , BADGE_PAD_Y = 8 , 5
172114
173115local TEXT_OUTLINES = { none = " " , thin = " OUTLINE" , thick = " THICKOUTLINE" }
174116local TEXT_COLORS = { white = { 1 , 1 , 1 }, gold = { 1 , 0.82 , 0 }, green = { 0.3 , 1 , 0.3 } }
@@ -475,20 +417,14 @@ local function StyleIcon(f)
475417 color = color or TEXT_COLORS .white
476418 label :SetTextColor (color [1 ], color [2 ], color [3 ])
477419 label :SetText (shown )
478- -- Badge: the chosen shape sized to the text, in the chosen fill and border colours.
479- if db .progressBadge then
480- local height = math.floor ((label :GetStringHeight () or 12 ) + BADGE_PAD_Y * 2 + 0.5 )
481- local width = math.floor ((label :GetStringWidth () or 30 ) + BADGE_PAD_X * 2 + 0.5 )
482- if BADGE_CAPS [db .badgeShape ] then width = width + height * BADGE_CAPS [db .badgeShape ].ratio * 0.6 end
483- width = math.max (width , height )
484- text :SetSize (width , height )
485- local border = db .badgeBorderSize or 0
486- ShapeLayer (text .badgeBorder , text , db .badgeShape , 0 , width , height , border > 0 and db .badgeBorderColor or { 0 , 0 , 0 , 0 })
487- ShapeLayer (text .badgeFill , text , db .badgeShape , border , width , height , db .badgeColor )
488- ShowBadge (text , true )
489- if border == 0 then for _ , tex in pairs (text .badgeBorder ) do tex :Hide () end end
420+ -- Badge: a dark pill sized to the text, with a gold border.
421+ if db .progressBadge and text .SetBackdrop then
422+ text :SetBackdrop (BADGE_BACKDROP )
423+ text :SetBackdropColor (0.05 , 0.04 , 0.02 , 0.85 )
424+ text :SetBackdropBorderColor (1 , 0.82 , 0 , 0.9 )
425+ text :SetSize ((label :GetStringWidth () or 30 ) + BADGE_PAD_X * 2 , (label :GetStringHeight () or 12 ) + BADGE_PAD_Y * 2 )
490426 else
491- ShowBadge ( text , false )
427+ if text . SetBackdrop then text : SetBackdrop ( nil ) end
492428 text :SetSize (60 , 20 )
493429 end
494430 text :SetScale (1 / scale )
@@ -556,12 +492,9 @@ local function CreateIcon()
556492 icon :SetAllPoints ()
557493 f .icon = icon
558494
559- local text = CreateFrame (" Frame" , nil , f )
495+ -- Backdrop template so the progress text can sit in a badge (dark pill, gold border).
496+ local text = CreateFrame (" Frame" , nil , f , BackdropTemplateMixin and " BackdropTemplate" or nil )
560497 text :SetSize (60 , 20 )
561- -- Badge layers under the text (see ShapeLayer): border, then the fill on top of it.
562- text .badgeBorder = BadgeLayer (text , " BACKGROUND" , 1 )
563- text .badgeFill = BadgeLayer (text , " BORDER" , 1 )
564- ShowBadge (text , false )
565498 text .label = text :CreateFontString (nil , " OVERLAY" )
566499 text .label :SetPoint (" CENTER" )
567500 text .label :SetFont (TEXT_FONTS .friz , DEFAULTS .progressSize , " OUTLINE" )
@@ -1081,71 +1014,6 @@ local function AddSlider(parent, labelKey, settingKey, low, high, step, x, y, fo
10811014 return slider , title , input
10821015end
10831016
1084- -- Opens the game's colour picker (with opacity) on `color` ({ r, g, b, a }); onChange gets a
1085- -- new table on every change, and the original back on cancel. Handles both the current
1086- -- picker API (SetupColorPickerAndShow) and the older one (fields + Show).
1087- local function OpenColorPicker (color , onChange )
1088- local picker = _G .ColorPickerFrame
1089- if not picker then return end
1090- local r , g , b , a = color [1 ], color [2 ], color [3 ], color [4 ] or 1
1091- local function Current ()
1092- local nr , ng , nb = picker :GetColorRGB ()
1093- local na = a
1094- if picker .GetColorAlpha then
1095- na = picker :GetColorAlpha ()
1096- elseif _G .OpacitySliderFrame then
1097- na = 1 - _G .OpacitySliderFrame :GetValue () -- the old slider holds transparency
1098- end
1099- onChange ({ nr , ng , nb , na })
1100- end
1101- local function Cancel () onChange ({ r , g , b , a }) end
1102- if picker .SetupColorPickerAndShow then
1103- picker :SetupColorPickerAndShow ({ r = r , g = g , b = b , opacity = a , hasOpacity = true ,
1104- swatchFunc = Current , opacityFunc = Current , cancelFunc = Cancel })
1105- else
1106- picker .func , picker .opacityFunc , picker .cancelFunc = Current , Current , Cancel
1107- picker .hasOpacity , picker .opacity , picker .previousValues = true , 1 - a , { r , g , b , a }
1108- picker :SetColorRGB (r , g , b )
1109- picker :Hide ()
1110- picker :Show ()
1111- end
1112- end
1113-
1114- -- A colour swatch with its label; a click opens the colour picker for db[settingKey].
1115- local function AddColorSwatch (parent , labelKey , settingKey , x , y )
1116- local b = CreateFrame (" Button" , nil , parent )
1117- b :SetSize (22 , 22 )
1118- b :SetPoint (" TOPLEFT" , x , y )
1119- local edge = b :CreateTexture (nil , " BACKGROUND" )
1120- edge :SetAllPoints ()
1121- edge :SetColorTexture (0.7 , 0.7 , 0.7 , 1 )
1122- local checker = b :CreateTexture (nil , " BORDER" ) -- dark under the colour, so transparency shows
1123- checker :SetPoint (" TOPLEFT" , 2 , - 2 )
1124- checker :SetPoint (" BOTTOMRIGHT" , - 2 , 2 )
1125- checker :SetColorTexture (0.15 , 0.15 , 0.15 , 1 )
1126- local swatch = b :CreateTexture (nil , " ARTWORK" )
1127- swatch :SetPoint (" TOPLEFT" , 2 , - 2 )
1128- swatch :SetPoint (" BOTTOMRIGHT" , - 2 , 2 )
1129- local label = parent :CreateFontString (nil , " ARTWORK" , " GameFontHighlight" )
1130- label :SetPoint (" LEFT" , b , " RIGHT" , 8 , 0 )
1131- Loc (label , labelKey )
1132- b :SetHighlightTexture (" Interface\\ Buttons\\ ButtonHilight-Square" , " ADD" )
1133- local function Sync ()
1134- local c = db [settingKey ] or DEFAULTS [settingKey ]
1135- swatch :SetColorTexture (c [1 ], c [2 ], c [3 ], c [4 ] or 1 )
1136- end
1137- b :SetScript (" OnClick" , function ()
1138- OpenColorPicker (db [settingKey ] or DEFAULTS [settingKey ], function (color )
1139- db [settingKey ] = color
1140- Sync ()
1141- ApplySettings ()
1142- end )
1143- end )
1144- refreshers [# refreshers + 1 ] = Sync
1145- parent :HookScript (" OnShow" , Sync )
1146- return b , label
1147- end
1148-
11491017-- A section heading with its own on/off check on the left.
11501018local function AddSectionCheck (parent , labelKey , settingKey , x , y )
11511019 local check = AddCheck (parent , labelKey , nil , settingKey , x - 4 , y + 6 )
@@ -1692,8 +1560,7 @@ local DISPLAY_KEYS = { "active", "enabled", "objects", "anchor", "scale", "offse
16921560 " objectAnchor" , " objectScale" , " objectOffsetX" , " objectOffset" }
16931561local ICON_KEYS = { " style" , " bounce" , " bounceHeight" , " bounceSpeed" , " glow" , " glowAlpha" }
16941562local PROGRESS_KEYS = { " progress" , " progressAttach" , " progressFloat" , " progressSize" , " progressFont" ,
1695- " progressOutline" , " progressColor" , " progressFormat" , " progressShadow" , " progressBadge" , " badgeShape" , " badgeBorderSize" , " badgeColor" , " badgeBorderColor" ,
1696- " progressX" , " progressY" }
1563+ " progressOutline" , " progressColor" , " progressFormat" , " progressShadow" , " progressBadge" , " progressX" , " progressY" }
16971564local BEHAVIOR_KEYS = { " colorByType" , " combat" , " minimap" , " minimapAngle" , " sound" , " soundChoice" }
16981565
16991566local function ResetKeys (keys )
@@ -1802,15 +1669,6 @@ local function BuildProgressTab(tab)
18021669 local function FreeTextOn () return ProgressOn () and not db .progressAttach end
18031670 Gate (FreeTextOn , AddSlider (tab , " POS_X" , " progressX" , - POSITION_RANGE , POSITION_RANGE , 1 , COL1 + 4 , TOP - 270 , " %d" ))
18041671 Gate (FreeTextOn , AddSlider (tab , " POS_Y" , " progressY" , - POSITION_RANGE , POSITION_RANGE , 1 , COL2 + 4 , TOP - 270 , " %d" ))
1805-
1806- -- Badge look: shape and border thickness, then fill and border colours (the text colour is above).
1807- local function BadgeOn () return ProgressOn () and db .progressBadge end
1808- Gate (BadgeOn , AddDropdown (tab , " BADGE_SHAPE" , BADGE_SHAPES ,
1809- function (value ) return L [" SHAPE_" .. value ] end , Choice (" badgeShape" ), SetChoice (" badgeShape" ),
1810- COL1 + 4 , TOP - 322 , COLUMN_DROPDOWN ))
1811- Gate (BadgeOn , AddSlider (tab , " BADGE_BORDER" , " badgeBorderSize" , 0 , 4 , 1 , COL2 + 4 , TOP - 322 , " %d" ))
1812- Gate (BadgeOn , AddColorSwatch (tab , " BADGE_COLOR" , " badgeColor" , COL1 + 4 , TOP - 376 ))
1813- Gate (BadgeOn , AddColorSwatch (tab , " BADGE_BORDER_COLOR" , " badgeBorderColor" , COL2 + 4 , TOP - 376 ))
18141672end
18151673
18161674local function BuildIconTab (tab )
@@ -1972,7 +1830,7 @@ end
19721830local SETTINGS_SECTIONS = {
19731831 { key = " TAB_DISPLAY" , build = BuildDisplayTab , height = 258 },
19741832 { key = " TAB_ICON" , build = BuildIconTab , height = 184 },
1975- { key = " TAB_PROGRESS" , build = BuildProgressTab , height = 404 },
1833+ { key = " TAB_PROGRESS" , build = BuildProgressTab , height = 310 },
19761834 { key = " TAB_BEHAVIOR" , build = BuildBehaviorTab , height = 152 },
19771835}
19781836local SECTION_GAP = 18
0 commit comments