Skip to content

Commit 864aeca

Browse files
committed
Bug fixes, made the whole frame draggable
- Fixed weapon skills for Shamans and Druids - Fixed a bug where it would still show learned spells on login - Fixed a bug where the amount of rows were too many on login/reload ("phantom" rows) - Fixed a bug where known weapon skills would still show - Fixed a bug where lower rank spells still show as unlearned - Made the whole frame draggable instead of only the title bar
1 parent 0f0c281 commit 864aeca

File tree

4 files changed

+51
-42
lines changed

4 files changed

+51
-42
lines changed

Database/WeaponSkills.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ local weapons = {
3737
["id"] = 266
3838
},
3939
["one_handed_axes"] = {
40-
["name"] = "One-Handed Axes",
40+
["name"] = "Axes",
4141
["rank"] = 1,
4242
["cost"] = 1000,
4343
["texture"] = "Interface/ICONS/inv_axe_01",
4444
["id"] = 196
4545
},
4646
["one_handed_maces"] = {
47-
["name"] = "One-Handed Maces",
47+
["name"] = "Maces",
4848
["rank"] = 1,
4949
["cost"] = 1000,
5050
["texture"] = "Interface/ICONS/inv_mace_01",
5151
["id"] = 198
5252
},
5353
["one_handed_swords"] = {
54-
["name"] = "One-Handed Swords",
54+
["name"] = "Swords",
5555
["rank"] = 1,
5656
["cost"] = 1000,
5757
["texture"] = "Interface/ICONS/ability_meleedamage",
@@ -165,11 +165,12 @@ FieldGuide.WEAPONS = {
165165
FieldGuide.copy(weapons.wands)
166166
},
167167
[6] = { -- Shaman.
168+
FieldGuide.copy(weapons.daggers),
168169
FieldGuide.copy(weapons.one_handed_axes),
169170
FieldGuide.copy(weapons.one_handed_maces),
170171
FieldGuide.copy(weapons.staves),
171172
FieldGuide.copy(weapons.two_handed_axes),
172-
FieldGuide.copy(weapons.two_handed_maces)
173+
FieldGuide.copy(weapons.two_handed_maces),
173174
},
174175
[7] = { -- Mage.
175176
FieldGuide.copy(weapons.daggers),
@@ -185,8 +186,9 @@ FieldGuide.WEAPONS = {
185186
},
186187
[9] = { -- Druid.
187188
FieldGuide.copy(weapons.daggers),
189+
FieldGuide.copy(weapons.fist_weapons),
188190
FieldGuide.copy(weapons.one_handed_maces),
189191
FieldGuide.copy(weapons.staves),
190-
FieldGuide.copy(weapons.wands)
192+
FieldGuide.copy(weapons.two_handed_maces),
191193
},
192194
}

FieldGuide.lua

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -358,20 +358,16 @@ end
358358
-- Iterates all weapon skills for the current class and shows/hides any known ones.
359359
local function hideUnwantedWeapons()
360360
local maxValue = 0
361-
for index, class in ipairs(CLASSES) do
362-
local nbrOfSpells = 0
363-
for weaponIndex, weaponInfo in ipairs(FieldGuide.WEAPONS[CLASS_INDECES[class:upper()]]) do
364-
if class == actualClass then
365-
if not FieldGuideOptions.showKnownSpells and IsSpellKnown(weaponInfo.id) then
366-
weaponInfo.hidden = true
367-
else
368-
weaponInfo.hidden = false
369-
end
370-
end
371-
nbrOfSpells = not weaponInfo.hidden and nbrOfSpells + 1 or nbrOfSpells
361+
local nbrOfSpells = 0
362+
for weaponIndex, weaponInfo in ipairs(FieldGuide.WEAPONS[CLASS_INDECES[actualClass]]) do
363+
if not FieldGuideOptions.showKnownSpells and FieldGuide.isWeaponKnown(weaponInfo.name) then
364+
weaponInfo.hidden = true
365+
else
366+
weaponInfo.hidden = false
372367
end
373-
maxValue = nbrOfSpells > maxValue and nbrOfSpells or maxValue
368+
nbrOfSpells = not weaponInfo.hidden and nbrOfSpells + 1 or nbrOfSpells
374369
end
370+
maxValue = nbrOfSpells > maxValue and nbrOfSpells or maxValue
375371
setHorizontalSliderMaxValue(maxValue)
376372
end
377373

@@ -404,16 +400,20 @@ end
404400

405401
-- Hides all unwanted spells (known spells/talents/opposite faction spells). Also adjusts the horizontal slider appropriately.
406402
local function hideUnwantedSpells()
403+
local knownSpells = {}
407404
local maxSpellIndex = 0
408405
local currentSpellIndex = 0
409406
local nbrOfHiddenRows = 0
410407
lowestLevel = 52
411-
for level = 2, 60, 2 do
408+
for level = 60, 2, -2 do
412409
local hiddenCounter = 0
413410
for spellIndex, spellInfo in ipairs(FieldGuide[selectedClass][level]) do
411+
if IsSpellKnown(spellInfo.id) then
412+
knownSpells[spellInfo.name] = true
413+
end
414414
if spellInfo.empty then
415415
spellInfo.hidden = true
416-
elseif not FieldGuideOptions.showKnownSpells and ((selectedClass == "HUNTER_PETS" or selectedClass == "WARLOCK_PETS") and IsSpellKnown(spellInfo.id, true) or IsSpellKnown(spellInfo.id)) then
416+
elseif not FieldGuideOptions.showKnownSpells and ((selectedClass == "HUNTER_PETS" or selectedClass == "WARLOCK_PETS") and IsSpellKnown(spellInfo.id, true) or knownSpells[spellInfo.name]) then
417417
spellInfo.hidden = true
418418
elseif not FieldGuideOptions.showEnemySpells and (isAlliance() and spellInfo.faction == 2 or (not isAlliance() and spellInfo.faction == 1)) then
419419
spellInfo.hidden = true
@@ -462,7 +462,7 @@ local function resetScroll()
462462
end
463463

464464
-- Changes the class to the given class.
465-
local function setClass(dropdownButton, class)
465+
local function setClass(_, class)
466466
if class == "HUNTER_PETS" then
467467
setBackground("HUNTER")
468468
ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
@@ -471,8 +471,6 @@ local function setClass(dropdownButton, class)
471471
setBackground("WARLOCK")
472472
ToggleDropDownMenu(nil, nil, FieldGuideDropdownFrame)
473473
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS.WARLOCK .. "Demon spells")
474-
elseif class ~= "WEAPONS" then
475-
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[class] .. class:sub(1, 1) .. class:sub(2):lower())
476474
else
477475
UIDropDownMenu_SetText(FieldGuideDropdownFrame, CLASS_COLORS[class] .. class:sub(1, 1) .. class:sub(2):lower())
478476
end
@@ -645,15 +643,12 @@ end
645643
local function init()
646644
tinsert(UISpecialFrames, FieldGuideFrame:GetName()) -- Allows us to close the window with escape.
647645
initFrames()
648-
selectedClass = actualClass
649-
setBackground(selectedClass)
650-
FieldGuide_ToggleButtons() -- Need to call this, or spells won't be hidden regardless of saved variables.
651-
resetScroll()
646+
setClass(nil, actualClass)
652647
initDropdown()
653648
initCheckboxes()
654649
initMinimapButton()
655650
initSlash()
656-
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).
651+
FieldGuide_ToggleButtons() -- Need to call this, or spells won't be hidden regardless of saved variables.
657652
FieldGuideFrameVerticalSlider:SetValue(1)
658653
FieldGuideFrameVerticalSlider:SetValue(0)
659654
if not tomtom then
@@ -829,13 +824,13 @@ function FieldGuide_Scroll(delta, horizontal)
829824
end
830825

831826
-- Shows or hides the talents (type == 1), enemy spells (type == 2), or known spells (type == 3).
832-
function FieldGuide_ToggleButtons(type)
827+
function FieldGuide_ToggleButtons(t)
833828
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
834-
if type == 3 then -- Known spells.
829+
if t == 3 then -- Known spells.
835830
FieldGuideOptions.showKnownSpells = not FieldGuideOptions.showKnownSpells
836-
elseif type == 2 then -- Enemy spells.
831+
elseif t == 2 then -- Enemy spells.
837832
FieldGuideOptions.showEnemySpells = not FieldGuideOptions.showEnemySpells
838-
elseif type == 1 then -- Talents.
833+
elseif t == 1 then -- Talents.
839834
FieldGuideOptions.showTalents = not FieldGuideOptions.showTalents
840835
end
841836
if selectedClass ~= "WEAPONS" then
@@ -845,7 +840,6 @@ function FieldGuide_ToggleButtons(type)
845840
updateButtons()
846841
else
847842
hideUnwantedWeapons()
848-
resetScroll()
849843
updateWeapons()
850844
end
851845
end
@@ -855,6 +849,7 @@ function FieldGuide_OnLoad(self)
855849
self:RegisterForDrag("LeftButton")
856850
self:RegisterEvent("ADDON_LOADED")
857851
self:RegisterEvent("LEARNED_SPELL_IN_TAB")
852+
self:RegisterEvent("PLAYER_ENTERING_WORLD")
858853
end
859854

860855
-- Called on each event the frame receives.
@@ -866,15 +861,14 @@ function FieldGuide_OnEvent(self, event, ...)
866861
FieldGuideOptions = FieldGuideOptions or {}
867862
FieldGuideOptions.pins = {}
868863
end
869-
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.")
870864
FieldGuideOptions = FieldGuideOptions or {}
871865
FieldGuideOptions.showTalents = FieldGuideOptions.showTalents
872866
FieldGuideOptions.showEnemySpells = FieldGuideOptions.showEnemySpells
873867
FieldGuideOptions.showKnownSpells = FieldGuideOptions.showKnownSpells
874868
FieldGuideOptions.unwantedSpells = FieldGuideOptions.unwantedSpells or {}
875869
FieldGuideOptions.minimapTable = FieldGuideOptions.minimapTable or {}
876870
FieldGuideOptions.pins = FieldGuideOptions.pins or {}
877-
init()
871+
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.")
878872
self:UnregisterEvent("ADDON_LOADED")
879873
end
880874
elseif event == "LEARNED_SPELL_IN_TAB" then
@@ -885,5 +879,9 @@ function FieldGuide_OnEvent(self, event, ...)
885879
hideUnwantedWeapons()
886880
updateWeapons()
887881
end
882+
elseif event == "PLAYER_ENTERING_WORLD" then
883+
init()
884+
FieldGuideFrame:Hide()
885+
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
888886
end
889887
end

FieldGuide.xml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,6 @@
112112
<Anchors>
113113
<Anchor point="TOP" x="0" y="10" />
114114
</Anchors>
115-
<Scripts>
116-
<OnMouseDown>
117-
self:GetParent():StartMoving()
118-
</OnMouseDown>
119-
<OnMouseUp>
120-
self:GetParent():StopMovingOrSizing()
121-
</OnMouseUp>
122-
</Scripts>
123115
</Frame>
124116
<Slider name="$parentVerticalSlider" orientation="VERTICAL" minValue="0" maxValue="0" defaultValue="0" valueStep="1">
125117
<Size x="22" y="1" />
@@ -279,6 +271,12 @@
279271
<OnHide>
280272
PlaySound(SOUNDKIT.IG_SPELLBOOK_CLOSE)
281273
</OnHide>
274+
<OnDragStart>
275+
self:StartMoving()
276+
</OnDragStart>
277+
<OnDragStop>
278+
self:StopMovingOrSizing()
279+
</OnDragStop>
282280
<OnMouseWheel>
283281
FieldGuide_Scroll(delta)
284282
</OnMouseWheel>

Util.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
local _, FieldGuide = ...
22

3+
local GetNumSkillLines, GetSkillLineInfo = GetNumSkillLines, GetSkillLineInfo
4+
35
FieldGuide.factions = {
46
["darnassus"] = 69,
57
["darkspear_trolls"] = 530,
@@ -93,3 +95,12 @@ end
9395
function FieldGuide.getContinent(map)
9496
return continents[map]
9597
end
98+
99+
function FieldGuide.isWeaponKnown(name)
100+
for i = 1, GetNumSkillLines() do
101+
if name == GetSkillLineInfo(i) then
102+
return true
103+
end
104+
end
105+
return false
106+
end

0 commit comments

Comments
 (0)