Skip to content

Commit ae70733

Browse files
committed
Many bug fixes
- Fixed a bug where at less than 5 rows to show it resulted in lua errors (for example at 60) - Fixed a bug which made hunter pet skills not show - Fixed an odd bug which tainted the raid unit frames when more than 8 dropdown items exists - Some other stuff
1 parent 864aeca commit ae70733

11 files changed

+2336
-47
lines changed

Database/HunterPets.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ local _, FieldGuide = ...
22

33
FieldGuide.HUNTER_PETS = {
44
[2] = {
5-
{ empty = true } -- No spells at this level.
5+
[1] = {
6+
["name"] = "Growl",
7+
["rank"] = 1,
8+
["cost"] = 0,
9+
["texture"] = "Interface/ICONS/ability_physical_taunt",
10+
["id"] = 2649
11+
},
612
},
713
[4] = {
814
{ empty = true }
@@ -22,6 +28,13 @@ FieldGuide.HUNTER_PETS = {
2228
["id"] = 4187
2329
},
2430
[2] = {
31+
["name"] = "Growl",
32+
["rank"] = 2,
33+
["cost"] = 0,
34+
["texture"] = "Interface/ICONS/ability_physical_taunt",
35+
["id"] = 14916
36+
},
37+
[3] = {
2538
["name"] = "Natural Armor",
2639
["rank"] = 1,
2740
["cost"] = 10,

Database/Mage.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,13 +1187,6 @@ FieldGuide.MAGE = {
11871187
["id"] = 10220
11881188
},
11891189
[9] = {
1190-
["name"] = "Frost Ward",
1191-
["rank"] = 5,
1192-
["cost"] = 42000,
1193-
["texture"] = "Interface/ICONS/spell_frost_frostward",
1194-
["id"] = 28609
1195-
},
1196-
[10] = {
11971190
["name"] = "Blizzard",
11981191
["rank"] = 6,
11991192
["cost"] = 42000,

Database/WeaponSkills.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ FieldGuide.WEAPONS = {
170170
FieldGuide.copy(weapons.one_handed_maces),
171171
FieldGuide.copy(weapons.staves),
172172
FieldGuide.copy(weapons.two_handed_axes),
173-
FieldGuide.copy(weapons.two_handed_maces),
173+
FieldGuide.copy(weapons.two_handed_maces)
174174
},
175175
[7] = { -- Mage.
176176
FieldGuide.copy(weapons.daggers),
@@ -189,6 +189,6 @@ FieldGuide.WEAPONS = {
189189
FieldGuide.copy(weapons.fist_weapons),
190190
FieldGuide.copy(weapons.one_handed_maces),
191191
FieldGuide.copy(weapons.staves),
192-
FieldGuide.copy(weapons.two_handed_maces),
192+
FieldGuide.copy(weapons.two_handed_maces)
193193
},
194194
}

FieldGuide.lua

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,21 @@ local function updateButtons()
376376
local frameCounter = 1
377377
local currentLevel = currentMinLevel
378378
for row = 1, NBR_OF_SPELL_ROWS do
379+
if currentLevel >= 62 then
380+
-- Hide all hidden rows.
381+
for i = NBR_OF_SPELL_COLUMNS * row - NBR_OF_SPELL_COLUMNS + 1, #spellButtons do
382+
spellButtons[i]:Hide()
383+
end
384+
for i = row, NBR_OF_SPELL_ROWS do
385+
levelStrings[i]:SetText("")
386+
end
387+
break
388+
end
379389
local hiddenCounter = 0
380390
local shownCounter = 0
381-
while emptyLevels[currentLevel] do
382-
currentLevel = currentLevel + 2
383-
end
391+
while currentLevel < 60 and emptyLevels[currentLevel] do
392+
currentLevel = currentLevel + 2
393+
end
384394
levelStrings[row]:SetText(currentLevel ~= 2 and "Level " .. currentLevel or "Level 1")
385395
for spellIndex, spellInfo in ipairs(FieldGuide[selectedClass][currentLevel]) do
386396
if not spellInfo.hidden then
@@ -408,7 +418,7 @@ local function hideUnwantedSpells()
408418
for level = 60, 2, -2 do
409419
local hiddenCounter = 0
410420
for spellIndex, spellInfo in ipairs(FieldGuide[selectedClass][level]) do
411-
if IsSpellKnown(spellInfo.id) then
421+
if selectedClass ~= "HUNTER_PETS" and selectedClass ~= "WARLOCK_PETS" and IsSpellKnown(spellInfo.id) then
412422
knownSpells[spellInfo.name] = true
413423
end
414424
if spellInfo.empty then
@@ -442,7 +452,13 @@ local function hideUnwantedSpells()
442452
end
443453
end
444454
setHorizontalSliderMaxValue(maxSpellIndex)
445-
FieldGuideFrameVerticalSlider:SetMinMaxValues(0, 30 - NBR_OF_SPELL_ROWS - nbrOfHiddenRows)
455+
if 30 - NBR_OF_SPELL_ROWS - nbrOfHiddenRows <= 0 then
456+
FieldGuideFrameVerticalSlider:SetMinMaxValues(0, 0)
457+
FieldGuideFrameVerticalSliderScrollDownButton:Disable()
458+
else
459+
FieldGuideFrameVerticalSlider:SetMinMaxValues(0, 30 - NBR_OF_SPELL_ROWS - nbrOfHiddenRows)
460+
FieldGuideFrameVerticalSliderScrollDownButton:Enable()
461+
end
446462
end
447463

448464
-- Sets the background to the given class. Class must be a capitalized string.
@@ -465,14 +481,14 @@ end
465481
local function setClass(_, class)
466482
if class == "HUNTER_PETS" then
467483
setBackground("HUNTER")
468-
ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
469-
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.HUNTER .. "Pet skills")
484+
L_ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
485+
L_UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.HUNTER .. "Pet skills")
470486
elseif class == "WARLOCK_PETS" then
471487
setBackground("WARLOCK")
472-
ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
473-
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.WARLOCK .. "Demon spells")
488+
L_ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
489+
L_UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.WARLOCK .. "Demon spells")
474490
else
475-
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[class] .. class:sub(1, 1) .. class:sub(2):lower())
491+
L_UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[class] .. class:sub(1, 1) .. class:sub(2):lower())
476492
end
477493
selectedClass = class
478494
if class ~= "WEAPONS" and class ~= "HUNTER_PETS" and class ~= "WARLOCK_PETS" then
@@ -521,9 +537,8 @@ end
521537

522538
-- Initializes the dropdown menu.
523539
local function initDropdown()
524-
local dropdown = FieldGuideDropdownFrame
525-
UIDropDownMenu_Initialize(dropdown, function(self, level, menuList)
526-
local info = UIDropDownMenu_CreateInfo()
540+
L_UIDropDownMenu_Initialize(FieldGuideDropdownFrame, function(self, level, menuList)
541+
local info = L_UIDropDownMenu_CreateInfo()
527542
info.isNotRadio = true
528543
info.func = setClass
529544
if level == 1 then
@@ -532,89 +547,89 @@ local function initDropdown()
532547
info.colorCode = CLASS_COLORS.WARRIOR
533548
info.arg1 = "WARRIOR"
534549
info.checked = isSelected("WARRIOR")
535-
UIDropDownMenu_AddButton(info, level)
550+
L_UIDropDownMenu_AddButton(info, level)
536551
-- Paladin.
537552
info.text = "Paladin"
538553
info.colorCode = CLASS_COLORS.PALADIN
539554
info.arg1 = "PALADIN"
540555
info.checked = isSelected("PALADIN")
541-
UIDropDownMenu_AddButton(info, level)
556+
L_UIDropDownMenu_AddButton(info, level)
542557
-- Hunter.
543558
info.text = "Hunter"
544559
info.colorCode = CLASS_COLORS.HUNTER
545560
info.arg1 = "HUNTER"
546561
info.checked = isSelected("HUNTER")
547562
info.hasArrow = true
548563
info.menuList = "HUNTER_PETS"
549-
UIDropDownMenu_AddButton(info, level)
564+
L_UIDropDownMenu_AddButton(info, level)
550565
-- Rogue.
551566
info.text = "Rogue"
552567
info.colorCode = CLASS_COLORS.ROGUE
553568
info.arg1 = "ROGUE"
554569
info.checked = isSelected("ROGUE")
555570
info.hasArrow = false
556571
info.menuList = nil
557-
UIDropDownMenu_AddButton(info, level)
572+
L_UIDropDownMenu_AddButton(info, level)
558573
-- Priest.
559574
info.text = "Priest"
560575
info.colorCode = CLASS_COLORS.PRIEST
561576
info.arg1 = "PRIEST"
562577
info.checked = isSelected("PRIEST")
563-
UIDropDownMenu_AddButton(info, level)
578+
L_UIDropDownMenu_AddButton(info, level)
564579
-- Shaman.
565580
info.text = "Shaman"
566581
info.colorCode = CLASS_COLORS.SHAMAN
567582
info.arg1 = "SHAMAN"
568583
info.checked = isSelected("SHAMAN")
569-
UIDropDownMenu_AddButton(info, level)
584+
L_UIDropDownMenu_AddButton(info, level)
570585
-- Mage.
571586
info.text = "Mage"
572587
info.colorCode = CLASS_COLORS.MAGE
573588
info.checked = isSelected("MAGE")
574589
info.arg1 = "MAGE"
575-
UIDropDownMenu_AddButton(info, level)
590+
L_UIDropDownMenu_AddButton(info, level)
576591
-- Warlock.
577592
info.text = "Warlock"
578593
info.colorCode = CLASS_COLORS.WARLOCK
579594
info.arg1 = "WARLOCK"
580595
info.checked = isSelected("WARLOCK")
581596
info.hasArrow = true
582597
info.menuList = "WARLOCK_PETS"
583-
UIDropDownMenu_AddButton(info, level)
598+
L_UIDropDownMenu_AddButton(info, level)
584599
-- Druid.
585600
info.text = "Druid"
586601
info.colorCode = CLASS_COLORS.DRUID
587602
info.arg1 = "DRUID"
588603
info.checked = isSelected("DRUID")
589604
info.hasArrow = false
590605
info.menuList = nil
591-
UIDropDownMenu_AddButton(info, level)
606+
L_UIDropDownMenu_AddButton(info, level)
592607
-- Weapon skills.
593608
info.text = "Weapons"
594609
info.colorCode = "|cFFDFDFDF"
595610
info.arg1 = "WEAPONS"
596611
info.checked = isSelected("WEAPONS")
597-
UIDropDownMenu_AddButton(info, level)
612+
L_UIDropDownMenu_AddButton(info, level)
598613
elseif menuList == "WARLOCK_PETS" then
599614
info.text = "Demon spells"
600615
info.colorCode = CLASS_COLORS.WARLOCK
601616
info.arg1 = "WARLOCK_PETS"
602617
info.checked = isSelected("WARLOCK_PETS")
603618
info.func = setClass
604-
UIDropDownMenu_AddButton(info, level)
619+
L_UIDropDownMenu_AddButton(info, level)
605620
elseif menuList == "HUNTER_PETS" then
606621
info.text = "Pet skills"
607622
info.colorCode = CLASS_COLORS.HUNTER
608623
info.arg1 = "HUNTER_PETS"
609624
info.checked = isSelected("HUNTER_PETS")
610625
info.func = setClass
611-
UIDropDownMenu_AddButton(info, level)
626+
L_UIDropDownMenu_AddButton(info, level)
612627
end
613628
end)
614-
UIDropDownMenu_SetWidth(dropdown, 100);
615-
UIDropDownMenu_SetButtonWidth(dropdown, 124)
616-
UIDropDownMenu_JustifyText(dropdown, "RIGHT")
617-
UIDropDownMenu_SetText(dropdown, CLASS_COLORS[actualClass].. actualClass:sub(1, 1) .. actualClass:sub(2):lower())
629+
L_UIDropDownMenu_SetWidth(FieldGuideDropdownFrame, 100);
630+
L_UIDropDownMenu_SetButtonWidth(FieldGuideDropdownFrame, 124)
631+
L_UIDropDownMenu_JustifyText(FieldGuideDropdownFrame, "RIGHT")
632+
L_UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[actualClass].. actualClass:sub(1, 1) .. actualClass:sub(2):lower())
618633
end
619634

620635
-- Initializes all frames, level strings, and textures for reuse.
@@ -637,6 +652,9 @@ local function initFrames()
637652
levelStrings[stringIndex] = FieldGuideFrame:CreateFontString(nil, "ARTWORK", "FieldGuideLevelStringTemplate")
638653
levelStrings[stringIndex]:SetPoint("TOPLEFT", LEVEL_STRING_X_START, -LEVEL_STRING_Y_START - Y_SPACING * stringIndex)
639654
end
655+
-- The fact that this is even needed...
656+
L_Create_UIDropDownMenu("FieldGuideDropdownFrame", FieldGuideFrame)
657+
FieldGuideDropdownFrame:SetPoint("TOPRIGHT", -36, -28)
640658
end
641659

642660
-- Initializes everything.
@@ -850,6 +868,8 @@ function FieldGuide_OnLoad(self)
850868
self:RegisterEvent("ADDON_LOADED")
851869
self:RegisterEvent("LEARNED_SPELL_IN_TAB")
852870
self:RegisterEvent("PLAYER_ENTERING_WORLD")
871+
self:RegisterEvent("SKILL_LINES_CHANGED")
872+
self:RegisterEvent("UNIT_PET")
853873
end
854874

855875
-- Called on each event the frame receives.
@@ -875,9 +895,18 @@ function FieldGuide_OnEvent(self, event, ...)
875895
if selectedClass ~= "WEAPONS" then
876896
hideUnwantedSpells()
877897
updateButtons()
878-
else
898+
resetScroll()
899+
end
900+
elseif event == "SKILL_LINES_CHANGED" then
901+
if selectedClass == "WEAPONS" then
879902
hideUnwantedWeapons()
880-
updateWeapons()
903+
updateButtons()
904+
end
905+
elseif event == "UNIT_PET" then
906+
if selectedClass == "HUNTER_PETS" or selectedClass == "WARLOCK_PETS" then
907+
hideUnwantedSpells()
908+
updateButtons()
909+
resetScroll()
881910
end
882911
elseif event == "PLAYER_ENTERING_WORLD" then
883912
init()

FieldGuide.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Libraries\LibDataBroker-1.1\LibDataBroker-1.1.lua
1414
Libraries\LibDBIcon-1.0\LibDBIcon-1.0.lua
1515
Libraries\HereBeDragons-2.0\HereBeDragons-2.0.lua
1616
Libraries\HereBeDragons-2.0\HereBeDragons-Pins-2.0.lua
17+
Libraries\LibUIDropDownMenu\LibUIDropDownMenu.xml
1718

1819
# Load utilites.
1920
Util.lua

FieldGuide.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
</Layer>
108108
</Layers>
109109
<Frames>
110-
<Frame name="$parentTitleDraggable" enableMouse="true">
110+
<Frame name="$parentTitleDraggable">
111111
<Size x="120" y="30" />
112112
<Anchors>
113113
<Anchor point="TOP" x="0" y="10" />
@@ -255,11 +255,6 @@
255255
<Anchor point="TOPRIGHT" x="-8" y="-8" />
256256
</Anchors>
257257
</Button>
258-
<Frame name="FieldGuideDropdownFrame" inherits="UIDropDownMenuTemplate">
259-
<Anchors>
260-
<Anchor point="TOPRIGHT" x="-36" y="-28" />
261-
</Anchors>
262-
</Frame>
263258
</Frames>
264259
<Scripts>
265260
<OnLoad>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--$Id: LibEasyMenu.lua 30 2018-04-24 06:44:39Z arith $
2+
-- Simplified Menu Display System
3+
-- This is a basic system for displaying a menu from a structure table.
4+
--
5+
-- See UIDropDownMenu.lua for the menuList details.
6+
--
7+
-- Args:
8+
-- menuList - menu table
9+
-- menuFrame - the UI frame to populate
10+
-- anchor - where to anchor the frame (e.g. CURSOR)
11+
-- x - x offset
12+
-- y - y offset
13+
-- displayMode - border type
14+
-- autoHideDelay - how long until the menu disappears
15+
--
16+
--
17+
-- ----------------------------------------------------------------------------
18+
-- Localized Lua globals.
19+
-- ----------------------------------------------------------------------------
20+
local _G = getfenv(0)
21+
-- ----------------------------------------------------------------------------
22+
local MAJOR_VERSION = "LibEasyMenu"
23+
local MINOR_VERSION = 90000 + tonumber(("$Rev: 30 $"):match("%d+"))
24+
25+
local LibStub = _G.LibStub
26+
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
27+
local Lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
28+
if not Lib then return end
29+
30+
function L_EasyMenu(menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay )
31+
if ( displayMode == "MENU" ) then
32+
menuFrame.displayMode = displayMode;
33+
end
34+
L_UIDropDownMenu_Initialize(menuFrame, L_EasyMenu_Initialize, displayMode, nil, menuList);
35+
L_ToggleDropDownMenu(1, nil, menuFrame, anchor, x, y, menuList, nil, autoHideDelay);
36+
end
37+
38+
function L_EasyMenu_Initialize( frame, level, menuList )
39+
for index = 1, #menuList do
40+
local value = menuList[index]
41+
if (value.text) then
42+
value.index = index;
43+
L_UIDropDownMenu_AddButton( value, level );
44+
end
45+
end
46+
end
47+

0 commit comments

Comments
 (0)