From 4d030d6fb18b430738ae60ccbd54918e4ea4b0c3 Mon Sep 17 00:00:00 2001 From: Noshei <8866000+Noshei@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:41:07 -0600 Subject: [PATCH] 3.0.1 Added option to hide in combat --- Config.lua | 17 +++++++++++++++++ GatheringTracker.lua | 18 ++++++++++++++++++ GatheringTracker.toc | 2 +- Utilities.lua | 31 ++++--------------------------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/Config.lua b/Config.lua index 854f683..0076c0f 100644 --- a/Config.lua +++ b/Config.lua @@ -56,6 +56,7 @@ GT.defaults = { groupHide = false, showDelve = false, showFollower = false, + combatHide = false, itemsPerHour = false, goldPerHour = false, collapseDisplay = false, @@ -317,6 +318,22 @@ local generalOptions = { end, order = 130 }, + combatHide = { + type = "toggle", + name = "Hide in Combat", + desc = "When selected the display will be hidden when you enter combat.\n" .. + "This overrides the options for Show in Delves and Show in Follower Dungeons.", + width = 1.70, + get = function() return GT.db.profile.General.combatHide end, + set = function(_, key) + GT.db.profile.General.combatHide = key + if key then + GT:RegisterEvent("PLAYER_REGEN_DISABLED") + GT:RegisterEvent("PLAYER_REGEN_ENABLED") + end + end, + order = 140 + }, header2 = { type = "header", name = "Collapse Display", diff --git a/GatheringTracker.lua b/GatheringTracker.lua index baa832f..6ee9787 100644 --- a/GatheringTracker.lua +++ b/GatheringTracker.lua @@ -57,6 +57,10 @@ function GT:OnEnable() GT:RegisterEvent("PLAYER_MONEY", "InventoryUpdate") GT:RegisterEvent("GROUP_ROSTER_UPDATE") GT:RegisterEvent("PLAYER_ENTERING_WORLD") + if GT.db.profile.General.combatHide then + GT:RegisterEvent("PLAYER_REGEN_DISABLED") + GT:RegisterEvent("PLAYER_REGEN_ENABLED") + end else GT:OnDisable() end @@ -73,6 +77,8 @@ function GT:OnDisable() GT:UnregisterEvent("PLAYER_MONEY") GT:UnregisterEvent("GROUP_ROSTER_UPDATE") GT:UnregisterEvent("PLAYER_ENTERING_WORLD") + GT:UnregisterEvent("PLAYER_REGEN_DISABLED") + GT:UnregisterEvent("PLAYER_REGEN_ENABLED") else GT:OnEnable() end @@ -107,6 +113,18 @@ function GT:BAG_UPDATE() end end +---Fires when the player enters combat +function GT:PLAYER_REGEN_DISABLED() + GT.combat = true + GT:SetDisplayState() +end + +---Fires when the player exits combat +function GT:PLAYER_REGEN_ENABLED() + GT.combat = false + GT:SetDisplayState() +end + function GT:SetDisplayState() if GT:DisplayVisibility() then GT.baseFrame.frame:Show() diff --git a/GatheringTracker.toc b/GatheringTracker.toc index df3e8b5..e5baefc 100644 --- a/GatheringTracker.toc +++ b/GatheringTracker.toc @@ -2,7 +2,7 @@ ## Title: Gathering Tracker ## Notes: Addon for tracking gathered items, supports solo players and groups ## Author: Noshei -## Version: 3.0.0 +## Version: 3.0.1 ## OptionalDeps: TradeSkillMaster, RECrystallize, Auctionator ## SavedVariables: GatheringTrackerDB ## AddonCompartmentFunc: GatheringTracker_OnAddonCompartmentClick diff --git a/Utilities.lua b/Utilities.lua index e785a62..8185d41 100644 --- a/Utilities.lua +++ b/Utilities.lua @@ -149,6 +149,10 @@ function GT:DisplayVisibility() local follower = C_LFGInfo.IsInLFGFollowerDungeon() local delve = select(3, GetInstanceInfo()) == 208 + if GT.db.profile.General.combatHide and GT.combat then + return false + end + if group and GT.db.profile.General.groupHide then if delve and GT.db.profile.General.showDelve then GT.Debug("DisplayVisibility", 1, "Group", "Delve", group, @@ -272,30 +276,3 @@ function GT:GetItemPrice(itemID) end return price end - ---[[function GT:SimulateGroup(case) - --This is for testing purposes only. - --It will simulate the effects of another player being in a group with you that also has the addon. - - GT.Debug("Simulate Group", 1) - GT.SimulateGroupRunning = true - - local message = "" - if case == 1 then - GT:GROUP_ROSTER_UPDATE("Simulate Group") - message = "1=4824 2=1 2447=452 2449=483 2450=85 2452=10 785=60 " .. - "765=490 2592=10 3685=10 2589=80 7100=40 6663=10 39354=50 171831=45" - elseif case == 2 then - message = "1=4824 2=2 2447=4520 2449=4830 2450=850 2452=10 785=600 " .. - "765=4900 2592=100 3685=10 2589=80 7100=400 6663=10 39354=50 171831=450" - elseif case == 3 then - message = "1=4824 2=3 2447=45200 2449=4830 2450=850 2452=100 785=600 " .. - "765=4900 2592=1000 3685=10 2589=800 7100=400 6663=100 39354=50 171831=450" - end - if case then - GT:DataMessageReceived("GT_Data", message, "GROUP", "SimulatedGroup") - else - GT.SimulateGroupRunning = nil - GT:GROUP_ROSTER_UPDATE("Simulate Group") - end -end]]