-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNxInfo.lua
1717 lines (1307 loc) · 40.1 KB
/
NxInfo.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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---------------------------------------------------------------------------------------
-- NxInfo - Information window
-- Copyright 2008-2012 Carbon Based Creations, LLC
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
-- Carbonite - Addon for World of Warcraft(tm)
-- Copyright 2007-2012 Carbon Based Creations, LLC
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
CarboniteInfo = LibStub("AceAddon-3.0"):NewAddon("Carbonite.Info", "AceEvent-3.0", "AceComm-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Carbonite.Info", true)
Nx.VERSIONINFO = .24 -- Info win data
Nx.Info = {}
Nx.InfoStats = {}
Nx.Info.Combat = {}
local defaults = {
profile = {
Info = {
ListCol = "0|0|0|0.4",
Lock = false,
InfoFont = "Arial",
InfoFontSize = 11,
InfoFontSpacing = 0,
},
},
}
local options
local function createOptions()
if not options then
options = {
type = "group",
name = L["Info Options"],
args = {
InfoLock = {
order = 1,
type = "toggle",
width = "full",
name = L["Lock Info Windows"],
desc = L["Locks the location of your info windows"],
get = function()
return Nx.idb.profile.Info.Lock
end,
set = function()
Nx.idb.profile.Info.Lock = not Nx.idb.profile.Info.Lock
Nx.Info:OptionsUpdate()
end,
},
InfoBGCol = {
order = 2,
type = "color",
width = "full",
name = L["Info Window Background Color"],
hasAlpha = true,
get = function()
local arr = { strsplit("|",Nx.idb.profile.Info.ListCol) }
local r = arr[1]
local g = arr[2]
local b = arr[3]
local a = arr[4]
return r,g,b,tonumber(a)
end,
set = function(_,r,g,b,a)
Nx.idb.profile.Info.ListCol = r .. "|" .. g .. "|" .. b .. "|" .. a
Nx.Info:OptionsUpdate()
end,
},
InfoFont = {
order = 3,
type = "select",
name = L["Info Font"],
desc = L["Sets the font to be used for info windows"],
get = function()
local vals = Nx.Opts:CalcChoices("FontFace","Get")
for a,b in pairs(vals) do
if (b == Nx.idb.profile.Info.InfoFont) then
return a
end
end
return ""
end,
set = function(info, name)
local vals = Nx.Opts:CalcChoices("FontFace","Get")
Nx.idb.profile.Info.InfoFont = vals[name]
Nx.Opts:NXCmdFontChange()
end,
values = function()
return Nx.Opts:CalcChoices("FontFace","Get")
end,
},
InfoFontSize = {
order = 4,
type = "range",
name = L["Info Font Size"],
desc = L["Sets the size of the info font"],
min = 6,
max = 14,
step = 1,
bigStep = 1,
get = function()
return Nx.idb.profile.Info.InfoFontSize
end,
set = function(info,value)
Nx.idb.profile.Info.InfoFontSize = value
Nx.Opts:NXCmdFontChange()
end,
},
InfoFontSpacing = {
order = 5,
type = "range",
name = L["Info Font Spacing"],
desc = L["Sets the spacing of the info font"],
min = -10,
max = 20,
step = 1,
bigStep = 1,
get = function()
return Nx.idb.profile.Info.InfoFontSpacing
end,
set = function(info,value)
Nx.idb.profile.Info.InfoFontSpacing = value
Nx.Opts:NXCmdFontChange()
end,
},
},
}
end
Nx.Opts:AddToProfileMenu(L["Info"],2,Nx.idb)
return options
end
function CarboniteInfo:OnInitialize()
if not Nx.Initialized then
CarbInfoInit = Nx:ScheduleTimer(CarboniteInfo.OnInitialize,1)
return
end
Nx.idb = LibStub("AceDB-3.0"):New("NXInfo",defaults, true)
Nx.Font:ModuleAdd("Info.InfoFont",{ "NxFontI", "GameFontNormal","idb" })
Nx.Info:Init()
Nx.Info.Combat:Init()
Nx.Info.Combat:Open()
CarboniteInfo:PLAYER_LOGIN()
local function func ()
Nx.Info:ToggleShow()
end
Nx.NXMiniMapBut.Menu:AddItem(0, L["Show Info Windows"], func, Nx.NXMiniMapBut)
local function func ()
Nx.Info.Combat:Open()
end
Nx.NXMiniMapBut.Menu:AddItem(0, L["Show Combat Graph"], func, Nx.NXMiniMapBut)
CarboniteInfo:RegisterEvent("PLAYER_LOGIN")
CarboniteInfo:RegisterComm("carbmodule",Nx.Info.OnChat_msg_addon)
tinsert(Nx.BrokerMenuTemplate,{ text = L["Toggle Info Windows"], func = function() Nx.Info:ToggleShow()end })
tinsert(Nx.BrokerMenuTemplate,{ text = L["Toggle Combat Graph"], func = function() Nx.Info.Combat:Open() end })
end
function CarboniteInfo:PLAYER_LOGIN()
local ch = Nx.CurCharacter
local _, honor = GetCurrencyInfo (392)
local _, conquest = GetCurrencyInfo (390)
local xprest = GetXPExhaustion() or 0
local xpmax = UnitXPMax ("player")
Nx.InfoStats["ArenaPts"] = conquest
Nx.InfoStats["Honor"] = honor
Nx.InfoStats["XPRest%"] = xprest / xpmax * 100
end
function Nx.Info:Init()
local info = Nx.idb.profile.InfoData
if not info or info.Version < Nx.VERSIONINFO then
if info then
Nx.prt (L["Reset old info data %f"], info.Version)
end
info = {}
Nx.idb.profile.InfoData = info
info.Version = Nx.VERSIONINFO
end
local cls = Nx:GetUnitClass()
if cls == "Death Knight" or cls == "Warrior" then
self.ManaInvert = true
end
if cls == "Death Knight" then
self.DeathKnight = true
end
self.DKRunes = {
{ 1, "|cffff8080" }, -- Blood
{ 2, "|cffff8080", true },
{ 5, "|cff8080ff" }, -- Frost
{ 6, "|cff8080ff", true },
{ 3, "|cff80ff80" }, -- Unholy
{ 4, "|cff80ff80" },
}
self.Vars = {} -- Variables
self.Infos = {} -- Remember all created info windows
self.ItemFuncs = {
["BarH%"] = self.CalcBarHPercent,
["Cast"] = self.CalcCast,
["Combo"] = self.CalcComboPoints,
["Cooldown"] = self.CalcCooldown,
["Dur"] = self.CalcDur,
["FPS"] = self.CalcFPS,
["Health"] = self.CalcHealth,
["Health%"] = self.CalcHealthPercent,
["HealthChange"] = self.CalcHealthChange,
["IfBG"] = self.CalcIfBG,
["IfCombat"] = self.CalcIfCombat,
["IfF"] = self.CalcIfFalse,
["IfLT"] = self.CalcIfLT,
["IfLTOrCombat"] = self.CalcIfLTOrCombat,
["IfMana"] = self.CalcIfMana,
["IfT"] = self.CalcIfTrue,
["LvlTime"] = self.CalcLvlTime,
["Mana"] = self.CalcMana,
["Mana%"] = self.CalcManaPercent,
["ManaChange"] = self.CalcManaChange,
["BGQueue"] = self.CalcBGQueue,
["BGStart"] = self.CalcBGStart,
["BGDuration"] = self.CalcBGDuration,
["BGHonor"] = self.CalcBGHonor,
["BGStats"] = self.CalcBGStats,
["BGWingWait"] = self.CalcBGWingWait,
["Stat"] = self.CalcStat,
["THealth"] = self.CalcTargetHealth,
["THealth%"] = self.CalcTargetHealthPercent,
-- ["THealthChange"] = self.CalcTargetHealthChange,
["Threat%"] = self.CalcThreatPercent,
["TMana"] = self.CalcTargetMana,
["TMana%"] = self.CalcTargetManaPercent,
-- ["TManaChange"] = self.CalcTargetManaChange,
["Time"] = self.CalcTime,
}
local dinfo = Nx.idb.profile.InfoData
self:OnTimer()
-- self:Create (1)
for n = 1, 10 do
local info = dinfo[n]
if info then
self:Create (n)
end
end
self:CreateMenu()
Nx:AddToConfig("Info Module",createOptions(),L["Info Module"])
self:OptionsUpdate()
end
function Nx.Info.Combat:Init()
self.Frm = nil
self.HitPeak = 1
self.HitTotal = 0
self.HitBest = 0
self.W = 400
self.H = 80
self.InCombat = false
self.AttackerName = "?"
end
function Nx.Info:OnChat_msg_addon(msg, dist, target)
local ssplit = { strsplit("|",msg) }
if ssplit[1] == "CMD" then
if ssplit[2] == "c" then
Nx.Info.Combat:Open()
end
end
end
---------------------------------------------------------------------------------------
-- Update all info windows
---------------------------------------------------------------------------------------
function Nx.Info:OnTimer()
local vars = self.Vars
self.NeedDurability = false
local h = UnitHealth ("player")
local m = UnitPower ("player")
if UnitIsDeadOrGhost ("player") then
h = 0
m = 0
end
vars["Health"] = h
vars["Mana"] = m
vars["HealthMax"] = UnitHealthMax ("player")
vars["ManaMax"] = UnitPowerMax ("player")
vars["Health%"] = h / vars["HealthMax"]
vars["Mana%"] = m / vars["ManaMax"]
local h = 0
local m = -1
local tarName = UnitName ("target")
vars["TName"] = tarName
if tarName then
m = UnitPowerMax ("target") > 0 and 0 or -1
if not UnitIsDeadOrGhost ("target") then
h = UnitHealth ("target")
m = UnitPowerMax ("target") > 0 and UnitPower ("target") or -1
end
vars["THealthMax"] = max (UnitHealthMax ("target"), 1)
vars["TManaMax"] = max (UnitPowerMax ("target"), 1)
end
vars["THealth"] = h
vars["TMana"] = m
vars["InBG"] = Nx.InBG
for i, info in pairs (self.Infos) do
if info.Data then -- Not deleted?
info:Update (n)
end
end
return .1
end
---------------------------------------------------------------------------------------
function Nx.Info:OptionsUpdate()
local lock = Nx.idb.profile.Info.Lock
for i, info in pairs (self.Infos) do
local win = info.Win
if win then
win:SetBGAlpha (0, 1)
if lock then
win:Lock (true, true)
else
win:Lock (false, true)
end
info.List:Lock (lock)
local arr = { strsplit("|",Nx.idb.profile.Info.ListCol) }
local cr = tonumber(arr[1])
local cg = tonumber(arr[2])
local cb = tonumber(arr[3])
local ca = tonumber(arr[4])
info.List:SetBGColor (cr, cg, cb, ca, true)
end
end
end
---------------------------------------------------------------------------------------
function Nx.Info:New()
local dinfo = Nx.idb.profile.InfoData
for n = 1, 10 do
if not dinfo[n] then
self:Create (n)
self.Infos[n].Win:ResetLayout()
break
end
end
self:OptionsUpdate()
end
---------------------------------------------------------------------------------------
-- Delete the info window
---------------------------------------------------------------------------------------
function Nx.Info:Delete (index)
Nx.idb.profile.InfoData[index] = nil
local info = self.Infos[index]
if info then
info.Win:Show (false)
end
info.Data = nil
Nx.Window:ClrSaveData ("NxInfo" .. index)
end
---------------------------------------------------------------------------------------
-- Create shared menu
---------------------------------------------------------------------------------------
function Nx.Info:CreateMenu()
local menu = Nx.Menu:Create (UIParent, 160)
self.Menu = menu
self.MenuITitle = menu:AddItem (0, "?", nil, self)
local item = menu:AddItem (0, L["Close"], self.Menu_OnClose, self)
self.MenuIEdit = menu:AddItem (0, "?", self.Menu_OnEdit, self)
menu:AddItem (0, L["Edit Item"], self.Menu_OnEditItem, self)
menu:AddItem (0, "", nil, self)
-- Create show sub menu
local showMenu = Nx.Menu:Create (UIParent)
menu:AddSubMenu (showMenu, L["Show"] .. "...")
self.MenuIShow = {}
for n = 1, 10 do
local function func (self, item)
-- Nx.prt ("%s", n)
Nx.Info.Infos[n].Win:Show()
end
self.MenuIShow[n] = showMenu:AddItem (0, "#" .. n, func, self)
end
--
menu:AddItem (0, "", nil, self)
local item = menu:AddItem (0, L["New Info Window"], self.Menu_OnNew, self)
local item = menu:AddItem (0, L["Delete This Window"], self.Menu_OnDelete, self)
--
menu:AddItem (0, "", nil, self)
local function func()
Nx.Opts:Open ("Info Windows")
end
menu:AddItem (0, L["Options"] .. "...", func)
end
---------------------------------------------------------------------------------------
-- Create menu
---------------------------------------------------------------------------------------
function Nx.Info:OpenMenu (info)
self.CurMenuInfo = info
self.MenuITitle:SetText (format ("-- " .. L["Info"] .. " %d --", info.Index))
self.MenuIEdit:SetText (info.Editing and L["Stop Edit"] or L["Edit View"])
for n = 1, 10 do
local info = self.Infos[n]
local b = info and info.Data and not self.Infos[n].Win:IsShown()
self.MenuIShow[n]:Show (b == true)
end
self.Menu:Open()
end
---------------------------------------------------------------------------------------
function Nx.Info:Menu_OnClose()
self.CurMenuInfo.Win:Show (false)
end
function Nx.Info:Menu_OnEdit()
local info = self.CurMenuInfo
local editing = not info.Editing
info.Editing = editing
-- info.Win:SetTitleLineH (editing and 18 or 0)
end
function Nx.Info:Menu_OnEditItem()
local info = self.CurMenuInfo
local function func (str, self)
str = gsub (str, "||", "|")
self.Data["Items"][self.SelItemIndex] = str
end
if info.SelItemIndex then
local s = info.Data["Items"][info.SelItemIndex] or ""
s = gsub (s, "|", "||")
Nx:ShowEditBox (L["Change Text"], s, info, func)
end
end
function Nx.Info:Menu_OnNew (item)
self:New()
end
function Nx.Info:Menu_OnDelete (item)
local function func()
Nx.Info:Delete (Nx.Info.CurMenuInfo.Index)
end
Nx:ShowMessage (L["Delete Info Window"] .. " #" .. self.CurMenuInfo.Index .. "?", L["Delete"], func, L["Cancel"])
end
---------------------------------------------------------------------------------------
-- Create info window
---------------------------------------------------------------------------------------
function Nx.Info:Create (index)
-- Nx.prt ("Info: create %s", index)
local info = self.Infos[index] or {}
self.Infos[index] = info
setmetatable (info, self)
self.__index = self
info:Create2 (index)
end
---------------------------------------------------------------------------------------
-- Create info window
-- self = instance
---------------------------------------------------------------------------------------
function Nx.Info:Create2 (index)
--PAIDS!
self.Index = index
self.Data = Nx.idb.profile.InfoData[index] or {}
Nx.idb.profile.InfoData[index] = self.Data
--
local items = self.Data["Items"]
-- items = nil -- DEBUG
if not items then
items = {}
self.Data["Items"] = items
if index == 1 then
tinsert (items, "<IfLTOrCombat;1;Health%><Health><c>HP <t> <HealthChange><c><t> <IfCombat>|cffff4040* <Threat%;player><c><t>")
tinsert (items, "<IfLTOrCombat;1;Health%> <Health%><c><t>%<BarH%;G;Health%><t>")
tinsert (items, "<IfMana><Mana><c>MP <t> <ManaChange><c><t>")
tinsert (items, "<IfMana> <Mana%><c><t>%<BarH%;B;Mana%><t>")
tinsert (items, "<Combo><c><t>")
tinsert (items, "<Cooldown><c><t>")
tinsert (items, "<Cast><c><t>")
elseif index == 2 then
tinsert (items, "<THealth><c>HP <t>")
tinsert (items, " <THealth%><c><t>%<BarH%;G;THealth%><t>")
tinsert (items, "<TMana><c>MP <t>")
tinsert (items, " <TMana%><c><t>%<BarH%;B;TMana%><t>")
tinsert (items, "<Cast;target><c><t>")
elseif index == 3 then
tinsert (items, "<Dur><c>Durability <t>%")
tinsert (items, "<LvlTime><c>Lvl <t> hours")
tinsert (items, "")
elseif index == 4 then
tinsert (items, "<BGQueue;1><c><t>")
tinsert (items, "<BGQueue;2><c><t>")
tinsert (items, "<BGQueue;3><c><t>")
tinsert (items, "<BGStart><c>BG start <t>")
tinsert (items, "<BGDuration><c>BG duration <t>")
tinsert (items, "<IfF;InBG><BGWingWait><c>Wing <t>")
tinsert (items, "<IfBG><BGHonor><c>Honor <t>")
tinsert (items, "<BGStats><c>Stats <t>")
elseif index == 5 then
tinsert (items, "<Time;%a %m/%d %I:%M %p><c><t>")
tinsert (items, "<FPS><t>")
tinsert (items, "")
elseif index == 6 then
tinsert (items, "<Stat;XPRest%><c>Rest <t>%")
tinsert (items, "")
tinsert (items, "")
end
end
self.HealthLast = UnitHealth ("player")
self.HealthLastVal = 0
self.ManaLast = UnitPower ("player")
self.ManaLastVal = 0
-- Show if it exists
-- Nx.Window:ClrSaveData ("NxInfo" .. index)
if self.Win then
self.Win:Show()
return
end
-- Create Window
local layouts = {
[0] = { -.72, -.2, 100, 41 },
{ 200000, -.20, 110, 80, 1.1 },
{ 300040, -.20, 120, 80, 1.1 },
}
Nx.Window:SetCreateFade (1, 0)
local win = Nx.Window:Create ("NxInfo" .. index, 50, 20, nil, 1, nil, nil, true)
self.Win = win
win.Frm.NxInst = self
-- win:CreateButtons (true)
win:SetTitleLineH (3)
local layout = layouts[index] or layouts[0]
-- Nx.prt ("#%s %s %s %s %s", index, layout[1], layout[2], layout[3], layout[4])
local i = index <= 2 and 0 or index - 3
local scale = layout[5] or 1
local x = layout[3] + scale * layout[4] - layout[4]
win:InitLayoutData (nil, layout[1], layout[2] - i * .06, x, layout[4], nil, layout[5])
win.Frm:SetToplevel (true)
-- Buttons
local bw, bh = win:GetBorderSize()
-- local but = Nx.Button:Create (win.Frm, "Txt64", "Up", nil, bw, -bh, "TOPLEFT", 44, 20, self.But_OnUp, self)
-- local but = Nx.Button:Create (but.Frm, "Txt64", "Down", nil, 46, 0, "TOPLEFT", 44, 20, self.But_OnDown, self)
-- List
Nx.List:SetCreateFont ("Info.InfoFont", 11)
local list = Nx.List:Create (false, 0, 0, 1, 1, win.Frm, false, true)
self.List = list
list:SetUser (self, self.OnListEvent)
list:SetLineHeight (0, 0)
list:ColumnAdd ("", 1, 900)
-- list:SetBGColor (0, 0, 0, .1)
win:Attach (list.Frm, 0, 1, 0, 1)
--
self.Frms = {} -- For health bars
self.Frms.Next = 1
--
self:Update()
self.List:FullUpdate()
--PAIDE!
end
---------------------------------------------------------------------------------------
-- Show or hide
---------------------------------------------------------------------------------------
--function Nx:NXInfoKeyToggleShow()
-- Nx.Info:ToggleShow()
--end
---------------------------------------------------------------------------------------
-- Show or hide window
---------------------------------------------------------------------------------------
function Nx.Info:ToggleShow()
for n = 1, 2 do
local info = self.Infos[n]
if not info or not info.Data then -- Deleted?
self:Create (n)
else
info.Win:Show (not info.Win:IsShown())
end
end
end
---------------------------------------------------------------------------------------
-- On list events
---------------------------------------------------------------------------------------
function Nx.Info:OnListEvent (eventName, sel, val2, click)
-- Nx.prt ("Guide list event "..eventName)
if eventName == "update" then
local listF = self.List.Frm
local lvl = listF:GetFrameLevel() - 1
local data = sel
local y = val2
local t = { strsplit ("&", data) }
for _, str in ipairs (t) do
-- Nx.prt ("info %s", str)
local v1, v2, v3 = strsplit ("^", str)
local f = Nx.List:GetFrame (self.List, "Info")
f:ClearAllPoints()
f:SetPoint ("TOPLEFT", listF, "TOPLEFT", 0, y)
f:SetFrameLevel (lvl)
f.texture:SetTexture (v1)
f:SetWidth (tonumber (v2) or 0)
f:SetHeight (tonumber (v3) or 0)
f:SetAlpha (.8)
f:Show()
end
return
end
local data = self.List:ItemGetData (sel)
if eventName == "select" or eventName == "mid" or eventName == "menu" then
if eventName == "menu" then
self.SelItemIndex = data
Nx.Info:OpenMenu (self)
end
self:Update()
end
end
function Nx.Info:Update()
local Nx = Nx
if not self.Win or not self.Win:IsVisible() then
return
end
-- List
local list = self.List
list:Empty()
self:UpdateItems()
list:Update()
end
--PAIDS!
function Nx.Info:UpdateItems()
local funcs = self.ItemFuncs
local list = self.List
local ch = Nx.CurCharacter
local items = self.Data["Items"]
for index, val in ipairs (items) do
local data = strsplit ("^", val)
local str = ""
local pos = 1
local color, text
while true do
-- local s1, s2, cap, extra = strfind (data, "<(%a+%%?)([^>]*)>", pos)
local s1, s2, cap = strfind (data, "<([^>]+)>", pos)
if s1 then
if s1 > pos then
str = str .. strsub (data, pos, s1 - 1)
end
-- Nx.prtCtrl ("item cap %s", cap)
if #cap == 1 then
if cap == "c" and color then
str = str .. color
elseif cap == "t" and text then
str = str .. text
end
else
local cmd, v1, v2, v3, v4 = strsplit (";", cap) -- FIX for multiple params!
local func = self.ItemFuncs[cmd]
if func then
color, text = func (self, v1, v2, v3, v4)
if not text then
break
end
end
end
pos = s2 + 1
else
str = str .. strsub (data, pos) -- Grab end
break
end
end
if self.Editing then
str = format ("#%d %s = ", index, gsub (data, "|", "||")) .. str
end
if #str > 0 then
-- Nx.prtStrHex ("Info:", str)
list:ItemAdd (index)
local str, extra = strsplit ("~", str)
if extra then
list:ItemSetFrame ("Info~" .. extra)
end
list:ItemSet (1, str)
end
end
end
--PAIDE!
---------------------------------------------------------------------------------------
function Nx.Info:CalcBarHPercent (color, perName, w, h)
w = tonumber (w) or 50
h = tonumber (h) or 10
local barW = (self.Vars[perName] or 0) * w -- perNamemax (0, min ((self.Val1 or 0) / (self.Val2 or 1), 1))
local xo = w
if barW >= 1 then
return "|cffc0c0c0", format ("~Interface\\Addons\\Carbonite\\Gfx\\Skin\\InfoBarBG^%d^%d^0&Interface\\Addons\\Carbonite\\Gfx\\Skin\\InfoBar%s^%d^%d^%d", w, h, color, barW, h, xo)
-- return "|cffc0c0c0", format ("|TInterface\\Addons\\Carbonite\\Gfx\\Skin\\InfoBarBG:%d:%d|t^Interface\\Addons\\Carbonite\\Gfx\\Skin\\InfoBar%s~%d~%d~%d", h, w, color, barW, h, xo)
-- return "|cffc0c0c0", format ("|TInterface\\Addons\\Carbonite\\Gfx\\Skin\\InfoBarBG:%d:%d|t|TInterface\\Addons\\Carbonite\\Gfx\\Skin\\InfoBar%s:%d:%d:-%d|t", h, w, color, h, barW, xo)
end
return "|cffc0c0c0", format ("~Interface\\Addons\\Carbonite\\Gfx\\Skin\\InfoBarBG^%d^%d^0", w, h)
-- return "|cffc0c0c0", format ("|TInterface\\Addons\\Carbonite\\Gfx\\Skin\\InfoBarBG:%d:%d|t", h, w)
end
function Nx.Info:CalcCast (target, w, h)
target = target or "player"
w = tonumber (w) or 50
h = tonumber (h) or 10
local spell, rank, name, icon, startTime, endTime = UnitCastingInfo (target)
if not name then
spell, rank, name, icon, startTime, endTime = UnitChannelInfo (target)
end
if name then
local remain = endTime / 1000 - GetTime()
local per = remain * 1000 / (endTime - startTime)
return "|cffc0c0f0", format ("|T%s:16|t %.1f |TInterface\\BUTTONS\\gradblue:%d:%d|t", icon, remain, h, max (per * w, 1))
end
end
function Nx.Info:CalcFPS()
return "|cffc0c0c0", format ("%.0f", GetFramerate())
end
function Nx.Info:CalcHealth()
return "|cffc0c0c0", format ("%d", self.Vars["Health"])
end
function Nx.Info:CalcHealthPercent()
return "|cffe0e0e0", format ("%d", self.Vars["Health%"] * 100)
end
function Nx.Info:CalcHealthChange()
local i = self.Vars["Health"] - self.HealthLast
self.HealthLast = self.Vars["Health"]
if i == 0 then
i = self.HealthLastVal
if i > 0 then
return "|cff205f20", format ("+%d", i)
end
return "|cff5f2020", format ("%d", i)
else
self.HealthLastVal = i
if i > 0 then
return "|cff20ff20", format ("+%d", i)
end
return "|cffff2020", format ("%d", i)
end
end
function Nx.Info:CalcMana()
return "|cffc0c0c0", format ("%d", self.Vars["Mana"])
end
function Nx.Info:CalcManaPercent()
return "|cffe0e0e0", format ("%d", self.Vars["Mana%"] * 100)
end
function Nx.Info:CalcManaChange()
local i = self.Vars["Mana"] - self.ManaLast
self.ManaLast = self.Vars["Mana"]
if i == 0 then
i = self.ManaLastVal
if i > 0 then
return "|cff205f20", format ("+%d", i)
end
return "|cff5f2020", format ("%d", i)
else
self.ManaLastVal = i
if i > 0 then
return "|cff20ff20", format ("+%d", i)
end
return "|cffff2020", format ("%d", i)
end
end
function Nx.Info:CalcCooldown()
if UnitCastingInfo ("player") or UnitChannelInfo ("player") then
return
end
local GetActionCooldown = GetActionCooldown
for n = 1, 120 do
local start, dur = GetActionCooldown (n)
if dur > 0 and dur <= 1.5 then
local low = dur - (GetTime() - start)
return "|cffc0c020", string.rep (".", low * 10)
end
end
end
function Nx.Info:CalcComboPoints()
if self.DeathKnight then
if self.Vars["TName"] then
local s = ""
for _, data in ipairs (self.DKRunes) do
local n = data[1]
s = s .. (GetRuneType (n) ~= 4 and data[2] or "|cff606060")
local start, duration, ready = GetRuneCooldown (n)
s = s .. (ready and "+" or "-")
if data[3] then
s = s .. " "
end
end