diff --git a/Collie.lua b/Collie.lua
index a12ab8e..07949a0 100644
--- a/Collie.lua
+++ b/Collie.lua
@@ -1,9 +1,15 @@
local filter = ''
local filterTable = {}
+local filterFlags = {
+ ['swimming'] = true,
+ ['flying'] = true,
+ ['ground'] = true,
+ ['combined'] = true,
+}
local Search = CreateFrame('EditBox', 'MountSearch', MountJournal, 'SearchBoxTemplate')
Search:SetSize(145, 20)
-Search:SetPoint('LEFT', MountJournal.MountCount, 'RIGHT', 15, 0)
+Search:SetPoint('TOPLEFT', MountJournal.LeftInset, 15, -9)
Search:SetMaxLetters(40)
Search:SetScript('OnTextChanged', function(self)
local text = self:GetText()
@@ -16,12 +22,31 @@ Search:SetScript('OnTextChanged', function(self)
MountJournal_UpdateMountList()
end)
+local mounts = {}
+for index = 1, GetNumCompanions('MOUNT') do
+ local id, name, _, _, _, flag = GetCompanionInfo('MOUNT', index)
+ if(flag == 12) then
+ mounts[index] = 'swimming'
+ elseif(flag == 7 or flag == 15) then
+ mounts[index] = 'flying'
+ elseif(flag == 29) then
+ mounts[index] = 'ground'
+ elseif(flag == 31) then
+ mounts[index] = 'combined'
+ end
+
+ -- exceptions
+ if(id == 34187) then
+ mounts[index] = 'swimming'
+ end
+end
+
function MountJournal_UpdateMountList()
local scroll = MountJournal.ListScrollFrame
local offset = HybridScrollFrame_GetOffset(scroll)
- local mounts = GetNumCompanions('MOUNT')
+ local total = GetNumCompanions('MOUNT')
- if(UnitLevel('player') < 20 or mounts < 1) then
+ if(UnitLevel('player') < 20 or total < 1) then
scroll:Hide()
MountJournal.MountDisplay.NoMounts:Show()
MountJournal.selectedSpellID = 0
@@ -37,9 +62,9 @@ function MountJournal_UpdateMountList()
table.wipe(filterTable)
- for index = 1, mounts do
- local id, name, spell, icon, active = GetCompanionInfo('MOUNT', index)
- if(name:lower():find(filter)) then
+ for index = 1, total do
+ local id, name, spell, icon, active, flag = GetCompanionInfo('MOUNT', index)
+ if(name:lower():find(filter) and filterFlags[mounts[index]]) then
table.insert(filterTable, index)
end
end
@@ -89,7 +114,66 @@ function MountJournal_UpdateMountList()
end
HybridScrollFrame_Update(scroll, #filterTable * 46, scroll:GetHeight())
- MountJournal.MountCount.Count:SetText(mounts)
+ MountJournal.MountCount.Count:SetText(total)
+end
+
+local scroll = MountJournal.ListScrollFrame
+scroll.update = MountJournal_UpdateMountList
+scroll:SetPoint('TOPLEFT', MountJournal.LeftInset, 3, -36)
+scroll.scrollBar:SetPoint('TOPLEFT', scroll, 'TOPRIGHT', 4, 20)
+
+local function CreateDropDown()
+ local info = UIDropDownMenu_CreateInfo()
+ info.keepShownOnClick = true
+ info.isNotRadio = true
+
+ info.text = 'Ground'
+ info.checked = filterFlags.ground
+ info.func = function(...)
+ local _, _, _, enabled = ...
+ filterFlags.ground = enabled
+ MountJournal_UpdateMountList()
+ end
+ UIDropDownMenu_AddButton(info)
+
+ info.text = 'Flying'
+ info.checked = filterFlags.flying
+ info.func = function(...)
+ local _, _, _, enabled = ...
+ filterFlags.flying = enabled
+ MountJournal_UpdateMountList()
+ end
+ UIDropDownMenu_AddButton(info)
+
+ info.text = 'Flying & Ground'
+ info.checked = filterFlags.combined
+ info.func = function(...)
+ local _, _, _, enabled = ...
+ filterFlags.combined = enabled
+ MountJournal_UpdateMountList()
+ end
+ UIDropDownMenu_AddButton(info)
+
+ info.text = 'Swimming'
+ info.checked = filterFlags.swimming
+ info.func = function(...)
+ local _, _, _, enabled = ...
+ filterFlags.swimming = enabled
+ MountJournal_UpdateMountList()
+ end
+ UIDropDownMenu_AddButton(info)
end
-MountJournal.ListScrollFrame.update = MountJournal_UpdateMountList
+local FilterDropDown = CreateFrame('Frame')
+FilterDropDown.initialize = CreateDropDown
+FilterDropDown.displayMode = 'MENU'
+
+local Filter = CreateFrame('Button', 'MountFilter', MountJournal, 'UIMenuButtonStretchTemplate')
+Filter:SetSize(93, 22)
+Filter:SetPoint('TOPRIGHT', MountJournal.LeftInset, -5, -9)
+Filter:SetText(FILTER)
+Filter.rightArrow:Show()
+Filter:SetScript('OnClick', function()
+ PlaySound('igMainMenuOptionCheckBoxOn')
+ ToggleDropDownMenu(1, nil, FilterDropDown, MountFilter, 74, 15)
+end)