From 9614443ea7e09aa303efd3635819a5295f583d4a Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 2 Dec 2016 19:51:00 +0100 Subject: [PATCH] uf: add option for dark and non-pastel colors --- modules/config.lua | 2 ++ modules/group.lua | 24 +++++++++++++++++++----- modules/gui.lua | 2 ++ modules/pet.lua | 22 +++++++++++++++++++--- modules/player.lua | 10 +++++++++- modules/raid.lua | 27 ++++++++++++++++++++++----- modules/target.lua | 20 +++++++++++++++++--- modules/targettarget.lua | 21 ++++++++++++++++++--- 8 files changed, 108 insertions(+), 20 deletions(-) diff --git a/modules/config.lua b/modules/config.lua index 0faedf45..5d251670 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -22,6 +22,8 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("appearance", "cd", "daycolor", "5555ff") pfUI:UpdateConfig("appearance", "cd", "threshold", "2") pfUI:UpdateConfig("unitframes", nil, "disable", "0") + pfUI:UpdateConfig("unitframes", nil, "pastel", "1") + pfUI:UpdateConfig("unitframes", nil, "dark", "0") pfUI:UpdateConfig("unitframes", nil, "animation_speed", "5") pfUI:UpdateConfig("unitframes", nil, "portrait", "1") pfUI:UpdateConfig("unitframes", nil, "buff_size", "20") diff --git a/modules/group.lua b/modules/group.lua index 05af6d72..3bf5c1e5 100644 --- a/modules/group.lua +++ b/modules/group.lua @@ -211,11 +211,25 @@ pfUI:RegisterModule("group", function () end _, class = UnitClass("party"..this.id) - local c = RAID_CLASS_COLORS[class] - local cr, cg, cb = 0, 0, 0 - if c then cr, cg, cb =(c.r + .5) * .5, (c.g + .5) * .5, (c.b + .5) * .5 end - - this.hp.bar:SetStatusBarColor(cr, cg, cb) + local color = RAID_CLASS_COLORS[class] + local r, g, b = .2, .2, .2 + if pfUI_config.unitframes.dark == "1" and color then + this.hp.bar:SetStatusBarColor(r, g, b) + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + this.caption:SetTextColor(r,g,b) + elseif color then + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + this.hp.bar:SetStatusBarColor(r, g, b) + this.caption:SetTextColor(1,1,1) + end local pcolor = ManaBarColor[UnitPowerType("party"..this.id)] this.power.bar:SetStatusBarColor(pcolor.r + .5, pcolor.g +.5, pcolor.b +.5, 1) diff --git a/modules/gui.lua b/modules/gui.lua index 54038268..24b63e60 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -636,6 +636,8 @@ pfUI:RegisterModule("gui", function () -- unitframes pfUI.gui.uf = pfUI.gui:CreateConfigTab("UnitFrames") pfUI.gui:CreateConfig(pfUI.gui.uf, "Disable pfUI-UnitFrames", pfUI_config.unitframes, "disable", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Use pastel colors", pfUI_config.unitframes, "pastel", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Use dark shades for healthbars", pfUI_config.unitframes, "dark", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Animation speed", pfUI_config.unitframes, "animation_speed") pfUI.gui:CreateConfig(pfUI.gui.uf, "Show portrait", pfUI_config.unitframes, "portrait", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff size", pfUI_config.unitframes, "buff_size") diff --git a/modules/pet.lua b/modules/pet.lua index 0badb18f..c3e06de6 100644 --- a/modules/pet.lua +++ b/modules/pet.lua @@ -62,6 +62,7 @@ pfUI:RegisterModule("pet", function () local power, powermax = UnitMana("pet"), UnitManaMax("pet") local happiness = GetPetHappiness() + local color = .2, .2, .2 if happiness == 1 then color = { r = 1, g = 0, b = 0 } elseif happiness == 2 then @@ -69,11 +70,26 @@ pfUI:RegisterModule("pet", function () else color = { r = 0, g = 1, b = 0 } end - local r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + + local r, g, b = .2, .2, .2 + if pfUI_config.unitframes.dark == "1" and color then + pfUI.uf.pet.hp.bar:SetStatusBarColor(r, g, b, hp / hpmax / 4 + .75) + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + elseif color then + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + pfUI.uf.pet.hp.bar:SetStatusBarColor(r, g, b, hp / hpmax / 4 + .75) + end + pfUI.uf.pet.hp.text:SetTextColor(r, g, b) pfUI.uf.pet.hp.bar:SetMinMaxValues(0, hpmax) - pfUI.uf.pet.hp.bar:SetStatusBarColor(r, g, b, hp / hpmax / 4 + .75) - pfUI.uf.pet.hp.text:SetTextColor(r+.3,g+.3,b+.3, 1) pfUI.uf.pet.hp.text:SetText(UnitName("pet")) pfUI.uf.pet.hpReal = hp diff --git a/modules/player.lua b/modules/player.lua index a426b678..fd410846 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -124,7 +124,15 @@ pfUI:RegisterModule("player", function () _, class = UnitClass("player") local color = RAID_CLASS_COLORS[class] - local cr, cg, cb = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + local cr, cg, cb + if pfUI_config.unitframes.dark == "1" then + cr, cg, cb = .2,.2,.2 + elseif pfUI_config.unitframes.pastel == "1" then + cr, cg, cb = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + cr, cg, cb = color.r, color.g, color.b + end + local perc = hp / hpmax pfUI.uf.player.hp.bar:SetMinMaxValues(0, hpmax) diff --git a/modules/raid.lua b/modules/raid.lua index 23d86ef7..67c2a098 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -260,10 +260,25 @@ pfUI:RegisterModule("raid", function () end _, class = UnitClass("raid"..unit.id) - local c = RAID_CLASS_COLORS[class] - local cr, cg, cb = 0, 0, 0 - if c then cr, cg, cb =(c.r + .5) * .5, (c.g + .5) * .5, (c.b + .5) * .5 end - unit.hp.bar:SetStatusBarColor(cr, cg, cb) + local color = RAID_CLASS_COLORS[class] + + local r, g, b = .2, .2, .2 + if pfUI_config.unitframes.dark == "1" and color then + unit.hp.bar:SetStatusBarColor(r, g, b) + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + elseif color then + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + unit.hp.bar:SetStatusBarColor(r, g, b) + end + unit.caption:SetTextColor(r,g,b) local p = ManaBarColor[UnitPowerType("raid"..unit.id)] local pr, pg, pb = 0, 0, 0 @@ -276,7 +291,9 @@ pfUI:RegisterModule("raid", function () unit.caption:SetTextColor(1,.3,.3) else unit.caption:SetText(UnitName("raid"..unit.id)) - unit.caption:SetTextColor(1,1,1) + if pfUI_config.unitframes.dark ~= "1" then + unit.caption:SetTextColor(1,1,1) + end end unit.caption:SetAllPoints(unit.hp.bar) end diff --git a/modules/target.lua b/modules/target.lua index d1d90294..6c03802c 100644 --- a/modules/target.lua +++ b/modules/target.lua @@ -113,11 +113,25 @@ pfUI:RegisterModule("target", function () color = UnitReactionColor[UnitReaction("target", "player")] end - local r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + local r, g, b = .2, .2, .2 + if pfUI_config.unitframes.dark == "1" then + pfUI.uf.target.hp.bar:SetStatusBarColor(r, g, b, hp / hpmax / 4 + .75) + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + else + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + pfUI.uf.target.hp.bar:SetStatusBarColor(r, g, b, hp / hpmax / 4 + .75) + end + pfUI.uf.target.powerText:SetTextColor(r, g, b, 1) pfUI.uf.target.hp.bar:SetMinMaxValues(0, hpmax) - pfUI.uf.target.hp.bar:SetStatusBarColor(r, g, b, hp / hpmax / 4 + .75) - pfUI.uf.target.powerText:SetTextColor(r, g, b, 1) local perc = hp / hpmax local r1, g1, b1, r2, g2, b2 diff --git a/modules/targettarget.lua b/modules/targettarget.lua index 215c0a4a..36ac9c95 100644 --- a/modules/targettarget.lua +++ b/modules/targettarget.lua @@ -58,9 +58,24 @@ pfUI:RegisterModule("targettarget", function () pfUI.uf.targettarget.hp.bar:SetMinMaxValues(0, UnitHealthMax("targettarget")) if color then - local r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 - pfUI.uf.targettarget.hp.bar:SetStatusBarColor(r, g, b, UnitHealth("targettarget") / UnitHealthMax("targettarget") / 4 + .75) - pfUI.uf.targettarget.hp.text:SetTextColor(r+.3,g+.3,b+.3, 1) + local r, g, b = .2, .2, .2 + if pfUI_config.unitframes.dark == "1" then + pfUI.uf.targettarget.hp.bar:SetStatusBarColor(r, g, b, UnitHealth("targettarget") / UnitHealthMax("targettarget") / 4 + .75) + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + else + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + pfUI.uf.targettarget.hp.bar:SetStatusBarColor(r, g, b, UnitHealth("targettarget") / UnitHealthMax("targettarget") / 4 + .75) + end + + pfUI.uf.targettarget.hp.text:SetTextColor(r, g, b, 1) end pfUI.uf.targettarget.hp.text:SetText( UnitName("targettarget"))