Skip to content

feat: Customizable action bar overlay position, font size, and number format#38

Merged
Xerrion merged 2 commits intomasterfrom
copilot/customize-size-and-location
Apr 29, 2026
Merged

feat: Customizable action bar overlay position, font size, and number format#38
Xerrion merged 2 commits intomasterfrom
copilot/customize-size-and-location

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

Overlay text was hardcoded to BOTTOM anchor at a fixed font size with no way to reposition or resize it — causing overlap with other UI elements (e.g. Warlock soul shards).

Changes

Persistent settings (db.profile.overlay, survives reloads via AceDB):

  • anchor — WoW anchor point (BOTTOM default; all 9 standard points accepted)
  • offsetX / offsetY — pixel nudge from anchor (0 / 2 defaults)
  • fontSize — font size in pt, clamped 6–24 (10 default)
  • abbreviateNumberstrue = 1.5k, false = 1500

/phd config slash commands (changes apply immediately, no reload):

/phd config                    -- print current settings
/phd config anchor LEFT        -- shift overlay left, away from soul shards
/phd config offsetX -4
/phd config fontSize 8         -- smaller text
/phd config abbreviate off     -- full integers

Presentation/ActionBar.lua

  • ApplyOverlayAppearance(fontString, button) reads live DB settings and calls SetFont + SetPoint; replaces the previous hardcoded NumberFontNormalSmall template + fixed BOTTOM anchor
  • ActionBar.ApplySettings() re-applies appearance to all live overlays and forces a value refresh — called by the config handler on every change

Presentation/Format.lua

  • Format.FormatNumberFull(n) — integer display without k abbreviation

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • luarocks.org
    • Triggering command: /usr/bin/lua5.1 /usr/bin/lua5.1 /usr/bin/luarocks install busted (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Summary by CodeRabbit

  • New Features

    • Added /phd config slash command to customize overlay appearance, including anchor position, offset, font size (6–24), and number abbreviation toggle.
  • Tests

    • Added unit tests for full number formatting functionality.

Copilot AI linked an issue Apr 27, 2026 that may be closed by this pull request
- Add overlay settings (anchor, offsetX, offsetY, fontSize, abbreviateNumbers)
  to DB_DEFAULTS profile so preferences survive reloads
- Extend /phd config command to read and update each setting live
- ApplyOverlayAppearance() applies font (Fonts\ARIALN.TTF + size + OUTLINE)
  and anchor point from DB whenever an overlay is created or settings change
- ActionBar.ApplySettings() re-applies appearance + forces full refresh
- FormatNumber local in ActionBar respects abbreviateNumbers flag
- Format.FormatNumberFull(n) added for unabbreviated integer display
- 10 new unit tests for FormatNumberFull; restore accidentally merged
  FormatDPS(0)/FormatDPS(1) test cases
- Add strupper to .luacheckrc read_globals (WoW global, sibling of strlower)

Agent-Logs-Url: https://github.com/Xerrion/PhDamage/sessions/9a5448c4-86c9-462a-837d-1b7098384ed9

Co-authored-by: Xerrion <1850632+Xerrion@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to customize text size and location feat: Customizable action bar overlay position, font size, and number format Apr 27, 2026
Copilot AI requested a review from Xerrion April 27, 2026 15:24
@Xerrion Xerrion marked this pull request as ready for review April 27, 2026 15:26
@Xerrion
Copy link
Copy Markdown
Owner

Xerrion commented Apr 27, 2026

@coderabbitai please review this

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

@Xerrion Sure, I'll review the changes in this PR right away!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

Introduces configurable overlay display settings (anchor, offsets, font size, number abbreviation) persisted to addon database. Implements /phd config command with validation for settings. Refactors overlay appearance application and adds ApplySettings() method to reapply configurations to existing overlays.

Changes

Cohort / File(s) Summary
Tooling Configuration
.luacheckrc
Adds strupper to read_globals allowlist to suppress luacheck warnings.
Configuration & Command Handling
Core/Init.lua
Adds profile defaults for overlay anchor, offsetX, offsetY, fontSize, and abbreviateNumbers. Implements /phd config subcommand with validation (anchor allowlist, fontSize 6–24 range, abbreviate on/off toggle). Calls ns.ActionBar.ApplySettings() after successful updates.
Overlay Presentation
Presentation/ActionBar.lua
Centralizes overlay appearance setup into ApplyOverlayAppearance() helper reading from DB profile. Updates FormatNumber to conditionally use FormatNumberFull() when abbreviation is disabled. Adds ApplySettings() public method to reapply appearance and re-render all tracked buttons.
Number Formatting
Presentation/Format.lua
Introduces FormatNumberFull() function to render numbers as full integers without "k" suffix abbreviation.
Test Coverage
tests/test_format.lua
Adds unit tests for FormatNumberFull covering nil, integer, and float inputs with expected string outputs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding customizable action bar overlay position, font size, and number format settings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Presentation/ActionBar.lua`:
- Around line 110-119: ApplyOverlayAppearance is using cfg.anchor, cfg.offsetX,
cfg.offsetY and cfg.fontSize directly from saved variables, which can be wrong
types and will crash fontString:SetPoint/SetFont; before calling those APIs
validate and normalize: ensure cfg.anchor is in an allowlist of valid anchors
(e.g. "TOP","BOTTOM","LEFT","RIGHT","CENTER", etc.) otherwise fall back to
"BOTTOM"; coerce cfg.offsetX and cfg.offsetY with tonumber() and default to 0
and 2 on failure; coerce cfg.fontSize with tonumber(), clamp it to the safe
range 6–24 and default to 10 if invalid; then call fontString:ClearAllPoints(),
fontString:SetPoint(anchor, button, anchor, offsetX, offsetY) and
fontString:SetFont(...) using the validated values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b02e3211-abf6-48ea-ba4a-a20bd4f0a38d

📥 Commits

Reviewing files that changed from the base of the PR and between f3e63e9 and 2a1c313.

📒 Files selected for processing (5)
  • .luacheckrc
  • Core/Init.lua
  • Presentation/ActionBar.lua
  • Presentation/Format.lua
  • tests/test_format.lua

Comment on lines +110 to +119
local function ApplyOverlayAppearance(fontString, button)
local cfg = ns.Addon and ns.Addon.db and ns.Addon.db.profile and ns.Addon.db.profile.overlay or {}
local anchor = cfg.anchor or "BOTTOM"
local offsetX = cfg.offsetX or 0
local offsetY = cfg.offsetY or 2
local fontSize = cfg.fontSize or 10

fontString:ClearAllPoints()
fontString:SetPoint(anchor, button, anchor, offsetX, offsetY)
fontString:SetFont("Fonts\\ARIALN.TTF", fontSize, "OUTLINE")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

find . -name "ActionBar.lua" -type f

Repository: Xerrion/PhDamage

Length of output: 89


🏁 Script executed:

# Read the file around the specified lines
if [ -f "Presentation/ActionBar.lua" ]; then
  wc -l "Presentation/ActionBar.lua"
fi

Repository: Xerrion/PhDamage

Length of output: 91


🏁 Script executed:

# Get context around lines 110-119
if [ -f "Presentation/ActionBar.lua" ]; then
  sed -n '100,130p' "Presentation/ActionBar.lua"
fi

Repository: Xerrion/PhDamage

Length of output: 1327


🏁 Script executed:

# Search for SavedVariables configuration and db schema
rg "SavedVariables|profile.*overlay" --max-count 20

Repository: Xerrion/PhDamage

Length of output: 645


🏁 Script executed:

# Check for any existing validation of overlay config
rg "overlay" -A 5 -B 5 Presentation/ActionBar.lua | head -50

Repository: Xerrion/PhDamage

Length of output: 2188


🏁 Script executed:

# Search for db initialization and defaults setup
rg "ns\.Addon\.db|defaults" --max-count 30

Repository: Xerrion/PhDamage

Length of output: 410


🏁 Script executed:

# Search for db defaults initialization
rg "db\.defaults|db\.profile|overlay.*=" -B 3 -A 3 | head -100

Repository: Xerrion/PhDamage

Length of output: 4084


🏁 Script executed:

# Find Core/Init.lua to see db initialization
if [ -f "Core/Init.lua" ]; then
  wc -l "Core/Init.lua"
fi

Repository: Xerrion/PhDamage

Length of output: 78


🏁 Script executed:

# Check the Init.lua file for SavedVariables schema
if [ -f "Core/Init.lua" ]; then
  cat -n "Core/Init.lua" | head -150
fi

Repository: Xerrion/PhDamage

Length of output: 6678


🏁 Script executed:

# Find all calls to ApplyOverlayAppearance
rg "ApplyOverlayAppearance" -B 2 -A 2

Repository: Xerrion/PhDamage

Length of output: 1474


🏁 Script executed:

# Check if there's SavedVariables migration logic or similar
rg "OnUpdate|MigrateDB|Cleanup" -A 3

Repository: Xerrion/PhDamage

Length of output: 260


🏁 Script executed:

# Look for any other code paths that might set these values outside of the config command
rg "\.anchor\s*=|\.offsetX\s*=|\.offsetY\s*=|\.fontSize\s*=" -B 2 -A 2

Repository: Xerrion/PhDamage

Length of output: 1004


Harden persisted overlay values before calling frame APIs.

cfg.anchor, cfg.offsetX, cfg.offsetY, and cfg.fontSize are consumed directly from SavedVariables. The fallback operators (or pattern) don't protect against type mismatches—corrupted data (e.g., cfg.anchor = 123 or cfg.offsetX = "abc") will be truthy and passed to SetPoint/SetFont, causing errors. If a profile has invalid/stale values, overlay updates break. Add runtime normalization: anchor allowlist validation, numeric coercion for offsets, fontSize clamp to 6–24.

Proposed fix
 local function ApplyOverlayAppearance(fontString, button)
     local cfg = ns.Addon and ns.Addon.db and ns.Addon.db.profile and ns.Addon.db.profile.overlay or {}
-    local anchor  = cfg.anchor  or "BOTTOM"
-    local offsetX = cfg.offsetX or 0
-    local offsetY = cfg.offsetY or 2
-    local fontSize = cfg.fontSize or 10
+    local VALID_ANCHORS = {
+        BOTTOM = true, TOP = true, CENTER = true,
+        LEFT = true, RIGHT = true,
+        BOTTOMLEFT = true, BOTTOMRIGHT = true,
+        TOPLEFT = true, TOPRIGHT = true,
+    }
+
+    local anchor = type(cfg.anchor) == "string" and strupper(cfg.anchor) or "BOTTOM"
+    if not VALID_ANCHORS[anchor] then
+        anchor = "BOTTOM"
+    end
+
+    local offsetX = tonumber(cfg.offsetX) or 0
+    local offsetY = tonumber(cfg.offsetY) or 2
+    local fontSize = tonumber(cfg.fontSize) or 10
+    if fontSize < 6 then fontSize = 6 end
+    if fontSize > 24 then fontSize = 24 end
 
     fontString:ClearAllPoints()
     fontString:SetPoint(anchor, button, anchor, offsetX, offsetY)
     fontString:SetFont("Fonts\\ARIALN.TTF", fontSize, "OUTLINE")
 end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Presentation/ActionBar.lua` around lines 110 - 119, ApplyOverlayAppearance is
using cfg.anchor, cfg.offsetX, cfg.offsetY and cfg.fontSize directly from saved
variables, which can be wrong types and will crash fontString:SetPoint/SetFont;
before calling those APIs validate and normalize: ensure cfg.anchor is in an
allowlist of valid anchors (e.g. "TOP","BOTTOM","LEFT","RIGHT","CENTER", etc.)
otherwise fall back to "BOTTOM"; coerce cfg.offsetX and cfg.offsetY with
tonumber() and default to 0 and 2 on failure; coerce cfg.fontSize with
tonumber(), clamp it to the safe range 6–24 and default to 10 if invalid; then
call fontString:ClearAllPoints(), fontString:SetPoint(anchor, button, anchor,
offsetX, offsetY) and fontString:SetFont(...) using the validated values.

@Xerrion Xerrion merged commit ff210d3 into master Apr 29, 2026
3 checks passed
@Xerrion Xerrion deleted the copilot/customize-size-and-location branch April 29, 2026 08:05
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.

[Feature]: Customize size and location

2 participants