-
Notifications
You must be signed in to change notification settings - Fork 1
/
GathererUI.lua
835 lines (719 loc) · 26.1 KB
/
GathererUI.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
--[[
GUI for Gatherer (by Islorgris, original idea and most of the base UI code came from bcui_TrackingMenu)
]]
-- Counter for fixed item count
fixedItemCount = 0;
gathererFixItems = 0;
-- Number of buttons for the menu defined in the XML file.
GathererUI_NUM_BUTTONS = 7;
-- Constants used in determining menu width/height.
GathererUI_BORDER_WIDTH = 15;
GathererUI_BUTTON_HEIGHT = 12;
GATHERERUI_SUBFRAMES = { "GathererUI_FiltersOptionsBorderFrame",
"GathererUI_GathererOptionsBorderFrame",
"GathererUI_DisplayOptionsBorderFrame" };
-- List of toggles to display.
GathererUI_QuickMenu = {
{name=GATHERER_TEXT_TOGGLE_MINIMAP, option="useMinimap"},
{name=GATHERER_TEXT_TOGGLE_MAINMAP, option="useMainmap"},
{name=GATHERER_TEXT_TOGGLE_HERBS, option="herbs"},
{name=GATHERER_TEXT_TOGGLE_MINERALS, option="mining"},
{name=GATHERER_TEXT_TOGGLE_TREASURE, option="treasure"},
{name=GATHERER_TEXT_TOGGLE_REPORT, option="report" },
{name=GATHERER_TEXT_TOGGLE_SEARCH, option="search" },
};
-- ******************************************************************
function GathererUI_OnLoad()
-- Create the slash commands to show/hide the menu.
SlashCmdList["GathererUI_SHOWMENU"] = GathererUI_ShowMenu;
SLASH_GathererUI_SHOWMENU1 = "/GathererUI_showmenu";
SlashCmdList["GathererUI_HIDEMENU"] = GathererUI_HideMenu;
SLASH_GathererUI_HIDEMENU1 = "/GathererUI_hidemenu";
-- Create the slash commands to show/hide the options window.
SlashCmdList["GathererUI_SHOWOPTIONS"] = GathererUI_ShowOptions;
SLASH_GathererUI_SHOWOPTIONS1 = "/GathererUI_showoptions";
SlashCmdList["GathererUI_HIDEOPTIONS"] = GathererUI_HideOptions;
SLASH_GathererUI_HIDEOPTIONS1 = "/GathererUI_hideoptions";
end
function GathererUI_OnEvent()
if ( event == "VARIABLES_LOADED" ) then
local playerName = UnitName("player");
if ((playerName) and (playerName ~= UNKNOWNOBJECT)) then Gather_Player = playerName; end;
GathererUI_InitializeOptions();
GathererUI_InitializeMenu();
return;
end
if ( event == "UNIT_NAME_UPDATE" ) then
if ((arg1) and (arg1 == "player")) then
local playerName = UnitName("player");
if ((playerName) and (playerName ~= UNKNOWNOBJECT)) then
Gather_Player = playerName;
GathererUI_InitializeMenu();
end
end
end
end
-- ***********************************************************
-- Tab selection code
function ToggleGathererUI_Dialog(tab)
local subFrame = getglobal(tab);
if ( subFrame ) then
PanelTemplates_SetTab(GathererUI_DialogFrame, subFrame:GetID());
if ( GathererUI_DialogFrame:IsVisible() ) then
PlaySound("igCharacterInfoTab");
GathererUI_DialogFrame_ShowSubFrame(tab);
else
GathererUI_DialogFrame:Show();
GathererUI_DialogFrame_ShowSubFrame(tab);
end
end
end
function GathererUI_DialogFrame_ShowSubFrame(frameName)
for index, value in GATHERERUI_SUBFRAMES do
if ( value == frameName ) then
getglobal(value):Show()
else
getglobal(value):Hide();
end
end
end
function GathererUIFrameTab_OnClick()
if ( this:GetName() == "GathererUI_DialogFrameTab1" ) then
ToggleGathererUI_Dialog("GathererUI_FiltersOptionsBorderFrame");
elseif ( this:GetName() == "GathererUI_DialogFrameTab2" ) then
ToggleGathererUI_Dialog("GathererUI_GathererOptionsBorderFrame");
elseif ( this:GetName() == "GathererUI_DialogFrameTab3" ) then
ToggleGathererUI_Dialog("GathererUI_DisplayOptionsBorderFrame");
end
PlaySound("igCharacterInfoTab");
end
-- ******************************************************************
function GathererUI_ShowMenu(x, y, anchor)
if (GathererUI_Popup:IsVisible()) then
GathererUI_Hide();
return;
end
if (not x or not y) then
-- Get the cursor position. Point is relative to the bottom left corner of the screen.
x, y = GetCursorPosition();
end
if (anchor == nil) then
anchor = "center";
end
-- Adjust for the UI scale.
x = x / UIParent:GetEffectiveScale();
y = y / UIParent:GetEffectiveScale();
-- Adjust for the height/width/anchor of the menu.
if (anchor == "topright") then
x = x - GathererUI_Popup:GetWidth();
y = y - GathererUI_Popup:GetHeight();
elseif (anchor == "topleft") then
y = y - GathererUI_Popup:GetHeight();
elseif (anchor == "bottomright") then
x = x - GathererUI_Popup:GetWidth();
elseif (anchor == "bottomleft") then
-- do nothing.
else
-- anchor is either "center" or not a valid value.
x = x - GathererUI_Popup:GetWidth() / 2;
y = y - GathererUI_Popup:GetHeight() / 2;
end
-- Clear the current anchor point, and set it to be centered under the mouse.
GathererUI_Popup:ClearAllPoints();
GathererUI_Popup:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", x, y);
GathererUI_Show();
end
-- ******************************************************************
function GathererUI_HideMenu()
GathererUI_Hide();
end
-- ******************************************************************
function GathererUI_InitializeOptions()
local SETTINGS = Gatherer_Settings;
if ( SETTINGS.showWorldMapFilters == 1 ) then
GathererWD_DropDownFilters:Show();
else
GathererWD_DropDownFilters:Hide();
end
if ( SETTINGS.disableWMFreezeWorkaround == 1 ) then
Gatherer_WorldMapDisplay:Show();
else
Gatherer_WorldMapDisplay:Hide();
end
if ( SETTINGS.useMainmap)
then
Gatherer_WorldMapDisplay:SetText("Hide Items");
GathererMapOverlayFrame:Show();
else
Gatherer_WorldMapDisplay:SetText("Show Items");
GathererMapOverlayFrame:Hide();
end
GathererHelp.currentPage = GathererHelp.currentPage or tonumber("1");
-- UI related
GathererUI_CheckShowOnMouse:SetChecked(SETTINGS.ShowOnMouse);
GathererUI_CheckHideOnMouse:SetChecked(SETTINGS.HideOnMouse);
GathererUI_CheckShowOnClick:SetChecked(SETTINGS.ShowOnClick);
GathererUI_CheckHideOnClick:SetChecked(SETTINGS.HideOnClick);
GathererUI_CheckHideIcon:SetChecked(SETTINGS.HideIcon);
GathererUI_CheckHideOnButton:SetChecked(SETTINGS.HideOnButton);
GathererUI_IconFrame:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", 52 - (SETTINGS.Radius * cos(SETTINGS.Position)), (SETTINGS.Radius * sin(SETTINGS.Position)) - 52);
-- Gatherer related
GathererUI_CheckNoMinIcon:SetChecked(SETTINGS.NoIconOnMinDist);
GathererUI_CheckRareOre:SetChecked(SETTINGS.rareOre);
GathererUI_CheckMapMinder:SetChecked(SETTINGS.mapMinder);
GathererUI_CheckHideMiniNotes:SetChecked(SETTINGS.HideMiniNotes);
GathererUI_CheckToggleWorldNotes:SetChecked(SETTINGS.ToggleWorldNotes);
GathererUI_CheckToggleWorldFilters:SetChecked(SETTINGS.showWorldMapFilters);
GathererUI_CheckHerbRecord:SetChecked(SETTINGS.filterRecording[1]);
GathererUI_CheckOreRecord:SetChecked(SETTINGS.filterRecording[2]);
GathererUI_CheckTreasureRecord:SetChecked(SETTINGS.filterRecording[0]);
GathererUI_CheckDisableWMFix:SetChecked(SETTINGS.disableWMFreezeWorkaround);
GathererUI_InitializeMenu();
end
-- ******************************************************************
function GathererUI_InitializeMenu()
GathererUI_IconFrame.haveAbilities = true;
if ( Gatherer_Settings and Gatherer_Settings.HideIcon and Gatherer_Settings.HideIcon == 1 ) then
GathererUI_IconFrame:Hide();
else
GathererUI_IconFrame:Show();
end
-- Set the text for the buttons while keeping track of how many
-- buttons we actually need.
local count = 0;
for quickoptionpos, quickoptiondata in GathererUI_QuickMenu do
quickoptions = quickoptiondata.name;
gathermap_id = quickoptiondata.option;
count = count + 1;
local button = getglobal("GathererUI_PopupButton"..count);
Gatherer_Value="none";
if ( gathermap_id =="useMinimap" ) then
Gatherer_Value = "off";
if (Gatherer_Settings.useMinimap) then Gatherer_Value = "on"; end
button.SpellID = "toggle"
elseif ( gathermap_id == "useMainmap" ) then
Gatherer_Value = "off";
if (Gatherer_Settings.useMainmap) then Gatherer_Value = "on"; end
button.SpellID = "mainmap toggle";
elseif ( gathermap_id == "report" ) then
button.SpellID = "report";
Gatherer_Value = "";
elseif ( gathermap_id == "search" ) then
button.SpellID = "search";
Gatherer_Value = "";
else
Gatherer_Value = Gatherer_GetFilterVal(gathermap_id);
button.SpellID = gathermap_id.." toggle";
end
if ( Gatherer_Value ~= "" ) then
button:SetText(quickoptions.."["..Gatherer_Value.."]");
else
button:SetText(quickoptions);
end
button:Show();
end
-- Set the width for the menu.
local width = GathererUI_TitleButton:GetWidth();
for i = 1, count do
width = math.max(width, getglobal("GathererUI_PopupButton"..i):GetTextWidth());
end
GathererUI_Popup:SetWidth(width + 2 * GathererUI_BORDER_WIDTH);
-- By default, the width of the button is set to the width of the text
-- on the button. Set the width of each button to the width of the
-- menu so that you can still click on it without being directly
-- over the text.
for i = 1, count do
getglobal("GathererUI_PopupButton"..i):SetWidth(width);
end
-- Hide the buttons we don't need.
for i = count + 1, GathererUI_NUM_BUTTONS do
getglobal("GathererUI_PopupButton"..i):Hide();
end
-- Set the height for the menu.
GathererUI_Popup:SetHeight(GathererUI_BUTTON_HEIGHT + ((count + 1) * GathererUI_BUTTON_HEIGHT) + (3 * GathererUI_BUTTON_HEIGHT));
end
-- ******************************************************************
function GathererUI_ButtonClick()
Gatherer_Command(this.SpellID);
GathererUI_InitializeMenu();
end
-- ******************************************************************
function GathererUI_Show()
-- Check to see if the aspect menu is shown. If so, hide it before
-- showing the tracking menu.
if (GathererUI_Popup and GathererUI_Popup:IsVisible()) then
GathererUI_Hide();
end
GathererUI_Popup:Show();
end
-- ******************************************************************
function GathererUI_Hide()
GathererUI_Popup:Hide();
end
-- ******************************************************************
function GathererUI_ShowOptions()
GathererUI_DialogFrame:Show();
-- ToggleGathererUI_Dialog(GATHERERUI_SUBFRAMES[PanelTemplates_GetSelectedTab(GathererUI_DialogFrame)]);
end
-- ******************************************************************
function GathererUI_HideOptions()
GathererUI_DialogFrame:Hide();
end
-- ******************************************************************
function GathererUI_OnUpdate(dummy)
-- Check to see if the mouse is still over the menu or the icon.
if (Gatherer_Settings.HideOnMouse == 1 and GathererUI_Popup:IsVisible()) then
if (not MouseIsOver(GathererUI_Popup) and not MouseIsOver(GathererUI_IconFrame)) then
-- If not, hide the menu.
GathererUI_Hide();
end
end
end
-- ******************************************************************
function GathererUI_IconFrameOnEnter()
-- Set the anchor point of the menu so it shows up next to the icon.
GathererUI_Popup:ClearAllPoints();
GathererUI_Popup:SetPoint("TOPRIGHT", "GathererUI_IconFrame", "TOPLEFT");
-- Show the menu.
if (Gatherer_Settings.ShowOnMouse == 1) then
GathererUI_Show();
end
end
-- ******************************************************************
function GathererUI_IconFrameOnClick()
if (GathererUI_Popup:IsVisible()) then
if (Gatherer_Settings.HideOnClick == 1) then
GathererUI_Hide();
end
else
if (Gatherer_Settings.ShowOnClick == 1) then
GathererUI_Show();
end
end
end
-- ******************************************************************
function GathererUIDropDownTheme_Initialize()
for value in Gather_IconSet do
local info = {};
info.text = value;
info.checked = nil;
info.func = GathererUIDropDownTheme_OnClick;
UIDropDownMenu_AddButton(info);
if (Gatherer_Settings.iconSet == info.text) then
UIDropDownMenu_SetText(info.text, GathererUI_DropDownTheme);
end
end
end
function GathererUIDropDownHerbs_Initialize()
local filterValue = "herbs";
local iconIndex = 1;
local dropDownText = "Herbs";
GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDownOre_Initialize()
local filterValue = "mining";
local iconIndex = 2;
local dropDownText = "Ore";
GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDownTreasure_Initialize()
local filterValue = "treasure";
local iconIndex = 0;
local dropDownText = "Treasure";
GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText)
local varMenuVal1, varMenuVal2;
local value = Gatherer_GetFilterVal(filterValue);
if ( value == "on" ) then
varMenuVal1 = NORMAL_FONT_COLOR_CODE.."auto".."|r";
varMenuVal2 = NORMAL_FONT_COLOR_CODE.."off".."|r";
elseif ( value == "off" ) then
varMenuVal1 = NORMAL_FONT_COLOR_CODE.."auto".."|r";
varMenuVal2 = NORMAL_FONT_COLOR_CODE.."on".."|r";
else
varMenuVal1 = NORMAL_FONT_COLOR_CODE.."on".."|r";
varMenuVal2 = NORMAL_FONT_COLOR_CODE.."off".."|r";
end
UIDropDownMenu_SetText(Gatherer_GetMenuName(value), getglobal("GathererUI_DropDown"..dropDownText));
local itemWithRareMatch = {};
local rareItem = {};
for iconName, rareMatch in Gather_RareMatch do
if (Gather_DB_IconIndex[iconIndex][iconName]) then
itemWithRareMatch[iconName] = rareMatch;
rareItem[rareMatch] = iconName;
end
end
if ( itemWithRareMatch[UIDROPDOWNMENU_MENU_VALUE] ) then
GathererUIDropDownSub_Initialize(UIDROPDOWNMENU_MENU_VALUE, iconIndex, dropDownText);
return;
end
local gathererFilters = {varMenuVal1, varMenuVal2};
for iconName in Gather_DB_IconIndex[iconIndex] do
if (iconName ~= "default" and not rareItem[iconName]) then
tinsert(gathererFilters, iconName);
end
end
table.sort(gathererFilters, function (a, b)
local aSkillLevel = Gather_SkillLevel[a] or 0;
local bSkillLevel = Gather_SkillLevel[b] or 0;
if (strfind(a, "on|r") or strfind(a, "off|r") or strfind(a, "auto|r")) then
aSkillLevel = -1;
end
if (strfind(b, "on|r") or strfind(b, "off|r") or strfind(b, "auto|r")) then
bSkillLevel = -1;
end
return string.format("%03d%s", aSkillLevel, a) < string.format("%03d%s", bSkillLevel, b);
end);
for index, value in gathererFilters do
local info = {};
info.text = Gatherer_GetMenuName(value);
info.value = value;
info.checked = nil;
if (itemWithRareMatch[value]) then
info.hasArrow = 1;
info.func = nil;
else
info.hasArrow = nil;
info.func = getglobal("GathererUIDropDownFilter"..dropDownText.."_OnClick");
end
if (string.find(value, "on|r")) then info.value = "on"; end
if (string.find(value, "off|r")) then info.value = "off"; end
if (string.find(value, "auto|r")) then info.value = "auto"; end
if ( index > 2 and Gatherer_Settings) then
info.keepShownOnClick = 1;
if ( Gatherer_Settings.interested[iconIndex][value] ) then
info.checked = 1;
end
info.textR = 1;
info.textG = 1;
info.textB = 1;
else
info.textR = 1;
info.textG = 1;
info.textB = 255;
info.checked = nil;
end
UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
end
end
function GathererUIDropDownSub_Initialize(rareItem, iconIndex, dropDownText)
if (not dropDownText) then
if (iconIndex == 1) then
dropDownText = "Herbs";
elseif (iconIndex == 2) then
dropDownText = "Ore";
elseif (iconIndex == 0) then
dropDownText = "Treasure";
end
end
for index, value in {rareItem, Gather_RareMatch[rareItem]} do
local info = {};
info.text = Gatherer_GetMenuName(value);
info.value = value;
info.checked = nil;
info.func = getglobal("GathererUIDropDownFilter"..dropDownText.."_OnClick");
info.keepShownOnClick = 1;
if ( Gatherer_Settings.interested[iconIndex][value] ) then
info.checked = 1;
end
info.textR = 1;
info.textG = 1;
info.textB = 1;
UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
end
end
-- World Map functions
-- World Map filters dropdown Load
function Gatherer_WorldMapFilter_Load()
UIDropDownMenu_SetText(GATHERER_FILTERDM_TEXT, GathererWD_DropDownFilters);
if ( UIDROPDOWNMENU_MENU_VALUE == "Herb" ) then
GathererUIDropDownHerbs_Initialize();
return;
elseif ( UIDROPDOWNMENU_MENU_VALUE == "Ore" ) then
GathererUIDropDownOre_Initialize();
return;
elseif ( UIDROPDOWNMENU_MENU_VALUE == "Treasure" ) then
GathererUIDropDownTreasure_Initialize();
return;
elseif( Gather_RareMatch[UIDROPDOWNMENU_MENU_VALUE] ) then
for iconIndex in Gather_DB_IconIndex do
if (Gather_DB_IconIndex[iconIndex][UIDROPDOWNMENU_MENU_VALUE]) then
GathererUIDropDownSub_Initialize(UIDROPDOWNMENU_MENU_VALUE, iconIndex);
break;
end
end
return;
end
local info = {};
info.text = GATHERER_TEXT_TOGGLE_HERBS.."["..Gatherer_GetFilterVal("herbs").."]";
info.value = "Herb"
info.hasArrow = 1;
info.func = nil;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
local info = {};
info.text = GATHERER_TEXT_TOGGLE_MINERALS.."["..Gatherer_GetFilterVal("mining").."]";
info.value = "Ore"
info.hasArrow = 1;
info.func = nil;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
local info = {};
info.text = GATHERER_TEXT_TOGGLE_TREASURE.."["..Gatherer_GetFilterVal("treasure").."]";
info.value = "Treasure"
info.hasArrow = 1;
info.func = nil;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
end
-- ******************************************************************
function GathererUIDropDownTheme_OnClick()
UIDropDownMenu_SetSelectedID(GathererUI_DropDownTheme, this:GetID());
local cmd = UIDropDownMenu_GetText(GathererUI_DropDownTheme);
Gatherer_Command("theme "..cmd);
end
function GathererUIDropDownFilterHerbs_OnClick()
local filterValue = "herbs";
local iconIndex = 1;
local dropDownText = "Herbs";
GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDownFilterOre_OnClick()
local filterValue = "mining";
local iconIndex = 2;
local dropDownText = "Ore";
GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDownFilterTreasure_OnClick()
local filterValue = "treasure";
local iconIndex = 0;
local dropDownText = "Treasure";
GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
end
function GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText)
if ( this:GetID() < 3 and (this.value == "on" or this.value == "off" or this.value == "auto")) then
UIDropDownMenu_SetText(Gatherer_GetMenuName(this.value), getglobal("GathererUI_DropDown"..dropDownText));
Gatherer_Command(filterValue.." "..this.value);
GathererUI_InitializeMenu();
else
Gatherer_Settings.interested[iconIndex][this.value] = not this.checked;
end
GatherMain_Draw();
end
function GathererUI_OnEnterPressed_HerbSkillEditBox()
if ( GathererUI_HerbSkillEditBox:GetNumber() > 300 ) then
GathererUI_HerbSkillEditBox:SetNumber(300);
end
if ( GathererUI_HerbSkillEditBox:GetNumber() < 0 ) then
GathererUI_HerbSkillEditBox:SetNumber(0);
end
Gatherer_Settings.minSetHerbSkill = GathererUI_HerbSkillEditBox:GetNumber();
end
function GathererUI_OnEnterPressed_OreSkillEditBox()
if ( GathererUI_OreSkillEditBox:GetNumber() > 300 ) then
GathererUI_OreSkillEditBox:SetNumber(300);
end
if ( GathererUI_OreSkillEditBox:GetNumber() < 0 ) then
GathererUI_OreSkillEditBox:SetNumber(0);
end
Gatherer_Settings.minSetOreSkill = GathererUI_OreSkillEditBox:GetNumber();
end
function GathererUI_OnEnterPressed_IconSizeEditBox()
if ( GathererUI_WorldMapIconSize:GetNumber() < 8 or GathererUI_WorldMapIconSize:GetNumber() > 16 ) then
if ( Gatherer_Settings.IconSize ) then
GathererUI_WorldMapIconSize:SetNumber(Gatherer_Settings.IconSize)
else
GathererUI_WorldMapIconSize:SetNumber(12);
end
end
Gatherer_Settings.IconSize = GathererUI_WorldMapIconSize:GetNumber();
end
function GathererUI_OnEnterPressed_IconAlphaEditBox()
if ( GathererUI_WorldMapIconAlpha:GetNumber() < 20 or GathererUI_WorldMapIconAlpha:GetNumber() > 100 ) then
if ( Gatherer_Settings.IconAlpha ) then
GathererUI_WorldMapIconAlpha:SetNumber(Gatherer_Settings.IconAlpha/100)
else
GathererUI_WorldMapIconAlpha:SetNumber(80);
end
end
Gatherer_Settings.IconAlpha = GathererUI_WorldMapIconAlpha:GetNumber();
end
-- *******************************************************************
-- Zone Rematch Section: Handle with care
function GathererUI_ZoneRematch(sourceZoneMapping, destZoneMapping)
local zone_swap=0;
local new_idx_z, gatherType;
NewGatherItems = {}
fixedItemCount = 0;
Gatherer_ChatPrint(GATHERER_TEXT_APPLY_REMATCH.." "..sourceZoneMapping.." -> "..destZoneMapping);
for idx_c, rec_continent in GatherItems do
if (idx_c ~= 0) then NewGatherItems[idx_c]= {}; end
for idx_z, rec_zone in rec_continent do
if ( idx_c ~= 0 and idx_z ~= 0) then
new_idx_z= GathererUI_ZoneMatchTable[sourceZoneMapping][destZoneMapping][idx_c][idx_z];
if ( idx_z ~= new_idx_z ) then zone_swap = zone_swap + 1; end;
NewGatherItems[idx_c][new_idx_z] = {};
for myItems, rec_gatheritem in rec_zone do
local fixedItemName;
if (gathererFixItems == 1) then
fixedItemName = GathererUI_FixItemName(myItems);
else
fixedItemName= myItems;
end
NewGatherItems[idx_c][new_idx_z][fixedItemName] = {};
for idx_item, myGather in rec_gatheritem do
local myGatherType, myIcon;
if ( type(myGather.gtype) == "number" ) then
myGatherType = myGather.gtype;
else
myGatherType = Gatherer_EGatherType[myGather.gtype];
end
if ( type(myGather.icon) == "number" ) then
myIcon= myGather.icon;
else
myIcon= Gatherer_GetDB_IconIndex(myGather.icon, myGatherType);
end
-- convertion of rich thorium veins to new format
if ( myGatherType == 2 and myIcon == 8 ) then
myIcon = Gatherer_GetDB_IconIndex(Gatherer_FindOreType(fixedItemName), myGatherType);
end
NewGatherItems[idx_c][new_idx_z][fixedItemName][idx_item] = { x=myGather.x, y=myGather.y, gtype=myGatherType, icon=myIcon, count=myGather.count };
fixedItemCount = fixedItemCount + 1;
end
end
end
end
end
Gatherer_ChatPrint("Zone swapping completed ("..zone_swap.." done, "..fixedItemCount.." items accounted for).")
end
-- *******************************************************************
-- Zone Match UI functions
function GathererUI_ShowRematchDialog()
if ( GathererUI_ZoneRematchDialog:IsVisible() ) then
GathererUI_ZoneRematchDialog:Hide()
GathererUI_DestinationZoneDropDown:Hide();
else
GathererUI_ZoneRematchDialog:Show()
end
end
-- *******************************************************************
-- DropDown Menu functions
function GathererUIDropDownSourceZone_Initialize()
for index in GathererUI_ZoneMatchTable do
local info = {};
info.text = index;
info.checked = nil;
info.func = GathererUIDropDownFilterSourceZone_OnClick;
UIDropDownMenu_AddButton(info);
if ( Gatherer_Settings.DataBuild and Gatherer_Settings.DataBuild == info.text ) then
UIDropDownMenu_SetText(info.text, GathererUI_SourceZoneDropDown);
end
end
end
function GathererUIDropDownDestionationZone_Initialize()
local cmd = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
if ( cmd and cmd ~= "" ) then
for index in GathererUI_ZoneMatchTable[cmd] do
local info = {};
info.text = index;
info.checked = nil;
info.func = GathererUIDropDownFilterDestinationZone_OnClick;
UIDropDownMenu_AddButton(info);
end
end
end
-- *******************************************************************
-- OnClick in DropDown Menu functions
function GathererUIDropDownFilterSourceZone_OnClick()
UIDropDownMenu_SetSelectedID(GathererUI_SourceZoneDropDown, this:GetID());
GathererUI_DestinationZoneDropDown:Show();
end
function GathererUIDropDownFilterDestinationZone_OnClick()
UIDropDownMenu_SetSelectedID(GathererUI_DestinationZoneDropDown, this:GetID());
end
-- *******************************************************************
-- Apply Button
function GathererUI_ShowRematchDialogApply()
local source, dest
source = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
dest = UIDropDownMenu_GetText(GathererUI_DestinationZoneDropDown);
if( source and dest ) then
-- hide Option dialog (since the position of the confirmation dialog can cause miss-click on stuff in there)
GathererUI_HideOptions()
-- add extra confirmation dialog
StaticPopup_Show("CONFIRM_REMATCH");
elseif ( not source ) then
Gatherer_ChatPrint(GATHERER_TEXT_SRCZONE_MISSING);
else
Gatherer_ChatPrint(GATHERER_TEXT_DESTZONE_MISSING);
end
end
StaticPopupDialogs["CONFIRM_REMATCH"] = {
text = TEXT(GATHERER_TEXT_CONFIRM_REMATCH),
button1 = TEXT(ACCEPT),
button2 = TEXT(DECLINE),
OnAccept = function()
Gatherer_ConfirmZoneRematch();
end,
timeout = 60,
showAlert = 1,
};
function Gatherer_ConfirmZoneRematch()
local source = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
local dest = UIDropDownMenu_GetText(GathererUI_DestinationZoneDropDown);
-- Swap tables and Recompute notes
GathererUI_ZoneRematch(source, dest);
GatherItems = NewGatherItems;
Gatherer_Settings.DataBuild = dest;
GathererUI_ShowRematchDialog();
end
-- **************************************************************************
-- Help Page functions.
-- Update the help
function GathererUI_HelpFrame_Update()
-- Check if an addon is selected
GathererUI_HelpFrameName:SetText("Gatherer Help");
local help = GathererHelp;
local currentPage = help.currentPage;
local totalPages = 9;
GathererUI_HelpFrameHelp:SetText(help[currentPage]);
GathererUI_HelpFramePage:SetText("Page "..currentPage.."/"..totalPages);
GathererUI_HelpFrame_UpdateButtons()
end
-- Enable/Disable the help buttons
function GathererUI_HelpFrame_UpdateButtons()
-- Get the help
local help = GathererHelp;
-- Check if there is an help
local currentPage = help.currentPage;
local totalPages = 9;
-- Check if the current help page is the first one
if (currentPage == 1) then
GathererUI_HelpFramePrevPageButton:Disable();
else
GathererUI_HelpFramePrevPageButton:Enable();
end
-- Check if the current help page is the last one
if (currentPage == totalPages) then
GathererUI_HelpFrameNextPageButton:Disable();
else
GathererUI_HelpFrameNextPageButton:Enable();
end
end
-- Help previous page OnClick event
function GathererUI_HelpFramePrevPageButton_OnClick()
-- Set the current page to previous page
local help = GathererHelp;
help.currentPage = help.currentPage - 1;
-- Update the help
GathererUI_HelpFrame_Update()
end
-- Help next page OnClick event
function GathererUI_HelpFrameNextPageButton_OnClick()
-- Set the current page to next page
local help = GathererHelp;
help.currentPage = help.currentPage + 1;
-- Update the help
GathererUI_HelpFrame_Update();
end