Skip to content

Commit 024c123

Browse files
committed
fixing border and border color
1 parent 665fd82 commit 024c123

File tree

11 files changed

+132
-44
lines changed

11 files changed

+132
-44
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Added
1818

19-
- `CHANGELOG.mf' initialized.
19+
- `CHANGELOG.mf' initialized.

Filger-Classic.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ config\config.lua
2828

2929
## core
3030
core\functions.lua
31+
core\colors.lua
3132
core\api.lua
3233
core\commands.lua
3334
core\development.lua

Filger-Mainline.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ config\config.lua
2525

2626
## core
2727
core\functions.lua
28+
core\colors.lua
2829
core\api.lua
2930
core\commands.lua
3031
core\development.lua

Filger-TBC.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ config\config.lua
2525

2626
## core
2727
core\functions.lua
28+
core\colors.lua
2829
core\api.lua
2930
core\commands.lua
3031
core\development.lua

Filger-Wrath.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ config\config.lua
2525

2626
## core
2727
core\functions.lua
28+
core\colors.lua
2829
core\api.lua
2930
core\commands.lua
3031
core\development.lua

Filger.lua

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@ end
3333
-- player info
3434
local class = Filger.MyClass
3535
local classColor = RAID_CLASS_COLORS[class]
36-
37-
local DebuffTypeColors = {
38-
["Curse"] = { 0.60, 0.00, 1.00 },
39-
["Disease"] = { 0.60, 0.40, 0.00 },
40-
["Magic"] = { 0.20, 0.60, 1.00 },
41-
["Poison"] = { 0.00, 0.60, 0.00 },
42-
["Unknown"] = { 0.80, 0.00, 0.00 }
43-
}
36+
local debuffColor = Filger.Colors
4437

4538
-- import
4639
local tinsert, tremove, tsort, wipe = table.insert, table.remove, table.sort, table.wipe
@@ -254,10 +247,11 @@ function Filger:PostUpdateAura(element, unit, aura, index, position, duration, e
254247
-- 1. dispel harmful effects from friendly target.
255248
-- 2. dispell beneficial effects from enemy target.
256249
local isDispellable = (not aura.casterIsPlayer) and IsDispelable(debuffType, aura.isPlayer, targetIsEnemy, isDebuff, spellID)
250+
local isPlayerDebuff = (unit == "player") and isDebuff
257251

258252
-- set border color by aura type, if it's dispelable.
259-
local color = DebuffTypeColors[debuffType]
260-
if ((isDispellable or isStealable) and color) then
253+
local color = (isDebuff) and debuffColor[debuffType or "none"] or debuffColor[debuffType]
254+
if (color and (isDispellable or isStealable or isPlayerDebuff)) then
261255
aura.Backdrop:SetBorderColor(unpack(color))
262256
else
263257
aura.Backdrop:SetBorderColor(unpack(BorderColor))

config/config.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Config["General"] = {
2020
["HideWellFed"] = true, -- enabled filter to hide well fed buff (too many spells with this name)
2121
["Gametoolip"] = true, -- enabled tooltips
2222

23-
["BackdropColor"] = { .05, .05, .05 },
24-
["BorderColor"] = { .125, .125, .125 },
23+
["BackdropColor"] = { .08, .08, .08 },
24+
["BorderColor"] = { .01, .01, .01 }
2525
}
2626

2727
Config["Plugins"] = {

core/api.lua

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -112,37 +112,69 @@ API.SetInside = function(self, Anchor, OffsetX, OffsetY)
112112
self:SetPoint("BOTTOMRIGHT", Anchor, "BOTTOMRIGHT", -OffsetX, OffsetY)
113113
end
114114

115+
API.SetBorderColor = function(self, R, G, B, Alpha)
116+
if self.BorderTop then
117+
self.BorderTop:SetColorTexture(R, G, B, Alpha)
118+
end
119+
120+
if self.BorderBottom then
121+
self.BorderBottom:SetColorTexture(R, G, B, Alpha)
122+
end
123+
124+
if self.BorderRight then
125+
self.BorderRight:SetColorTexture(R, G, B, Alpha)
126+
end
127+
128+
if self.BorderLeft then
129+
self.BorderLeft:SetColorTexture(R, G, B, Alpha)
130+
end
131+
end
132+
115133
API.CreateBackdrop = function(self, template)
116-
local BackdropColorR, BackdropColorG, BackdropColorB, BackdropColorA = unpack(Config.General.BackdropColor)
117-
local BorderColorR, BorderColorG, BorderColorB = unpack(Config.General.BorderColor)
118-
local BackgroundAlpha = (template == "Transparent") and 0.75 or BackdropColorA or 1
119-
local Texture = Config.Medias.Blank
120-
121-
local Backdrop = {
122-
bgFile = Texture,
123-
edgeFile = Texture,
124-
edgeSize = Scale(1),
125-
insets = {
126-
top = 0,
127-
left = 0,
128-
bottom = 0,
129-
right = 0
130-
}
131-
}
134+
if (self.Backdrop) then return end
132135

133136
self.Backdrop = CreateFrame("Frame", nil, self, "BackdropTemplate")
134137
self.Backdrop:SetAllPoints()
135-
-- self.Backdrop:SetOutside(self, 2, 2)
136138
self.Backdrop:SetFrameLevel(self:GetFrameLevel())
137-
self.Backdrop:SetBackdrop(Backdrop)
138-
self.Backdrop:SetBackdropColor(BackdropColorR, BackdropColorG, BackdropColorB, BackgroundAlpha)
139-
self.Backdrop:SetBackdropBorderColor(BorderColorR, BorderColorG, BorderColorB)
140-
end
141139

142-
API.SetBorderColor = function(self, R, G, B, Alpha)
143-
if (self.Backdrop) then
144-
self.Backdrop:SetBackdropBorderColor(R, G, B, Alpha or 1)
145-
end
140+
local BorderR, BorderG, BorderB = unpack(Config.General.BorderColor)
141+
local BackdropR, BackdropG, BackdropB, BackdropA = unpack(Config.General.BackdropColor)
142+
local BackgroundAlpha = (template == "Transparent") and 0.75 or BackdropA or 1
143+
local BorderSize = Scale(1)
144+
local Texture = Config.Medias.Blank
145+
146+
self.Backdrop:SetBackdrop({ bgFile = Texture })
147+
self.Backdrop:SetBackdropColor(BackdropR, BackdropG, BackdropB, BackgroundAlpha)
148+
149+
self.Backdrop.BorderTop = self.Backdrop:CreateTexture(nil, "BORDER", nil, 1)
150+
self.Backdrop.BorderTop:SetSize(BorderSize, BorderSize)
151+
self.Backdrop.BorderTop:SetPoint("TOPLEFT", self.Backdrop, "TOPLEFT", 0, 0)
152+
self.Backdrop.BorderTop:SetPoint("TOPRIGHT", self.Backdrop, "TOPRIGHT", 0, 0)
153+
self.Backdrop.BorderTop:SetSnapToPixelGrid(false)
154+
self.Backdrop.BorderTop:SetTexelSnappingBias(0)
155+
156+
self.Backdrop.BorderBottom = self.Backdrop:CreateTexture(nil, "BORDER", nil, 1)
157+
self.Backdrop.BorderBottom:SetSize(BorderSize, BorderSize)
158+
self.Backdrop.BorderBottom:SetPoint("BOTTOMLEFT", self.Backdrop, "BOTTOMLEFT", 0, 0)
159+
self.Backdrop.BorderBottom:SetPoint("BOTTOMRIGHT", self.Backdrop, "BOTTOMRIGHT", 0, 0)
160+
self.Backdrop.BorderBottom:SetSnapToPixelGrid(false)
161+
self.Backdrop.BorderBottom:SetTexelSnappingBias(0)
162+
163+
self.Backdrop.BorderLeft = self.Backdrop:CreateTexture(nil, "BORDER", nil, 1)
164+
self.Backdrop.BorderLeft:SetSize(BorderSize, BorderSize)
165+
self.Backdrop.BorderLeft:SetPoint("TOPLEFT", self.Backdrop, "TOPLEFT", 0, 0)
166+
self.Backdrop.BorderLeft:SetPoint("BOTTOMLEFT", self.Backdrop, "BOTTOMLEFT", 0, 0)
167+
self.Backdrop.BorderLeft:SetSnapToPixelGrid(false)
168+
self.Backdrop.BorderLeft:SetTexelSnappingBias(0)
169+
170+
self.Backdrop.BorderRight = self.Backdrop:CreateTexture(nil, "BORDER", nil, 1)
171+
self.Backdrop.BorderRight:SetSize(BorderSize, BorderSize)
172+
self.Backdrop.BorderRight:SetPoint("TOPRIGHT", self.Backdrop, "TOPRIGHT", 0, 0)
173+
self.Backdrop.BorderRight:SetPoint("BOTTOMRIGHT", self.Backdrop, "BOTTOMRIGHT", 0, 0)
174+
self.Backdrop.BorderRight:SetSnapToPixelGrid(false)
175+
self.Backdrop.BorderRight:SetTexelSnappingBias(0)
176+
177+
self.Backdrop:SetBorderColor(BorderR, BorderG, BorderB, BorderA)
146178
end
147179

148180
function Filger:EnableAPI()

core/colors.lua

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
local _, ns = ...
2+
local Filger = ns.Filger
3+
4+
local colorMixin = {
5+
SetRGBA = function(self, r, g, b, a)
6+
if(r > 1 or g > 1 or b > 1) then
7+
r, g, b = r / 255, g / 255, b / 255
8+
end
9+
10+
self.r = r
11+
self[1] = r
12+
self.g = g
13+
self[2] = g
14+
self.b = b
15+
self[3] = b
16+
self.a = a
17+
18+
-- pre-generate the hex color, there's no point to this being generated on the fly
19+
self.hex = string.format('ff%02x%02x%02x', self:GetRGBAsBytes())
20+
end,
21+
SetAtlas = function(self, atlas)
22+
self.atlas = atlas
23+
end,
24+
GetAtlas = function(self)
25+
return self.atlas
26+
end,
27+
GenerateHexColor = function(self)
28+
return self.hex
29+
end,
30+
}
31+
32+
function Filger:CreateColor(r, g, b, a)
33+
local color = Mixin({}, ColorMixin, colorMixin)
34+
color:SetRGBA(r, g, b, a)
35+
return color
36+
end
37+
38+
local Colors = {
39+
Stealable = Filger:CreateColor(0.93, 0.91, 0.55)
40+
}
41+
42+
for debuffType, color in next, _G.DebuffTypeColor do
43+
Colors[debuffType] = Filger:CreateColor(color.r, color.g, color.b)
44+
end
45+
46+
Filger.Colors = Colors

core/functions.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ function Filger.Debug(...)
3232
print(format("|cffff330fFilger WARNING:|r"), ...)
3333
end
3434

35+
-- Want HEX color instead of RGB?
36+
Filger.RGBToHex = function(r, g, b)
37+
r = r <= 1 and r >= 0 and r or 0
38+
g = g <= 1 and g >= 0 and g or 0
39+
b = b <= 1 and b >= 0 and b or 0
40+
return format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
41+
end
42+
3543
-- format seconds to min/hour/day
3644
function Filger.FormatTime(s)
3745
local Day, Hour, Minute = 86400, 3600, 60

0 commit comments

Comments
 (0)