-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathArh.lua
1902 lines (1744 loc) · 65.2 KB
/
Arh.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 addonName, vars = ...
local L = vars.L
Arh = {}
local addon = Arh
addon.vars = vars
vars.svnrev = vars.svnrev or {}
local svnrev = vars.svnrev
svnrev["Arh.lua"] = tonumber(("$Revision: 107 $"):match("%d+"))
local Config = nil -- AceConfig-3.0
local minimapIcon = LibStub("LibDBIcon-1.0")
local LDB, LDBo
local cfg = nil
local ARH_GREEN = 1
local ARH_YELLOW = 2
local ARH_RED = 3
local id2cname = {
[ARH_GREEN] = "Green",
[ARH_YELLOW] = "Yellow",
[ARH_RED] = "Red",
}
local id2rgb = {
[ARH_GREEN] = { 0, 1, 0 },
[ARH_YELLOW] = { 0.5, 0.5, 0 },
[ARH_RED] = { 1, 0, 0 },
}
addon.colorButton = {}
local CONYARDS = {[ARH_GREEN] = 40, [ARH_YELLOW] = 80, [ARH_RED] = 640}
local minimap_size =
{
indoor =
{
[0] = 300, -- scale
[1] = 240, -- 1.25
[2] = 180, -- 5/3
[3] = 120, -- 2.5
[4] = 80, -- 3.75
[5] = 50, -- 6
},
outdoor =
{
[0] = 466 + 2/3, -- scale
[1] = 400, -- 7/6
[2] = 333 + 1/3, -- 1.4
[3] = 266 + 2/6, -- 1.75
[4] = 200, -- 7/3
[5] = 133 + 1/3, -- 3.5
},
}
local minimap_scale =
{
indoor =
{
[0] = 1,
[1] = 1.25,
[2] = 5/3,
[3] = 2.5,
[4] = 3.75,
[5] = 6,
},
outdoor =
{
[0] = 1,
[1] = 7/6,
[2] = 1.4,
[3] = 1.75,
[4] = 7/3,
[5] = 3.5,
},
}
local function CopyByValue(t)
if type(t) ~= "table" then return t end
local t2 = {}
for k,v in pairs(t) do
t2[CopyByValue(k)] = CopyByValue(v)
end
return t2
end
local function GetNewestStructure(old, new)
if new == nil then return nil end
if old == nil then return CopyByValue(new) end -- field added
if type(old) ~= type(new) then return CopyByValue(new) end -- structure changed
if type(old) ~= "table" then return old end -- same structure, using old value
local t = {}
for k,v in pairs(new) do -- using new structure
t[CopyByValue(k)] = GetNewestStructure(old[k], v)
end
return t
end
local function SetVisible(self, visible)
if visible then
self:Show()
else
self:Hide()
end
end
local SOUND_SHOWMAINFRAME = 567529 --"Sound\\interface\\uMiniMapOpen.ogg"
local SOUND_HIDEMAINFRAME = 567515 --"Sound\\interface\\uMiniMapClose.ogg"
local SOUND_ADDCON = 567481 --"Sound\\Interface\\iUiInterfaceButtonA.ogg"
local SOUND_SHOWCOLOR = 569839 --"Sound\\Universal\\TomeUnSheath.ogg"
local SOUND_HIDECOLOR = 569842 --"Sound\\Universal\\TomeSheath.ogg"
local SOUND_BACK = 567573 --"Sound\\interface\\PickUp\\PickUpMeat.ogg"
--local SOUND_GATHERING = "Sound\\interface\\PickUp\\PickUpMeat.wav"
local function PlaySound(soundfile)
if cfg.MainFrame.PlaySounds then
PlaySoundFile(soundfile)
end
end
local function ArchyShown()
return Archy and Archy.db and Archy.db.profile and Archy.db.profile.general and Archy.db.profile.general.show
end
local function ArchyUpdate()
local shown = ArchyShown()
if addon.archy_state == shown then return end -- no change
addon.archy_state = shown
local follow = cfg and cfg.MainFrame and cfg.MainFrame.FollowArchy
if not follow then return end -- disabled
addon:ToggleMainFrame(shown)
end
function addon:HookArchy()
if Archy and Archy.ConfigUpdated and not addon.archy_hooked then
hooksecurefunc(Archy, "ConfigUpdated", ArchyUpdate)
addon.archy_hooked = true
addon.archy_state = ArchyShown()
end
end
local function DigsiteUpdate(self, elapsed)
if InCombatLockdown() then return end
local shown = CanScanResearchSite()
local follow = cfg and cfg.MainFrame and cfg.MainFrame.FollowDigsite
if follow and not cfg.MainFrame.Visible ~= not shown then
addon:ToggleMainFrame(shown)
end
end
addon.hiddenFrame = CreateFrame("Button", "ArhHiddenFrame", UIParent)
addon.hiddenFrame:SetScript("OnUpdate",DigsiteUpdate)
function addon:ToggleMainFrame(enable)
if enable ~= nil then
cfg.MainFrame.Visible = enable
else
cfg.MainFrame.Visible = not Arh_MainFrame:IsVisible()
end
if not InCombatLockdown() then SetVisible(Arh_MainFrame, cfg.MainFrame.Visible) end
addon:ToggleHUD(cfg.MainFrame.Visible)
if cfg.MainFrame.Visible then
PlaySound(SOUND_SHOWMAINFRAME)
else
PlaySound(SOUND_HIDEMAINFRAME)
end
end
function addon:ToggleHUD(enable)
if enable ~= nil then
cfg.HUD.Visible = enable
else
cfg.HUD.Visible = not Arh_HudFrame:IsVisible()
end
Arh_MainFrame_ButtonDig.Canceled = not cfg.HUD.Visible
SetVisible(Arh_MainFrame_ButtonDig.CanceledTexture, not cfg.HUD.Visible)
SetVisible(Arh_HudFrame, cfg.HUD.Visible)
addon.suppress = false -- manual override disables suppression
--[[
if cfg.HUD.Visible then
PlaySound(SOUND_SHOWMAINFRAME)
else
PlaySound(SOUND_HIDEMAINFRAME)
end
--]]
end
function addon:CheckSuppress()
local shouldsuppress = false
if UnitIsGhost("player") or
UnitInBattleground("player") or
UnitInVehicle("player") or
IsInInstance() or
(C_PetBattles and C_PetBattles.IsInBattle()) or -- in pet battle
not select(3,GetProfessions()) -- lacks archaeology
then
shouldsuppress = true
elseif cfg.MainFrame.HideCombat and (InCombatLockdown() or UnitAffectingCombat("player") or UnitAffectingCombat("pet")) then
shouldsuppress = true
elseif cfg.MainFrame.HideResting and IsResting() then
shouldsuppress = true
end
if shouldsuppress and not addon.suppress then -- begin suppress
if not InCombatLockdown() then SetVisible(Arh_MainFrame, false) end
SetVisible(Arh_HudFrame, false)
addon.suppress = true
elseif not shouldsuppress and addon.suppress then -- end suppress
if not InCombatLockdown() then SetVisible(Arh_MainFrame, cfg.MainFrame.Visible) end
SetVisible(Arh_HudFrame, cfg.HUD.Visible)
addon.suppress = false
end
end
function addon:Config()
if Settings and Settings.OpenToCategory then
Settings.OpenToCategory(addonName)
else
InterfaceOptionsFrame_OpenToCategory(addonName)
end
end
function addon:ToggleArch()
if not C_AddOns.IsAddOnLoaded("Blizzard_ArchaeologyUI") then
local loaded, reason = C_AddOns.LoadAddOn("Blizzard_ArchaeologyUI")
if not loaded then return end
end
if ArchaeologyFrame:IsShown() then
HideUIPanel(ArchaeologyFrame)
else
ShowUIPanel(ArchaeologyFrame)
end
end
local function cs(str)
return "|cffffff78"..str.."|r"
end
Arh_DefaultConfig =
{
MainFrame =
{
Visible = true,
FollowArchy = true,
FollowDigsite = true,
HideCombat = true,
HideResting = true,
Locked = false,
Scale = 1,
Alpha = 1,
ShowTooltips = true,
TooltipsScale = 1,
PlaySounds = true,
MountGreen = false,
MountYellow = true,
MountRed = true,
posX = 0,
posY = 0,
point = "CENTER",
},
HUD =
{
Visible = true,
UseGatherMate2 = true,
Scale = 1,
Alpha = 1,
PosX = 0,
PosY = 0,
ShowArrow = true,
ArrowScale = 1,
ArrowAlpha = 1,
ArchOnly = true,
ShowSuccessCircle = true,
SuccessCircleColor = {r=1, g=0, b=0, a=1},
ShowCompass = false,
CompassRadius = 120,
CompassColor = {r=0, g=1, b=0, a=0.5},
CompassTextColor = {r=0, g=1, b=0, a=0.5},
RedSectAlpha = 0.1,
RedLineAlpha = 0.05,
YellowSectAlpha = 0.1,
YellowLineAlpha = 0.2,
GreenSectAlpha = 0.1,
GreenLineAlpha = 0.2,
},
DigSites =
{
ShowOnBattlefieldMinimap = true,
},
Minimap =
{
hide = false,
minimapPos = 0,
},
}
-- label bindings
BINDING_HEADER_ARH = L["Archaeology Helper"]
local bindings = {
{ name="Dig:Left", desc=L["Cast Survey"], },
{ name="SHOWARCH", desc=L["Open archaeology window"] },
{ name="TOGGLEMAIN", desc=L["Show/Hide the Main Window"], alias="t" },
{ name="TOGGLEHUD", desc=L["Show/Hide the HUD"], alias="h" },
{ name="Back:Left", desc=L["Remove one previously added area"], alias="b", order=-1 },
}
for _,color in ipairs(id2cname) do
local c = color:lower():sub(1,1)
table.insert(bindings, { name=color..":Left", desc=L["Add %s area to the HUD"]:format(L[color:lower()]), alias="a"..c })
table.insert(bindings, { name=color..":Right", desc=L["Show/Hide all %s areas"]:format(L[color:lower()]), alias="t"..c })
end
for _, info in ipairs(bindings) do
local bindname
if info.name:find(":") then
info.bindname = string.format("CLICK Arh_MainFrame_Button%sButton",info.name)
else
info.bindname = string.format("ARH_%s",info.name)
end
_G["BINDING_NAME_"..info.bindname] = info.desc
end
function addon:ResetSettings()
local c
-- MainFrame
SetVisible(Arh_MainFrame, cfg.MainFrame.Visible)
Arh_MainFrame:SetScale(cfg.MainFrame.Scale)
Arh_MainFrame:SetAlpha(cfg.MainFrame.Alpha)
Arh_MainFrame:ClearAllPoints()
Arh_MainFrame:SetPoint("CENTER")
-- HUD
Arh_SetUseGatherMate2(cfg.HUD.UseGatherMate2)
addon:HUD_config_update()
Arh_UpdateHudFrameSizes(true)
-- Annulus Sectors
addon:UpdateAlphaEverything()
addon:ToggleHUD(cfg.HUD.Visible)
-- Dig Sites
SetVisible(Arh_ArchaeologyDigSites_BattlefieldMinimap, cfg.DigSites.ShowOnBattlefieldMinimap)
end
-- return current value of minimap arch tracking
function addon:GetDigsiteTracking()
local id, active
for i=1,C_Minimap.GetNumTrackingTypes() do
local trackingInfo = C_Minimap.GetTrackingInfo(i)
if trackingInfo["name"]:find("Track Digsites") then
id = i
active = a
break
end
end
return active, id
end
-- set minimap arch tracking and return the old enabled value
function addon:SetDigsiteTracking(on)
local active, id = addon:GetDigsiteTracking()
if id then
C_Minimap.SetTracking(id, on)
end
return active
end
local OptionsTable =
{
type = "group",
args =
{
ResetToDefaults =
{
order = 1,
name = L["Reset All Settings"],
desc = L["Resets all settings to defaults"],
type = "execute",
confirm = true,
confirmText = L["This will overwrite current settings!"],
func =
function()
Arh_Config = CopyByValue(Arh_DefaultConfig)
cfg = Arh_Config
addon:ResetSettings()
end,
},
MainFrame =
{
order = 2,
name = L["Main Window"],
desc = L["Main window settings"],
type = "group",
get = function(info)
return cfg.MainFrame[info[#info]]
end,
set = function(info, value)
cfg.MainFrame[info[#info]] = value
end,
args =
{
VisualOptions =
{
order = 1,
type = "group",
name = L["Visual Settings"],
inline = true,
args =
{
reset =
{
order = 1,
name = L["Reset Position"],
desc = L["Resets window position to the center of the screen"],
type = "execute",
width = "full",
confirm = true,
confirmText = L["This will reset Main Window position"],
func =
function()
Arh_MainFrame:ClearAllPoints()
Arh_MainFrame:SetPoint("CENTER")
end,
},
Visible =
{
order = 2,
name = L["Visible"],
desc = L["Whether window is visible"],
type = "toggle",
set = function(info, val)
addon:ToggleMainFrame(val)
end,
disabled = function(info) return cfg.MainFrame.FollowDigsite end,
},
FollowArchy =
{
order = 2.5,
name = L["Toggle with Archy"],
desc = L["Show/Hide window when you show/hide Archy addon"],
type = "toggle",
disabled = function(info) return not Archy or cfg.MainFrame.FollowDigsite end,
},
FollowDigsite =
{
order = 1.9,
name = L["Toggle with digsite"],
desc = L["Show/Hide window when entering/leaving a digsite"],
type = "toggle",
},
HideCombat =
{
order = 2.7,
name = L["Hide on combat"],
desc = L["Hide on combat"],
type = "toggle",
},
HideResting =
{
order = 2.9,
name = L["Hide when resting"],
desc = L["Hide when resting"],
type = "toggle",
},
Locked =
{
order = 3,
name = L["Locked"],
desc = L["Locks window to prevent accidental repositioning"],
type = "toggle",
set = function(info, val)
cfg.MainFrame.Locked = val
end,
},
minimap = {
order = 3.5,
name = L["Minimap Icon"],
desc = L["Display minimap icon"],
type = "toggle",
set = function(info,val)
cfg.Minimap.hide = not val
minimapIcon:Refresh(addonName)
end,
get = function() return not cfg.Minimap.hide end,
},
Scale =
{
order = 4,
name = L["Scaling"],
desc = L["Size of the main window"],
type = "range",
min = 0.1,
max = 100,
softMin = 0.5,
softMax = 5,
step = 0.1,
set =
function(info, val)
cfg.MainFrame.Scale = val
Arh_MainFrame:SetScale(val)
end,
},
Alpha =
{
order = 5,
name = L["Alpha"],
desc = L["How transparent is window"],
type = "range",
min = 0,
max = 1,
step = 0.01,
isPercent = true,
set =
function(info, val)
cfg.MainFrame.Alpha = val
Arh_MainFrame:SetAlpha(val)
end,
},
ShowTooltips =
{
order = 6,
name = L["Show Tooltips"],
desc = L["Show Tooltips in the main window"],
type = "toggle",
},
TooltipsScale =
{
order = 7,
name = L["Tooltips Scaling"],
desc = L["Scale main window Tooltips"],
type = "range",
min = 0.10,
max = 3.00,
step = 0.05,
isPercent = true,
disabled = function(info) return not cfg.MainFrame.ShowTooltips end,
set =
function(info, val)
cfg.MainFrame.TooltipsScale = val
Arh_Tooltip:SetScale(val)
end,
},
},
},
MiscOptions =
{
order = 2,
type = "group",
name = L["Misc Settings"],
inline = true,
args = (function()
local ret = {}
ret.PlaySounds = {
order = 1,
name = L["Play Sounds"],
desc = L["Play confirmation sounds for various actions"],
type = "toggle",
}
for id,cname in ipairs(id2cname) do
ret["Mount"..cname] = {
order = 10+id,
name = L["Mount %s"]:format(L[cname:lower()]),
desc = L["Automatically mount when adding this color to the HUD"],
type = "toggle",
set = function(info, value)
cfg.MainFrame[info[#info]] = value
addon:init_travelform()
end,
}
end
return ret
end)(),
},
},
},
KeyBindings = {
order = 3.5,
type = "group",
name = KEY_BINDINGS,
get = function(info)
return GetBindingKey(info.arg)
end,
set = function(info, key)
local action = info.arg
if key == "" then
oldkey = GetBindingKey(action)
if oldkey then
SetBinding(oldkey, nil)
end
else
SetBinding(key, action)
end
SaveBindings(GetCurrentBindingSet())
end,
args = (function()
local ret = {}
for i,info in ipairs(bindings) do
ret[info.name] = {
order = info.order or i,
width = "full",
type = "keybinding",
name = info.desc,
arg = info.bindname,
desc = info.alias and string.format(L["You can also use %s command for this action"],
string.format("|cff69ccf0/arh %s|r", info.alias))
or info.desc,
}
end
return ret
end)(),
},
HUD =
{
order = 3,
name = L["HUD"],
desc = L["HUD settings"],
type = "group",
args =
{
General =
{
order = 1,
type = "group",
name = L["General HUD Settings"],
inline = true,
get = function(info) return cfg.HUD[info[#info]] end,
set = function(info,val)
cfg.HUD[info[#info]] = val
addon:HUD_config_update()
end,
args = {
ShowGatherMate2 = {
order = 1,
name = L["Show GatherMate2 pins on the HUD (recomended)"],
desc = L["Redirect GatherMate2 output to the HUD when visible"],
type = "toggle",
width = "full",
disabled = function(info) return not GatherMate2 end,
get = function(info) return cfg.HUD.UseGatherMate2 end,
set = function(info,val) Arh_SetUseGatherMate2(val) end,
},
ArchOnly = {
order = 1.5,
name = L["Arch nodes only"],
desc = L["Only show Archaeology nodes from GatherMate2 on the HUD"],
type = "toggle",
width = "full",
set = function(info,val)
cfg.HUD.ArchOnly = val
addon:ToggleHUD();addon:ToggleHUD()
end,
disabled = function(info) return not cfg.HUD.UseGatherMate2 end,
},
Scale = {
order = 2,
name = L["HUD Scaling"],
desc = L["Size of the HUD\nIf you need ZOOM - use Minimap ZOOM instead"],
type = "range",
min = 0.1,
max = 100,
softMin = 0.1,
softMax = 3,
step = 0.1,
},
Alpha = {
order = 3,
name = L["HUD Alpha"],
desc = L["How transparent is HUD"],
type = "range",
min = 0,
max = 1,
step = 0.01,
isPercent = true,
},
PosX = {
order = 3,
name = L["HUD X-Offset"],
desc = L["Horizontal position of HUD relative to screen center"],
type = "range",
min = -0.5,
max = 0.5,
step = 0.01,
isPercent = true,
},
PosY = {
order = 3,
name = L["HUD Y-Offset"],
desc = L["Vertical position of HUD relative to screen center"],
type = "range",
min = -0.5,
max = 0.5,
step = 0.01,
isPercent = true,
},
ShowArrow = {
order = 4,
name = L["Show Player Arrow"],
desc = L["Draw arrow in the center of the HUD"],
type = "toggle",
width = "full",
},
ArrowScale = {
order = 5,
name = L["Arrow Scaling"],
desc = L["Size of the Player Arrow"],
type = "range",
disabled = function(info) return not cfg.HUD.ShowArrow end,
min = 0.1,
max = 100,
softMin = 0.1,
softMax = 10,
step = 0.1,
},
ArrowAlpha = {
order = 6,
name = L["Arrow Alpha"],
desc = L["How transparent is Player Arrow"],
type = "range",
disabled = function(info) return not cfg.HUD.ShowArrow end,
min = 0,
max = 1,
step = 0.01,
isPercent = true,
},
ShowSuccessCircle = {
order = 7,
name = L["Show Success Circle"],
desc = L["Survey will succeed if fragment lies within this circle"],
type = "toggle",
},
SuccessCircleColor = {
order = 8,
name = L["Success Circle Color"],
desc = L["Color of the Success Circle (you can also set alpha here)"],
type = "color",
hasAlpha = true,
disabled = function(info) return not cfg.HUD.ShowSuccessCircle end,
get =
function(info)
local c = cfg.HUD.SuccessCircleColor
return c.r, c.g, c.b, c.a
end,
set =
function(info, r, g, b, a)
local c = cfg.HUD.SuccessCircleColor
c.r, c.g, c.b, c.a = r, g, b, a
addon:HUD_config_update()
end,
},
},
},
Compass =
{
order = 2,
type = "group",
name = L["Compass Settings"],
inline = true,
args =
{
ShowCompass =
{
order = 1,
name = L["Show compass"],
desc = L["Draw compass-like circle on the HUD"],
type = "toggle",
get = function(info) return cfg.HUD.ShowCompass end,
set =
function(info,val)
cfg.HUD.ShowCompass = val
addon:HUD_config_update()
end,
},
CompassRadius =
{
order = 2,
name = L["Radius (yards)"],
desc = L["Radius of the compass circle"],
type = "range",
disabled = function(info) return not cfg.HUD.ShowCompass end,
min = 1,
max = 1000,
softMin = 10,
softMax = 300,
step = 1,
get = function(info) return cfg.HUD.CompassRadius end,
set =
function(info,val)
cfg.HUD.CompassRadius = val
Arh_UpdateHudFrameSizes(true)
end,
},
CompassColor =
{
order = 3,
name = L["Compass Circle Color"],
desc = L["Color of the Compass Circle (you can also set alpha here)"],
type = "color",
hasAlpha = true,
disabled = function(info) return not cfg.HUD.ShowCompass end,
get =
function(info)
local c = cfg.HUD.CompassColor
return c.r, c.g, c.b, c.a
end,
set =
function(info, r, g, b, a)
local c = cfg.HUD.CompassColor
c.r, c.g, c.b, c.a = r, g, b, a
addon:HUD_config_update()
end,
},
CompassTextColor =
{
order = 4,
name = L["Direction Marks Color"],
desc = L["Color of Compass Direction Marks (you can also set alpha here)"],
type = "color",
hasAlpha = true,
disabled = function(info) return not cfg.HUD.ShowCompass end,
get =
function(info)
local c = cfg.HUD.CompassTextColor
return c.r, c.g, c.b, c.a
end,
set =
function(info, r, g, b, a)
local c = cfg.HUD.CompassTextColor
c.r, c.g, c.b, c.a = r, g, b, a
addon:HUD_config_update()
end,
},
},
},
AnnulusSectors =
{
order = 3,
type = "group",
name = L["Annulus Sectors Settings"],
inline = true,
get = function(info) return cfg.HUD[info[#info]] end,
set = function(info,val)
cfg.HUD[info[#info]] = val
addon:UpdateAlphaEverything()
end,
args = (function()
local ret = {}
for id,cname in ipairs(id2cname) do
ret[cname.."SectAlpha"] = {
order = id*2,
name = L["%s Sector Alpha"]:format(L[cname]),
desc = L["How transparent is %s Annulus Sector"]:format(L[cname]),
type = "range",
min = 0,
max = 1,
step = 0.01,
isPercent = true,
}
ret[cname.."LineAlpha"] = {
order = id*2+1,
name = L["%s Line Alpha"]:format(L[cname]),
desc = L["How transparent is %s Direction Line"]:format(L[cname]),
type = "range",
min = 0,
max = 1,
step = 0.01,
isPercent = true,
}
end
return ret
end)()
},
},
},
DigSites =
{
order = 4,
name = L["Dig Sites"],
desc = L["Dig Sites"],
type = "group",
args =
{
ShowOnBattlefieldMinimap =
{
order = 1,
name = L["Show digsites on the Battlefield Minimap"],
desc = L["Use |cff69ccf0Shift-M|r to open or hide Battlefield Minimap"],
type = "toggle",
width = "full",
get = function(info) return cfg.DigSites.ShowOnBattlefieldMinimap end,
set =
function(info,val)
cfg.DigSites.ShowOnBattlefieldMinimap = val
SetVisible(Arh_ArchaeologyDigSites_BattlefieldMinimap, val)
end,
},
ShowOnMinimap =
{
order = 2,
name = L["Show digsites on the Minimap"],
desc = string.format(L["You can also use %s command for this action"],"|cff69ccf0/arh mm|r"),
type = "toggle",
width = "full",
get = function(info) return addon:GetDigsiteTracking() end,
set = function(info,val) addon:SetDigsiteTracking(val) end,
},
},
},
}
}
function Arh_ShowTooltip(self)
if not cfg.MainFrame.ShowTooltips then return end
if not self.TooltipText then return end
local text
if type(self.TooltipText)=="string" then
text = self.TooltipText
elseif type(self.TooltipText)=="function" then
text = self.TooltipText(self)
if not text then return end
end
Arh_Tooltip:SetScale(cfg.MainFrame.TooltipsScale)
Arh_Tooltip:SetOwner(self, "ANCHOR_CURSOR")
Arh_Tooltip:AddLine(text, 1, 1, 1)
Arh_Tooltip:Show()
end
function Arh_HideTooltip(self)
Arh_Tooltip:Hide()
end
local function SetTooltips()
Arh_MainFrame.TooltipText =
function(self)
if cfg.MainFrame.Locked then
return cs(L["Right Click"])..": "..L["Show/Hide Config"]
else
return cs(L["Left Click"])..": "..L["move window"].."\n"..cs(L["Right Click"])..": "..L["Show/Hide Config"]
end
end
for id, button in ipairs(addon.colorButton) do
local cname = id2cname[id]:lower()
button.TooltipText = cs(L["Left Click"])..": "..L["add new %s zone to the HUD"]:format(L[cname]).."\n"..
cs(L["Right Click"])..": "..L["show/hide all %s areas on the HUD"]:format(L[cname])
end
Arh_MainFrame_ButtonDig.TooltipText = cs(L["Left Click"])..": "..L["cast Survey"].."\n"..
cs(L["Right Click"])..": "..L["Show/Hide the HUD"].."\n"..
cs(L["Middle Click"])..": "..L["Open archaeology window"]
Arh_MainFrame_ButtonBack.TooltipText = cs(L["Left Click"])..": "..L["remove one previously added area"]
end
local function RotateTexture(item, angle)
--item.texture:SetRotation(angle)
--item.texture_line:SetRotation(angle)
local cos, sin = math.cos(angle), math.sin(angle)
local p, m = (sin+cos)/2, (sin-cos)/2
local pp, pm, mp, mm = 0.5+p, 0.5+m, 0.5-p, 0.5-m
item.texture:SetTexCoord(pm, mp, mp, mm, pp, pm, mm, pp)
item.texture_line:SetTexCoord(pm, mp, mp, mm, pp, pm, mm, pp)
end
local function CreateConTexture(parent, color)
local t = parent:CreateTexture()
t:SetBlendMode("ADD")
t:SetPoint("CENTER", parent, "CENTER", 0, 0)
t:SetTexture("Interface\\AddOns\\Arh\\img\\con1024_"..color)
t:Show()
return t
end
local function CreateLineTexture(parent, contexture, color)
local t = parent:CreateTexture()
t:SetBlendMode("ADD")
t:SetPoint("CENTER", contexture, "CENTER", 0, 0)
t:SetTexture("Interface\\AddOns\\Arh\\img\\line1024_"..color)
t:Show()
return t
end
local function SetTextureColor(texture, color, isline)
local r,g,b = unpack(id2rgb[color])
local a = cfg.HUD[string.format("%s%sAlpha",id2cname[color],(isline and "Line" or "Sect"))]
texture:SetVertexColor(r,g,b,a)
end
local function PixelsInYardOnHud_Calc()
local mapSizePix = Arh_HudFrame:GetHeight()
local zoom = Minimap:GetZoom()
--local indoors = GetCVar("minimapZoom")+0 == Minimap:GetZoom() and "outdoor" or "indoor"
local indoors = IsIndoors() and "indoor" or "outdoor"
local mapSizeYards = minimap_size[indoors][zoom]
return mapSizePix/mapSizeYards
end
local PixelsInYardOnHud = -1