Jaliborc / PetTracker

Tracks pets, alerts for upgrades and helps you in pet battles.
48 stars 26 forks source link

hide tracking when complete #240

Open vioray opened 3 years ago

vioray commented 3 years ago

it's great to be able to see when the zone contains pets I still need, but once I have them all at max level and quality there's really no need to see it anymore. however if I disable it then I often forget to turn it back on when I get to another zone it'd be helpful to have an option to hide the tracking in zones with no upgrades and automatically display in zones where there are upgrades

ghoselle commented 3 years ago

Or as an idea, maybe a toggle that appears on the map that can turn off pet tracker for that specific map?

bloerwald commented 3 years ago

What I use myself:

diff --git a/addons/config/options.lua b/addons/config/options.lua
index a13b7cf..864c4eb 100644
--- a/addons/config/options.lua
+++ b/addons/config/options.lua
@@ -58,6 +58,8 @@ function Options:OnMain()
    self:AddCheck('TrackPets')
    self:AddCheck('SpecieIcons')
    self:AddCheck('RivalPortraits')
+   self:AddCheck('HideIfEmpty')
+   self:AddCheck('CapturedPets')

    self:Add('Header', L.Source5, GameFontHighlight, true)
    self:AddCheck('Switcher')
diff --git a/addons/main/classes/tracking/Tracker.lua b/addons/main/classes/tracking/Tracker.lua
index 8210ef7..a15aec6 100644
--- a/addons/main/classes/tracking/Tracker.lua
+++ b/addons/main/classes/tracking/Tracker.lua
@@ -116,6 +116,12 @@ function Tracker:ToggleDropdown()
                checked = Addon.sets.capturedPets,
                func = Tracker.ToggleCaptured,
                isNotRadio = true,
+           },
+           {
+               text = L.HideIfEmpty,
+               checked = Addon.sets.hideIfEmpty,
+               func = Tracker.ToggleHideIfEmpty,
+               isNotRadio = true,
            }
        }
    end
@@ -130,3 +136,8 @@ function Tracker:ToggleCaptured()
    Addon.sets.capturedPets = not Addon.sets.capturedPets
    Addon:SendSignal('OPTIONS_CHANGED')
 end
+
+function Tracker:ToggleHideIfEmpty()
+   Addon.sets.hideIfEmpty = not Addon.sets.hideIfEmpty
+   Addon:SendSignal('OPTIONS_CHANGED')
+end
diff --git a/addons/main/features/objectives.lua b/addons/main/features/objectives.lua
index 29d9b1a..4fd081f 100644
--- a/addons/main/features/objectives.lua
+++ b/addons/main/features/objectives.lua
@@ -65,7 +65,7 @@ end

 function Objectives:Update()
    self:GetClass().Update(self)
-   self:SetShown(Addon.sets.trackPets)
+   self:SetShown(Addon.sets.trackPets and (not Addon.sets.hideIfEmpty or self:Count() ~= 0))
    self:UpdateMinimize()

    OBJECTIVE_TRACKER_ADDONS[self.Index] = self:IsShown() and self:GetHeight() or 0
diff --git a/addons/main/localization/en.lua b/addons/main/localization/en.lua
index c684327..4f8c7b5 100644
--- a/addons/main/localization/en.lua
+++ b/addons/main/localization/en.lua
@@ -11,7 +11,6 @@ L.AskForfeit = 'No upgrades are available. Quit battle?'
 L.AvailableBreeds = 'Available Breeds'
 L.Breed = 'Breed'
 L.BreedExplanation = 'Determines how stats gained at each level are distributed.'
-L.CapturedPets = 'Show Captured'
 L.CommonSearches = 'Common Searches'
 L.FilterSpecies = 'Filter Species'
 L.LoadTeam = 'Load Team'
@@ -53,6 +52,10 @@ L.SpecieIconsTip = 'If disabled, pets will be marked by their type instead of sp
 L.Switcher = 'Switcher'
 L.SwitcherTip = 'If enabled, the default UI for switching pets in combat will be replaced by an improved one.'
 L.TrackPetsTip = 'If enabled, a list of pet capture progress in the current zone will be displayed next to the quest objectives.'
+L.CapturedPets = 'Show Captured'
+L.CapturedPetsTip = 'If enabled, the tracker will list names and levels of pets you captured in this zone.'
+L.HideIfEmpty = 'Hide if nothing to track'
+L.HideIfEmptyTip = 'If enabled, the tracker bar will be hidden if a zone has nothing to offer.'

 L.FAQ = {
    'How do I show/hide all pets on the map?',
diff --git a/addons/main/main.lua b/addons/main/main.lua
index eb5898c..d18ddc7 100644
--- a/addons/main/main.lua
+++ b/addons/main/main.lua
@@ -27,7 +27,7 @@ function Addon:OnEnable()
    PetTracker_State = PetTracker_State or {}
    PetTracker_Sets = setmetatable(PetTracker_Sets or {}, {__index = {
        trackPets = true, capturedPets = true, specieIcons = true, rivalPortraits = true,
-       switcher = true, alertUpgrades = true, forfeit = true,
+       switcher = true, alertUpgrades = true, forfeit = true, hideIfEmpty = false,
    }})

    self.sets, self.state = PetTracker_Sets, PetTracker_State
Jaliborc commented 3 years ago

it's great to be able to see when the zone contains pets I still need, but once I have them all at max level and quality there's really no need to see it anymore. however if I disable it then I often forget to turn it back on when I get to another zone it'd be helpful to have an option to hide the tracking in zones with no upgrades and automatically display in zones where there are upgrades

Yeah, the tracker really shouldn't show up if there are not species to track or if you've completed the zone.

addonaddict commented 3 years ago

I second this There is an empty "Pets" header always on in Oribos even though there are no pets.. Should be hidden by default unless there is relevant information to show No pets or all pets at level 25 and blue is not relevant information as it can be considered 100% collected in my eyes

Thanks

image