This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.lua
1523 lines (1398 loc) · 53.6 KB
/
core.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
--[[
]]
local font = [[Interface\AddOns\PredatorArchy\media\accid__.ttf]]
local textures = {
['border'] = [[Interface\AddOns\PredatorArchy\media\border_generic]],
['bar'] = [[Interface\AddOns\PredatorArchy\media\bar]],
['solid'] = [[Interface\AddOns\PredatorArchy\media\solid]],
['minimap'] = [[Interface\AddOns\PredatorArchy\media\button_minimap]],
['button_back'] = [[Interface\AddOns\PredatorArchy\media\button_back]],
['button_config'] = [[Interface\AddOns\PredatorArchy\media\button_config]],
['button_hide'] = [[Interface\AddOns\PredatorArchy\media\button_hide]],
['button_sleep'] = [[Interface\AddOns\PredatorArchy\media\button_sleep]],
['button_statistics'] = [[Interface\AddOns\PredatorArchy\media\button_statistics]]
}
local artifactsWidth = 300
local artifactsLineHeight = 28
local digSitesWidth = 200
local texts = {
['noskill'] = 'no archaeology skill detected!',
['notavailable'] = 'not available',
['solvable'] = 'you can solve',
['notsolvable'] = 'You do not have enough fragments!',
['keystones'] = 'Keystones',
['solving_with_keystones'] = 'Would you like to solve this artifact using your keystones?',
['confirm_reset'] = 'Do you really want to reset the settings?',
['stats'] = 'Statistics',
['rare'] = 'rares',
['max_solved'] = 'Most solved',
['alwaysShowRareCaption'] = 'always show rares',
['showMinimapButtonCaption'] = 'show Minimap button',
['mode_caption'] = 'Mode',
['mode_all'] = 'All',
['mode_artifacts'] = 'Artifacts',
['mode_fragments'] = 'Fragments',
['mode_custom'] = 'Custom',
['button_show'] = 'Show',
['button_hide'] = 'Hide',
['button_sleep'] = 'Sleep',
['button_reset'] = 'Reset',
['button_toggle'] = 'Toggle',
['button_statistics'] = 'Statistics',
['tooltip_showSkill'] = 'Show skill',
['tooltip_openConfig'] = 'Open configuration dialogue',
['tooltip_show'] = 'Show PredatorArchy windows',
['tooltip_hide'] = 'Hide PredatorArchy windows',
['tooltip_sleep'] = 'Send PredatorArchy to sleep',
['tooltip_reset'] = 'Reset PredatorArchy settings',
['tooltip_statistics'] = 'Show statistics',
}
local artifactColors = {
[0] = {0.7, 0.7, 0.7}, -- for normal, 'grey' artifacts
[1] = {0, 0.3, 0.9} -- for the exciting rare artifacts ;)
}
-- *********************************************************************************
-- *** DON'T EDIT BEYOND THIS LINE!!! **********************************************
-- *********************************************************************************
local numArchRaces = 10 -- made this static, so we don't have to wait for PLAYER_ALIVE on login
--[[
This table holds all information about the races, including their current active
fragment count
]]
local PredatorArchy, PredatorArchyArtifacts, PredatorArchyDigSites, PredatorArchyMenu, PredatorArchyMinimapButton
local currentSkill = 0
local infoTable = {}
local continentRaceTable = {
[1] = { -- Kalimdor
[3] = true, -- Fossiles
[4] = true, -- Night Elves
[7] = true, -- Tol'vir
},
[2] = { -- Eastern Kingdoms
[1] = true, -- Dwarf
[3] = true, -- Fossiles
[8] = true -- Trolls
},
[3] = { -- Outland
[2] = true, -- Draenei
[6] = true -- Orcs
},
[4] = { -- Northrend
[4] = true, -- Night Elves
[5] = true, -- Neruber
[8] = true, -- Trolls
[9] = true -- Vrykul
}
}
local rareArtifactNums = {
[1] = 4,
[2] = 2,
[3] = 5,
[4] = 7,
[5] = 2,
[6] = 1,
[7] = 6,
[8] = 3,
[9] = 2,
[10] = 0
}
local continentTable = {}
local raceIDNameTable = {}
local digSiteRaceTable = {
[54097] = 1, -- Ironband's Excavation Site
[54124] = 1, -- Ironbeard's Tomb
[54126] = 1, -- Whelgar's Excavation Site
[54127] = 3, -- Greenwarden's Fossil Bank
[54129] = 1, -- Thoradin's Wall
[54132] = 8, -- Witherbark Digsite
[54133] = 1, -- Thandol Span
[54134] = 1, -- Dun Garok Digsite
[54135] = 3, -- Southshore Fossil Field
[54136] = 1, -- Aerie Peak Digsite
[54137] = 8, -- Shadra'Alor Digsite
[54138] = 8, -- Altar of Zul Digsite
[54139] = 8, -- Jintha'Alor Lower City Digsite
[54140] = 8, -- Jintha'Alor Upper City Digsite
[54141] = 8, -- Agol'watha Digsite
[54832] = 1, -- Hammertoe's Digsite
[54834] = 1, -- Tomb of the Watchers Digsite
[54838] = 1, -- Uldaman Entrance Digsite
[54862] = 8, -- Sunken Temple Digsite
[54864] = 3, -- Misty Reed Fossil Bank
[55350] = 4, -- Twilight Grove Digsite
[55352] = 3, -- Vul'Gol Fossil Bank
[55354] = 4, -- Nazj'vel Digsite
[55356] = 4, -- Zoram Strand Digsite
[55398] = 4, -- Ruins of Ordil'Aran
[55400] = 4, -- Ruins of Stardust
[55402] = 4, -- Forest Song Digsite
[55404] = 4, -- Stonetalon Peak
[55406] = 4, -- Ruins of Eldre'Thar
[55408] = 3, -- Unearthed Grounds
[55410] = 1, -- Bael Modan Digsite
[55412] = 4, -- Ruins of Eldarath
[55414] = 4, -- Ruins of Arkkoran
[55416] = 3, -- Lakeridge Highway Fossil Bank
[55418] = 4, -- Slitherblade Shore Digsite
[55420] = 4, -- Ethel Rethor Digsite
[55422] = 3, -- Valley of Bones
[55424] = 4, -- Mannoroc Coven Digsite
[55426] = 3, -- Kodo Graveyard
[55428] = 4, -- Sargeron Digsite
[55434] = 3, -- Red Reaches Fossil Bank
[55436] = 3, -- Dreadmaul Fossil Field
[55438] = 1, -- Grimsilt Digsite
[55440] = 1, -- Pyrox Flats Digsite
[55442] = 1, -- Western Ruins of Thaurissan
[55444] = 1, -- Eastern Ruins of Thaurissan
[55446] = 3, -- Terror Wing Fossil Field
[55448] = 8, -- Zul'Mashar Digsite
[55450] = 4, -- Quel'Lithien Lodge Digsite
[55452] = 3, -- Infectis Scar Fossil Field
[55454] = 8, -- Eastern Zul'Kunda Digsite
[55456] = 8, -- Western Zul'Kunda Digsite
[55458] = 8, -- Bal'lal Ruins Digsite
[55460] = 8, -- Balia'mah Digsite
[55462] = 8, -- Ziata'jai Digsite
[55464] = 8, -- Eastern Zul'Mamwe Digsite
[55466] = 8, -- Western Zul'Mamwe Digsite
[55468] = 3, -- Savage Coast Raptor Fields
[55470] = 8, -- Ruins of Aboraz
[55472] = 8, -- Ruins of Jubuwal
[55474] = 8, -- Gurubashi Arena Digsite
[55476] = 8, -- Nek'mani Wellspring Digsite
[55478] = 3, -- Felstone Fossil Field
[55480] = 3, -- Northridge Fossil Filed
[55482] = 3, -- Andorhal Fossil Bank
[55755] = 3, -- Wyrmbog Fossil Field
[55757] = 3, -- Quagmire Fossil Field
[56327] = 4, -- Dire Maul Digsite
[56329] = 4, -- Broken Commons Digsite
[56331] = 4, -- Ravenwind Digsite
[56333] = 4, -- Oneiros Digsite
[56335] = 4, -- Solarsal Digsite
[56337] = 4, -- Darkmist Digsite
[56339] = 4, -- South Isildien Digsite
[56341] = 4, -- North Isildien Digsite
[56343] = 4, -- Constellas Digsite
[56345] = 4, -- Morlos'Aran Digsite
[56347] = 4, -- Jaedenar Digsite
[56349] = 4, -- Ironwood Digsite
[56351] = 4, -- Lake Kel'Theril Digsite
[56354] = 4, -- Owl Wing Thicket Digsite
[56356] = 4, -- Frostwhisper Gorge Digsite
[56358] = 3, -- Fields of Blood Fossil Bank
[56362] = 4, -- Nightmare Scar Digsite
[56364] = 8, -- Zul'Farrak Digsite
[56367] = 8, -- Broken Pillar Digsite
[56369] = 8, -- Eastmoon Ruins Digsite
[56371] = 8, -- Southmoon Ruins Digsite
[56373] = 3, -- Dunemaul Fossil Ridge
[56375] = 3, -- Abyssal Sands Fossil Ridge
[56380] = 3, -- Lower Lakkari Tar Pits
[56382] = 3, -- Upper Lakkari Tar Pits
[56384] = 3, -- Terror Run Fossil Field
[56386] = 3, -- Screaming Reaches Fossil Field
[56388] = 3, -- Marshlands Fossil Bank
[56390] = 4, -- Southwind Village Digsite
[56392] = 6, -- Gor'gaz Outpost Digsite
[56394] = 6, -- Zeth'Gor Digsite
[56396] = 6, -- Hellfire Basin Digsite
[56398] = 6, -- Hellfire Citadel Digsite
[56400] = 2, -- Sha'naar Digsite
[56402] = 2, -- Boha'mu Ruins Digsite
[56404] = 2, -- Twin Spire Ruins Digsite
[56406] = 2, -- Ruins of Enkaat Digsite
[56408] = 2, -- Arklon Ruins Digsite
[56410] = 2, -- Ruins of Farahlon Digsite
[56412] = 6, -- Ancestral Grounds Digsite
[56416] = 6, -- Sunspring Post Digsite
[56418] = 6, -- Laughing Skull Digsite
[56420] = 6, -- Burning Blade Digsite
[56422] = 2, -- Halaa Digsite
[56424] = 6, -- Grangol'var Village Digsite
[56426] = 2, -- Tuurem Digsite
[56428] = 6, -- Bleeding Hollow Ruins Digsite
[56430] = 6, -- Bonechewer Ruins Digsite
[56432] = 2, -- Bone Wastes Digsite
[56434] = 2, -- East Auchindoun Digsite
[56437] = 2, -- West Auchindoun Digsite
[56439] = 2, -- Illidari Point Digsite
[56441] = 2, -- Coilskar Point Digsite
[56446] = 2, -- Ruins of Baa'ri Digsite
[56448] = 2, -- Eclipse Point Digsite
[56450] = 6, -- Warden's Cage Digsite
[56455] = 6, -- Dragonmaw Fortress
[56504] = 9, -- Skorn Digsite
[56506] = 9, -- Halgrind Digsite
[56508] = 9, -- Wyrmskull Digsite
[56510] = 9, -- Shield Hill Digsite
[56512] = 9, -- Baleheim Digsite
[56514] = 9, -- Nifflevar Digsite
[56516] = 9, -- Gjalerbron Digsite
[56518] = 5, -- Pit of Narjun Digsite
[56520] = 4, -- Moonrest Gardens Digsite
[56522] = 5, -- En'kilah Digsite
[56524] = 5, -- Kolramas Digsite
[56526] = 4, -- Riplash Ruins Digsite
[56528] = 4, -- Violet Stand Digsite
[56530] = 4, -- Ruins of Shandaral Digsite
[56533] = 8, -- Altar of Sseratus Digsite
[56535] = 8, -- Zim'Rhuk Digsite
[56537] = 8, -- Zol'Heb Digsite
[56539] = 8, -- Altar of Quetz'lun Digsite
[56541] = 5, -- Talramas Digsite
[56543] = 9, -- Voldrune Digsite
[56547] = 8, -- Drakil'Jin Ruins Digsite
[56549] = 9, -- Brunnhildar Village Digsite
[56551] = 9, -- Sifreldar Village Digsite
[56553] = 9, -- Valkyrion Digsite
[56555] = 5, -- Scourgeholme Digsite
[56560] = 9, -- Ymirheim Digsite
[56562] = 9, -- Jotunheim Digsite
[56564] = 9, -- Njorndar Village Digsite
[56566] = 4, -- Ruins of Lar'donir Digsite
[56568] = 4, -- Shrine of Goldrinn Digsite
[56570] = 4, -- Grove of Aessina Digsite
[56572] = 4, -- Sanctuary of Malorne Digsite
[56574] = 4, -- Scorched Plain Digsite
[56576] = 4, -- Quel'Dormir Gardens Digsite
[56578] = 4, -- Nar'shola (Middle Tier) Digsite
[56580] = 4, -- Biel'aran Ridge Digsite
[56583] = 1, -- Dunwald Ruins Digsite
[56585] = 1, -- Thundermar Ruins Digsite
[56587] = 1, -- Humboldt Conflagration Digsite
[56589] = 1, -- Grim Batol Digsite
[56591] = 7, -- Khartut's Tomb Digsite
[56593] = 7, -- Tombs of the Precursors Digsite
[56595] = 7, -- Steps of Fate Digsite
[56597] = 7, -- Neferset Digsite
[56599] = 7, -- Orsis Digsite
[56601] = 7, -- Ruins of Ammon Digsite
[56603] = 7, -- Ruins of Khintaset Digsite
[56605] = 7, -- Temple of Uldum Digsite
[56607] = 7, -- Ruins of Ahmtul Digsite
[60350] = 7, -- Ausgrabungsstätte am Flussdelta
[60352] = 7, -- Ausgrabungsstätte am Verfluchten Landeplatz
[60354] = 7, -- Ausgrabungsstätte am Kesetpass
[60356] = 7, -- Ausgrabungsstätte der Felder von Akhenet
[60358] = 7, -- Ausgrabungsstätte am Obelisk der Sterne
[60361] = 7, -- Ausgrabungsstätte der Sahketwüste
[60363] = 7, -- Grabungsstätte bei Schnottz' Landeplatz
[60442] = 5, -- Ausgrabungsstätte des Schreckenstunnels
[60444] = 5, -- Ausbragungsstätte des Pestwaldes
}
local POIDigX1, POIDigX2, POIDigY1, POIDigY2 = WorldMap_GetPOITextureCoords(177)
--[[
]]
local lib = {}
local core = {}
local ctrl = {}
--[[ Popup for the confirmation of keystone-usage while solving an artifact
]]
StaticPopupDialogs['PREDATORARCHY_CONFIRM_SOLVE'] = {
text = texts.solving_with_keystones,
button1 = 'Ok',
button2 = 'No',
OnAccept = function()
SolveArtifact()
end,
timeout = 0,
whileDead = false,
hideOnEscape = false,
}
--[[ Popup for the confirmation of reset
]]
StaticPopupDialogs['PREDATORARCHY_CONFIRM_RESET'] = {
text = texts.confirm_reset,
button1 = 'Ok',
OnAccept = function()
ctrl.Reset()
end,
timeout = 30,
whileDead = false,
hideOnEscape = false,
}
--[[ Debugging to ChatFrame
VOID debugging(STRING text)
]]
lib.debugging = function(text)
DEFAULT_CHAT_FRAME:AddMessage('|cffffd700PredatorArchy:|r |cffeeeeee'..text..'|r')
end
--[[ Debugging the whole InfoTable
VOID DumpInfoTable()
]]
lib.DumpInfoTable = function()
lib.debugging('Dump: '..numArchRaces)
local i, race
for i = 1, numArchRaces do
race = GetArchaeologyRaceInfo(i)
-- lib.debugging(race..':')
lib.debugging(infoTable[race].name..', '..infoTable[race].keystoneID..', '..infoTable[race].frags..', '..infoTable[race].artifactFragsTotal)
end
end
--[[ Creates a font-object
FONTOBJECT CreateFontObject(FRAME parent, INT size, STRING font)
Creates a font-object with the given 'parent' and 'size', using 'font'. Shadow and Outline are constant throughout the layout.
]]
lib.CreateFontObject = function(parent, size, font)
local fo = parent:CreateFontString(nil, 'OVERLAY')
fo:SetFont(font, size, 'OUTLINE')
fo:SetJustifyH('LEFT')
fo:SetShadowColor(0, 0, 0)
fo:SetShadowOffset(1, -1)
return fo
end
--[[
]]
lib.CreateBorder = function(frame)
frame.tex[1] = frame:CreateTexture(nil, 'ARTWORK')
frame.tex[1]:SetPoint('TOPLEFT', frame, 'TOPLEFT', -1, 1)
frame.tex[1]:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMLEFT', 0, 0)
frame.tex[1]:SetTexture(textures.solid)
frame.tex[1]:SetVertexColor(0, 0, 0, 1)
frame.tex[2] = frame:CreateTexture(nil, 'ARTWORK')
frame.tex[2]:SetPoint('TOPLEFT', frame, 'TOPLEFT', 0, 1)
frame.tex[2]:SetPoint('BOTTOMRIGHT', frame, 'TOPRIGHT', 1, 0)
frame.tex[2]:SetTexture(textures.solid)
frame.tex[2]:SetVertexColor(0, 0, 0, 1)
frame.tex[3] = frame:CreateTexture(nil, 'ARTWORK')
frame.tex[3]:SetPoint('TOPLEFT', frame, 'TOPRIGHT', 0, 0)
frame.tex[3]:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', 1, -1)
frame.tex[3]:SetTexture(textures.solid)
frame.tex[3]:SetVertexColor(0, 0, 0, 1)
frame.tex[4] = frame:CreateTexture(nil, 'ARTWORK')
frame.tex[4]:SetPoint('TOPLEFT', frame, 'BOTTOMLEFT', -1, 0)
frame.tex[4]:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', 0, -1)
frame.tex[4]:SetTexture(textures.solid)
frame.tex[4]:SetVertexColor(0, 0, 0, 1)
end
--[[
]]
lib.CreateCtrlButton = function(parent, texture, caption)
local tmp = CreateFrame('Button', nil, parent)
tmp:SetSize(18, 18)
tmp.tex = {}
tmp.tex['icon'] = tmp:CreateTexture(nil, 'OVERLAY')
tmp.tex['icon']:SetAllPoints(tmp)
tmp.tex['icon']:SetTexture(texture)
tmp.tex['icon']:SetVertexColor(0.7, 0.7, 0.7, 0.9)
lib.CreateBorder(tmp)
tmp:SetScript('OnLeave', function()
GameTooltip:Hide()
end)
--[[
tmp.caption = lib.CreateFontObject(tmp, 14, font)
tmp.caption:SetPoint('CENTER')
tmp.caption:SetText(caption)
]]
return tmp
end
--[[ Creates a StatusBar with border and text
FRAME CreateStatusBar(FRAME parent)
]]
lib.CreateStatusBar = function(parent)
local tmp = CreateFrame('StatusBar', nil, parent)
tmp:SetHeight(20)
tmp:SetStatusBarTexture(textures.bar)
tmp:SetStatusBarColor(0.7, 0, 0)
tmp.tex = {}
tmp.tex['back'] = tmp:CreateTexture(nil, 'BACKGROUND')
tmp.tex['back']:SetAllPoints(tmp)
tmp.tex['back']:SetTexture(textures.bar)
tmp.tex['back']:SetVertexColor(0.3, 0.3, 0.3, 1)
tmp.text = lib.CreateFontObject(tmp, 14, font)
tmp.text:SetPoint('LEFT', 5, 1)
tmp.text:SetPoint('RIGHT', -15)
tmp.text:SetJustifyH('LEFT')
tmp.text:SetText('INIT')
lib.CreateBorder(tmp)
return tmp
end
-- *********************************************************************************
-- ***** CORE FUNCTIONS ************************************************************
-- *********************************************************************************
--[[ Updates the current archaeology skill
VOID UpdateSkill(INT index)
INT index is the index of the archaeology skill
]]
core.UpdateSkill = function(index)
local name, _, current, max = GetProfessionInfo(index)
currentSkill = current
PredatorArchyArtifacts.Skill:SetMinMaxValues(0, max)
PredatorArchyArtifacts.Skill:SetValue(current)
PredatorArchyArtifacts.Skill.text:SetText(name..': '..current..'/'..max)
end
--[[ Updates the projects of the race
VOID UpdateProject()
Iterates over all (known) races, wheather or not they are currently shown.
The function only updates the (internal) InfoTable, display is updated by UpdateArtifactWindow().
]]
core.UpdateProject = function()
local i, raceName, raceFragsNeed, artifactName, artifactRarity, artifactIcon, artifactDesc, artifactKeystoneCount
for i = 1, numArchRaces do
raceName, _, _, _, raceFragsNeed = GetArchaeologyRaceInfo(i)
artifactName, _, artifactRarity, artifactIcon, artifactDesc, artifactKeystoneCount = GetActiveArtifactByRace(i)
if ( artifactName ) then
-- lib.debugging(raceName..': '..artifactName)
infoTable[raceName].artifactFragsTotal = raceFragsNeed
infoTable[raceName].artifactName = artifactName
infoTable[raceName].artifactRarity = artifactRarity
infoTable[raceName].artifactIcon = artifactIcon
infoTable[raceName].artifactDesc = artifactDesc
infoTable[raceName].artifactKeystoneSlots = artifactKeystoneCount
else
infoTable[raceName].artifactName = nil
end
end
end
--[[ Updates the artifact window (PredatorArchyArtifacts).
VOID UpdateArtifactWindow()
]]
core.UpdateArtifactWindow = function()
-- lib.debugging('UpdateArtifactWindow()')
local i, race, raceFrags, line, lineCount
lineCount = 1
PredatorArchyArtifacts:SetHeight(330)
for i = 1, numArchRaces do
race, _, _, raceFrags = GetArchaeologyRaceInfo(i)
infoTable[race].frags = raceFrags
line = PredatorArchyArtifacts.Lines[lineCount]
if ( (line) and (
( core.CheckForSolvable(race) and infoTable[race].artifactFragsTotal > 0 ) or
( PredatorArchyOptions.alwaysShowRare and infoTable[race].artifactRarity and ( infoTable[race].artifactRarity > 0 ) ) or
( (PredatorArchyOptions.mode == texts.mode_custom) and PredatorArchyOptions.customMode[race] ) or
( (PredatorArchyOptions.mode == texts.mode_fragments) and continentRaceTable[GetCurrentMapContinent()][i] ) or
( (PredatorArchyOptions.mode == texts.mode_artifacts) and infoTable[race].artifactName ) or
( PredatorArchyOptions.mode == texts.mode_all ) )
) then
line.race = race
line:SetID(infoTable[race].ID)
line.RaceButton.tex:SetTexture(infoTable[race].tex)
line.ArtifactIcon.tex['icon']:SetTexture(infoTable[race].artifactIcon or nil)
if ( infoTable[race].artifactName ) then
line.Bar:SetMinMaxValues(0, infoTable[race].artifactFragsTotal)
line.Bar:SetValue(infoTable[race].frags)
line.Bar:SetStatusBarColor(unpack(artifactColors[infoTable[race].artifactRarity]))
line.Bar.tex['back']:SetVertexColor(unpack(artifactColors[infoTable[race].artifactRarity]))
line.Bar.tex['back']:SetAlpha(0.5)
line.Bar.text:SetText(infoTable[race].frags..'/'..infoTable[race].artifactFragsTotal..' - '..infoTable[race].artifactName)
if ( core.CheckForSolvable(race) ) then
line.Bar.text:SetTextColor(0, 1, 0)
else
line.Bar.text:SetTextColor(1, 1, 1)
end
line.Bar:Show()
line.ArtifactIcon:Show()
else
line.Bar:Hide()
line.RaceButton.tex:SetDesaturated(true)
line.ArtifactIcon:Hide()
end
line:Show()
lineCount = lineCount + 1
else
PredatorArchyArtifacts:SetHeight(PredatorArchyArtifacts:GetHeight()-28)
end
end
for i = lineCount, numArchRaces do
line = PredatorArchyArtifacts.Lines[i]
line:Hide()
line.Bar:Hide()
line.ArtifactIcon:Hide()
end
end
--[[ Checks, if an artifact is solvable.
BOOL CheckForSolvable(STRING race)
]]
core.CheckForSolvable = function(race)
-- lib.debugging('CheckForSolvable()')
if (
( infoTable[race].frags >= infoTable[race].artifactFragsTotal ) or
( ( infoTable[race].artifactKeystoneSlots ) and
( (infoTable[race].frags + min(GetItemCount(infoTable[race].keystoneID), infoTable[race].artifactKeystoneSlots) * 12) >= infoTable[race].artifactFragsTotal ) )
) then
return true
end
return false
end
--[[ Triggers the solving of an artifact.
VOID SolveArtifact(STRING race)
If keystones must be used, a popup will be shown to confirm this, otherwise the solving is triggered.
]]
core.SolveArtifact = function(race)
if ( not core.CheckForSolvable(race) ) then
lib.debugging(texts.notsolvable)
return
end
local i, raceIndex
-- look for the race index (are dwarfes always 1?!?)
for i = 1, numArchRaces do
if ( race == GetArchaeologyRaceInfo(i) ) then
raceIndex = i
end
end
SetSelectedArtifact(raceIndex)
local numFragsCollected, numFragmentsAdded, numFragsRequired = GetArtifactProgress()
local keystoneAmount = ceil((numFragsRequired-numFragsCollected)/12)
-- lib.debugging(keystoneAmount)
for i = 1, keystoneAmount do
SocketItemToArtifact()
end
if ( keystoneAmount > 0 ) then
StaticPopup_Show('PREDATORARCHY_CONFIRM_SOLVE')
else
SolveArtifact()
end
end
--[[ Populates the race InfoTable
VOID BuildInfoTable()
]]
core.BuildInfoTable = function()
local i, raceName, raceTex, raceKeystoneID, raceFrags, raceFragsNeed, artifactName, artifactRarity, artifactIcon, artifactDesc, artifactKeystoneCount
for i = 1, numArchRaces do
raceName, raceTex, raceKeystoneID, raceFrags, raceFragsNeed = GetArchaeologyRaceInfo(i)
raceIDNameTable[i] = raceName
infoTable[raceName] = {
['name'] = raceName,
['tex'] = raceTex,
['keystoneID'] = raceKeystoneID,
['frags'] = raceFrags or 0,
['artifactFragsTotal'] = raceFragsNeed or 0,
['ID'] = i
}
artifactName, _, artifactRarity, artifactIcon, artifactDesc, artifactKeystoneCount = GetActiveArtifactByRace(i)
if ( artifactName ) then
infoTable[raceName].artifactName = artifactName
infoTable[raceName].artifactRarity = artifactRarity
infoTable[raceName].artifactIcon = artifactIcon
infoTable[raceName].artifactDesc = artifactDesc
infoTable[raceName].artifactKeystoneSlots = artifactKeystoneCount
else
infoTable[raceName].artifactName = nil
end
end
end
--[[ Populates the continent table
VOID BuildContinentTable()
]]
core.BuildContinentTable = function()
local cid, cname
for cid, cname in pairs{GetMapContinents()} do
-- lib.debugging(cid..': '..cname..' ('..mapid..')')
continentTable[cid] = {}
for zid, zname in pairs{GetMapZones(cid)} do
SetMapZoom(cid, zid)
local mapid = GetCurrentMapAreaID()
-- lib.debugging('_'..zid..': '..zname..' ('..mapid..')')
continentTable[cid][mapid] = zname
end
end
end
--[[ Finds the dig sites on the current continent
VOID FindDigSiteOnContinent()
This function works by iterating through all zones of a continent.
This way, it is possible to use just IDs, rather than names.
]]
core.FindDigSiteOnContinent = function()
SetMapToCurrentZone()
local cid = GetCurrentMapContinent()
-- lib.debugging('Kontinent: '..cid)
local zid, zname, numDigSites, blobID, i, line
line = 1
for zid, zname in pairs(continentTable[cid]) do
-- lib.debugging('_'..zid..': '..zname)
SetMapByID(zid)
numDigSites = ArchaeologyMapUpdateAll()
if ( numDigSites > 0 ) then
for i = 1, numDigSites do
blobID = ArcheologyGetVisibleBlobID(i)
-- lib.debugging('found dig site '..blobID..' in '..zname)
-- lib.debugging(raceIDNameTable[digSiteRaceTable[blobID]]..' in '..zname)
if ( digSiteRaceTable[blobID] ) then
PredatorArchyDigSites.Lines[line].tex:SetTexture(infoTable[raceIDNameTable[digSiteRaceTable[blobID]]].tex)
PredatorArchyDigSites.Lines[line].text:SetText(zname)
PredatorArchyDigSites.Lines[line]:SetID(zid)
else
PredatorArchyDigSites.Lines[line].tex:SetTexture()
PredatorArchyDigSites.Lines[line].text:SetText('MISSING: '..blobID)
end
line = line + 1
end
end
end
end
--[[ Displays the DigSites in the TaxiMap
VOID FindDigSitesOnTaxiMap()
]]
core.FindDigSitesOnTaxiMap = function()
-- lib.debugging('FindDigSitesOnTaxiMap()')
local taxiFrame, taxiWidth, taxiHeight, worldWidth, i, lmName, lmTex, lmX, lmY, digSiteName, digSite
local digSites = {}
local mapBackup = GetCurrentMapAreaID()
SetMapToCurrentZone()
SetMapZoom(GetCurrentMapContinent())
taxiFrame = _G['TaxiRouteMap']
taxiWidth = taxiFrame:GetWidth()
taxiHeight = taxiFrame:GetHeight()
worldWidth = WorldMapFrame:GetWidth()
for i = 1, GetNumMapLandmarks() do
lmName, _, lmTex, lmX, lmY = GetMapLandmarkInfo(i)
if ( lmTex == 177 ) then
digSiteName = 'WorldMapFramePOIdigsite'..i
digSite = _G[digSiteName]
if ( not digSite ) then
WorldMap_CreatePOI('digsite'..i)
digSite = _G[digSiteName]
end
digSite:SetParent(taxiFrame)
_G[digSiteName..'Texture']:SetTexCoord(POIDigX1, POIDigX2, POIDigY1, POIDigY2)
digSite:EnableMouse(false)
digSite:SetPoint('CENTER', taxiFrame, 'TOPLEFT', (taxiWidth/2)+((lmX*worldWidth)-worldWidth/2)*(630/1000), -lmY*taxiHeight)
digSite:SetScale(1)
digSite:Show()
end
end
SetMapByID(mapBackup)
end
--[[ Prints statistics about your digging
VOID PrintStatistics()
]]
core.PrintStatistics = function()
local i, j, raceName, raceCount, raceRar, curName, curRar, curCount, maxName, maxCount
RequestArtifactCompletionHistory()
maxName = ''
maxCount = 0
lib.debugging(texts.stats)
for i = 1, numArchRaces do
raceName = GetArchaeologyRaceInfo(i)
raceCount = 0
raceRar = 0
for j = 1, GetNumArtifactsByRace(i) do
curName, _, curRar, _, _, _, _, _, curCount = GetArtifactInfoByRace(i, j)
if ( curCount > maxCount ) then
maxName = curName
maxCount = curCount
end
if ( curRar == 1 ) then
raceRar = raceRar + curCount
end
raceCount = raceCount + curCount
end
if ( raceCount > 0 ) then
lib.debugging(raceName..': '..raceCount..' ('..raceRar..'/'..rareArtifactNums[i]..' '..texts.rare..')')
end
end
lib.debugging(texts.max_solved..': '..maxName..' ('..maxCount..')')
end
-- *********************************************************************************
-- ***** CONTROL FUNCTIONS *********************************************************
-- *********************************************************************************
--[[
]]
ctrl.MinimapShapes = {
['ROUND'] = {true, true, true, true},
['SQUARE'] = {false, false, false, false},
['CORNER-TOPLEFT'] = {true, false, false, false},
['CORNER-TOPRIGHT'] = {false, false, true, false},
['CORNER-BOTTOMLEFT'] = {false, true, false, false},
['CORNER-BOTTOMRIGHT'] = {false, false, false, true},
['SIDE-LEFT'] = {true, true, false, false},
['SIDE-RIGHT'] = {false, false, true, true},
['SIDE-TOP'] = {true, false, true, false},
['SIDE-BOTTOM'] = {false, true, false, true},
['TRICORNER-TOPLEFT'] = {true, true, true, false},
['TRICORNER-TOPRIGHT'] = {true, false, true, true},
['TRICORNER-BOTTOMLEFT'] = {true, true, false, true},
['TRICORNER-BOTTOMRIGHT'] = {false, true, true, true},
}
--[[ Updates the Position of the Minimap button
VOID SetMinimapButtonPos()
]]
ctrl.SetMinimapButtonPos = function()
local angle = math.rad(PredatorArchyOptions.minimapButtonAngle)
local x, y, q = math.cos(angle), math.sin(angle), 1
if ( x < 0 ) then q = q+1 end
if ( y > 0 ) then q = q+2 end
local shape = GetMinimapShape() or 'ROUND'
local quadTable = ctrl.MinimapShapes[shape]
if ( quadTable[q] ) then
x, y = x*80, y*80
else
local diagRad = 103.12308498985
x = math.max(-80, math.min(x*diagRad, 80))
y = math.max(-80, math.min(y*diagRad, 80))
end
PredatorArchyMinimapButton:SetPoint('CENTER', Minimap, 'CENTER', x, y)
end
--[[ Shows the frames and registers the events
VOID Show()
]]
ctrl.Show = function()
PredatorArchyOptions.state = true
core.BuildInfoTable()
PredatorArchyArtifacts:Show()
PredatorArchyDigSites:Show()
core.UpdateProject()
core.UpdateArtifactWindow()
core.FindDigSiteOnContinent()
PredatorArchy:RegisterEvent('CHAT_MSG_CURRENCY')
PredatorArchy:RegisterEvent('ARTIFACT_UPDATE')
PredatorArchy:RegisterEvent('ARTIFACT_DIG_SITE_UPDATED')
PredatorArchy:RegisterEvent('ZONE_CHANGED_NEW_AREA')
PredatorArchy:RegisterEvent('TAXIMAP_OPENED')
end
--[[ Hides the frames
VOID Hide()
]]
ctrl.Hide = function()
PredatorArchyOptions.state = false
PredatorArchyArtifacts:Hide()
PredatorArchyDigSites:Hide()
end
--[[ Sends the addon to sleep and unregisters the events
VOID Sleep()
]]
ctrl.Sleep = function()
PredatorArchyOptions.state = false
PredatorArchy:UnregisterEvent('PLAYER_ALIVE')
PredatorArchy:UnregisterEvent('CHAT_MSG_CURRENCY')
PredatorArchy:UnregisterEvent('ARTIFACT_UPDATE')
PredatorArchy:UnregisterEvent('ARTIFACT_DIG_SITE_UPDATED')
PredatorArchy:UnregisterEvent('ZONE_CHANGED_NEW_AREA')
PredatorArchy:UnregisterEvent('TAXIMAP_OPENED')
ctrl.Hide()
end
--[[ Sets the default-values of the SavedVars
VOID SetDefaults()
]]
ctrl.SetDefaults = function()
PredatorArchyOptions = {}
PredatorArchyOptions.state = true
PredatorArchyOptions.mode = texts.mode_all
PredatorArchyOptions.customMode = {}
PredatorArchyOptions.PredatorArchyArtifacts = {
['point'] = 'CENTER',
['relPoint'] = 'CENTER',
['x'] = 0,
['y'] = 0
}
PredatorArchyOptions.PredatorArchyDigSites = {
['point'] = 'CENTER',
['relPoint'] = 'CENTER',
['x'] = 0,
['y'] = 0
}
end
--[[ Resets all settings to default
VOID Reset()
]]
ctrl.Reset = function()
ctrl.SetDefaults()
core.BuildInfoTable()
core.UpdateArtifactWindow()
PredatorArchyArtifacts:ClearAllPoints()
PredatorArchyArtifacts:SetPoint(PredatorArchyOptions['PredatorArchyArtifacts'].point, UIParent, PredatorArchyOptions['PredatorArchyArtifacts'].relPoint, PredatorArchyOptions['PredatorArchyArtifacts'].x, PredatorArchyOptions['PredatorArchyArtifacts'].y)
PredatorArchyDigSites:ClearAllPoints()
PredatorArchyDigSites:SetPoint(PredatorArchyOptions['PredatorArchyDigSites'].point, UIParent, PredatorArchyOptions['PredatorArchyDigSites'].relPoint, PredatorArchyOptions['PredatorArchyDigSites'].x, PredatorArchyOptions['PredatorArchyDigSites'].y)
end
--[[ Toggles the windows between Show() and Sleep()
VOID Toggle()
]]
ctrl.Toggle = function()
if ( PredatorArchyOptions.state ) then
ctrl.Sleep()
else
ctrl.Show()
end
end
--[[ Controls what happens while using a slash-command
VOID SlashCmdHandler(STRING msg, EDITBOX editbox)
Remember that the SlashCmds are '/predatorarchy' and '/pa'
]]
ctrl.SlashCmdHandler = function(msg, editbox)
local cmd, param = msg:match('^(%S*)%s*(.-)$')
if ( cmd == 'show' ) then
lib.debugging('Shows up...')
ctrl.Show()
elseif ( cmd == 'hide' ) then
lib.debugging('Is now hidden...')
ctrl.Hide()
elseif ( cmd == 'sleep' ) then
lib.debugging('Is now sleeping...')
ctrl.Sleep()
elseif ( cmd == 'toggle' ) then
ctrl.Toggle()
elseif ( cmd == 'reset' ) then
StaticPopup_Show('PREDATORARCHY_CONFIRM_RESET')
else
lib.debugging('/pa [show | hide | sleep | reset]')
lib.debugging(' show - shows the PredatorArchy windows')
lib.debugging(' hide - hides the windows')
lib.debugging(' sleep - sends the addon to sleep and hides the windows')
lib.debugging(' reset - resets the settings')
end
end
--[[
]]
ctrl.MinimapButtonHandler = function(frame, button)
if ( button == 'LeftButton' ) then
ctrl.Toggle()
elseif ( button == 'RightButton' ) then
ToggleDropDownMenu(1, nil, frame.DropDown, frame, 0, -5)
end
end
-- *********************************************************************************
PredatorArchy = CreateFrame('Frame', 'PredatorArchy', UIParent)
PredatorArchy:RegisterEvent('PLAYER_LOGIN')
PredatorArchy:SetScript('OnEvent', function(self)
local _, _, hasArch = GetProfessions()
if ( not hasArch ) then
lib.debugging(texts.noskill)
return
end
core.BuildInfoTable()
core.UpdateArtifactWindow()
core.UpdateSkill(hasArch)
core.BuildContinentTable()
core.FindDigSiteOnContinent()
-- build the event handler
if ( PredatorArchyOptions.state ) then
self:RegisterEvent('PLAYER_ALIVE')
self:RegisterEvent('CHAT_MSG_CURRENCY')
self:RegisterEvent('ARTIFACT_UPDATE')
self:RegisterEvent('ARTIFACT_DIG_SITE_UPDATED')
self:RegisterEvent('ZONE_CHANGED_NEW_AREA')
self:RegisterEvent('TAXIMAP_OPENED')
PredatorArchyArtifacts:Show()
PredatorArchyDigSites:Show()
end
self:UnregisterEvent('PLAYER_LOGIN')
self:SetScript('OnEvent', function(self, event)
-- lib.debugging(event)
if ( event == 'PLAYER_ALIVE' ) then
core.BuildInfoTable()
core.UpdateArtifactWindow()
core.FindDigSiteOnContinent()
self:UnregisterEvent('PLAYER_ALIVE')
elseif ( event == 'CHAT_MSG_CURRENCY' ) then
if ( currentSkill < 100 ) then
core.UpdateSkill(hasArch)
end
core.UpdateArtifactWindow()
elseif ( event == 'ARTIFACT_UPDATE' ) then
core.UpdateSkill(hasArch)
core.UpdateProject()
core.UpdateArtifactWindow()
elseif ( event == 'ARTIFACT_DIG_SITE_UPDATED' ) then
core.FindDigSiteOnContinent()
elseif ( event == 'ZONE_CHANGED_NEW_AREA' ) then
core.FindDigSiteOnContinent()
elseif ( event == 'TAXIMAP_OPENED' ) then
core.FindDigSitesOnTaxiMap()
end
end)
end)
-- *********************************************************************************
local loader = CreateFrame('Frame')
loader:RegisterEvent('ADDON_LOADED')
loader:SetScript('OnEvent', function(self, event, addon)
if ( addon ~= 'PredatorArchy' ) then
return
end
local i, tmp
--[[
SAVED VARIABLES
]]
if ( not PredatorArchyOptions ) then
ctrl.SetDefaults()
else
if ( not PredatorArchyOptions.state ) then
PredatorArchyOptions.state = (PredatorArchyOptions.state and true) or false
end
if ( not PredatorArchyOptions.mode ) then
PredatorArchyOptions.mode = texts.mode_all
end
if ( not PredatorArchyOptions.customMode ) then
PredatorArchyOptions.customMode = {}
end
if ( not PredatorArchyOptions.alwaysShowRare ) then
PredatorArchyOptions.alwaysShowRare = (PredatorArchyOptions.alwaysShowRare and true) or false
end
if ( not PredatorArchyOptions.showMinimapButton ) then
PredatorArchyOptions.showMinimapButton = (PredatorArchyOptions.showMinimapButton and true) or false
end
if ( not PredatorArchyOptions.minimapButtonAngle ) then