Skip to content

Commit

Permalink
Many bug fixes
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
cloudbells committed Sep 14, 2019
1 parent 864aeca commit ae70733
Show file tree
Hide file tree
Showing 11 changed files with 2,336 additions and 47 deletions.
15 changes: 14 additions & 1 deletion Database/HunterPets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ local _, FieldGuide = ...

FieldGuide.HUNTER_PETS = {
[2] = {
{ empty = true } -- No spells at this level.
[1] = {
["name"] = "Growl",
["rank"] = 1,
["cost"] = 0,
["texture"] = "Interface/ICONS/ability_physical_taunt",
["id"] = 2649
},
},
[4] = {
{ empty = true }
Expand All @@ -22,6 +28,13 @@ FieldGuide.HUNTER_PETS = {
["id"] = 4187
},
[2] = {
["name"] = "Growl",
["rank"] = 2,
["cost"] = 0,
["texture"] = "Interface/ICONS/ability_physical_taunt",
["id"] = 14916
},
[3] = {
["name"] = "Natural Armor",
["rank"] = 1,
["cost"] = 10,
Expand Down
7 changes: 0 additions & 7 deletions Database/Mage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1187,13 +1187,6 @@ FieldGuide.MAGE = {
["id"] = 10220
},
[9] = {
["name"] = "Frost Ward",
["rank"] = 5,
["cost"] = 42000,
["texture"] = "Interface/ICONS/spell_frost_frostward",
["id"] = 28609
},
[10] = {
["name"] = "Blizzard",
["rank"] = 6,
["cost"] = 42000,
Expand Down
4 changes: 2 additions & 2 deletions Database/WeaponSkills.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ FieldGuide.WEAPONS = {
FieldGuide.copy(weapons.one_handed_maces),
FieldGuide.copy(weapons.staves),
FieldGuide.copy(weapons.two_handed_axes),
FieldGuide.copy(weapons.two_handed_maces),
FieldGuide.copy(weapons.two_handed_maces)
},
[7] = { -- Mage.
FieldGuide.copy(weapons.daggers),
Expand All @@ -189,6 +189,6 @@ FieldGuide.WEAPONS = {
FieldGuide.copy(weapons.fist_weapons),
FieldGuide.copy(weapons.one_handed_maces),
FieldGuide.copy(weapons.staves),
FieldGuide.copy(weapons.two_handed_maces),
FieldGuide.copy(weapons.two_handed_maces)
},
}
91 changes: 60 additions & 31 deletions FieldGuide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,21 @@ local function updateButtons()
local frameCounter = 1
local currentLevel = currentMinLevel
for row = 1, NBR_OF_SPELL_ROWS do
if currentLevel >= 62 then
-- Hide all hidden rows.
for i = NBR_OF_SPELL_COLUMNS * row - NBR_OF_SPELL_COLUMNS + 1, #spellButtons do
spellButtons[i]:Hide()
end
for i = row, NBR_OF_SPELL_ROWS do
levelStrings[i]:SetText("")
end
break
end
local hiddenCounter = 0
local shownCounter = 0
while emptyLevels[currentLevel] do
currentLevel = currentLevel + 2
end
while currentLevel < 60 and emptyLevels[currentLevel] do
currentLevel = currentLevel + 2
end
levelStrings[row]:SetText(currentLevel ~= 2 and "Level " .. currentLevel or "Level 1")
for spellIndex, spellInfo in ipairs(FieldGuide[selectedClass][currentLevel]) do
if not spellInfo.hidden then
Expand Down Expand Up @@ -408,7 +418,7 @@ local function hideUnwantedSpells()
for level = 60, 2, -2 do
local hiddenCounter = 0
for spellIndex, spellInfo in ipairs(FieldGuide[selectedClass][level]) do
if IsSpellKnown(spellInfo.id) then
if selectedClass ~= "HUNTER_PETS" and selectedClass ~= "WARLOCK_PETS" and IsSpellKnown(spellInfo.id) then
knownSpells[spellInfo.name] = true
end
if spellInfo.empty then
Expand Down Expand Up @@ -442,7 +452,13 @@ local function hideUnwantedSpells()
end
end
setHorizontalSliderMaxValue(maxSpellIndex)
FieldGuideFrameVerticalSlider:SetMinMaxValues(0, 30 - NBR_OF_SPELL_ROWS - nbrOfHiddenRows)
if 30 - NBR_OF_SPELL_ROWS - nbrOfHiddenRows <= 0 then
FieldGuideFrameVerticalSlider:SetMinMaxValues(0, 0)
FieldGuideFrameVerticalSliderScrollDownButton:Disable()
else
FieldGuideFrameVerticalSlider:SetMinMaxValues(0, 30 - NBR_OF_SPELL_ROWS - nbrOfHiddenRows)
FieldGuideFrameVerticalSliderScrollDownButton:Enable()
end
end

-- Sets the background to the given class. Class must be a capitalized string.
Expand All @@ -465,14 +481,14 @@ end
local function setClass(_, class)
if class == "HUNTER_PETS" then
setBackground("HUNTER")
ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.HUNTER .. "Pet skills")
L_ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
L_UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.HUNTER .. "Pet skills")
elseif class == "WARLOCK_PETS" then
setBackground("WARLOCK")
ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.WARLOCK .. "Demon spells")
L_ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
L_UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.WARLOCK .. "Demon spells")
else
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[class] .. class:sub(1, 1) .. class:sub(2):lower())
L_UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[class] .. class:sub(1, 1) .. class:sub(2):lower())
end
selectedClass = class
if class ~= "WEAPONS" and class ~= "HUNTER_PETS" and class ~= "WARLOCK_PETS" then
Expand Down Expand Up @@ -521,9 +537,8 @@ end

-- Initializes the dropdown menu.
local function initDropdown()
local dropdown = FieldGuideDropdownFrame
UIDropDownMenu_Initialize(dropdown, function(self, level, menuList)
local info = UIDropDownMenu_CreateInfo()
L_UIDropDownMenu_Initialize(FieldGuideDropdownFrame, function(self, level, menuList)
local info = L_UIDropDownMenu_CreateInfo()
info.isNotRadio = true
info.func = setClass
if level == 1 then
Expand All @@ -532,89 +547,89 @@ local function initDropdown()
info.colorCode = CLASS_COLORS.WARRIOR
info.arg1 = "WARRIOR"
info.checked = isSelected("WARRIOR")
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Paladin.
info.text = "Paladin"
info.colorCode = CLASS_COLORS.PALADIN
info.arg1 = "PALADIN"
info.checked = isSelected("PALADIN")
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Hunter.
info.text = "Hunter"
info.colorCode = CLASS_COLORS.HUNTER
info.arg1 = "HUNTER"
info.checked = isSelected("HUNTER")
info.hasArrow = true
info.menuList = "HUNTER_PETS"
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Rogue.
info.text = "Rogue"
info.colorCode = CLASS_COLORS.ROGUE
info.arg1 = "ROGUE"
info.checked = isSelected("ROGUE")
info.hasArrow = false
info.menuList = nil
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Priest.
info.text = "Priest"
info.colorCode = CLASS_COLORS.PRIEST
info.arg1 = "PRIEST"
info.checked = isSelected("PRIEST")
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Shaman.
info.text = "Shaman"
info.colorCode = CLASS_COLORS.SHAMAN
info.arg1 = "SHAMAN"
info.checked = isSelected("SHAMAN")
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Mage.
info.text = "Mage"
info.colorCode = CLASS_COLORS.MAGE
info.checked = isSelected("MAGE")
info.arg1 = "MAGE"
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Warlock.
info.text = "Warlock"
info.colorCode = CLASS_COLORS.WARLOCK
info.arg1 = "WARLOCK"
info.checked = isSelected("WARLOCK")
info.hasArrow = true
info.menuList = "WARLOCK_PETS"
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Druid.
info.text = "Druid"
info.colorCode = CLASS_COLORS.DRUID
info.arg1 = "DRUID"
info.checked = isSelected("DRUID")
info.hasArrow = false
info.menuList = nil
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
-- Weapon skills.
info.text = "Weapons"
info.colorCode = "|cFFDFDFDF"
info.arg1 = "WEAPONS"
info.checked = isSelected("WEAPONS")
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
elseif menuList == "WARLOCK_PETS" then
info.text = "Demon spells"
info.colorCode = CLASS_COLORS.WARLOCK
info.arg1 = "WARLOCK_PETS"
info.checked = isSelected("WARLOCK_PETS")
info.func = setClass
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
elseif menuList == "HUNTER_PETS" then
info.text = "Pet skills"
info.colorCode = CLASS_COLORS.HUNTER
info.arg1 = "HUNTER_PETS"
info.checked = isSelected("HUNTER_PETS")
info.func = setClass
UIDropDownMenu_AddButton(info, level)
L_UIDropDownMenu_AddButton(info, level)
end
end)
UIDropDownMenu_SetWidth(dropdown, 100);
UIDropDownMenu_SetButtonWidth(dropdown, 124)
UIDropDownMenu_JustifyText(dropdown, "RIGHT")
UIDropDownMenu_SetText(dropdown, CLASS_COLORS[actualClass].. actualClass:sub(1, 1) .. actualClass:sub(2):lower())
L_UIDropDownMenu_SetWidth(FieldGuideDropdownFrame, 100);
L_UIDropDownMenu_SetButtonWidth(FieldGuideDropdownFrame, 124)
L_UIDropDownMenu_JustifyText(FieldGuideDropdownFrame, "RIGHT")
L_UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[actualClass].. actualClass:sub(1, 1) .. actualClass:sub(2):lower())
end

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

-- Initializes everything.
Expand Down Expand Up @@ -850,6 +868,8 @@ function FieldGuide_OnLoad(self)
self:RegisterEvent("ADDON_LOADED")
self:RegisterEvent("LEARNED_SPELL_IN_TAB")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("SKILL_LINES_CHANGED")
self:RegisterEvent("UNIT_PET")
end

-- Called on each event the frame receives.
Expand All @@ -875,9 +895,18 @@ function FieldGuide_OnEvent(self, event, ...)
if selectedClass ~= "WEAPONS" then
hideUnwantedSpells()
updateButtons()
else
resetScroll()
end
elseif event == "SKILL_LINES_CHANGED" then
if selectedClass == "WEAPONS" then
hideUnwantedWeapons()
updateWeapons()
updateButtons()
end
elseif event == "UNIT_PET" then
if selectedClass == "HUNTER_PETS" or selectedClass == "WARLOCK_PETS" then
hideUnwantedSpells()
updateButtons()
resetScroll()
end
elseif event == "PLAYER_ENTERING_WORLD" then
init()
Expand Down
1 change: 1 addition & 0 deletions FieldGuide.toc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Libraries\LibDataBroker-1.1\LibDataBroker-1.1.lua
Libraries\LibDBIcon-1.0\LibDBIcon-1.0.lua
Libraries\HereBeDragons-2.0\HereBeDragons-2.0.lua
Libraries\HereBeDragons-2.0\HereBeDragons-Pins-2.0.lua
Libraries\LibUIDropDownMenu\LibUIDropDownMenu.xml

# Load utilites.
Util.lua
Expand Down
7 changes: 1 addition & 6 deletions FieldGuide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
</Layer>
</Layers>
<Frames>
<Frame name="$parentTitleDraggable" enableMouse="true">
<Frame name="$parentTitleDraggable">
<Size x="120" y="30" />
<Anchors>
<Anchor point="TOP" x="0" y="10" />
Expand Down Expand Up @@ -255,11 +255,6 @@
<Anchor point="TOPRIGHT" x="-8" y="-8" />
</Anchors>
</Button>
<Frame name="FieldGuideDropdownFrame" inherits="UIDropDownMenuTemplate">
<Anchors>
<Anchor point="TOPRIGHT" x="-36" y="-28" />
</Anchors>
</Frame>
</Frames>
<Scripts>
<OnLoad>
Expand Down
47 changes: 47 additions & 0 deletions Libraries/LibUIDropDownMenu/LibEasyMenu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
--$Id: LibEasyMenu.lua 30 2018-04-24 06:44:39Z arith $
-- Simplified Menu Display System
-- This is a basic system for displaying a menu from a structure table.
--
-- See UIDropDownMenu.lua for the menuList details.
--
-- Args:
-- menuList - menu table
-- menuFrame - the UI frame to populate
-- anchor - where to anchor the frame (e.g. CURSOR)
-- x - x offset
-- y - y offset
-- displayMode - border type
-- autoHideDelay - how long until the menu disappears
--
--
-- ----------------------------------------------------------------------------
-- Localized Lua globals.
-- ----------------------------------------------------------------------------
local _G = getfenv(0)
-- ----------------------------------------------------------------------------
local MAJOR_VERSION = "LibEasyMenu"
local MINOR_VERSION = 90000 + tonumber(("$Rev: 30 $"):match("%d+"))

local LibStub = _G.LibStub
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
local Lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
if not Lib then return end

function L_EasyMenu(menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay )
if ( displayMode == "MENU" ) then
menuFrame.displayMode = displayMode;
end
L_UIDropDownMenu_Initialize(menuFrame, L_EasyMenu_Initialize, displayMode, nil, menuList);
L_ToggleDropDownMenu(1, nil, menuFrame, anchor, x, y, menuList, nil, autoHideDelay);
end

function L_EasyMenu_Initialize( frame, level, menuList )
for index = 1, #menuList do
local value = menuList[index]
if (value.text) then
value.index = index;
L_UIDropDownMenu_AddButton( value, level );
end
end
end

Loading

0 comments on commit ae70733

Please sign in to comment.