forked from mikepauer/Carbonite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNxMapGuide.lua
3278 lines (3230 loc) · 79.8 KB
/
NxMapGuide.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
---------------------------------------------------------------------------------------
-- NxMapGuide - Map guide code
-- Copyright 2007-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/>.
---------------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Tables
local L = LibStub("AceLocale-3.0"):GetLocale("Carbonite")
Nx.GuideAbr = {
["K"] = L["Kalimdor"],
["E"] = L["Eastern Kingdoms"],
["O"] = L["Outland"],
["N"] = L["Northrend"],
["M"] = L["The Maelstrom"],
["P"] = L["Pandaria"],
["D"] = L["Draenor"],
["B"] = L["Broken Isles"],
["A"] = L["Argus"],
["ZA"] = L["Zandalar"],
["KU"] = L["Kul Tiras"],
}
Nx.GuideInfo = {
Name = L["All"],
Tx = "INV_Misc_Map02",
{
Name = L["Quest Givers"],
T = "&",
Tx = "INV_Misc_Note_02",
Persist = "ShowQuestGivers",
},
{
T = L["Stable Master"],
Tx = "Ability_Hunter_BeastTaming",
},
{
T = L["Flight Master"],
Tx = "Ability_Mount_Wyvern_01",
},
{
T = L["Lightforged Beacon"],
Tx = "INV_Alchemy_AstralAlchemistStone",
},
{
Name = L["Common Place"],
Tx = "INV_Misc_Map02",
{
T = L["Auctioneer"],
Tx = "Racial_Dwarf_FindTreasure",
},
{
T = L["Banker"],
Tx = "INV_Misc_Coin_02",
},
{
T = L["Innkeeper"],
Tx = "Spell_Shadow_Twilight",
},
{
T = L["Void Storage"],
Tx = "spell_nature_astralrecalgroup",
},
{
T = L["Transmogrifier"],
Tx = "INV_Arcane_Orb",
},
{
T = L["Battle Pet Trainer"],
Tx = "INV_Pet_BattlePetTraining",
},
{
T = L["Barber"],
Tx = "INV_Misc_Comb_02",
},
{
T = L["Mailbox"],
Tx = "INV_Letter_15",
},
{
T = L["Anvil"],
Tx = "Trade_BlackSmithing",
},
{
T = L["Forge"],
Tx = "INV_Sword_09",
},
},
{
Name = L["Class Trainer"],
T = "^C",
Tx = "INV_Misc_Book_10",
{
T = L["Death Knight Trainer"],
Tx = "Spell_Deathknight_ClassIcon",
},
{
T = L["Druid Trainer"],
Tx = "Ability_Druid_Maul",
},
{
T = L["Hunter Trainer"],
Tx = "INV_Weapon_Bow_07",
},
{
T = L["Mage Trainer"],
Tx = "INV_Staff_13",
},
{
T = L["Paladin Trainer"],
Tx = "INV_Hammer_01",
},
{
T = L["Priest Trainer"],
Tx = "INV_Staff_30",
},
{
T = L["Rogue Trainer"],
Tx = "INV_ThrowingKnife_04",
},
{
T = L["Shaman Trainer"],
Tx = "Spell_Nature_BloodLust",
},
{
T = L["Warlock Trainer"],
Tx = "Spell_Nature_FaerieFire",
},
{
T = L["Warrior Trainer"],
Tx = "INV_Sword_27",
},
{
T = L["Monk Trainer"],
Tx = "Class_Monk",
},
{
T = L["Demon Hunter Trainer"],
Tx = "ClassIcon_DemonHunter",
},
},
{
Name = L["Trainer"],
T = "^C",
Tx = "INV_Misc_Book_01",
{
Pre = L["Alchemy"],
Name = L["Trainer"],
T = "^P",
Tx = "Trade_Alchemy",
},
{
Pre = L["Archaeology"],
Name = L["Trainer"],
T = "^P",
Tx = "trade_archaeology",
},
{
Pre = L["Blacksmithing"],
Name = L["Trainer"],
T = "^P",
Tx = "Trade_BlackSmithing",
},
{
Pre = L["Enchanting"],
Name = L["Trainer"],
T = "^P",
Tx = "Trade_Engraving",
},
{
Pre = L["Engineering"],
Name = L["Trainer"],
T = "^P",
Tx = "Trade_Engineering",
},
{
Pre = L["Herbalism"],
Name = L["Trainer"],
T = "^P",
Tx = "Trade_Herbalism",
},
{
Pre = L["Inscription"],
Name = L["Trainer"],
T = "^P",
Tx = "INV_Inscription_Tradeskill01",
},
{
Pre = L["Jewelcrafting"],
Name = L["Trainer"],
T = "^P",
Tx = "INV_Misc_Gem_02",
},
{
Pre = L["Leatherworking"],
Name = L["Trainer"],
T = "^P",
Tx = "INV_Misc_ArmorKit_17",
},
{
Pre = L["Mining"],
Name = L["Trainer"],
T = "^P",
Tx = "Trade_Mining",
},
{
Pre = L["Skinning"],
Name = L["Trainer"],
T = "^P",
Tx = "INV_Misc_Pelt_Wolf_01",
},
{
Pre = L["Tailoring"],
Name = L["Trainer"],
T = "^P",
Tx = "Trade_Tailoring",
},
{
Pre = L["Cooking"],
Name = L["Trainer"],
T = "^S",
Tx = "INV_Misc_Food_15",
},
{
Pre = L["First Aid"],
Name = L["Trainer"],
T = "^S",
Tx = "Spell_Holy_SealOfSacrifice",
},
{
Pre = L["Fishing"],
Name = L["Trainer"],
T = "^S",
Tx = "Trade_Fishing",
},
{
Pre = L["Flying"],
Name = L["Trainer"],
T = "^S",
Tx = "inv_scroll_11",
},
{
Pre = L["Riding"],
Name = L["Trainer"],
T = "^S",
Tx = "spell_nature_swiftness",
},
},
{
Name = L["Travel"],
Tx = "Ability_Townwatch",
},
-- {
-- Name = "Items",
-- Tx = "Achievement_Arena_3v3_4",
-- },
{
Name = L["Visited Vendor"],
Tx = "INV_Misc_Coin_05",
{
Name = L["All Items"],
NoShowChild = true,
},
},
{
Name = L["Gather"],
Tx = "INV_Misc_Bag_10",
{
Name = L["Herb"],
Tx = "INV_Misc_Flower_02",
Persist = "ShowGatherH",
},
{
Name = L["Ore"],
Tx = "INV_Ore_Copper_01",
Persist = "ShowGatherM",
},
{
Name = L["Timber"],
Tx = "INV_Tradeskillitem_03",
Persist = "ShowGatherL",
},
{
Name = L["Artifacts"],
T = "$ A",
Id = "Art",
Tx = "Trade_Archaeology",
Persist = "ShowGatherA",
},
{
Name = L["Everfrost"],
T = "$ E",
Id = "Everfrost",
Tx = "spell_shadow_teleport",
},
{
Name = L["Gas"],
T = "$ G",
Id = "Gas",
Tx = "inv_gizmo_zapthrottlegascollector",
},
},
{
Name = L["Instances"],
Tx = "INV_Misc_ShadowEgg",
{
Name = "@K",
Inst = 1
},
{
Name = "@E",
Inst = 2
},
{
Name = "@O",
Inst = 3
},
{
Name = "@N",
Inst = 4
},
{
Name = "@M",
Inst = 5
},
{
Name = "@P",
Inst = 6
},
{
Name = "@D",
Inst = 7
},
{
Name = "@B",
Inst = 8
},
{
Name = "@A",
Inst = 9
},
{
Name = "@ZA",
Inst = 10
},
{
Name = "@KU",
Inst = 11
},
},
{
Name = L["Zone"],
Tx = "INV_Misc_Map_01",
{
Name = "All",
Map = 0
},
{
Name = "@K",
Map = 1
},
{
Name = "@E",
Map = 2
},
{
Name = "@O",
Map = 3
},
{
Name = "@N",
Map = 4
},
{
Name = "@M",
Map = 5
},
{
Name = "@P",
Map = 6
},
{
Name = "@D",
Map = 7
},
{
Name = "@B",
Map = 8
},
{
Name = "@A",
Map = 9
},
},
{
Name = L["Trade Skill"],
Tx = "INV_Misc_Note_04",
{
T = L["Alchemy Lab"],
Tx = "INV_Potion_06",
},
{
T = L["Altar Of Shadows"],
Tx = "INV_Fabric_Felcloth_Ebon",
},
{
T = L["Mana Loom"],
Tx = "INV_Fabric_Netherweave_Bolt_Imbued",
},
{
T = L["Grace Loom"],
Tx = "inv_tailoring_70_silkweaveimbued",
},
{
T = L["Moonwell"],
Tx = "INV_Fabric_MoonRag_Primal",
},
},
}
Nx.Map.Guide.FindType = nil
function Nx.Map.Guide:Create (map)
self:PatchData()
local g = {}
setmetatable (g, self)
self.__index = self
g.Map = map
g.GuideIndex = map.MapIndex
local opts = Nx.db.profile.MapSettings.Maps[g.GuideIndex]
g.TitleH = 0
g.ToolBarW = 0
g.PadX = 0
g:PatchFolder (Nx.GuideInfo, nil)
g.PathHistory = {}
g.PathHistory[1] = Nx.GuideInfo
g.PathHistorySel = {}
g.ShowFolders = {}
g.ShowQuestGiverCompleted = true
local win = Nx.Window:Create ("NxGuide" .. g.GuideIndex, nil, nil, nil, 1)
g.Win = win
win.Frm.NxInst = g
win:SetUser (g, g.OnWin)
win:RegisterHide()
win:CreateButtons (true)
win:SetTitleLineH (18)
win:SetTitleXOff (50)
win:InitLayoutData (nil, -.15, -.2, -.63, -.5)
win.Frm:SetToplevel (true)
win:Show (false)
tinsert (UISpecialFrames, win.Frm:GetName())
local but = Nx.Button:Create (win.Frm, "Txt64", "Back ", nil, 0, 0, "TOPLEFT", 100, 24, self.But_OnBack, g)
win:Attach (but.Frm, 1.01, 1.01+44, -10020, -10001)
Nx.List:SetCreateFont ("Font.Medium", 28)
local list = Nx.List:Create (false, 0, 0, 1, 1, win.Frm)
g.List = list
list:SetUser (g, g.OnListEvent)
list:SetLineHeight (16, 3)
list:ColumnAdd ("", 1, 35)
list:ColumnAdd ("", 2, 900)
win:Attach (list.Frm, 0, .33, 0, 1)
g:CreateMenu()
Nx.List:SetCreateFont ("Font.Medium", 28)
local list = Nx.List:Create (false, 0, 0, 1, 1, win.Frm)
g.List2 = list
list:SetUser (g, g.OnList2Event)
list:SetLineHeight (16, 11)
list:ColumnAdd ("", 1, 35)
list:ColumnAdd ("Name", 2, 220)
list:ColumnAdd ("Info", 3, 80)
list:ColumnAdd ("Info2", 4, 150)
list:ColumnAdd ("Info3", 5, 230)
win:Attach (list.Frm, .33, 1, 18, 1)
g.EditBox = Nx.EditBox:Create (win.Frm, g, g.OnEditBox, 30)
win:Attach (g.EditBox.Frm, .33, 1, 0, 18)
g:ClearShowFolders()
g:UpdateVisitedVendors()
g:Update()
map:InitIconType ("!POI", "WP", "", 1, 1)
map:InitIconType ("!POIIn", "WP", "", 1, 1)
map:InitIconType ("!CUSTOM", "WP", "", 1, 1)
return g
end
function Nx.Map.Guide:PatchData()
Nx.GuideData = Nx["GuideData"] or Nx.GuideData
Nx.NPCData = Nx["NPCData"] or Nx.NPCData
local data = Nx.GuideData
local npc = Nx.NPCData
local fix = {
}
local typ
local n = 1
while fix[n] do
if type (fix[n]) == "string" then
typ = fix[n]
n = n + 1
else
local x = fix[n + 3] * 100
local y = fix[n + 4] * 100
local xs = strchar (floor (x / 221) + 35, x % 221 + 35)
local ys = strchar (floor (y / 221) + 35, y % 221 + 35)
local cont = floor (fix[n + 2] / 1000)
local zone = fix[n + 2] % 1000
if fix[n + 1] then
else
local s = format ("%c%c%s%s", fix[n] + 35, zone + 35, xs, ys)
data[typ][cont] = data[typ][cont] .. s
end
n = n + 5
end
end
end
function Nx.Map.Guide:CreateMenu()
local menu = Nx.Menu:Create (self.List.Frm)
self.Menu = menu
self.MenuIDelete = menu:AddItem (0, L["Delete"], self.Menu_OnDelete, self)
self.MenuIGotoQ = menu:AddItem (0, L["Add Goto Quest"], self.Menu_OnAddGotoQ, self)
local item = menu:AddItem (0, L["Show On All Continents"], self.Menu_OnShowAllCont, self)
item:SetChecked (true)
self.ShowAllCont = true
local function func (self, item)
self.ShowQuestGiverCompleted = item:GetChecked()
self:Update()
end
local item = menu:AddItem (0, L["Show Completed Quest Givers"], func, self)
item:SetChecked (false)
self.ShowQuestGiverCompleted = false
local str = UnitFactionGroup ("player") == "Horde" and "Alliance" or "Horde"
local item = menu:AddItem (0, L["Show " .. str], self.Menu_OnShowEnemy, self)
item:SetChecked (false)
menu:AddItem (0, L["Clear Selection"], self.Menu_OnClearSel, self)
local function func()
Nx.Opts:Open ("Guide")
end
menu:AddItem (0, L["Options..."], func, self)
end
function Nx.Map.Guide:OpenMenu (item)
self.MenuCurItem = item
local canDel = false
local canGotoQ = false
if type (item) == "table" then
if item.T then
local mode = strbyte (item.T)
if mode == 40 then
canDel = true
end
end
if item.QId then
canGotoQ = true
end
end
self.MenuIDelete:Show (canDel)
self.MenuIGotoQ:Show (canGotoQ)
self.Menu:Open()
end
function Nx.Map.Guide:Menu_OnDelete()
local item = self.MenuCurItem
local mode = strbyte (item.T)
if mode == 40 then
local npcName = strsub (item.T, 2)
local vv = Nx.db.profile.VendorV.Vendors
vv[npcName] = nil
end
self:UpdateVisitedVendors()
local parent = Nx.GuideInfo
for n = 2, #self.PathHistory do
local i = max (min (self.PathHistorySel[n - 1], #parent), 1)
self.PathHistory[n] = parent[i]
parent = self.PathHistory[n]
end
self:ClearAll()
self:SelectLists()
end
function Nx.Map.Guide:Menu_OnAddGotoQ()
local item = self.MenuCurItem
if item.QId and Nx.Quest then
Nx.Quest:Goto (item.QId)
end
end
function Nx.Map.Guide:Menu_OnShowAllCont (item)
self.ShowAllCont = item:GetChecked()
self:Update()
end
function Nx.Map.Guide:Menu_OnShowEnemy (item)
self.ShowEnemy = item:GetChecked()
self:ClearAll()
end
function Nx.Map.Guide:Menu_OnClearSel()
self:ClearAll()
end
function Nx.Map.Guide:But_OnBack()
self:Back()
end
function Nx:NXGuideKeyToggleShow()
local map = Nx.Map:GetMap (1)
map.Guide:ToggleShow()
end
function Nx.Map.Guide:ToggleShow()
self.Win:Show (not self.Win:IsShown())
end
function Nx.Map.Guide:OnWin (typ)
if typ == "Hide" then
end
end
function Nx.Map.Guide:OnListEvent (eventName, sel, val2, click)
self:OnListEventDo (self.List, eventName, sel, val2, click)
end
function Nx.Map.Guide:OnList2Event (eventName, sel, val2, click)
self:OnListEventDo (self.List2, eventName, sel, val2, click)
end
function Nx.Map.Guide:OnListEventDo (list, eventName, sel, val2, click)
local typ = list:ItemGetData (sel) or 0
local pathI = max (#self.PathHistory - 1, 1)
if list == self.List2 then
pathI = #self.PathHistory
end
if eventName == "select" or eventName == "mid" or eventName == "menu" then
self.PathHistorySel[pathI] = sel
local folder = self.PathHistory[pathI]
local item = folder[typ]
if eventName ~= "menu" or list == self.List then
if type (item) == "table" then
if item[1] or item.Item then
self.PathHistory[pathI + 1] = item
self.PathHistorySel[pathI + 1] = 1
self:SelectLists()
else
if list == self.List then
if #self.PathHistory == 2 then
self:Back()
end
end
end
end
end
if type (item) == "number" then
local id = item
if IsControlKeyDown() then
DressUpItemLink (format ("item:%d", id))
else
local name, link = GetItemInfo (id)
SetItemRef (format ("item:%d", id), link)
end
else
if IsControlKeyDown() then
if item.Link then
DressUpItemLink (item.Link)
end
end
end
self:Update()
if eventName == "menu" then
self:OpenMenu (item)
end
elseif eventName == "back" then
self:Back()
elseif eventName == "sort" then
if list == self.List2 then
list:ColumnSort (val2)
self:Update()
end
elseif eventName == "button" then
local pressed = val2
if typ > 0 then
local map = self.Map
local folder = self.PathHistory[pathI]
if type (folder[typ]) == "table" then
folder = folder[typ]
end
if folder.TrialMsg then
Nx.ShowMessageTrial()
end
local single = not (IsShiftKeyDown() or click == "MiddleButton")
if folder.MId and pressed then
map:SetCurrentMap (folder.MId)
map:CenterMap (folder.MId, 1)
if Nx.Quest then
Nx.Quest.List:Update()
end
single = true
end
if single then
self:ClearShowFolders()
Nx.Map.Guide.FindType = nil
map:ClearTargets (not pressed and "Guide")
elseif not pressed then
local typ, id = map:GetTargetInfo()
if id == folder then
Nx.Map.Guide.FindType = nil
map:ClearTargets()
end
end
if folder.Persist and not pressed then
local v = Nx.db.char.Map[folder.Persist]
if v then
self:AddShowFolders (folder, not pressed)
end
else
self:AddShowFolders (folder, not pressed)
end
self:Update()
if single and pressed then
local typ, filt = self:CalcType (folder)
self.FindingClosest = typ
if typ then
local npcI, mapId, x, y, npcI2, mapId2, x2, y2 = self:FindClosest (typ)
if npcI then
if Nx.Quest then
Nx.Quest.Watch:ClearAutoTarget()
end
map:SetTarget ("Guide", x, y, x, y, false, folder, folder.Name, false, mapId)
if false and npcI2 then
map:SetTarget("Guide2", x2, y2, x2, y2, false, folder, folder.Name, true ,mapId2)
end
map:GotoPlayer()
end
else
PlaySound(SOUNDKIT.MONEY_FRAME_CLOSE);
end
end
end
end
end
function Nx.Map.Guide:Back()
if #self.PathHistory > 1 then
tremove (self.PathHistory)
end
self:Update()
self:SelectLists()
end
function Nx.Map.Guide:SelectLists()
local i = self.PathHistorySel[max (#self.PathHistory - 1, 1)]
if i and i <= self.List:ItemGetNum() then
self.List:Select (i)
end
self.List:Update()
local i = self.PathHistorySel[#self.PathHistory]
if i and i <= self.List2:ItemGetNum() then
self.List2:Select (i)
end
self.List2:Update()
end
function Nx.Map.Guide:OnEditBox (editbox, message)
if message == "Changed" then
self:Update()
end
end
function Nx.Map.Guide:PatchFolder (folder, parent)
local trainer
if folder.Name == L["Trainer"] and folder.Pre then
trainer = true
end
if folder.Pre and folder.Name then
folder.Name = folder.Pre .. folder.Name
folder.Name = strtrim (gsub (folder.Name, "%u", " %1"), " ")
end
if parent and parent.Pre and folder.T then
folder.T = parent.Pre .. folder.T
end
if not folder.Name and folder.T then
local name = Nx.Split ("^", folder.T)
folder.Name = strtrim (gsub (name, "%u", " %1"), " ")
end
if folder.Name then
folder.Name = gsub (folder.Name, " " .. L["Trainer"], "")
end
if not folder.Tx then
folder.Tx = parent.Tx
end
if not trainer then
for showType, child in ipairs (folder) do
if type (child) == "table" then
self:PatchFolder (child, folder)
end
end
end
if folder.Name == L["Travel"] then
local txT = {
["Boat"] = "Spell_Shadow_DemonBreath",
["Portal"] = "INV_Misc_QuestionMark",
["Tram"] = "INV_Misc_MissileSmall_White",
["Zeppelin"] = "INV_Misc_MissileSmall_Red",
}
local portalT = {
["Blasted Lands"] = "Spell_Arcane_TeleportStonard",
["Darnassus"] = "Spell_Arcane_TeleportDarnassus",
["Teldrassil"] = "Spell_Arcane_TeleportDarnassus",
["The Exodar"] = "Spell_Arcane_TeleportExodar",
["Hellfire Peninsula"] = "Spell_Arcane_TeleportStonard",
["Ironforge"] = "Spell_Arcane_TeleportIronForge",
["Isle of Quel'Danas"] = "Achievement_Zone_IsleOfQuelDanas",
["Lake Wintergrasp"] = "Ability_WIntergrasp_rank1",
["Orgrimmar"] = "Spell_Arcane_TeleportOrgrimmar",
["Shattrath"] = "Spell_Arcane_TeleportShattrath",
["Silvermoon City"] = "Spell_Arcane_TeleportSilvermoon",
["Stormwind City"] = "Spell_Arcane_TeleportStormWind",
["Thunder Bluff"] = "Spell_Arcane_TeleportThunderBluff",
["Undercity"] = "Spell_Arcane_TeleportUnderCity",
["Dalaran"] = "Spell_Arcane_TeleportDalaran",
["Shattrath City"] = "Spell_Arcane_TeleportShattrath",
["The Jade Forest"] = "Spell_Arcane_TeleportShattrath",
}
for i, str in ipairs (Nx.ZoneConnections) do
local flags, conTime, name1, mapId1, x1, y1, level1, name2, mapId2, x2, y2, level2 = Nx.Map:ConnectionUnpack (str)
if conTime ~= 1 then
local fac = bit.band (flags, 6) / 2
local facStr = fac == 1 and "^FA" or fac == 2 and "^FH" or ""
if #name1 > 0 then
local f = {}
tinsert (folder, f)
f.Name = format ("%s", name1)
f.Fac = fac
f.MapId = mapId1
f.ConIndex = i
f.T = "*" .. i .. facStr
local typ, locName = strmatch (name1, "(%S+) to (.+)")
f.Tx = typ == "Portal" and portalT[locName] or txT[typ]
end
if #name2 > 0 and bit.band (flags, 1) ~= 0 then
local f = {}
tinsert (folder, f)
f.Name = format ("%s", name2)
f.Fac = fac
f.MapId = mapId2
f.ConIndex = i
f.Con2 = true
f.T = "*b" .. i .. facStr
local typ, locName = strmatch (name2, "(%S+) to (.+)")
f.Tx = typ == "Portal" and portalT[locName] or txT[typ]
end
end
end
sort (folder, function (a, b) return a.Name < b.Name end)
elseif folder.Name == L["Herb"] then
for a,b in pairs(Nx.GatherInfo["H"]) do
local name, tx, skill = Nx:GetGather ("H", a)
if not name then
break
end
local f = {}
f.Name = name
f.Column2 = format ("%3d", skill)
f.T = "$H" .. a
f.Tx = tx
f.Id = a
folder[a] = f
end
elseif folder.Name == L["Timber"] then
for a,b in pairs(Nx.GatherInfo["L"]) do
local name, tx, skill = Nx:GetGather ("L", a)
if not name then
break
end
local f = {}
f.Name = name
f.Column2 = format("Level %d", skill)
f.Column3 = "Lumbermill"
f.T = "$L" .. a
f.Tx = tx
f.Id = a
folder[a] = f
end
elseif folder.Name == L["Ore"] then
for a,b in pairs(Nx.GatherInfo["M"]) do
local name, tx, skill = Nx:GetGather ("M", a)
if not name then
break
end
local f = {}
f.Name = name
f.Column2 = format ("%3d", skill)
f.T = "$M" .. (a + 500)
f.Tx = tx
f.Id = a
folder[a] = f
end
elseif folder.Map then
local Map = Nx.Map
local cont1 = folder.Map
local cont2 = cont1
if cont1 == 0 then
cont1 = 1
cont2 = Map.ContCnt
end
for cont = cont1, cont2 do
for _,id in pairs(Nx.Map.MapZones[cont]) do
local f = {}
local color, infoStr, minLvl = Map:GetMapNameDesc (id)
local name = Map:IdToName (id)
f.Name = format ("%s%s", color, name)
f.Column2 = infoStr
if not Map.MapWorldInfo[id] then
Nx.prt("err: " .. id)
end
f.T = "#Map" .. id
f.Tx = parent.Tx
f.MId = id
f.SrtN = name
f.Srt = minLvl
tinsert (folder, f)
end
end
if folder.Map == 0 then
sort (folder, function (a, b) if a.Srt == b.Srt then return a.SrtN < b.SrtN else return a.Srt < b.Srt end end)
else
sort (folder, function (a, b) return a.SrtN < b.SrtN end)
end
elseif folder.Inst then
local fcont = folder.Inst
local n = 1
for nxid, v in pairs (Nx.Zones) do
local longname, minLvl, maxLvl, faction, typ, owner, posx, posy, numPlyr = Nx.Split ("|", v)
if faction == "3" and typ == "5" and tonumber(numPlyr) > 0 then
local mapId = nxid
if mapId then
local cont = Nx.Map:IdToContZone (mapId)
if tonumber(cont) == tonumber(fcont) then
if nxid == 16 then
Nx.prt ("%s [%s] %s", longname, nxid, v)
end
local f = {}
local numPlyrStr = numPlyr
if tonumber (numPlyr) == 1025 then
numPlyrStr = "Raid"
end
if tonumber (numPlyr) == 50 then
numPlyrStr = "Mythic Dungeon"
end
if tonumber (numPlyr) == 1 then
numPlyrStr = "Solo"
end
if tonumber (numPlyr) == 3 then
numPlyrStr = "Scenario"
end
if tonumber (numPlyr) == 5 then
numPlyrStr = "Dungeon"
end
local plStr = ""
if (numPlyrStr) then
plStr = format ("|cffff4040%s", numPlyrStr)
else
Nx.prt("err: " .. nxid)
end
f.Name = format ("%s", longname)
f.Column3 = plStr
f.Column2 = "?"
if minLvl ~= "0" then
if minLvl == maxLvl then
f.Column2 = format ("%d", minLvl)
else
f.Column2 = format ("%d-%d", minLvl, maxLvl)
end
end
f.T = "%In" .. nxid
f.InstMapId = mapId
local ownName = Nx.Split ("|", Nx.Zones[tonumber (owner)])
local x, y = posx, posy
f.InstTip = format ("%s |cffe0e040Lvl %s\n|r%s (%.1f %.1f)", f.Name, f.Column2, ownName, x, y)
f.Tx = parent.Tx
folder[n] = f
n = n + 1
end
end
end
end