diff --git a/Database/WeaponSkills.lua b/Database/WeaponSkills.lua
index bd58064..39bb5cc 100644
--- a/Database/WeaponSkills.lua
+++ b/Database/WeaponSkills.lua
@@ -37,21 +37,21 @@ local weapons = {
["id"] = 266
},
["one_handed_axes"] = {
- ["name"] = "One-Handed Axes",
+ ["name"] = "Axes",
["rank"] = 1,
["cost"] = 1000,
["texture"] = "Interface/ICONS/inv_axe_01",
["id"] = 196
},
["one_handed_maces"] = {
- ["name"] = "One-Handed Maces",
+ ["name"] = "Maces",
["rank"] = 1,
["cost"] = 1000,
["texture"] = "Interface/ICONS/inv_mace_01",
["id"] = 198
},
["one_handed_swords"] = {
- ["name"] = "One-Handed Swords",
+ ["name"] = "Swords",
["rank"] = 1,
["cost"] = 1000,
["texture"] = "Interface/ICONS/ability_meleedamage",
@@ -165,11 +165,12 @@ FieldGuide.WEAPONS = {
FieldGuide.copy(weapons.wands)
},
[6] = { -- Shaman.
+ FieldGuide.copy(weapons.daggers),
FieldGuide.copy(weapons.one_handed_axes),
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),
@@ -185,8 +186,9 @@ FieldGuide.WEAPONS = {
},
[9] = { -- Druid.
FieldGuide.copy(weapons.daggers),
+ FieldGuide.copy(weapons.fist_weapons),
FieldGuide.copy(weapons.one_handed_maces),
FieldGuide.copy(weapons.staves),
- FieldGuide.copy(weapons.wands)
+ FieldGuide.copy(weapons.two_handed_maces),
},
}
diff --git a/FieldGuide.lua b/FieldGuide.lua
index c578eac..87d772c 100644
--- a/FieldGuide.lua
+++ b/FieldGuide.lua
@@ -358,20 +358,16 @@ end
-- Iterates all weapon skills for the current class and shows/hides any known ones.
local function hideUnwantedWeapons()
local maxValue = 0
- for index, class in ipairs(CLASSES) do
- local nbrOfSpells = 0
- for weaponIndex, weaponInfo in ipairs(FieldGuide.WEAPONS[CLASS_INDECES[class:upper()]]) do
- if class == actualClass then
- if not FieldGuideOptions.showKnownSpells and IsSpellKnown(weaponInfo.id) then
- weaponInfo.hidden = true
- else
- weaponInfo.hidden = false
- end
- end
- nbrOfSpells = not weaponInfo.hidden and nbrOfSpells + 1 or nbrOfSpells
+ local nbrOfSpells = 0
+ for weaponIndex, weaponInfo in ipairs(FieldGuide.WEAPONS[CLASS_INDECES[actualClass]]) do
+ if not FieldGuideOptions.showKnownSpells and FieldGuide.isWeaponKnown(weaponInfo.name) then
+ weaponInfo.hidden = true
+ else
+ weaponInfo.hidden = false
end
- maxValue = nbrOfSpells > maxValue and nbrOfSpells or maxValue
+ nbrOfSpells = not weaponInfo.hidden and nbrOfSpells + 1 or nbrOfSpells
end
+ maxValue = nbrOfSpells > maxValue and nbrOfSpells or maxValue
setHorizontalSliderMaxValue(maxValue)
end
@@ -404,16 +400,20 @@ end
-- Hides all unwanted spells (known spells/talents/opposite faction spells). Also adjusts the horizontal slider appropriately.
local function hideUnwantedSpells()
+ local knownSpells = {}
local maxSpellIndex = 0
local currentSpellIndex = 0
local nbrOfHiddenRows = 0
lowestLevel = 52
- for level = 2, 60, 2 do
+ for level = 60, 2, -2 do
local hiddenCounter = 0
for spellIndex, spellInfo in ipairs(FieldGuide[selectedClass][level]) do
+ if IsSpellKnown(spellInfo.id) then
+ knownSpells[spellInfo.name] = true
+ end
if spellInfo.empty then
spellInfo.hidden = true
- elseif not FieldGuideOptions.showKnownSpells and ((selectedClass == "HUNTER_PETS" or selectedClass == "WARLOCK_PETS") and IsSpellKnown(spellInfo.id, true) or IsSpellKnown(spellInfo.id)) then
+ elseif not FieldGuideOptions.showKnownSpells and ((selectedClass == "HUNTER_PETS" or selectedClass == "WARLOCK_PETS") and IsSpellKnown(spellInfo.id, true) or knownSpells[spellInfo.name]) then
spellInfo.hidden = true
elseif not FieldGuideOptions.showEnemySpells and (isAlliance() and spellInfo.faction == 2 or (not isAlliance() and spellInfo.faction == 1)) then
spellInfo.hidden = true
@@ -462,7 +462,7 @@ local function resetScroll()
end
-- Changes the class to the given class.
-local function setClass(dropdownButton, class)
+local function setClass(_, class)
if class == "HUNTER_PETS" then
setBackground("HUNTER")
ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
@@ -471,8 +471,6 @@ local function setClass(dropdownButton, class)
setBackground("WARLOCK")
ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.WARLOCK .. "Demon spells")
- elseif class ~= "WEAPONS" then
- UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[class] .. class:sub(1, 1) .. class:sub(2):lower())
else
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[class] .. class:sub(1, 1) .. class:sub(2):lower())
end
@@ -645,15 +643,12 @@ end
local function init()
tinsert(UISpecialFrames, FieldGuideFrame:GetName()) -- Allows us to close the window with escape.
initFrames()
- selectedClass = actualClass
- setBackground(selectedClass)
- FieldGuide_ToggleButtons() -- Need to call this, or spells won't be hidden regardless of saved variables.
- resetScroll()
+ setClass(nil, actualClass)
initDropdown()
initCheckboxes()
initMinimapButton()
initSlash()
- FieldGuideFrameVerticalSlider:SetMinMaxValues(0, 30 - NBR_OF_SPELL_ROWS) -- If we show 5 spell rows, the scroll max value should be 25 (it scrolls to 25th row, and shows the last 5 already).
+ FieldGuide_ToggleButtons() -- Need to call this, or spells won't be hidden regardless of saved variables.
FieldGuideFrameVerticalSlider:SetValue(1)
FieldGuideFrameVerticalSlider:SetValue(0)
if not tomtom then
@@ -829,13 +824,13 @@ function FieldGuide_Scroll(delta, horizontal)
end
-- Shows or hides the talents (type == 1), enemy spells (type == 2), or known spells (type == 3).
-function FieldGuide_ToggleButtons(type)
+function FieldGuide_ToggleButtons(t)
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
- if type == 3 then -- Known spells.
+ if t == 3 then -- Known spells.
FieldGuideOptions.showKnownSpells = not FieldGuideOptions.showKnownSpells
- elseif type == 2 then -- Enemy spells.
+ elseif t == 2 then -- Enemy spells.
FieldGuideOptions.showEnemySpells = not FieldGuideOptions.showEnemySpells
- elseif type == 1 then -- Talents.
+ elseif t == 1 then -- Talents.
FieldGuideOptions.showTalents = not FieldGuideOptions.showTalents
end
if selectedClass ~= "WEAPONS" then
@@ -845,7 +840,6 @@ function FieldGuide_ToggleButtons(type)
updateButtons()
else
hideUnwantedWeapons()
- resetScroll()
updateWeapons()
end
end
@@ -855,6 +849,7 @@ function FieldGuide_OnLoad(self)
self:RegisterForDrag("LeftButton")
self:RegisterEvent("ADDON_LOADED")
self:RegisterEvent("LEARNED_SPELL_IN_TAB")
+ self:RegisterEvent("PLAYER_ENTERING_WORLD")
end
-- Called on each event the frame receives.
@@ -866,7 +861,6 @@ function FieldGuide_OnEvent(self, event, ...)
FieldGuideOptions = FieldGuideOptions or {}
FieldGuideOptions.pins = {}
end
- print(not tomtom and "|cFFFFFF00Field Guide|r loaded! Type /fg help for commands and controls. By the way, it is highly recommended to use TomTom with Field Guide." or "|cFFFFFF00Field Guide|r loaded! Type /fg help for commands and controls.")
FieldGuideOptions = FieldGuideOptions or {}
FieldGuideOptions.showTalents = FieldGuideOptions.showTalents
FieldGuideOptions.showEnemySpells = FieldGuideOptions.showEnemySpells
@@ -874,7 +868,7 @@ function FieldGuide_OnEvent(self, event, ...)
FieldGuideOptions.unwantedSpells = FieldGuideOptions.unwantedSpells or {}
FieldGuideOptions.minimapTable = FieldGuideOptions.minimapTable or {}
FieldGuideOptions.pins = FieldGuideOptions.pins or {}
- init()
+ print(not tomtom and "|cFFFFFF00Field Guide|r loaded! Type /fg help for commands and controls. By the way, it is highly recommended to use TomTom with Field Guide." or "|cFFFFFF00Field Guide|r loaded! Type /fg help for commands and controls.")
self:UnregisterEvent("ADDON_LOADED")
end
elseif event == "LEARNED_SPELL_IN_TAB" then
@@ -885,5 +879,9 @@ function FieldGuide_OnEvent(self, event, ...)
hideUnwantedWeapons()
updateWeapons()
end
+ elseif event == "PLAYER_ENTERING_WORLD" then
+ init()
+ FieldGuideFrame:Hide()
+ self:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
end
diff --git a/FieldGuide.xml b/FieldGuide.xml
index f43b5f4..354ad7c 100644
--- a/FieldGuide.xml
+++ b/FieldGuide.xml
@@ -112,14 +112,6 @@
-
-
- self:GetParent():StartMoving()
-
-
- self:GetParent():StopMovingOrSizing()
-
-
@@ -279,6 +271,12 @@
PlaySound(SOUNDKIT.IG_SPELLBOOK_CLOSE)
+
+ self:StartMoving()
+
+
+ self:StopMovingOrSizing()
+
FieldGuide_Scroll(delta)
diff --git a/Util.lua b/Util.lua
index 58b7c54..21b4068 100644
--- a/Util.lua
+++ b/Util.lua
@@ -1,5 +1,7 @@
local _, FieldGuide = ...
+local GetNumSkillLines, GetSkillLineInfo = GetNumSkillLines, GetSkillLineInfo
+
FieldGuide.factions = {
["darnassus"] = 69,
["darkspear_trolls"] = 530,
@@ -93,3 +95,12 @@ end
function FieldGuide.getContinent(map)
return continents[map]
end
+
+function FieldGuide.isWeaponKnown(name)
+ for i = 1, GetNumSkillLines() do
+ if name == GetSkillLineInfo(i) then
+ return true
+ end
+ end
+ return false
+end