Skip to content

Fix: CDM show buff and target debuff stack count at 1 stack - #2083

Open
daniel-lewinski wants to merge 1 commit into
EllesmereGaming:mainfrom
daniel-lewinski:fix/show-buff-at-1-stack
Open

daniel-lewinski wants to merge 1 commit into
EllesmereGaming:mainfrom
daniel-lewinski:fix/show-buff-at-1-stack

Conversation

@daniel-lewinski

@daniel-lewinski daniel-lewinski commented Sep 14, 2026

Copy link
Copy Markdown

What does this PR do?

Displays the stack count text when a buff or player-applied target debuff is at 1 stack (in addition to 2+ stacks), across Cooldown Manager (BuffIconCooldownViewer) icons, tracking buff bars, and AuraKit engine aura buttons. By default, Blizzard's native aura widgets hide the count text at 0 and 1 stack, only revealing numbers starting from 2 stacks.

Cause

In World of Warcraft (Midnight 12.x):

  1. Engine Aura Buttons (EllesmereUI_AuraKit.lua): button:SetApplicationCount(d.stack, {}) is called with empty options, causing Blizzard's internal formatter to default to hiding count text when application count <= 1.
  2. CDM Buff/Debuff Icons (EllesmereUICooldownManager.lua): icon.Applications fontstrings rely on Blizzard's internal display logic which suppresses rendering at 1 stack.
  3. Tracking Buff Bars (EllesmereUICdmBuffBars.lua): UpdateStacks checks appsText.GetText(appsText). Since Blizzard's native text is empty string "" at 1 stack, bar._stacksText is hidden even though ReadStackApplications(blzChild) reads 1.

Fix

  1. AuraKit Stack Formatter (EllesmereUI_AuraKit.lua):

    • Implements AK.GetStackFormatter() using C_StringUtil.CreateNumericRuleFormatter() with breakpoints { threshold = 0, format = "" } and { threshold = 1, format = "%d" }.
    • Passes this formatter to button:SetApplicationCount(d.stack, { formatter = stackFmt }).
  2. CDM Single-Stack Display & Mirror (EllesmereUICooldownManager.lua):

    • In RefreshCDMIconAppearance, creates a dedicated overlay FontString mirror (icon._euiStackText) positioned identically to the native stack count text and sets Blizzard's native icon.Applications.Applications alpha to 0.
    • Adds ns.UpdateSingleStackText(icon) which safely resolves application count from icon.auraDataCached.applications or C_UnitAuras.GetAuraDataByAuraInstanceID (guarding against secret values in 12.x combat environments).
    • Hooks lifecycle methods (OnAuraInstanceInfoSet, OnUnitAuraUpdatedEvent, OnUnitAuraAddedEvent, ClearAuraInstanceInfo, OnAuraInstanceInfoCleared, OnCooldownIDSet) on CDM frames once per frame using hooksecurefunc.
    • Registers PLAYER_TARGET_CHANGED on an addon-owned frame to update target debuff single-stack counts when switching targets.
    • Respects showChargeStackText = false (csAlpha == 0).
  3. Tracking Buff Bars (EllesmereUICdmBuffBars.lua):

    • In UpdateStacks, falls back to ReadStackApplications(blzChild) if native appsText is empty, showing the stack text when applications are present.

Cost

  • Zero OnUpdate polling: completely event-driven via hooksecurefunc on aura lifecycle hooks and PLAYER_TARGET_CHANGED.
  • Single-instance formatter cached at file scope in AuraKit.
  • Secret-safe handling for 12.x: all numeric checks are guarded with issecretvalue() and pcall, and FontString:SetText() is used as a safe sink.

How was it tested?

  • Tested in-game on live client:
    1. Gained a 1-stack buff (e.g. tracking buff on CDM bar / player aura) -> count text "1" correctly displays.
    2. Reapplied / increased stacks to 2+ -> count updates dynamically to "2", "3", etc.
    3. Buff expired / removed -> count text clears properly to empty string.
    4. Applied target debuff at 1 stack -> count text displays "1"; switching targets updates accurately via PLAYER_TARGET_CHANGED.
    5. Verified options toggle Show Charges/Stacks Text: Off (showChargeStackText = false) continues to hide the count text cleanly.

Checklist

  • New settings default OFF (no behavior change without opt-in) (N/A - bug fix / parity enhancement for stack display)
  • Zero cost while disabled: no events registered, no polling, no hooks doing work, no frames built
  • Cheap while enabled: event-driven (no polling, no timer-based logic, no per-frame allocations)
  • No writes onto Blizzard-owned frames (weak-table pattern used); HookScript/hooksecurefunc only, never SetScript on Blizzard frames
  • Tested in-game on live; no version gates or pre-Midnight APIs added

@daniel-lewinski
daniel-lewinski marked this pull request as ready for review September 14, 2026 10:28
@daniel-lewinski daniel-lewinski changed the title cdm: show buff and target debuff stack count at 1 stack Fix: CDM show buff and target debuff stack count at 1 stack Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant