Skip to content

Conversation

@adan291
Copy link

@adan291 adan291 commented Jan 22, 2026

Pull Request: Modular Custom Health Percentage Color System

Overview

This PR introduces a modular custom health percentage color system for all unit frames (Player, Target, TargetOfTarget, Pet, Focus, FocusTarget), allowing users to customize health bar colors with 5 configurable color points (0%, 25%, 50%, 75%, 100%).

Key Features

  • 5 Fixed Color Points: Users can configure colors at 0%, 25%, 50%, 75%, and 100% health
  • Toggle-able Points: Intermediate points (25%, 50%, 75%) can be enabled/disabled
  • Editable Percentages: Intermediate points can have their percentage values adjusted
  • Mandatory Endpoints: 0% and 100% points are always enabled for gradient consistency
  • Smooth Gradients: Automatic color interpolation between enabled points using oUF's colorSmooth
  • Reset to Defaults: One-click button to restore default color configuration
  • Backward Compatible: Automatically migrates old data structure to new format
  • Mutual Exclusion: Cannot be active at the same time as "Colour by Class"

Technical Implementation

Modular Design

All custom logic is contained in a single independent module (Core/CustomHealthColors.lua - 300+ lines), making it:

  • Easy to maintain and extend
  • Never overwritten during base addon updates
  • Simple to disable if needed
  • Clean separation of concerns

Minimal Impact on Base Code

Only 4 files modified with minimal changes:

  1. Core/Init.xml (1 line added)

    • Loads the custom module
  2. Core/Config/GUI.lua (~70 lines)

    • Creates GUI for all unit frames (except boss)
    • Delegates widget creation to custom module
    • Implements mutual exclusion with "Colour by Class"
    • Falls back gracefully if module not loaded
  3. Elements/HealthBar.lua (~20 lines in 2 locations)

    • Applies color curve using custom module
    • Clears curve when disabled
    • Includes fallback logic
  4. Core/Defaults.lua (data structure update)

    • New array-based structure for all units (Player, Target, TargetOfTarget, Pet, Focus, FocusTarget)
    • Consistent structure across all unit frames

Data Structure

New Structure (All Units):

HealthPercentColors = {
    {percent = 0,    color = {1, 0, 0},     enabled = true},   -- Red (0%)
    {percent = 0.25, color = {1, 0.5, 0},   enabled = false},  -- Orange (25%)
    {percent = 0.50, color = {1, 1, 0},     enabled = false},  -- Yellow (50%)
    {percent = 0.75, color = {0.5, 1, 0},   enabled = false},  -- Light Green (75%)
    {percent = 1.0,  color = {0, 1, 0},     enabled = true},   -- Green (100%)
}

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.

2 participants