forked from jzlhll/FilteredNamePlate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilteredNamePlate.lua
executable file
·648 lines (604 loc) · 23.7 KB
/
FilteredNamePlate.lua
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
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
local _
local L = FNP_LOCALE_TEXT
local GetNamePlateForUnit , GetNamePlates, UnitThreatSituation = C_NamePlate.GetNamePlateForUnit, C_NamePlate.GetNamePlates, UnitThreatSituation
local UnitName, GetUnitName = UnitName, GetUnitName
local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax
local string_find = string.find
local IsGeneralRegistered, IsKillLineRegistered, isScaleInited, isErrInLoad, isNullOnlyList, isNullFilterList
local IsKillLine1, IsKillLine2, AllInfos
local isInOnlySt
local curNpFlag, curNpFlag1Type
FilteredNamePlate.FilterNp_Event_General_List = {
["NAME_PLATE_UNIT_ADDED"] = actionUnitAdded,
["NAME_PLATE_UNIT_REMOVED"] = actionUnitRemoved,
["UNIT_SPELLCAST_START"] = actionUnitSpellCastStart,
["UNIT_SPELLCAST_CHANNEL_START"] = actionUnitSpellCastStart,
["UNIT_SPELLCAST_STOP"] = actionUnitSpellCastStop,
["UNIT_SPELLCAST_CHANNEL_STOP"] = actionUnitSpellCastStop,
};
-- ["UNIT_TTARGET"] = actionUnitTTarget
FilteredNamePlate.FilterNp_Event_Heal_List = {
["UNIT_HEALTH"] = actionUnitHealth,
["UNIT_MAXHEALTH"] = actionUnitHealth,
};
FilteredNamePlate.FilterNp_Event_Enter_List = {
["PLAYER_ENTERING_WORLD"] = registerMyEvents,
};
local function setCVarValues()
SetCVar("nameplateShowEnemies", 1)
SetCVar("nameplateShowEnemyMinions", 1)
SetCVar("nameplateShowEnemyMinus", 1)
SetCVar("nameplateShowAll", 1)
end
local function getTableCount(atab)
local count = 0
for pos, name in ipairs(atab) do
count = count + 1
end
return count
end
local function regHealthEvents(registed)
if registed then
for k, v in pairs(FilteredNamePlate.FilterNp_Event_Heal_List) do
self:RegisterEvent(k,v)
end
else
for k, v in pairs(FilteredNamePlate.FilterNp_Event_Heal_List) do
self:UnregisterEvent(k,v)
end
end
end
local function regGeneralEvents(registed)
if registed then
for k, v in pairs(FilteredNamePlate.FilterNp_Event_General_List) do
self:RegisterEvent(k,v)
end
else
for k, v in pairs(FilteredNamePlate.FilterNp_Event_General_List) do
self:UnregisterEvent(k,v)
end
end
end
local function registerMyEvents(self, event, ...)
if (IsGeneralRegistered == nil or IsGeneralRegistered == false) then
curNpFlag, curNpFlag1Type = FilteredNamePlate:GenCurNpFlags()
isNullOnlyList = false
isNullFilterList = false
if getTableCount(Fnp_ONameList) == 0 then isNullOnlyList = true end
if getTableCount(Fnp_FNameList) == 0 then isNullFilterList = true end
regGeneralEvents(true)
IsGeneralRegistered = true
end
if Fnp_Enable and FnpEnableKeys.killlineMod and (IsKillLineRegistered == nil or IsKillLineRegistered == false) then
regHealthEvents(true)
AllInfos = {}
IsKillLine1 = FnpEnableKeys.killlineMod and (Fnp_SavedScaleList.killline1 < 1.0)
IsKillLine2 = FnpEnableKeys.killlineMod and (Fnp_SavedScaleList.killline2 >= 0.01)
IsKillLineRegistered = true
end
end
local function unRegisterMyEvents(self)
if IsGeneralRegistered == true then
IsGeneralRegistered = false
regGeneralEvents(false)
end
if IsKillLineRegistered == true then
IsKillLineRegistered = false
regHealthEvents(false)
end
end
local function isMatchedNameList(tabList, tName)
if tName == nil then return false end
local isMatch = false
for key, var in ipairs(tabList) do
local _, ret = string_find(tName, var)
if ret ~= nil then
isMatch = true
break
end
end
return isMatch
end
---------kkkkk---kkkkk---kkkkk-------------
local HideAFrame = {
[0] = function(frame) --orig
if frame == nil then return end
if frame.UnitFrame then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.name.small)
if frame.UnitFrame.healthBar then frame.UnitFrame.healthBar:Hide() end
frame.UnitFrame.castBar:SetHeight(FilteredNamePlate.curScaleList.bars.cast_midHeight)
end
end,
[1] = function(frame) -- all the scaled one
if frame == nil then return end
if frame[curNpFlag1Type] then
frame[curNpFlag1Type]:SetScale(FilteredNamePlate.curScaleList.small)
end
end,
[2] = function(frame) --ek number
if frame == nil then return end
if frame.UnitFrame then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.SMALLW)
frame.UnitFrame.name:SetHeight(FilteredNamePlate.curScaleList.SMALLH)
if frame.UnitFrame.healthperc then
frame.UnitFrame.healthperc:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.small_perc_font, FilteredNamePlate.curScaleList.fontFlag)
end
end
end,
[3] = function(frame) --sheStack
if frame == nil then return end
if frame.ouf then
if frame.ouf.Name then
frame.ouf.Name:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.small_name_font, FilteredNamePlate.curScaleList.fontFlag)
end
if frame.ouf.Health then frame.ouf.Health:Hide() end
end
end,
[4] = function(frame) --cbl
if frame == nil then return end
if frame.UnitFrame then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.NAME_SMALLW)
if frame.UnitFrame.healthBar then frame.UnitFrame.healthBar:SetScale(FilteredNamePlate.curScaleList.small_scale) end
frame.UnitFrame.castBar:SetHeight(FilteredNamePlate.curScaleList.mid_scale)
end
end,
}
--isOnlyShowSpellCast 的情况下,就代表是仅显模式。并且该怪是非仅显目标而且施法了!
local ShowAFrame = {
[0] = function(frame, isOnlyShowSpellCast, restore, isOnlyUnit)
if frame and frame.UnitFrame then
if restore == true then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.name.SYSTEM)
if frame.UnitFrame.healthBar then
frame.UnitFrame.healthBar:Show()
frame.UnitFrame.healthBar:SetHeight(FilteredNamePlate.curScaleList.bars.HEAL_SYS_HEIGHT)
end
frame.UnitFrame.castBar:SetHeight(FilteredNamePlate.curScaleList.bars.CAST_SYS_HEIGHT)
elseif isOnlyShowSpellCast == false then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.name.normal)
if frame.UnitFrame.healthBar then
frame.UnitFrame.healthBar:Show()
if isOnlyUnit then
frame.UnitFrame.healthBar:SetHeight(FilteredNamePlate.curScaleList.bars.heal_onlyHeight)
else
frame.UnitFrame.healthBar:SetHeight(FilteredNamePlate.curScaleList.bars.heal_normalHeight)
end
end
frame.UnitFrame.castBar:SetHeight(FilteredNamePlate.curScaleList.bars.CAST_SYS_HEIGHT)
else
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.name.middle)
frame.UnitFrame.castBar:SetHeight(FilteredNamePlate.curScaleList.bars.cast_midHeight)
--frame.UnitFrame.healthBar:Show()
end
end
end,
[1] = function(frame, isOnlyShowSpellCast, restore, isOnlyUnit)
if frame and frame[curNpFlag1Type] then
if restore == true then
frame[curNpFlag1Type]:SetScale(FilteredNamePlate.curScaleList.SYSTEM)
elseif isOnlyShowSpellCast == false then
if isOnlyUnit == true then
frame[curNpFlag1Type]:SetScale(FilteredNamePlate.curScaleList.only)
else
frame[curNpFlag1Type]:SetScale(FilteredNamePlate.curScaleList.normal)
end
else
frame[curNpFlag1Type]:SetScale(FilteredNamePlate.curScaleList.middle)
end
end
end,
[2] = function(frame, isOnlyShowSpellCast, restore, isOnlyUnit)
if frame and frame.UnitFrame then
if restore == true then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.SYSTEMW)
frame.UnitFrame.name:SetHeight(FilteredNamePlate.curScaleList.SYSTEMH)
if frame.UnitFrame.healthperc then
frame.UnitFrame.healthperc:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.PERC_FONT, FilteredNamePlate.curScaleList.fontFlag)
end
elseif isOnlyShowSpellCast == false then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.SYSTEMW)
if frame.UnitFrame.healthperc then
if isOnlyUnit then
frame.UnitFrame.healthperc:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.only_perc_font, FilteredNamePlate.curScaleList.fontFlag)
else
frame.UnitFrame.healthperc:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.normal_perc_font, FilteredNamePlate.curScaleList.fontFlag)
end
end
else
if frame.UnitFrame.healthperc then
frame.UnitFrame.healthperc:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.mid_perc_font, FilteredNamePlate.curScaleList.fontFlag)
end
--frame.UnitFrame.healthBar:Show()
end
end
end,
[3] = function(frame, isOnlyShowSpellCast, restore, isOnlyUnit)
if frame and frame.ouf then
if restore == true then
frame.ouf.Name:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.NAME_FONT, FilteredNamePlate.curScaleList.fontFlag)
frame.ouf.Health:Show()
elseif isOnlyShowSpellCast == false then
frame.ouf.Health:Show()
if isOnlyUnit then
frame.ouf.Name:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.only_name_font, FilteredNamePlate.curScaleList.fontFlag)
else
frame.ouf.Name:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.normal_name_font, FilteredNamePlate.curScaleList.fontFlag)
end
else
frame.ouf.Name:SetFont(FilteredNamePlate.curScaleList.fontFace, FilteredNamePlate.curScaleList.mid_name_font, FilteredNamePlate.curScaleList.fontFlag)
end
end
end,
[4] = function(frame, isOnlyShowSpellCast, restore, isOnlyUnit)
if frame and frame.UnitFrame then
if restore == true then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.NAME_SYSTEMW)
if frame.UnitFrame.healthBar then
frame.UnitFrame.healthBar:SetScale(FilteredNamePlate.curScaleList.SYS_SCALE)
end
frame.UnitFrame.castBar:SetScale(FilteredNamePlate.curScaleList.SYS_SCALE)
elseif isOnlyShowSpellCast == false then
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.NAME_SYSTEMW)
if frame.UnitFrame.healthBar then
if isOnlyUnit then
frame.UnitFrame.healthBar:SetScale(FilteredNamePlate.curScaleList.only_scale)
else
frame.UnitFrame.healthBar:SetScale(FilteredNamePlate.curScaleList.nor_scale)
end
end
frame.UnitFrame.castBar:SetScale(FilteredNamePlate.curScaleList.SYS_SCALE)
else
frame.UnitFrame.name:SetWidth(FilteredNamePlate.curScaleList.NAME_SYSTEMW)
frame.UnitFrame.healthBar:SetScale(FilteredNamePlate.curScaleList.mid_scale)
--frame.UnitFrame.healthBar:Show()
end
end
end,
}
local function resetUnitState(restore)
for _, frame in pairs(GetNamePlates()) do
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
if foundUnit then
ShowAFrame[curNpFlag](frame, false, restore, false)
end
end
end
function FilteredNamePlate:actionUnitStateAfterChanged()
if isErrInLoad then return print(FNP_LOCALE_TEXT.FNP_CHANGED_UITYPE) end
local lastNp = curNpFlag
curNpFlag, curNpFlag1Type = FilteredNamePlate:GenCurNpFlags()
if not (curNpFlag == lastNp) then --UI类型有变,请重载,继续当做没有改变来工作
print(FNP_LOCALE_TEXT.FNP_CHANGED_UITYPE)
return
end
setCVarValues()
-- reset global vars{{
isInOnlySt = false
FilteredNamePlate.isSettingChanged = false
IsKillLine1 = FnpEnableKeys.killlineMod and (Fnp_SavedScaleList.killline1 < 1.0)
IsKillLine2 = FnpEnableKeys.killlineMod and (Fnp_SavedScaleList.killline2 >= 0.01)
-- 我们只计算下这个,生效交给每次health change
-- TODO
isScaleInited = FilteredNamePlate:initScaleValues(curNpFlag, isScaleInited)
isNullOnlyList = false
isNullFilterList = false
if getTableCount(Fnp_ONameList) == 0 then isNullOnlyList = true end
if getTableCount(Fnp_FNameList) == 0 then isNullFilterList = true end
-- reset global vars}}
local matched = false
local matched2 = false
if Fnp_Enable == true then
local isHide = false
for _, frame in pairs(GetNamePlates()) do
if isNullOnlyList == true then -- 如果没有仅显单位则过滤单位hide,其他show normal模式
matched2 = false
if isNullFilterList == false then
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
if foundUnit then matched2 = isMatchedNameList(Fnp_FNameList, GetUnitName(foundUnit)) end
end
if matched2 == true then
HideAFrame[curNpFlag](frame)
else
ShowAFrame[curNpFlag](frame, false, false, false) -- 全是普通情况
end
else -- 如果有仅显单位则
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
matched = false
if foundUnit then matched = isMatchedNameList(Fnp_ONameList, GetUnitName(foundUnit)) end
if matched == true then
isHide = true
break
end
end
end
if isHide == true then -- onlyShow Mode
isInOnlySt = true
for _, frame in pairs(GetNamePlates()) do
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
matched = false
if foundUnit then matched = isMatchedNameList(Fnp_ONameList, GetUnitName(foundUnit)) end
if matched == true then
-- 仅显模式仅显的怪
ShowAFrame[curNpFlag](frame, false, false, true)
else
HideAFrame[curNpFlag](frame)
end
end
else
resetUnitState(false)
end
elseif FnpEnableKeys.killlineMod then
resetUnitState(false)
else
resetUnitState(true)
end
end
local function actionChangedByHeal(unitid, shouldBig, needShowBack)
if shouldBig then
local frame = GetNamePlateForUnit(unitid)
ShowAFrame[curNpFlag](frame, false, false, true)
else
if needShowBack then
local frame = GetNamePlateForUnit(unitid)
if isInOnlySt and AllInfos[unitid].matchType == 1 then
ShowAFrame[curNpFlag](frame, false, false, true) -- 仇恨回来了,恢复正常。但是是仅显目标则变大
elseif (not isInOnlySt) and AllInfos[unitid].matchType == 0 then
ShowAFrame[curNpFlag](frame, false, false, false) -- 仇恨回来了,恢复正常。
elseif (not isInOnlySt) and AllInfos[unitid].matchType == 1 then
print("Error not only Show but match 1 !!")
else
HideAFrame[curNpFlag](frame) -- 仇恨回来了,恢复正常。 但是这些情况应该变小Hide
end
end -- 如果是在UNIT_ADD传过来nil,将不处理,继续让Add函数处理即可
end
end
local function actionUnitHealth(self, event, ...)
local unitid = ...
if UnitIsPlayer(unitid) then
return
end
getUnitIdInfo(unitid, false)
local ts = GetTime()
if (AllInfos[unitid].healModTS + 0.1) >= ts then -- ###刷新血量监听频率
return
end
AllInfos[unitid].healModTS = ts
local hmax = UnitHealthMax(unitid)
local curh = UnitHealth(unitid)
if hmax > 0 then
local perc = (curh * 100) / hmax
local isKill = false
if IsKillLine1 and perc >= Fnp_SavedScaleList.killline1 then
isKill = true
end
if (not isKill) and IsKillLine2 and perc <= Fnp_SavedScaleList.killline2 then
isKill = true
end
actionChangedByHeal(unitid, isKill, event)
else
AllInfos[unitid] = nil
end
end
local function actionUnitAddedForce(unitid)
local addedname = UnitName(unitid)
--AllInfos[unitid].name = addedname -- #ALLMYINFOS#
-- 0. 当前Add的单位名,是否match filter
local curFilterMatch = false
if isNullFilterList == false then curFilterMatch = isMatchedNameList(Fnp_FNameList, addedname) end
if curFilterMatch == true then
--AllInfos[unitid].matchType = 2 -- #ALLMYINFOS#
local frame = GetNamePlateForUnit(unitid)
HideAFrame[curNpFlag](frame)
return
end
-- 1. 当前add的单位名,是否match
local curOnlyMatch = isMatchedNameList(Fnp_ONameList, addedname)
if curOnlyMatch == false and isInOnlySt == true then
--新增单位不需要仅显,但是目前处于仅显情况下, 那么,就将当前这个Hide
--AllInfos[unitid].matchType = 0 -- #ALLMYINFOS#
local frame = GetNamePlateForUnit(unitid)
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
if UnitIsPlayer(foundUnit) == false then HideAFrame[curNpFlag](frame) end
elseif curOnlyMatch == false and isInOnlySt == false then
-- 新增单位不需要仅显, 此时也没有仅显, 就不管了.现在我们将当前的效果展示出来
--AllInfos[unitid].matchType = 0 -- #ALLMYINFOS#
local frame = GetNamePlateForUnit(unitid)
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
if UnitIsPlayer(foundUnit) == false then ShowAFrame[curNpFlag](GetNamePlateForUnit(unitid), false, false, false) end
elseif curOnlyMatch == true and isInOnlySt == true then
-- 新增单位是需要仅显的,而此时已经有仅显的了,于是我们什么也不用干 -- 更新,怀疑在异步调用的时候莫名奇妙被hide了这里开出来确保
--AllInfos[unitid].matchType = 1 -- #ALLMYINFOS#
ShowAFrame[curNpFlag](GetNamePlateForUnit(unitid), false, false, true)
elseif curOnlyMatch == true and isInOnlySt == false then
--新增单位是需要仅显的,而此时不是仅显, 于是我们就将之前的都Hide,当前这个仅显
--AllInfos[unitid].matchType = 1 -- #ALLMYINFOS#
for _, frame in pairs(GetNamePlates()) do
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
if foundUnit then
-- TODO 判断是否是正在读条
if (unitid == foundUnit) then
-- 刚刚进入仅显模式!这个是仅显单位,那么将他变大一些
ShowAFrame[curNpFlag](frame, false, false, true)
else
if UnitIsPlayer(foundUnit) == false then HideAFrame[curNpFlag](frame) end
end
end
end
isInOnlySt = true
end
end
local function actionUnitRemovedForce(unitid)
-- 1. 当前移除的单位名,是否match
-- if AllInfos and AllInfos[unitid] then
-- AllInfos[unitid].inSee = false -- #ALLMYINFOS#
-- end
local curOnlyMatch = isMatchedNameList(Fnp_ONameList, UnitName(unitid))
if curOnlyMatch == true then
-- 移除单位是需要仅显的,而此时肯定已经仅显,
--于是我们判断剩余的是否还含有,如果还有就什么也不动.如果没有了,就恢复显示
local matched = false
local name = ""
for _, frame in pairs(GetNamePlates()) do
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
if foundUnit then
matched = isMatchedNameList(Fnp_ONameList, GetUnitName(foundUnit))
if matched == true then
return --have & return
end
end
end
--没有找到,说明我们该退出了就显示
for _, frame in pairs(GetNamePlates()) do
local foundUnit = (frame.namePlateUnitToken or (frame.UnitFrame and frame.UnitFrame.unit)) or (frame.unitFrame and frame.unitFrame.unit)
if foundUnit then
matched = isMatchedNameList(Fnp_ONameList, GetUnitName(foundUnit))
if matched == false then
-- 退出仅显模式, 说明这些都是普通
if UnitIsPlayer(foundUnit) == false then ShowAFrame[curNpFlag](frame, false, false, false) end
end
end
end
isInOnlySt = false
end
end
---------k k k---k k k---k k k-------------
local function actionUnitAdded(self, event, ...)
if Fnp_Enable == false then return end
if isScaleInited == false then
isScaleInited = FilteredNamePlate:initScaleValues(curNpFlag, isScaleInited)
setCVarValues()
end
if isScaleInited == false then
if isErrInLoad == false then
isErrInLoad = true
print(L.FNP_PRINT_ERROR_UITYPE)
print(L.FNP_PRINT_ERROR_UITYPE)
print(L.FNP_PRINT_ERROR_UITYPE)
end
return
end
--TODO 是否移除
if isNullOnlyList == true and isNullFilterList == true then
return
end
local unitid = ...
if UnitIsPlayer(unitid) then
return
end
actionUnitAddedForce(unitid)
end
local function actionUnitRemoved(self, event, ...)
--这里不需要判断是否为空
-- if isNullOnlyList == true and isNullFilterList == true then
-- return
-- end
--TODO 是否移除
if isInOnlySt == false then
-- 当前处于没有仅显模式,表明所有血条都开着的
return
end
local unitid = ...
if UnitIsPlayer(unitid) then
return
end
actionUnitRemovedForce(unitid)
end
local function actionUnitSpellCastStart(self, event, ...)
if isInOnlySt == false then
-- 当前处于没有仅显模式,表明所有血条都开着的
return
end
local unitid = ...
if UnitIsPlayer(unitid) then
return
end
local curName = UnitName(unitid)
if curName == nil then return end
local curMatch = isMatchedNameList(Fnp_ONameList, curName)
-- true的话,表明是我们要的,那么肯定是在显示了。就不管了
if curMatch == false then
local frame = GetNamePlateForUnit(unitid)
--仅显模式,非仅显怪施法啦!我们放大到miiddle大小
ShowAFrame[curNpFlag](frame, true, false, false)
end
end
local function actionUnitSpellCastStop(self, event, ...)
if isInOnlySt == false then
-- 当前处于没有仅显模式,表明所有血条都开着的
return
end
local unitid = ...
if UnitIsPlayer(unitid) then
return
end
local curName = UnitName(unitid)
if curName == nil then return end
local curMatch = isMatchedNameList(Fnp_ONameList, curName)
-- true的话,表明是我们要的,那么肯定是在显示了。
if curMatch == false then --false,而且是处于isCurrentOnlyShow
local frame = GetNamePlateForUnit(unitid)
HideAFrame[curNpFlag](frame)
end
end
function FilteredNamePlate_OnEvent(self, event, ...)
local handler = FilteredNamePlate.FilterNp_Event_General_List[event] or FilteredNamePlate.FilterNp_Event_Heal_List[event] or FilteredNamePlate.FilterNp_Event_Enter_List[event]
if handler then
handler(self, event, ...)
else
end
function FilteredNamePlate_OnLoad()
--** global vars reset
isErrInLoad = false
IsGeneralRegistered = false
IsKillLineRegistered = false
isScaleInited = false
isInOnlySt = false
FilteredNamePlate.isSettingChanged = false
-- MYNAME = UnitName("player")
---** first install, init values
if Fnp_Enable == nil then
Fnp_Enable = false
end
if FnpEnableKeys == nil or Fnp_CurVersion == nil then
FnpEnableKeys = {
killlineMod = false,
}
end
if Fnp_OtherNPFlag == nil then
Fnp_OtherNPFlag = 0
end
if Fnp_ONameList == nil then
Fnp_ONameList = {}
local thisname = "邪能炸药"
local localename = GetLocale()
if localename == "enUS" then
thisname = "Fel Explosive"
elseif localename == "zhTW" then
thisname = "魔化炸彈"
elseif localname == "ruRU" then
thisname = "Желч"
end
table.insert(Fnp_ONameList, thisname)
end
if Fnp_FNameList == nil then
Fnp_FNameList = {}
end
if Fnp_CurVersion == nil or Fnp_SavedScaleList == nil then
Fnp_SavedScaleList = {
normal = 1,
small = 0.25,
only = 1.4,
killline1 = 1.0,
killline2 = 0,
}
FilteredNamePlate:ChangedSavedScaleList(Fnp_OtherNPFlag)
end
-- TODO 以后增加新的参数根据版本号来处理
if Fnp_CurVersion ~= nil and (tonumber(Fnp_CurVersion) < tonumber(FNP_LOCALE_TEXT.FNP_VERSION)) then
print("Updated filteredNamePlate!")
Fnp_SavedScaleList.tankMod = 2.0
end
----
Fnp_CurVersion = FNP_LOCALE_TEXT.FNP_VERSION
FilteredNamePlate_Frame:RegisterEvent("PLAYER_ENTERING_WORLD")
end