-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleRaidFrames.lua
More file actions
executable file
·610 lines (586 loc) · 21.9 KB
/
SimpleRaidFrames.lua
File metadata and controls
executable file
·610 lines (586 loc) · 21.9 KB
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
local ADDON_NAME = ...
local M = _G[ADDON_NAME] or {}
_G[ADDON_NAME] = M
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
local LSM = LibStub and LibStub("LibSharedMedia-3.0", true)
local DEFAULT_FONT_NAME = (LSM and LSM.GetDefault and LSM:GetDefault("font")) or "Friz Quadrata TT"
local DEFAULT_FONT_PATH = STANDARD_TEXT_FONT or "Fonts\\FRIZQT__.TTF"
local DEFAULT_FONT_SIZE = 11
local issecretvalue = issecretvalue or function()
return false
end
local ICONS = {
offline = "Interface\\AddOns\\SimpleRaidFrames\\media\\icons\\connection.png",
leader = "Interface\\GroupFrame\\UI-Group-LeaderIcon",
assist = "Interface\\GroupFrame\\UI-Group-AssistantIcon",
afk = "Interface\\AddOns\\SimpleRaidFrames\\media\\icons\\afk.png",
dnd = "Interface\\AddOns\\SimpleRaidFrames\\media\\icons\\dnd.png",
dead = "Interface\\AddOns\\SimpleRaidFrames\\media\\icons\\dead.png",
ghost = "Interface\\AddOns\\SimpleRaidFrames\\media\\icons\\ghost.png",
}
local OUTLINE_OPTIONS = {
{ label = "None", value = "" },
{ label = "Outline", value = "OUTLINE" },
{ label = "Thick Outline", value = "THICKOUTLINE" },
{ label = "Mono Outline", value = "MONOCHROME,OUTLINE" },
{ label = "Mono Thick", value = "MONOCHROME,THICKOUTLINE" },
}
local INDICATOR_ANCHORS = {
{ label = "Top", value = "TOP" },
{ label = "Right", value = "RIGHT" },
{ label = "Bottom", value = "BOTTOM" },
{ label = "Left", value = "LEFT" },
{ label = "Center", value = "CENTER" },
}
do
local _, size = GameFontNormalSmall and GameFontNormalSmall:GetFont()
if size then
DEFAULT_FONT_SIZE = size
end
end
local DEFAULTS = {
hideRaidFrameTooltips = false,
hidePlayerInParty = false,
showPartyWhenSolo = false,
maxNameLength = 4,
nameFont = "Expressway",
nameFontSize = 14,
nameFontOutline = "",
nameShadow = true,
nameClassColor = true,
roleIconStyle = "pixels",
roleIconSize = 16,
roleIconOffsetX = 3,
roleIconOffsetY = -3,
roleIconClassColor = true,
healthColorEnabled = true,
healthColorClassColor = true,
healthColorClassColorDarkness = 0.9,
healthColor = { r = 0.0745098039, g = 0.0745098039, b = 0.0745098039, a = 1.0 },
healthBgColorEnabled = true,
healthBgClassColor = true,
healthBgColor = { r = 0.0, g = 0.0, b = 0.0, a = 0.6 },
healthDeadBgColorEnabled = true,
healthDeadBgColor = { r = 0.2509803922, g = 0.0431372549, b = 0.0, a = 1.0 },
healthBlackBorders = true,
auraBarsEnabled = false,
auraBarsWidth = 26,
auraBarsHeight = 8,
auraBarsSpacing = -1,
auraBarsOffsetX = -6,
auraBarsOffsetY = -6,
auraBarsAnchor = "TOPRIGHT",
auraBarsGrow = "DOWN",
auraBarsFillDirection = "LTR",
auraBarsTexture = "Flat",
auraBarsMax = 7,
auraBarsPlayerOnly = true,
auraBarsDefaultColor = { r = 0.3, g = 0.9, b = 0.4, a = 1.0 },
auraBarsList = {},
leaderAssistEnabled = true,
leaderAssistAnchor = "TOP",
leaderAssistOffsetX = 0,
leaderAssistOffsetY = -6,
statusIndicatorsEnabled = true,
statusIndicatorAnchor = "LEFT",
statusIndicatorOffsetX = 0,
statusIndicatorOffsetY = 0,
readyCheckIconEnabled = false,
readyCheckIconAnchor = "CENTER",
readyCheckIconSize = 20,
readyCheckIconOffsetX = 0,
readyCheckIconOffsetY = 0,
leaderAssistClassColor = false,
statusIndicatorClassColor = false,
}
M.AceGUI = AceGUI
M.LSM = LSM
M.DEFAULTS = DEFAULTS
M.CONST = {
DEFAULT_FONT_NAME = DEFAULT_FONT_NAME,
DEFAULT_FONT_PATH = DEFAULT_FONT_PATH,
DEFAULT_FONT_SIZE = DEFAULT_FONT_SIZE,
OUTLINE_OPTIONS = OUTLINE_OPTIONS,
INDICATOR_ANCHORS = INDICATOR_ANCHORS,
ICONS = ICONS,
}
M._settingsCategoryName = "SimpleRaidFrames"
M.DB = nil
M._settingsFrame = nil
M._pendingRoleIconRefresh = false
M._pendingPartyVisibilityRefresh = false
M._pendingPartySoloVisibilityRefresh = false
local function ensureDefaults()
SimpleRaidFramesDB = SimpleRaidFramesDB or {}
SimpleRaidFramesDB.hideRealmNames = nil
if SimpleRaidFramesDB.hideRaidFrameTooltips == nil then
SimpleRaidFramesDB.hideRaidFrameTooltips = DEFAULTS.hideRaidFrameTooltips
end
if SimpleRaidFramesDB.hidePlayerInParty == nil then
SimpleRaidFramesDB.hidePlayerInParty = DEFAULTS.hidePlayerInParty
end
if SimpleRaidFramesDB.showPartyWhenSolo == nil then
SimpleRaidFramesDB.showPartyWhenSolo = DEFAULTS.showPartyWhenSolo
end
if SimpleRaidFramesDB.partyFrameWidthOverride ~= nil then
SimpleRaidFramesDB.partyFrameWidthOverride = nil
end
if SimpleRaidFramesDB.partyFrameWidthOriginal ~= nil then
SimpleRaidFramesDB.partyFrameWidthOriginal = nil
end
if SimpleRaidFramesDB.maxNameLength == nil then
SimpleRaidFramesDB.maxNameLength = DEFAULTS.maxNameLength
end
if SimpleRaidFramesDB.nameFont == nil then
SimpleRaidFramesDB.nameFont = DEFAULTS.nameFont
end
if SimpleRaidFramesDB.nameFontSize == nil then
SimpleRaidFramesDB.nameFontSize = DEFAULTS.nameFontSize
end
if SimpleRaidFramesDB.nameFontOutline == nil then
SimpleRaidFramesDB.nameFontOutline = DEFAULTS.nameFontOutline
end
if SimpleRaidFramesDB.nameShadow == nil then
SimpleRaidFramesDB.nameShadow = DEFAULTS.nameShadow
end
if SimpleRaidFramesDB.nameClassColor == nil then
SimpleRaidFramesDB.nameClassColor = DEFAULTS.nameClassColor
end
if SimpleRaidFramesDB.roleIconStyle ~= "pixels" and SimpleRaidFramesDB.roleIconStyle ~= "blizzard" then
SimpleRaidFramesDB.roleIconStyle = DEFAULTS.roleIconStyle
end
if SimpleRaidFramesDB.roleIconSize == nil then
SimpleRaidFramesDB.roleIconSize = DEFAULTS.roleIconSize
end
if SimpleRaidFramesDB.roleIconOffsetX == nil then
SimpleRaidFramesDB.roleIconOffsetX = DEFAULTS.roleIconOffsetX
end
if SimpleRaidFramesDB.roleIconOffsetY == nil then
SimpleRaidFramesDB.roleIconOffsetY = DEFAULTS.roleIconOffsetY
end
SimpleRaidFramesDB.roleIconSize = tonumber(SimpleRaidFramesDB.roleIconSize) or DEFAULTS.roleIconSize
SimpleRaidFramesDB.roleIconOffsetX = tonumber(SimpleRaidFramesDB.roleIconOffsetX) or DEFAULTS.roleIconOffsetX
SimpleRaidFramesDB.roleIconOffsetY = tonumber(SimpleRaidFramesDB.roleIconOffsetY) or DEFAULTS.roleIconOffsetY
if SimpleRaidFramesDB.roleIconClassColor == nil then
SimpleRaidFramesDB.roleIconClassColor = DEFAULTS.roleIconClassColor
end
if SimpleRaidFramesDB.healthColorEnabled == nil then
SimpleRaidFramesDB.healthColorEnabled = DEFAULTS.healthColorEnabled
end
if SimpleRaidFramesDB.healthColorClassColor == nil then
SimpleRaidFramesDB.healthColorClassColor = DEFAULTS.healthColorClassColor
end
if SimpleRaidFramesDB.healthColorClassColorDarkness == nil then
SimpleRaidFramesDB.healthColorClassColorDarkness = DEFAULTS.healthColorClassColorDarkness
end
SimpleRaidFramesDB.healthColorClassColorDarkness = tonumber(SimpleRaidFramesDB.healthColorClassColorDarkness)
or DEFAULTS.healthColorClassColorDarkness
if SimpleRaidFramesDB.healthColorClassColorDarkness < 0 then
SimpleRaidFramesDB.healthColorClassColorDarkness = 0
elseif SimpleRaidFramesDB.healthColorClassColorDarkness > 1 then
SimpleRaidFramesDB.healthColorClassColorDarkness = 1
end
if SimpleRaidFramesDB.healthBgColorEnabled == nil then
SimpleRaidFramesDB.healthBgColorEnabled = DEFAULTS.healthBgColorEnabled
end
if SimpleRaidFramesDB.healthBgClassColor == nil then
SimpleRaidFramesDB.healthBgClassColor = DEFAULTS.healthBgClassColor
end
if SimpleRaidFramesDB.healthDeadBgColorEnabled == nil then
SimpleRaidFramesDB.healthDeadBgColorEnabled = DEFAULTS.healthDeadBgColorEnabled
end
if SimpleRaidFramesDB.healthBlackBorders == nil then
SimpleRaidFramesDB.healthBlackBorders = DEFAULTS.healthBlackBorders
end
if type(SimpleRaidFramesDB.healthColor) ~= "table" then
SimpleRaidFramesDB.healthColor = {
r = DEFAULTS.healthColor.r,
g = DEFAULTS.healthColor.g,
b = DEFAULTS.healthColor.b,
a = DEFAULTS.healthColor.a,
}
end
if type(SimpleRaidFramesDB.healthBgColor) ~= "table" then
SimpleRaidFramesDB.healthBgColor = {
r = DEFAULTS.healthBgColor.r,
g = DEFAULTS.healthBgColor.g,
b = DEFAULTS.healthBgColor.b,
a = DEFAULTS.healthBgColor.a,
}
end
if type(SimpleRaidFramesDB.healthDeadBgColor) ~= "table" then
SimpleRaidFramesDB.healthDeadBgColor = {
r = DEFAULTS.healthDeadBgColor.r,
g = DEFAULTS.healthDeadBgColor.g,
b = DEFAULTS.healthDeadBgColor.b,
a = DEFAULTS.healthDeadBgColor.a,
}
end
SimpleRaidFramesDB.healthColor.r = tonumber(SimpleRaidFramesDB.healthColor.r) or DEFAULTS.healthColor.r
SimpleRaidFramesDB.healthColor.g = tonumber(SimpleRaidFramesDB.healthColor.g) or DEFAULTS.healthColor.g
SimpleRaidFramesDB.healthColor.b = tonumber(SimpleRaidFramesDB.healthColor.b) or DEFAULTS.healthColor.b
SimpleRaidFramesDB.healthColor.a = tonumber(SimpleRaidFramesDB.healthColor.a)
or (DEFAULTS.healthColor.a or 1)
SimpleRaidFramesDB.healthBgColor.r = tonumber(SimpleRaidFramesDB.healthBgColor.r) or DEFAULTS.healthBgColor.r
SimpleRaidFramesDB.healthBgColor.g = tonumber(SimpleRaidFramesDB.healthBgColor.g) or DEFAULTS.healthBgColor.g
SimpleRaidFramesDB.healthBgColor.b = tonumber(SimpleRaidFramesDB.healthBgColor.b) or DEFAULTS.healthBgColor.b
SimpleRaidFramesDB.healthBgColor.a = tonumber(SimpleRaidFramesDB.healthBgColor.a)
or (DEFAULTS.healthBgColor.a or 1)
SimpleRaidFramesDB.healthDeadBgColor.r = tonumber(SimpleRaidFramesDB.healthDeadBgColor.r)
or DEFAULTS.healthDeadBgColor.r
SimpleRaidFramesDB.healthDeadBgColor.g = tonumber(SimpleRaidFramesDB.healthDeadBgColor.g)
or DEFAULTS.healthDeadBgColor.g
SimpleRaidFramesDB.healthDeadBgColor.b = tonumber(SimpleRaidFramesDB.healthDeadBgColor.b)
or DEFAULTS.healthDeadBgColor.b
SimpleRaidFramesDB.healthDeadBgColor.a = tonumber(SimpleRaidFramesDB.healthDeadBgColor.a)
or (DEFAULTS.healthDeadBgColor.a or 1)
SimpleRaidFramesDB.hideBuffs = nil
if SimpleRaidFramesDB.auraBarsEnabled == nil then
SimpleRaidFramesDB.auraBarsEnabled = DEFAULTS.auraBarsEnabled
end
if SimpleRaidFramesDB.auraBarsWidth == nil then
SimpleRaidFramesDB.auraBarsWidth = DEFAULTS.auraBarsWidth
end
if SimpleRaidFramesDB.auraBarsAnchor == nil then
SimpleRaidFramesDB.auraBarsAnchor = DEFAULTS.auraBarsAnchor
end
if SimpleRaidFramesDB.auraBarsGrow == nil then
SimpleRaidFramesDB.auraBarsGrow = DEFAULTS.auraBarsGrow
end
if SimpleRaidFramesDB.auraBarsFillDirection == nil then
SimpleRaidFramesDB.auraBarsFillDirection = DEFAULTS.auraBarsFillDirection
end
if SimpleRaidFramesDB._auraBarsPlayerOnlyMigrated ~= true then
SimpleRaidFramesDB.auraBarsPlayerOnly = true
SimpleRaidFramesDB._auraBarsPlayerOnlyMigrated = true
end
if SimpleRaidFramesDB.auraBarsHeight == nil then
SimpleRaidFramesDB.auraBarsHeight = DEFAULTS.auraBarsHeight
end
if SimpleRaidFramesDB.auraBarsSpacing == nil then
SimpleRaidFramesDB.auraBarsSpacing = DEFAULTS.auraBarsSpacing
end
if SimpleRaidFramesDB.auraBarsOffsetX == nil then
SimpleRaidFramesDB.auraBarsOffsetX = DEFAULTS.auraBarsOffsetX
end
if SimpleRaidFramesDB.auraBarsOffsetY == nil then
SimpleRaidFramesDB.auraBarsOffsetY = DEFAULTS.auraBarsOffsetY
end
if SimpleRaidFramesDB.auraBarsTexture == nil then
SimpleRaidFramesDB.auraBarsTexture = DEFAULTS.auraBarsTexture
end
if SimpleRaidFramesDB.auraBarsMax == nil then
SimpleRaidFramesDB.auraBarsMax = DEFAULTS.auraBarsMax
end
if SimpleRaidFramesDB.auraBarsPlayerOnly == nil then
SimpleRaidFramesDB.auraBarsPlayerOnly = DEFAULTS.auraBarsPlayerOnly
end
if type(SimpleRaidFramesDB.auraBarsDefaultColor) ~= "table" then
SimpleRaidFramesDB.auraBarsDefaultColor = {
r = DEFAULTS.auraBarsDefaultColor.r,
g = DEFAULTS.auraBarsDefaultColor.g,
b = DEFAULTS.auraBarsDefaultColor.b,
a = DEFAULTS.auraBarsDefaultColor.a,
}
end
SimpleRaidFramesDB.auraBarsDefaultColor.r = tonumber(SimpleRaidFramesDB.auraBarsDefaultColor.r)
or DEFAULTS.auraBarsDefaultColor.r
SimpleRaidFramesDB.auraBarsDefaultColor.g = tonumber(SimpleRaidFramesDB.auraBarsDefaultColor.g)
or DEFAULTS.auraBarsDefaultColor.g
SimpleRaidFramesDB.auraBarsDefaultColor.b = tonumber(SimpleRaidFramesDB.auraBarsDefaultColor.b)
or DEFAULTS.auraBarsDefaultColor.b
SimpleRaidFramesDB.auraBarsDefaultColor.a = tonumber(SimpleRaidFramesDB.auraBarsDefaultColor.a)
or DEFAULTS.auraBarsDefaultColor.a
if type(SimpleRaidFramesDB.auraBarsList) ~= "table" then
SimpleRaidFramesDB.auraBarsList = {}
end
SimpleRaidFramesDB.auraBarsWidth = tonumber(SimpleRaidFramesDB.auraBarsWidth) or DEFAULTS.auraBarsWidth
SimpleRaidFramesDB.auraBarsHeight = tonumber(SimpleRaidFramesDB.auraBarsHeight) or DEFAULTS.auraBarsHeight
SimpleRaidFramesDB.auraBarsSpacing = tonumber(SimpleRaidFramesDB.auraBarsSpacing) or DEFAULTS.auraBarsSpacing
SimpleRaidFramesDB.auraBarsOffsetX = tonumber(SimpleRaidFramesDB.auraBarsOffsetX) or DEFAULTS.auraBarsOffsetX
SimpleRaidFramesDB.auraBarsOffsetY = tonumber(SimpleRaidFramesDB.auraBarsOffsetY) or DEFAULTS.auraBarsOffsetY
SimpleRaidFramesDB.auraBarsMax = tonumber(SimpleRaidFramesDB.auraBarsMax) or DEFAULTS.auraBarsMax
SimpleRaidFramesDB.privateAurasEnabled = nil
if SimpleRaidFramesDB.leaderAssistEnabled == nil then
if SimpleRaidFramesDB.leaderIndicatorEnabled ~= nil or SimpleRaidFramesDB.assistIndicatorEnabled ~= nil then
SimpleRaidFramesDB.leaderAssistEnabled = (SimpleRaidFramesDB.leaderIndicatorEnabled == true)
or (SimpleRaidFramesDB.assistIndicatorEnabled == true)
else
SimpleRaidFramesDB.leaderAssistEnabled = DEFAULTS.leaderAssistEnabled
end
end
if SimpleRaidFramesDB.leaderAssistAnchor == nil then
SimpleRaidFramesDB.leaderAssistAnchor = DEFAULTS.leaderAssistAnchor
end
if SimpleRaidFramesDB.leaderAssistOffsetX == nil then
SimpleRaidFramesDB.leaderAssistOffsetX = DEFAULTS.leaderAssistOffsetX
end
if SimpleRaidFramesDB.leaderAssistOffsetY == nil then
SimpleRaidFramesDB.leaderAssistOffsetY = DEFAULTS.leaderAssistOffsetY
end
if SimpleRaidFramesDB.statusIndicatorsEnabled == nil then
SimpleRaidFramesDB.statusIndicatorsEnabled = DEFAULTS.statusIndicatorsEnabled
end
if SimpleRaidFramesDB.statusIndicatorAnchor == nil then
SimpleRaidFramesDB.statusIndicatorAnchor = DEFAULTS.statusIndicatorAnchor
end
if SimpleRaidFramesDB.statusIndicatorOffsetX == nil then
SimpleRaidFramesDB.statusIndicatorOffsetX = DEFAULTS.statusIndicatorOffsetX
end
if SimpleRaidFramesDB.statusIndicatorOffsetY == nil then
SimpleRaidFramesDB.statusIndicatorOffsetY = DEFAULTS.statusIndicatorOffsetY
end
if SimpleRaidFramesDB.readyCheckIconEnabled == nil then
SimpleRaidFramesDB.readyCheckIconEnabled = DEFAULTS.readyCheckIconEnabled
end
if SimpleRaidFramesDB.readyCheckIconAnchor == nil then
SimpleRaidFramesDB.readyCheckIconAnchor = DEFAULTS.readyCheckIconAnchor
end
if SimpleRaidFramesDB.readyCheckIconSize == nil then
SimpleRaidFramesDB.readyCheckIconSize = DEFAULTS.readyCheckIconSize
end
if SimpleRaidFramesDB.readyCheckIconOffsetX == nil then
SimpleRaidFramesDB.readyCheckIconOffsetX = DEFAULTS.readyCheckIconOffsetX
end
if SimpleRaidFramesDB.readyCheckIconOffsetY == nil then
SimpleRaidFramesDB.readyCheckIconOffsetY = DEFAULTS.readyCheckIconOffsetY
end
if SimpleRaidFramesDB.leaderAssistAnchor ~= "TOP"
and SimpleRaidFramesDB.leaderAssistAnchor ~= "RIGHT"
and SimpleRaidFramesDB.leaderAssistAnchor ~= "BOTTOM"
and SimpleRaidFramesDB.leaderAssistAnchor ~= "LEFT"
and SimpleRaidFramesDB.leaderAssistAnchor ~= "CENTER" then
SimpleRaidFramesDB.leaderAssistAnchor = DEFAULTS.leaderAssistAnchor
end
SimpleRaidFramesDB.leaderAssistOffsetX = tonumber(SimpleRaidFramesDB.leaderAssistOffsetX)
or DEFAULTS.leaderAssistOffsetX
SimpleRaidFramesDB.leaderAssistOffsetY = tonumber(SimpleRaidFramesDB.leaderAssistOffsetY)
or DEFAULTS.leaderAssistOffsetY
if SimpleRaidFramesDB.statusIndicatorAnchor ~= "TOP"
and SimpleRaidFramesDB.statusIndicatorAnchor ~= "RIGHT"
and SimpleRaidFramesDB.statusIndicatorAnchor ~= "BOTTOM"
and SimpleRaidFramesDB.statusIndicatorAnchor ~= "LEFT"
and SimpleRaidFramesDB.statusIndicatorAnchor ~= "CENTER" then
SimpleRaidFramesDB.statusIndicatorAnchor = DEFAULTS.statusIndicatorAnchor
end
SimpleRaidFramesDB.statusIndicatorOffsetX = tonumber(SimpleRaidFramesDB.statusIndicatorOffsetX)
or DEFAULTS.statusIndicatorOffsetX
SimpleRaidFramesDB.statusIndicatorOffsetY = tonumber(SimpleRaidFramesDB.statusIndicatorOffsetY)
or DEFAULTS.statusIndicatorOffsetY
if SimpleRaidFramesDB.readyCheckIconAnchor ~= "TOP"
and SimpleRaidFramesDB.readyCheckIconAnchor ~= "RIGHT"
and SimpleRaidFramesDB.readyCheckIconAnchor ~= "BOTTOM"
and SimpleRaidFramesDB.readyCheckIconAnchor ~= "LEFT"
and SimpleRaidFramesDB.readyCheckIconAnchor ~= "CENTER" then
SimpleRaidFramesDB.readyCheckIconAnchor = DEFAULTS.readyCheckIconAnchor
end
SimpleRaidFramesDB.readyCheckIconSize = tonumber(SimpleRaidFramesDB.readyCheckIconSize)
or DEFAULTS.readyCheckIconSize
SimpleRaidFramesDB.readyCheckIconOffsetX = tonumber(SimpleRaidFramesDB.readyCheckIconOffsetX)
or DEFAULTS.readyCheckIconOffsetX
SimpleRaidFramesDB.readyCheckIconOffsetY = tonumber(SimpleRaidFramesDB.readyCheckIconOffsetY)
or DEFAULTS.readyCheckIconOffsetY
if SimpleRaidFramesDB.leaderAssistClassColor == nil then
SimpleRaidFramesDB.leaderAssistClassColor = DEFAULTS.leaderAssistClassColor
end
if SimpleRaidFramesDB.statusIndicatorClassColor == nil then
SimpleRaidFramesDB.statusIndicatorClassColor = DEFAULTS.statusIndicatorClassColor
end
SimpleRaidFramesDB.indicatorClassColor = nil
if LSM and LSM.HashTable then
local fonts = LSM:HashTable("font")
if fonts then
if SimpleRaidFramesDB.nameFont and not fonts[SimpleRaidFramesDB.nameFont] then
for key, path in pairs(fonts) do
if path == SimpleRaidFramesDB.nameFont then
SimpleRaidFramesDB.nameFont = key
break
end
end
end
end
end
M.DB = SimpleRaidFramesDB
if M.SeedAuraBarsClassDefaults then
M:SeedAuraBarsClassDefaults()
end
end
local function safeGetValue(object, key)
if object == nil then return nil end
local ok, value = pcall(function()
return object[key]
end)
if ok and not issecretvalue(value) then
return value
end
return nil
end
local function safeGetParent(object)
local getParent = safeGetValue(object, "GetParent")
if type(getParent) ~= "function" then
return nil
end
local ok, parent = pcall(getParent, object)
if ok and not issecretvalue(parent) then
return parent
end
return nil
end
local function getFrameUnit(frame)
local unit = safeGetValue(frame, "displayedUnit")
if type(unit) ~= "string" or unit == "" then
unit = safeGetValue(frame, "unit")
end
if type(unit) == "string" and unit ~= "" then
return unit
end
return nil
end
local function isFrameInPreview(frame)
if not frame then return false end
local previewFrame = _G and _G.RaidFrameSettingsPreviewFrame
if not previewFrame then return false end
local parent = frame
while parent do
if parent == previewFrame then
return true
end
parent = safeGetParent(parent)
end
return false
end
local function isFrameInRaidContainer(frame)
if not frame then return false end
local unit = getFrameUnit(frame)
if type(unit) == "string" then
if unit ~= "player" and not unit:find("^raid") and not unit:find("^party") then
return false
end
end
if isFrameInPreview(frame) then
return true
end
local parent = frame
while parent do
if parent == CompactRaidFrameContainer or parent == CompactPartyFrame then
return true
end
parent = safeGetParent(parent)
end
return false
end
local function isInCombatLockdown()
return InCombatLockdown and InCombatLockdown()
end
local function canMutateRaidFrames(frame, allowCombat)
if not allowCombat and isInCombatLockdown() then
return false
end
if EditModeManagerFrame and EditModeManagerFrame.IsEditModeActive then
if EditModeManagerFrame:IsEditModeActive() then
if frame and isFrameInPreview(frame) then
return true
end
return false
end
end
return true
end
local function truncateUtf8(text, maxLen)
if not text or maxLen <= 0 then return text end
local bytes = #text
local len = 0
local i = 1
while i <= bytes do
len = len + 1
if len > maxLen then
return text:sub(1, i - 1)
end
local c = text:byte(i)
if c < 0x80 then
i = i + 1
elseif c < 0xE0 then
i = i + 2
elseif c < 0xF0 then
i = i + 3
else
i = i + 4
end
end
return text
end
local function resolveFont(fontValue)
if LSM and LSM.Fetch then
local fetched = LSM:Fetch("font", fontValue, true)
if fetched then
return fetched
end
end
if type(fontValue) == "string" then
if fontValue:find("\\") or fontValue:lower():find("%.ttf") then
return fontValue
end
end
return DEFAULT_FONT_PATH
end
local FONT_KEY_SEPARATOR = "\31"
local function buildFontKey(fontPath, size, outline, shadow)
return tostring(fontPath or "") .. FONT_KEY_SEPARATOR .. tostring(size or "")
.. FONT_KEY_SEPARATOR .. tostring(outline or "")
.. FONT_KEY_SEPARATOR .. (shadow and "1" or "0")
end
local function applyFontToFontString(fontString, fontPath, size, outline, shadow)
if not fontString or not fontString.SetFont then return end
local key = buildFontKey(fontPath, size, outline, shadow)
if fontString._srfFontKey == key then
return
end
local ok = fontString:SetFont(fontPath, size, outline)
if not ok and fontPath ~= DEFAULT_FONT_PATH then
fontPath = DEFAULT_FONT_PATH
key = buildFontKey(fontPath, size, outline, shadow)
fontString:SetFont(fontPath, size, outline)
end
if shadow then
fontString:SetShadowColor(0, 0, 0, 1)
fontString:SetShadowOffset(1, -1)
else
fontString:SetShadowColor(0, 0, 0, 0)
fontString:SetShadowOffset(0, 0)
end
fontString._srfFontKey = key
end
local function setStatusBarColorCached(statusBar, r, g, b, a)
if not statusBar or not statusBar.SetStatusBarColor then return end
statusBar:SetStatusBarColor(r, g, b, a)
local c = statusBar._srfBarColor
if not c then
c = {}
statusBar._srfBarColor = c
end
c.r, c.g, c.b, c.a = r, g, b, a
end
local function setTextureColorCached(tex, r, g, b, a)
if not tex or not tex.SetColorTexture then return end
local c = tex._srfTexColor
if c and c.r == r and c.g == g and c.b == b and c.a == a then
return
end
tex:SetColorTexture(r, g, b, a)
if not c then
c = {}
tex._srfTexColor = c
end
c.r, c.g, c.b, c.a = r, g, b, a
end
M.EnsureDefaults = ensureDefaults
M.SafeGetValue = safeGetValue
M.IsSecretValue = issecretvalue
M.GetFrameUnit = getFrameUnit
M.IsFrameInRaidContainer = isFrameInRaidContainer
M.CanMutateRaidFrames = canMutateRaidFrames
M.TruncateUtf8 = truncateUtf8
M.ResolveFont = resolveFont
M.ApplyFontToFontString = applyFontToFontString
M.SetStatusBarColorCached = setStatusBarColorCached
M.SetTextureColorCached = setTextureColorCached