From 12366cfc17671e03afa57697731e8ae714aa359c Mon Sep 17 00:00:00 2001 From: yinzara Date: Sun, 29 Dec 2013 11:07:54 -0800 Subject: [PATCH 1/3] Added "Favorites" quickfilter button Since quickfilter doesn't work when only showing favorites, it made sense to have an easy way to do that. I shrunk the current breed filter buttons slightly to fit an extra button at the end. It uses the "Star" favorites icon and reads your current "favorites filter" state when loaded. --- PetJournal_QuickFilter.lua | 72 ++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 7 deletions(-) diff --git a/PetJournal_QuickFilter.lua b/PetJournal_QuickFilter.lua index 03feff6..b6270a6 100644 --- a/PetJournal_QuickFilter.lua +++ b/PetJournal_QuickFilter.lua @@ -1,8 +1,8 @@ -- 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) @@ -43,30 +43,53 @@ 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 + PJE.modules.Sorting:UpdatePets() + elseif PJE.UpdatePets then + PJE:UpdatePets() + end + end +end + +local maxPetType = 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") @@ -75,3 +98,38 @@ for petType, suffix in ipairs(PET_TYPE_SUFFIX) do btn:SetScript("OnMouseUp", QuickFilter_Function) 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 \ No newline at end of file From e1d423f0acbc3b543007559af960252e5bacc8c0 Mon Sep 17 00:00:00 2001 From: yinzara Date: Sun, 29 Dec 2013 11:21:32 -0800 Subject: [PATCH 2/3] Read filtering state on load Since filtering state is saved between reloads, it makes sense to set the filters status according to the current filters state. This fix reads the state of the filter at load time and sets the buttons accordingly. If all pet types are currently not filtered (i.e. all pet types are showing) we update the ui to not show any filter. --- PetJournal_QuickFilter.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/PetJournal_QuickFilter.lua b/PetJournal_QuickFilter.lua index b6270a6..7b7dd67 100644 --- a/PetJournal_QuickFilter.lua +++ b/PetJournal_QuickFilter.lua @@ -65,6 +65,9 @@ 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) @@ -93,10 +96,28 @@ for petType, suffix in ipairs(PET_TYPE_SUFFIX) do 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) From 2e9ab5b173d3c6fc75ecc18f3b4c761bf82bf336 Mon Sep 17 00:00:00 2001 From: yinzara Date: Sun, 29 Dec 2013 11:35:17 -0800 Subject: [PATCH 3/3] Enhancement for PetJournalEnhanced and favorites button Since many times favorites are used to store pets the user would like to level, I've enhanced the new "Favorites" button to swap your sort order when you right click it (as well as swap your favorites). This allows you to quickly see your low level favorite pets or high level favorite pets quickly. --- PetJournal_QuickFilter.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PetJournal_QuickFilter.lua b/PetJournal_QuickFilter.lua index 7b7dd67..a6e21ad 100644 --- a/PetJournal_QuickFilter.lua +++ b/PetJournal_QuickFilter.lua @@ -1,3 +1,5 @@ +local ASCENDING = 1 +local DESCENDING = 2 -- Move the pet list down PetJournalListScrollFrame:SetPoint("TOPLEFT", PetJournalLeftInset, 3, -55) -- PetJournalEnhanced draws their own ScrollFrame @@ -56,6 +58,13 @@ local Favorites_Function = function(self, button) 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()