My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373

-- // rDiabloPlates
-- // zork - 2010

-----------------------------
-- CONFIG
-----------------------------

--color is in RGB (red (r), green (g), blue (b), alpha (a)), values are from 0 (dark color) to 1 (bright color). 1,1,1 = white / 0,0,0 = black / 1,0,0 = red etc
local colorswitcher = {
bright = { r = 1, g = 0, b = 0, a = 0.9, }, -- the bright color
dark = { r = 0.15, g = 0.15, b = 0.15, a = 1, }, -- the dark color
classcolored = false, -- true -> override the bright color with the unit specific color (class, faction, happiness)
useBrightForeground = false, -- true -> use bright color in foreground and dark color in background
-- false -> use dark color in foreground and bright color in background
}

local showhpvalue = true --true/false will enable disable of hp value on the nameplate
local alwaysshowhp = true --true/false will make the hp value appear even if the unit has 100% life, requires showhpvalue to be true

-----------------------------
-- FUNCTIONS
-----------------------------

local function RGBPercToHex(r, g, b)
r = r <= 1 and r >= 0 and r or 0
g = g <= 1 and g >= 0 and g or 0
b = b <= 1 and b >= 0 and b or 0
return string.format("%02x%02x%02x", r*255, g*255, b*255)
end

--set txt func
local applyText = function(f,levelText,dragonTexture,bossIcon,nameText,healthBar)

local r,g,b = levelText:GetTextColor()
r,g,b = floor(r*100+.5)/100, floor(g*100+.5)/100, floor(b*100+.5)/100
local colorstring = RGBPercToHex(r,g,b)

local r,g,b = healthBar:GetStatusBarColor()
r,g,b = floor(r*100+.5)/100, floor(g*100+.5)/100, floor(b*100+.5)/100
if r==0 and g==0 and b==1 then
--dark blue color of members of the own faction is barely readable
f.na:SetTextColor(1,0,1)
else
f.na:SetTextColor(r,g,b)
end

local color = {
r = r,
g = g,
b = b,
}

if not colorswitcher.classcolored then
color = colorswitcher.bright
end
if colorswitcher.useBrightForeground then
healthBar.new:SetVertexColor(color.r,color.g,color.b,color.a or 1)
healthBar.bg:SetVertexColor(colorswitcher.dark.r,colorswitcher.dark.g,colorswitcher.dark.b,colorswitcher.dark.a)
else
healthBar.new:SetVertexColor(colorswitcher.dark.r,colorswitcher.dark.g,colorswitcher.dark.b,colorswitcher.dark.a)
healthBar.bg:SetVertexColor(color.r,color.g,color.b,color.a or 1)
end

local name = nameText:GetText() or ""
local level = levelText:GetText() or ""
if bossIcon:IsShown() == 1 then
level = "??"
colorstring = "ff6600"
elseif dragonTexture:IsShown() == 1 then
level = level.."+"
end

f.na:SetText("|c00"..colorstring..""..level.."|r "..name)

end

--number format func
local numFormat = function(v)
local string = ""
if v > 1E6 then
string = (floor((v/1E6)*10)/10).."m"
elseif v > 1E3 then
string = (floor((v/1E3)*10)/10).."k"
else
string = v
end
return string
end

--update healthbar function (only called when certain config settings are made)
local updateHealthbar = function(healthBar,value)
if healthBar and value then
local min, max = healthBar:GetMinMaxValues()
if value == 'x' then value = max end
local p = floor(value/max*100)
if colorswitcher then
if p == 100 then
healthBar.bg:SetWidth(0.01) --fix (0) makes the bar go anywhere
elseif p < 100 then
if p <= 25 then
healthBar.shadow:SetVertexColor(1,0,0,1)
else
healthBar.shadow:SetVertexColor(0,0,0,0.7)
end
local w = healthBar.w
healthBar.bg:SetWidth(w-(w*p/100)) --calc new width of bar based on size of healthbar
end
end
if showhpvalue then
if p < 100 then
healthBar.hpval:SetText(numFormat(value).." / "..p.."%")
elseif p == 100 and alwaysshowhp then
healthBar.hpval:SetText(numFormat(value).." / "..p.."%")
else
healthBar.hpval:SetText("")
end
end
end

end

--move raid icon func
local moveRaidIcon = function(raidIcon,f)
raidIcon:ClearAllPoints()
raidIcon:SetSize(20,20)
raidIcon:SetPoint("BOTTOM",f,"TOP",0,7)
end

--create castbar background func
local createCastbarBG = function(castBar)
local t = castBar:CreateTexture(nil,"BACKGROUND",nil,-8)
t:SetAllPoints(castBar)
t:SetTexture("Interface\\Addons\\rTextures\\statusbar5")
t:SetVertexColor(0,0,0,0.4)
t:Hide()
castBar.bg = t
end

--create healthbar background func
local createHealthbarBG = function(healthBar,f,castBar)

local fw, fh, hw,hh = f:GetWidth(), f:GetHeight(), healthBar:GetWidth(), healthBar:GetHeight()

healthBar.w = fw
healthBar.h = hh
castBar.w = hw
castBar.h = hh

local bgsize = hw*197.8/128

local back = f:CreateTexture(nil,"BACKGROUND",nil,-8)
back:SetPoint("CENTER",f,"CENTER",0,0)
back:SetSize(bgsize,bgsize/4)
back:SetTexture("Interface\\AddOns\\rTextures\\castbar")
f.back = back

local innershadow = f:CreateTexture(nil,"BACKGROUND",nil,-6)
innershadow:SetAllPoints(back)
innershadow:SetTexture("Interface\\AddOns\\rTextures\\castbar_glow")
innershadow:SetVertexColor(0,0,0,0.7)
healthBar.shadow = innershadow

local t = f:CreateTexture(nil,"BACKGROUND",nil,-7)
t:SetPoint("TOPRIGHT",f,"TOPRIGHT",0,-11)
t:SetPoint("BOTTOMRIGHT",f,"BOTTOMRIGHT",0,11)
t:SetWidth(0.01)
t:SetTexture("Interface\\Addons\\rTextures\\statusbar5")
healthBar.bg = t

local n = f:CreateTexture(nil,"BACKGROUND",nil,-7)
n:SetPoint("TOPLEFT",f,"TOPLEFT",0,-11)
n:SetPoint("BOTTOMLEFT",f,"BOTTOMLEFT",0,11)
n:SetPoint("RIGHT", t, "LEFT", 0, 0) --right point of n will anchor left point of t
n:SetTexture("Interface\\Addons\\rTextures\\statusbar5")
healthBar.new = n

healthBar:SetFrameLevel(f:GetFrameLevel()+2)
healthBar:SetAllPoints(f)

end

--new fontstrings for name and lvl func
local createNewFontStrings = function(f,healthBar)
--new name
local na = f:CreateFontString(nil, "BORDER")
na:SetFont(STANDARD_TEXT_FONT, 12, "THINOUTLINE")
na:SetPoint("BOTTOM", f, "TOP", 0, -5)
na:SetPoint("RIGHT", f, 0, 0)
na:SetPoint("LEFT", f, 0, 0)
na:SetJustifyH("CENTER")
f.na = na
if showhpvalue then
local hp = healthBar:CreateFontString(nil, "BORDER")
hp:SetFont(STANDARD_TEXT_FONT, 10, "THINOUTLINE")
hp:SetPoint("RIGHT",f.back,"RIGHT",-18,1)
hp:SetJustifyH("RIGHT")
healthBar.hpval = hp
end
end

--update the castbar positioning
local updateCastbarPosition = function(castBar)

--local point, relativeTo, relativePoint, xOfs, yOfs = castBar:GetPoint(n)
--xOfs = floor(xOfs+0.5)
--yOfs = floor(yOfs+0.5)

castBar.border:ClearAllPoints()
castBar.border:SetPoint("CENTER",0,-29)

--change castbar color to dark red if the cast is shielded
if castBar.shield:IsShown() == 1 then
castBar:SetStatusBarColor(0.7,0,0)
else
castBar:SetStatusBarColor(1,0.7,0)
end
castBar.shield:ClearAllPoints()
castBar.shield:SetPoint("CENTER",0,-29)

castBar:SetPoint("RIGHT",castBar.border,-1,0)
castBar:SetPoint("TOP",castBar.border,0,-10)
castBar:SetPoint("BOTTOM",castBar.border,0,12)
castBar:SetPoint("LEFT",castBar.border,24,0)

castBar.icon:ClearAllPoints()
castBar.icon:SetPoint("LEFT",castBar.border,3,0)

end

--init the castbar objects
local initCastbars = function(castBar,castborderTexture, shield, castbaricon)
castborderTexture:SetTexture("Interface\\Tooltips\\Nameplate-CastBar")
castborderTexture:SetSize(castBar.w+25,(castBar.w+25)/4)
castborderTexture:SetTexCoord(0,1,0,1)
castBar.border = castborderTexture

shield:SetSize(castBar.w+25,(castBar.w+25)/4)
shield:SetTexCoord(0,1,0,1)
castBar.shield = shield

castbaricon:SetTexCoord(0.1,0.9,0.1,0.9)
castBar.icon = castbaricon

castBar:SetStatusBarColor(1,0.7,0)
createCastbarBG(castBar)

castBar:HookScript("OnShow", function(s)
s.bg:Show()
updateCastbarPosition(s)
end)

castBar:HookScript("OnHide", function(s)
s.bg:Hide()
end)
end

--update style func
local updateStyle = function(f)
--get the value
local healthBar, castBar = f:GetChildren()
local threatTexture, borderTexture, castborderTexture, shield, castbaricon, highlightTexture, nameText, levelText, bossIcon, raidIcon, dragonTexture = f:GetRegions()

--update threat texture
threatTexture:ClearAllPoints()
threatTexture:SetAllPoints(f.back)
healthBar.shadow:SetVertexColor(0,0,0,0.7)

--apply text
applyText(f,levelText,dragonTexture,bossIcon,nameText,healthBar)

--disable some stuff
nameText:Hide()
levelText:Hide()
dragonTexture:SetTexture("")
end

--init style func
local initStyle = function(f)
--get the value
local healthBar, castBar = f:GetChildren()
local threatTexture, borderTexture, castborderTexture, shield, castbaricon, highlightTexture, nameText, levelText, bossIcon, raidIcon, dragonTexture = f:GetRegions()

--init the size of health and castbar
createHealthbarBG(healthBar,f,castBar)

threatTexture:SetTexCoord(0,1,0,1)
threatTexture:SetTexture("Interface\\AddOns\\rTextures\\target_threatglow")
threatTexture:ClearAllPoints()
threatTexture:SetAllPoints(f.back)

--create new fontstrings
createNewFontStrings(f,healthBar)

--apply text
applyText(f,levelText,dragonTexture,bossIcon,nameText,healthBar)

--move some icons
moveRaidIcon(raidIcon,f)

--initialize the castbars
initCastbars(castBar,castborderTexture, shield, castbaricon)

--disable some stuff
nameText:Hide()
levelText:Hide()
dragonTexture:SetTexture("")
borderTexture:SetTexture("")
bossIcon:SetTexture("")
healthBar:SetStatusBarTexture("")
castBar:SetStatusBarTexture("Interface\\Addons\\rTextures\\statusbar5")
highlightTexture:SetTexture("")

if colorswitcher or showhpvalue then
healthBar:SetScript("OnValueChanged", updateHealthbar)
if alwaysshowhp then
updateHealthbar(healthBar,'x')
end
end

f:HookScript("OnShow", function(s)
updateStyle(s)
end)

return true

end


--STYLE NAMEPLATE FUNC
local styleNamePlate = function(f)
f.styled = initStyle(f)
end

local IsNamePlateFrame = function(f)
if f:GetName() then return false end
local o = select(2,f:GetRegions())
if not o or o:GetObjectType() ~= "Texture" or o:GetTexture() ~= "Interface\\Tooltips\\Nameplate-Border" then return false end
return true
end

local lastupdate = 0

local searchNamePlates = function(self,elapsed)
lastupdate = lastupdate + elapsed

if lastupdate > 0.33 then
lastupdate = 0
local num = select("#", WorldFrame:GetChildren())
for i = 1, num do
local f = select(i, WorldFrame:GetChildren())
if not f.styled and IsNamePlateFrame(f) then
styleNamePlate(f)
end
end

end
end

local a = CreateFrame("Frame")
a:SetScript("OnEvent", function(self, event)
if(event=="PLAYER_LOGIN") then
SetCVar("ShowClassColorInNameplate",1)--1
SetCVar("bloattest",0)--0.0
SetCVar("bloatnameplates",0)--0.0
SetCVar("spreadnameplates",0)--1
SetCVar("bloatthreat",0)--1
self:SetScript("OnUpdate", searchNamePlates)
end
end)

a:RegisterEvent("PLAYER_LOGIN")

Change log

r650 by erik.raetz on Nov 18, 2010   Diff
raidframes, colorswitcher, 4.004 todolist
Go to: 

Older revisions

r639 by erik.raetz on Nov 14, 2010   Diff
roth ui beta 4.003
r637 by erik.raetz on Nov 13, 2010   Diff
rothui beta 4.002
r633 by erik.raetz on Nov 11, 2010   Diff
diablo themed nameplates finished
All revisions of this file

File info

Size: 12281 bytes, 373 lines
Powered by Google Project Hosting