vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 GUI for Gatherer (by Islorgris, original idea and most of the base UI code came from bcui_TrackingMenu)
3 ]]
4  
5 -- Counter for fixed item count
6 fixedItemCount = 0;
7 gathererFixItems = 0;
8  
9 -- Number of buttons for the menu defined in the XML file.
10 GathererUI_NUM_BUTTONS = 7;
11  
12 -- Constants used in determining menu width/height.
13 GathererUI_BORDER_WIDTH = 15;
14 GathererUI_BUTTON_HEIGHT = 12;
15 GATHERERUI_SUBFRAMES = { "GathererUI_FiltersOptionsBorderFrame",
16 "GathererUI_GathererOptionsBorderFrame",
17 "GathererUI_DisplayOptionsBorderFrame" };
18  
19 -- List of toggles to display.
20 GathererUI_QuickMenu = {
21 {name=GATHERER_TEXT_TOGGLE_MINIMAP, option="useMinimap"},
22 {name=GATHERER_TEXT_TOGGLE_MAINMAP, option="useMainmap"},
23 {name=GATHERER_TEXT_TOGGLE_HERBS, option="herbs"},
24 {name=GATHERER_TEXT_TOGGLE_MINERALS, option="mining"},
25 {name=GATHERER_TEXT_TOGGLE_TREASURE, option="treasure"},
26 {name=GATHERER_TEXT_TOGGLE_REPORT, option="report" },
27 {name=GATHERER_TEXT_TOGGLE_SEARCH, option="search" },
28 };
29  
30  
31 -- ******************************************************************
32 function GathererUI_OnLoad()
33 -- Create the slash commands to show/hide the menu.
34 SlashCmdList["GathererUI_SHOWMENU"] = GathererUI_ShowMenu;
35 SLASH_GathererUI_SHOWMENU1 = "/GathererUI_showmenu";
36 SlashCmdList["GathererUI_HIDEMENU"] = GathererUI_HideMenu;
37 SLASH_GathererUI_HIDEMENU1 = "/GathererUI_hidemenu";
38  
39 -- Create the slash commands to show/hide the options window.
40 SlashCmdList["GathererUI_SHOWOPTIONS"] = GathererUI_ShowOptions;
41 SLASH_GathererUI_SHOWOPTIONS1 = "/GathererUI_showoptions";
42 SlashCmdList["GathererUI_HIDEOPTIONS"] = GathererUI_HideOptions;
43 SLASH_GathererUI_HIDEOPTIONS1 = "/GathererUI_hideoptions";
44 end
45  
46 function GathererUI_OnEvent()
47 if ( event == "VARIABLES_LOADED" ) then
48 local playerName = UnitName("player");
49 if ((playerName) and (playerName ~= UNKNOWNOBJECT)) then Gather_Player = playerName; end;
50 GathererUI_InitializeOptions();
51 GathererUI_InitializeMenu();
52 return;
53 end
54 if ( event == "UNIT_NAME_UPDATE" ) then
55 if ((arg1) and (arg1 == "player")) then
56 local playerName = UnitName("player");
57 if ((playerName) and (playerName ~= UNKNOWNOBJECT)) then
58 Gather_Player = playerName;
59 GathererUI_InitializeMenu();
60 end
61 end
62 end
63 end
64  
65 -- ***********************************************************
66 -- Tab selection code
67 function ToggleGathererUI_Dialog(tab)
68 local subFrame = getglobal(tab);
69 if ( subFrame ) then
70 PanelTemplates_SetTab(GathererUI_DialogFrame, subFrame:GetID());
71 if ( GathererUI_DialogFrame:IsVisible() ) then
72 PlaySound("igCharacterInfoTab");
73 GathererUI_DialogFrame_ShowSubFrame(tab);
74 else
75 GathererUI_DialogFrame:Show();
76 GathererUI_DialogFrame_ShowSubFrame(tab);
77 end
78 end
79 end
80  
81 function GathererUI_DialogFrame_ShowSubFrame(frameName)
82 for index, value in GATHERERUI_SUBFRAMES do
83 if ( value == frameName ) then
84 getglobal(value):Show()
85 else
86 getglobal(value):Hide();
87 end
88 end
89 end
90 function GathererUIFrameTab_OnClick()
91 if ( this:GetName() == "GathererUI_DialogFrameTab1" ) then
92 ToggleGathererUI_Dialog("GathererUI_FiltersOptionsBorderFrame");
93 elseif ( this:GetName() == "GathererUI_DialogFrameTab2" ) then
94 ToggleGathererUI_Dialog("GathererUI_GathererOptionsBorderFrame");
95 elseif ( this:GetName() == "GathererUI_DialogFrameTab3" ) then
96 ToggleGathererUI_Dialog("GathererUI_DisplayOptionsBorderFrame");
97 end
98 PlaySound("igCharacterInfoTab");
99 end
100  
101 -- ******************************************************************
102 function GathererUI_ShowMenu(x, y, anchor)
103 if (GathererUI_Popup:IsVisible()) then
104 GathererUI_Hide();
105 return;
106 end
107  
108 if (not x or not y) then
109 -- Get the cursor position. Point is relative to the bottom left corner of the screen.
110 x, y = GetCursorPosition();
111 end
112  
113 if (anchor == nil) then
114 anchor = "center";
115 end
116  
117 -- Adjust for the UI scale.
118 x = x / UIParent:GetEffectiveScale();
119 y = y / UIParent:GetEffectiveScale();
120  
121 -- Adjust for the height/width/anchor of the menu.
122 if (anchor == "topright") then
123 x = x - GathererUI_Popup:GetWidth();
124 y = y - GathererUI_Popup:GetHeight();
125 elseif (anchor == "topleft") then
126 y = y - GathererUI_Popup:GetHeight();
127 elseif (anchor == "bottomright") then
128 x = x - GathererUI_Popup:GetWidth();
129 elseif (anchor == "bottomleft") then
130 -- do nothing.
131 else
132 -- anchor is either "center" or not a valid value.
133 x = x - GathererUI_Popup:GetWidth() / 2;
134 y = y - GathererUI_Popup:GetHeight() / 2;
135 end
136  
137 -- Clear the current anchor point, and set it to be centered under the mouse.
138 GathererUI_Popup:ClearAllPoints();
139 GathererUI_Popup:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", x, y);
140 GathererUI_Show();
141 end
142  
143 -- ******************************************************************
144 function GathererUI_HideMenu()
145 GathererUI_Hide();
146 end
147  
148 -- ******************************************************************
149 function GathererUI_InitializeOptions()
150 local SETTINGS = Gatherer_Settings;
151  
152 if ( SETTINGS.showWorldMapFilters == 1 ) then
153 GathererWD_DropDownFilters:Show();
154 else
155 GathererWD_DropDownFilters:Hide();
156 end
157  
158 if ( SETTINGS.disableWMFreezeWorkaround == 1 ) then
159 Gatherer_WorldMapDisplay:Show();
160 else
161 Gatherer_WorldMapDisplay:Hide();
162 end
163  
164 if ( SETTINGS.useMainmap)
165 then
166 Gatherer_WorldMapDisplay:SetText("Hide Items");
167 GathererMapOverlayFrame:Show();
168 else
169 Gatherer_WorldMapDisplay:SetText("Show Items");
170 GathererMapOverlayFrame:Hide();
171 end
172  
173 GathererHelp.currentPage = GathererHelp.currentPage or tonumber("1");
174  
175 -- UI related
176 GathererUI_CheckShowOnMouse:SetChecked(SETTINGS.ShowOnMouse);
177 GathererUI_CheckHideOnMouse:SetChecked(SETTINGS.HideOnMouse);
178 GathererUI_CheckShowOnClick:SetChecked(SETTINGS.ShowOnClick);
179 GathererUI_CheckHideOnClick:SetChecked(SETTINGS.HideOnClick);
180 GathererUI_CheckHideIcon:SetChecked(SETTINGS.HideIcon);
181 GathererUI_CheckHideOnButton:SetChecked(SETTINGS.HideOnButton);
182 GathererUI_IconFrame:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", 52 - (SETTINGS.Radius * cos(SETTINGS.Position)), (SETTINGS.Radius * sin(SETTINGS.Position)) - 52);
183  
184 -- Gatherer related
185 GathererUI_CheckNoMinIcon:SetChecked(SETTINGS.NoIconOnMinDist);
186 GathererUI_CheckRareOre:SetChecked(SETTINGS.rareOre);
187 GathererUI_CheckMapMinder:SetChecked(SETTINGS.mapMinder);
188 GathererUI_CheckHideMiniNotes:SetChecked(SETTINGS.HideMiniNotes);
189 GathererUI_CheckToggleWorldNotes:SetChecked(SETTINGS.ToggleWorldNotes);
190 GathererUI_CheckToggleWorldFilters:SetChecked(SETTINGS.showWorldMapFilters);
191 GathererUI_CheckHerbRecord:SetChecked(SETTINGS.filterRecording[1]);
192 GathererUI_CheckOreRecord:SetChecked(SETTINGS.filterRecording[2]);
193 GathererUI_CheckTreasureRecord:SetChecked(SETTINGS.filterRecording[0]);
194 GathererUI_CheckDisableWMFix:SetChecked(SETTINGS.disableWMFreezeWorkaround);
195  
196 GathererUI_InitializeMenu();
197 end
198  
199 -- ******************************************************************
200 function GathererUI_InitializeMenu()
201  
202 GathererUI_IconFrame.haveAbilities = true;
203  
204 if ( Gatherer_Settings and Gatherer_Settings.HideIcon and Gatherer_Settings.HideIcon == 1 ) then
205 GathererUI_IconFrame:Hide();
206 else
207 GathererUI_IconFrame:Show();
208 end
209  
210  
211 -- Set the text for the buttons while keeping track of how many
212 -- buttons we actually need.
213 local count = 0;
214 for quickoptionpos, quickoptiondata in GathererUI_QuickMenu do
215 quickoptions = quickoptiondata.name;
216 gathermap_id = quickoptiondata.option;
217 count = count + 1;
218 local button = getglobal("GathererUI_PopupButton"..count);
219 Gatherer_Value="none";
220 if ( gathermap_id =="useMinimap" ) then
221 Gatherer_Value = "off";
222 if (Gatherer_Settings.useMinimap) then Gatherer_Value = "on"; end
223 button.SpellID = "toggle"
224 elseif ( gathermap_id == "useMainmap" ) then
225 Gatherer_Value = "off";
226 if (Gatherer_Settings.useMainmap) then Gatherer_Value = "on"; end
227 button.SpellID = "mainmap toggle";
228 elseif ( gathermap_id == "report" ) then
229 button.SpellID = "report";
230 Gatherer_Value = "";
231 elseif ( gathermap_id == "search" ) then
232 button.SpellID = "search";
233 Gatherer_Value = "";
234 else
235 Gatherer_Value = Gatherer_GetFilterVal(gathermap_id);
236 button.SpellID = gathermap_id.." toggle";
237 end
238  
239 if ( Gatherer_Value ~= "" ) then
240 button:SetText(quickoptions.."["..Gatherer_Value.."]");
241 else
242 button:SetText(quickoptions);
243 end
244 button:Show();
245 end
246  
247 -- Set the width for the menu.
248 local width = GathererUI_TitleButton:GetWidth();
249 for i = 1, count do
250 width = math.max(width, getglobal("GathererUI_PopupButton"..i):GetTextWidth());
251 end
252 GathererUI_Popup:SetWidth(width + 2 * GathererUI_BORDER_WIDTH);
253  
254 -- By default, the width of the button is set to the width of the text
255 -- on the button. Set the width of each button to the width of the
256 -- menu so that you can still click on it without being directly
257 -- over the text.
258 for i = 1, count do
259 getglobal("GathererUI_PopupButton"..i):SetWidth(width);
260 end
261  
262 -- Hide the buttons we don't need.
263 for i = count + 1, GathererUI_NUM_BUTTONS do
264 getglobal("GathererUI_PopupButton"..i):Hide();
265 end
266  
267 -- Set the height for the menu.
268 GathererUI_Popup:SetHeight(GathererUI_BUTTON_HEIGHT + ((count + 1) * GathererUI_BUTTON_HEIGHT) + (3 * GathererUI_BUTTON_HEIGHT));
269 end
270  
271 -- ******************************************************************
272 function GathererUI_ButtonClick()
273 Gatherer_Command(this.SpellID);
274 GathererUI_InitializeMenu();
275 end
276  
277 -- ******************************************************************
278 function GathererUI_Show()
279 -- Check to see if the aspect menu is shown. If so, hide it before
280 -- showing the tracking menu.
281 if (GathererUI_Popup and GathererUI_Popup:IsVisible()) then
282 GathererUI_Hide();
283 end
284  
285 GathererUI_Popup:Show();
286 end
287  
288 -- ******************************************************************
289 function GathererUI_Hide()
290 GathererUI_Popup:Hide();
291 end
292  
293 -- ******************************************************************
294 function GathererUI_ShowOptions()
295 GathererUI_DialogFrame:Show();
296 -- ToggleGathererUI_Dialog(GATHERERUI_SUBFRAMES[PanelTemplates_GetSelectedTab(GathererUI_DialogFrame)]);
297 end
298  
299 -- ******************************************************************
300 function GathererUI_HideOptions()
301 GathererUI_DialogFrame:Hide();
302 end
303  
304 -- ******************************************************************
305 function GathererUI_OnUpdate(dummy)
306 -- Check to see if the mouse is still over the menu or the icon.
307 if (Gatherer_Settings.HideOnMouse == 1 and GathererUI_Popup:IsVisible()) then
308 if (not MouseIsOver(GathererUI_Popup) and not MouseIsOver(GathererUI_IconFrame)) then
309 -- If not, hide the menu.
310 GathererUI_Hide();
311 end
312 end
313 end
314  
315 -- ******************************************************************
316 function GathererUI_IconFrameOnEnter()
317 -- Set the anchor point of the menu so it shows up next to the icon.
318 GathererUI_Popup:ClearAllPoints();
319 GathererUI_Popup:SetPoint("TOPRIGHT", "GathererUI_IconFrame", "TOPLEFT");
320  
321 -- Show the menu.
322 if (Gatherer_Settings.ShowOnMouse == 1) then
323 GathererUI_Show();
324 end
325 end
326  
327 -- ******************************************************************
328 function GathererUI_IconFrameOnClick()
329 if (GathererUI_Popup:IsVisible()) then
330 if (Gatherer_Settings.HideOnClick == 1) then
331 GathererUI_Hide();
332 end
333 else
334 if (Gatherer_Settings.ShowOnClick == 1) then
335 GathererUI_Show();
336 end
337 end
338 end
339  
340 -- ******************************************************************
341 function GathererUIDropDownTheme_Initialize()
342 for value in Gather_IconSet do
343 local info = {};
344 info.text = value;
345 info.checked = nil;
346 info.func = GathererUIDropDownTheme_OnClick;
347 UIDropDownMenu_AddButton(info);
348 if (Gatherer_Settings.iconSet == info.text) then
349 UIDropDownMenu_SetText(info.text, GathererUI_DropDownTheme);
350 end
351 end
352 end
353  
354 function GathererUIDropDownHerbs_Initialize()
355 local filterValue = "herbs";
356 local iconIndex = 1;
357 local dropDownText = "Herbs";
358 GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
359 end
360  
361 function GathererUIDropDownOre_Initialize()
362 local filterValue = "mining";
363 local iconIndex = 2;
364 local dropDownText = "Ore";
365 GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
366 end
367  
368 function GathererUIDropDownTreasure_Initialize()
369 local filterValue = "treasure";
370 local iconIndex = 0;
371 local dropDownText = "Treasure";
372 GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText);
373 end
374  
375 function GathererUIDropDown_Initialize(filterValue, iconIndex, dropDownText)
376 local varMenuVal1, varMenuVal2;
377 local value = Gatherer_GetFilterVal(filterValue);
378 if ( value == "on" ) then
379 varMenuVal1 = NORMAL_FONT_COLOR_CODE.."auto".."|r";
380 varMenuVal2 = NORMAL_FONT_COLOR_CODE.."off".."|r";
381 elseif ( value == "off" ) then
382 varMenuVal1 = NORMAL_FONT_COLOR_CODE.."auto".."|r";
383 varMenuVal2 = NORMAL_FONT_COLOR_CODE.."on".."|r";
384 else
385 varMenuVal1 = NORMAL_FONT_COLOR_CODE.."on".."|r";
386 varMenuVal2 = NORMAL_FONT_COLOR_CODE.."off".."|r";
387 end
388 UIDropDownMenu_SetText(Gatherer_GetMenuName(value), getglobal("GathererUI_DropDown"..dropDownText));
389  
390 local itemWithRareMatch = {};
391 local rareItem = {};
392 for iconName, rareMatch in Gather_RareMatch do
393 if (Gather_DB_IconIndex[iconIndex][iconName]) then
394 itemWithRareMatch[iconName] = rareMatch;
395 rareItem[rareMatch] = iconName;
396 end
397 end
398  
399 if ( itemWithRareMatch[UIDROPDOWNMENU_MENU_VALUE] ) then
400 GathererUIDropDownSub_Initialize(UIDROPDOWNMENU_MENU_VALUE, iconIndex, dropDownText);
401 return;
402 end
403  
404 local gathererFilters = {varMenuVal1, varMenuVal2};
405 for iconName in Gather_DB_IconIndex[iconIndex] do
406 if (iconName ~= "default" and not rareItem[iconName]) then
407 tinsert(gathererFilters, iconName);
408 end
409 end
410  
411 table.sort(gathererFilters, function (a, b)
412 local aSkillLevel = Gather_SkillLevel[a] or 0;
413 local bSkillLevel = Gather_SkillLevel[b] or 0;
414 if (strfind(a, "on|r") or strfind(a, "off|r") or strfind(a, "auto|r")) then
415 aSkillLevel = -1;
416 end
417 if (strfind(b, "on|r") or strfind(b, "off|r") or strfind(b, "auto|r")) then
418 bSkillLevel = -1;
419 end
420 return string.format("%03d%s", aSkillLevel, a) < string.format("%03d%s", bSkillLevel, b);
421 end);
422  
423  
424 for index, value in gathererFilters do
425 local info = {};
426 info.text = Gatherer_GetMenuName(value);
427 info.value = value;
428 info.checked = nil;
429 if (itemWithRareMatch[value]) then
430 info.hasArrow = 1;
431 info.func = nil;
432 else
433 info.hasArrow = nil;
434 info.func = getglobal("GathererUIDropDownFilter"..dropDownText.."_OnClick");
435 end
436  
437 if (string.find(value, "on|r")) then info.value = "on"; end
438 if (string.find(value, "off|r")) then info.value = "off"; end
439 if (string.find(value, "auto|r")) then info.value = "auto"; end
440  
441 if ( index > 2 and Gatherer_Settings) then
442 info.keepShownOnClick = 1;
443  
444 if ( Gatherer_Settings.interested[iconIndex][value] ) then
445 info.checked = 1;
446 end
447 info.textR = 1;
448 info.textG = 1;
449 info.textB = 1;
450 else
451 info.textR = 1;
452 info.textG = 1;
453 info.textB = 255;
454 info.checked = nil;
455 end
456  
457 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
458 end
459 end
460  
461 function GathererUIDropDownSub_Initialize(rareItem, iconIndex, dropDownText)
462 if (not dropDownText) then
463 if (iconIndex == 1) then
464 dropDownText = "Herbs";
465 elseif (iconIndex == 2) then
466 dropDownText = "Ore";
467 elseif (iconIndex == 0) then
468 dropDownText = "Treasure";
469 end
470 end
471  
472 for index, value in {rareItem, Gather_RareMatch[rareItem]} do
473 local info = {};
474 info.text = Gatherer_GetMenuName(value);
475 info.value = value;
476 info.checked = nil;
477 info.func = getglobal("GathererUIDropDownFilter"..dropDownText.."_OnClick");
478  
479 info.keepShownOnClick = 1;
480 if ( Gatherer_Settings.interested[iconIndex][value] ) then
481 info.checked = 1;
482 end
483 info.textR = 1;
484 info.textG = 1;
485 info.textB = 1;
486  
487 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL);
488 end
489 end
490  
491 -- World Map functions
492 -- World Map filters dropdown Load
493 function Gatherer_WorldMapFilter_Load()
494 UIDropDownMenu_SetText(GATHERER_FILTERDM_TEXT, GathererWD_DropDownFilters);
495  
496 if ( UIDROPDOWNMENU_MENU_VALUE == "Herb" ) then
497 GathererUIDropDownHerbs_Initialize();
498 return;
499 elseif ( UIDROPDOWNMENU_MENU_VALUE == "Ore" ) then
500 GathererUIDropDownOre_Initialize();
501 return;
502 elseif ( UIDROPDOWNMENU_MENU_VALUE == "Treasure" ) then
503 GathererUIDropDownTreasure_Initialize();
504 return;
505 elseif( Gather_RareMatch[UIDROPDOWNMENU_MENU_VALUE] ) then
506 for iconIndex in Gather_DB_IconIndex do
507 if (Gather_DB_IconIndex[iconIndex][UIDROPDOWNMENU_MENU_VALUE]) then
508 GathererUIDropDownSub_Initialize(UIDROPDOWNMENU_MENU_VALUE, iconIndex);
509 break;
510 end
511 end
512  
513 return;
514 end
515  
516  
517 local info = {};
518 info.text = GATHERER_TEXT_TOGGLE_HERBS.."["..Gatherer_GetFilterVal("herbs").."]";
519 info.value = "Herb"
520 info.hasArrow = 1;
521 info.func = nil;
522 info.notCheckable = 1;
523 UIDropDownMenu_AddButton(info);
524  
525 local info = {};
526 info.text = GATHERER_TEXT_TOGGLE_MINERALS.."["..Gatherer_GetFilterVal("mining").."]";
527 info.value = "Ore"
528 info.hasArrow = 1;
529 info.func = nil;
530 info.notCheckable = 1;
531 UIDropDownMenu_AddButton(info);
532  
533 local info = {};
534 info.text = GATHERER_TEXT_TOGGLE_TREASURE.."["..Gatherer_GetFilterVal("treasure").."]";
535 info.value = "Treasure"
536 info.hasArrow = 1;
537 info.func = nil;
538 info.notCheckable = 1;
539 UIDropDownMenu_AddButton(info);
540 end
541  
542 -- ******************************************************************
543 function GathererUIDropDownTheme_OnClick()
544 UIDropDownMenu_SetSelectedID(GathererUI_DropDownTheme, this:GetID());
545 local cmd = UIDropDownMenu_GetText(GathererUI_DropDownTheme);
546 Gatherer_Command("theme "..cmd);
547 end
548  
549 function GathererUIDropDownFilterHerbs_OnClick()
550 local filterValue = "herbs";
551 local iconIndex = 1;
552 local dropDownText = "Herbs";
553 GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
554 end
555  
556 function GathererUIDropDownFilterOre_OnClick()
557 local filterValue = "mining";
558 local iconIndex = 2;
559 local dropDownText = "Ore";
560 GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
561 end
562  
563 function GathererUIDropDownFilterTreasure_OnClick()
564 local filterValue = "treasure";
565 local iconIndex = 0;
566 local dropDownText = "Treasure";
567 GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText);
568 end
569  
570 function GathererUIDropDownFilter_OnClick(filterValue, iconIndex, dropDownText)
571 if ( this:GetID() < 3 and (this.value == "on" or this.value == "off" or this.value == "auto")) then
572 UIDropDownMenu_SetText(Gatherer_GetMenuName(this.value), getglobal("GathererUI_DropDown"..dropDownText));
573  
574 Gatherer_Command(filterValue.." "..this.value);
575 GathererUI_InitializeMenu();
576 else
577 Gatherer_Settings.interested[iconIndex][this.value] = not this.checked;
578 end
579 GatherMain_Draw();
580 end
581  
582 function GathererUI_OnEnterPressed_HerbSkillEditBox()
583 if ( GathererUI_HerbSkillEditBox:GetNumber() > 300 ) then
584 GathererUI_HerbSkillEditBox:SetNumber(300);
585 end
586 if ( GathererUI_HerbSkillEditBox:GetNumber() < 0 ) then
587 GathererUI_HerbSkillEditBox:SetNumber(0);
588 end
589  
590 Gatherer_Settings.minSetHerbSkill = GathererUI_HerbSkillEditBox:GetNumber();
591 end
592  
593 function GathererUI_OnEnterPressed_OreSkillEditBox()
594 if ( GathererUI_OreSkillEditBox:GetNumber() > 300 ) then
595 GathererUI_OreSkillEditBox:SetNumber(300);
596 end
597 if ( GathererUI_OreSkillEditBox:GetNumber() < 0 ) then
598 GathererUI_OreSkillEditBox:SetNumber(0);
599 end
600 Gatherer_Settings.minSetOreSkill = GathererUI_OreSkillEditBox:GetNumber();
601 end
602  
603 function GathererUI_OnEnterPressed_IconSizeEditBox()
604 if ( GathererUI_WorldMapIconSize:GetNumber() < 8 or GathererUI_WorldMapIconSize:GetNumber() > 16 ) then
605 if ( Gatherer_Settings.IconSize ) then
606 GathererUI_WorldMapIconSize:SetNumber(Gatherer_Settings.IconSize)
607 else
608 GathererUI_WorldMapIconSize:SetNumber(12);
609 end
610 end
611 Gatherer_Settings.IconSize = GathererUI_WorldMapIconSize:GetNumber();
612 end
613  
614 function GathererUI_OnEnterPressed_IconAlphaEditBox()
615 if ( GathererUI_WorldMapIconAlpha:GetNumber() < 20 or GathererUI_WorldMapIconAlpha:GetNumber() > 100 ) then
616 if ( Gatherer_Settings.IconAlpha ) then
617 GathererUI_WorldMapIconAlpha:SetNumber(Gatherer_Settings.IconAlpha/100)
618 else
619 GathererUI_WorldMapIconAlpha:SetNumber(80);
620 end
621 end
622 Gatherer_Settings.IconAlpha = GathererUI_WorldMapIconAlpha:GetNumber();
623 end
624  
625 -- *******************************************************************
626 -- Zone Rematch Section: Handle with care
627  
628 function GathererUI_ZoneRematch(sourceZoneMapping, destZoneMapping)
629 local zone_swap=0;
630 local new_idx_z, gatherType;
631 NewGatherItems = {}
632 fixedItemCount = 0;
633  
634 Gatherer_ChatPrint(GATHERER_TEXT_APPLY_REMATCH.." "..sourceZoneMapping.." -> "..destZoneMapping);
635  
636 for idx_c, rec_continent in GatherItems do
637 if (idx_c ~= 0) then NewGatherItems[idx_c]= {}; end
638 for idx_z, rec_zone in rec_continent do
639 if ( idx_c ~= 0 and idx_z ~= 0) then
640 new_idx_z= GathererUI_ZoneMatchTable[sourceZoneMapping][destZoneMapping][idx_c][idx_z];
641 if ( idx_z ~= new_idx_z ) then zone_swap = zone_swap + 1; end;
642  
643 NewGatherItems[idx_c][new_idx_z] = {};
644 for myItems, rec_gatheritem in rec_zone do
645 local fixedItemName;
646 if (gathererFixItems == 1) then
647 fixedItemName = GathererUI_FixItemName(myItems);
648 else
649 fixedItemName= myItems;
650 end
651 NewGatherItems[idx_c][new_idx_z][fixedItemName] = {};
652 for idx_item, myGather in rec_gatheritem do
653 local myGatherType, myIcon;
654 if ( type(myGather.gtype) == "number" ) then
655 myGatherType = myGather.gtype;
656 else
657 myGatherType = Gatherer_EGatherType[myGather.gtype];
658 end
659 if ( type(myGather.icon) == "number" ) then
660 myIcon= myGather.icon;
661 else
662 myIcon= Gatherer_GetDB_IconIndex(myGather.icon, myGatherType);
663 end
664 -- convertion of rich thorium veins to new format
665 if ( myGatherType == 2 and myIcon == 8 ) then
666 myIcon = Gatherer_GetDB_IconIndex(Gatherer_FindOreType(fixedItemName), myGatherType);
667 end
668  
669 NewGatherItems[idx_c][new_idx_z][fixedItemName][idx_item] = { x=myGather.x, y=myGather.y, gtype=myGatherType, icon=myIcon, count=myGather.count };
670 fixedItemCount = fixedItemCount + 1;
671 end
672 end
673 end
674 end
675 end
676 Gatherer_ChatPrint("Zone swapping completed ("..zone_swap.." done, "..fixedItemCount.." items accounted for).")
677 end
678  
679 -- *******************************************************************
680 -- Zone Match UI functions
681 function GathererUI_ShowRematchDialog()
682 if ( GathererUI_ZoneRematchDialog:IsVisible() ) then
683 GathererUI_ZoneRematchDialog:Hide()
684 GathererUI_DestinationZoneDropDown:Hide();
685 else
686 GathererUI_ZoneRematchDialog:Show()
687 end
688 end
689  
690 -- *******************************************************************
691 -- DropDown Menu functions
692 function GathererUIDropDownSourceZone_Initialize()
693 for index in GathererUI_ZoneMatchTable do
694 local info = {};
695 info.text = index;
696 info.checked = nil;
697 info.func = GathererUIDropDownFilterSourceZone_OnClick;
698 UIDropDownMenu_AddButton(info);
699 if ( Gatherer_Settings.DataBuild and Gatherer_Settings.DataBuild == info.text ) then
700 UIDropDownMenu_SetText(info.text, GathererUI_SourceZoneDropDown);
701 end
702 end
703 end
704  
705 function GathererUIDropDownDestionationZone_Initialize()
706 local cmd = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
707 if ( cmd and cmd ~= "" ) then
708 for index in GathererUI_ZoneMatchTable[cmd] do
709 local info = {};
710 info.text = index;
711 info.checked = nil;
712 info.func = GathererUIDropDownFilterDestinationZone_OnClick;
713 UIDropDownMenu_AddButton(info);
714 end
715 end
716 end
717  
718 -- *******************************************************************
719 -- OnClick in DropDown Menu functions
720 function GathererUIDropDownFilterSourceZone_OnClick()
721 UIDropDownMenu_SetSelectedID(GathererUI_SourceZoneDropDown, this:GetID());
722 GathererUI_DestinationZoneDropDown:Show();
723 end
724  
725 function GathererUIDropDownFilterDestinationZone_OnClick()
726 UIDropDownMenu_SetSelectedID(GathererUI_DestinationZoneDropDown, this:GetID());
727 end
728  
729 -- *******************************************************************
730 -- Apply Button
731 function GathererUI_ShowRematchDialogApply()
732 local source, dest
733 source = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
734 dest = UIDropDownMenu_GetText(GathererUI_DestinationZoneDropDown);
735  
736 if( source and dest ) then
737 -- hide Option dialog (since the position of the confirmation dialog can cause miss-click on stuff in there)
738 GathererUI_HideOptions()
739 -- add extra confirmation dialog
740 StaticPopup_Show("CONFIRM_REMATCH");
741 elseif ( not source ) then
742 Gatherer_ChatPrint(GATHERER_TEXT_SRCZONE_MISSING);
743 else
744 Gatherer_ChatPrint(GATHERER_TEXT_DESTZONE_MISSING);
745 end
746 end
747  
748  
749 StaticPopupDialogs["CONFIRM_REMATCH"] = {
750 text = TEXT(GATHERER_TEXT_CONFIRM_REMATCH),
751 button1 = TEXT(ACCEPT),
752 button2 = TEXT(DECLINE),
753 OnAccept = function()
754 Gatherer_ConfirmZoneRematch();
755 end,
756 timeout = 60,
757 showAlert = 1,
758 };
759  
760 function Gatherer_ConfirmZoneRematch()
761 local source = UIDropDownMenu_GetText(GathererUI_SourceZoneDropDown);
762 local dest = UIDropDownMenu_GetText(GathererUI_DestinationZoneDropDown);
763  
764 -- Swap tables and Recompute notes
765 GathererUI_ZoneRematch(source, dest);
766 GatherItems = NewGatherItems;
767 Gatherer_Settings.DataBuild = dest;
768 GathererUI_ShowRematchDialog();
769 end
770  
771 -- **************************************************************************
772 -- Help Page functions.
773 -- Update the help
774 function GathererUI_HelpFrame_Update()
775  
776 -- Check if an addon is selected
777 GathererUI_HelpFrameName:SetText("Gatherer Help");
778  
779 local help = GathererHelp;
780  
781 local currentPage = help.currentPage;
782 local totalPages = 9;
783  
784 GathererUI_HelpFrameHelp:SetText(help[currentPage]);
785 GathererUI_HelpFramePage:SetText("Page "..currentPage.."/"..totalPages);
786 GathererUI_HelpFrame_UpdateButtons()
787 end
788  
789 -- Enable/Disable the help buttons
790 function GathererUI_HelpFrame_UpdateButtons()
791  
792 -- Get the help
793 local help = GathererHelp;
794  
795 -- Check if there is an help
796 local currentPage = help.currentPage;
797 local totalPages = 9;
798  
799 -- Check if the current help page is the first one
800 if (currentPage == 1) then
801 GathererUI_HelpFramePrevPageButton:Disable();
802 else
803 GathererUI_HelpFramePrevPageButton:Enable();
804 end
805  
806 -- Check if the current help page is the last one
807 if (currentPage == totalPages) then
808 GathererUI_HelpFrameNextPageButton:Disable();
809 else
810 GathererUI_HelpFrameNextPageButton:Enable();
811 end
812 end
813  
814 -- Help previous page OnClick event
815 function GathererUI_HelpFramePrevPageButton_OnClick()
816  
817 -- Set the current page to previous page
818 local help = GathererHelp;
819 help.currentPage = help.currentPage - 1;
820  
821 -- Update the help
822 GathererUI_HelpFrame_Update()
823 end
824  
825 -- Help next page OnClick event
826 function GathererUI_HelpFrameNextPageButton_OnClick()
827  
828 -- Set the current page to next page
829 local help = GathererHelp;
830 help.currentPage = help.currentPage + 1;
831  
832 -- Update the help
833 GathererUI_HelpFrame_Update();
834 end
835