Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements to load time filtering and favorites #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 96 additions & 8 deletions PetJournal_QuickFilter.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
local ASCENDING = 1
local DESCENDING = 2
-- Move the pet list down
PetJournalListScrollFrame:SetPoint("TOPLEFT", PetJournalLeftInset, 3, -60)
PetJournalListScrollFrame:SetPoint("TOPLEFT", PetJournalLeftInset, 3, -55)
-- PetJournalEnhanced draws their own ScrollFrame
if PetJournalEnhancedListScrollFrame then
PetJournalEnhancedListScrollFrame:SetPoint("TOPLEFT", PetJournalLeftInset, 3, -60)
PetJournalEnhancedListScrollFrame:SetPoint("TOPLEFT", PetJournalLeftInset, 3, -55)
end

local QuickFilter_Function = function(self, button)
Expand Down Expand Up @@ -43,35 +45,121 @@ local QuickFilter_Function = function(self, button)
end
end

local Favorites_Function = function(self, button)
if C_PetJournal.IsFlagFiltered(LE_PET_JOURNAL_FLAG_FAVORITES) == false then
C_PetJournal.SetFlagFilter(LE_PET_JOURNAL_FLAG_FAVORITES, false)
self:UnlockHighlight()
else
C_PetJournal.SetFlagFilter(LE_PET_JOURNAL_FLAG_FAVORITES, true)
self:LockHighlight()
end

-- PetJournalEnhanced support
if PetJournalEnhanced then
local PJE = PetJournalEnhanced
if PJE.modules and PJE.modules.Sorting then
if ("RightButton" == button) then
if PJE.modules.Sorting.sorting.order == ASCENDING then
PJE.modules.Sorting.sorting.order = DESCENDING
else
PJE.modules.Sorting.sorting.order = ASCENDING
end
end
PJE.modules.Sorting:UpdatePets()
elseif PJE.UpdatePets then
PJE:UpdatePets()
end
end
end

local maxPetType = 0

local totalActiveCount = 0
local totalCount = 0

-- Create the pet type buttons
for petType, suffix in ipairs(PET_TYPE_SUFFIX) do
local btn = CreateFrame("Button", "PetJournalQuickFilterButton"..petType, PetJournalLeftInset)
btn:SetSize(24, 24)
btn:SetPoint("TOPLEFT", PetJournalLeftInset, 6 + 25 * (petType-1), -33)
btn:SetSize(21, 21)
btn:SetPoint("TOPLEFT", PetJournalLeftInset, 6 + 22 * (petType-1), -33)
maxPetType = petType;

local background = btn:CreateTexture(nil, "BACKGROUND")
background:SetTexture("Interface\\PetBattles\\PetBattleHud")
background:SetTexCoord(0.92089844, 0.95410156, 0.34960938, 0.41601563)
background:SetSize(23, 23)
background:SetSize(22, 22)
background:SetAllPoints()
btn.Background = background

local icon = btn:CreateTexture(nil, "ARTWORK")
icon:SetTexture("Interface\\PetBattles\\PetIcon-"..suffix)
icon:SetTexCoord(0.79687500, 0.49218750, 0.50390625, 0.65625000)
icon:SetSize(22, 22)
icon:SetSize(21, 21)
icon:SetPoint("CENTER")
btn.Icon = icon

local highlight = btn:CreateTexture("Highlight", "OVERLAY")
highlight:SetTexture("Interface\\PetBattles\\PetBattleHud")
highlight:SetTexCoord(0.94921875, 0.99414063, 0.67382813, 0.76367188)
highlight:SetSize(30, 30)
highlight:SetSize(27, 27)
highlight:SetPoint("CENTER")
btn:SetHighlightTexture(highlight, "BLEND")

btn.isActive = false
btn.petType = petType

btn:SetScript("OnMouseUp", QuickFilter_Function)

if C_PetJournal.IsPetTypeFiltered(petType) == false then
btn.isActive = true
totalActiveCount = totalActiveCount + 1
btn:LockHighlight()
else
btn.isActive = false
end

totalCount = totalCount + 1
end

-- If they are all active then uncheck all of them
if (totalCount == totalActiveCount) then
for petType, _ in ipairs(PET_TYPE_SUFFIX) do
local btn = _G["PetJournalQuickFilterButton"..petType]
btn.isActive = false
btn:UnlockHighlight()
end
end

local btn = CreateFrame("Button", "PetJournalQuickFilterButtonFavorites", PetJournalLeftInset)

btn:SetSize(21, 21)
btn:SetPoint("TOPLEFT", PetJournalLeftInset, 6 + 22 * (maxPetType), -33)

local background = btn:CreateTexture(nil, "BACKGROUND")
background:SetTexture("Interface\\PetBattles\\PetBattleHud")
background:SetTexCoord(0.92089844, 0.95410156, 0.34960938, 0.41601563)
background:SetSize(22, 22)
background:SetAllPoints()
btn.Background = background

local icon = btn:CreateTexture(nil, "ARTWORK")
icon:SetTexture("Interface\\PetBattles\\PetJournal")
icon:SetTexCoord(0.11328125,0.16210938,0.02246094,0.04687500)
icon:SetSize(21, 21)
icon:SetPoint("CENTER")
btn.Icon = icon

local highlight = btn:CreateTexture("Highlight", "OVERLAY")
highlight:SetTexture("Interface\\PetBattles\\PetBattleHud")
highlight:SetTexCoord(0.94921875, 0.99414063, 0.67382813, 0.76367188)
highlight:SetSize(27, 27)
highlight:SetPoint("CENTER")
btn:SetHighlightTexture(highlight, "BLEND")


btn:SetScript("OnMouseUp", Favorites_Function)

if C_PetJournal.IsFlagFiltered(LE_PET_JOURNAL_FLAG_FAVORITES) == false then
btn:LockHighlight()
else
btn:UnlockHighlight()
end