Skip to content

Commit

Permalink
3.0.1
Browse files Browse the repository at this point in the history
Added option to hide in combat
  • Loading branch information
Noshei committed Oct 30, 2024
1 parent 705dac2 commit 4d030d6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
17 changes: 17 additions & 0 deletions Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ GT.defaults = {
groupHide = false,
showDelve = false,
showFollower = false,
combatHide = false,
itemsPerHour = false,
goldPerHour = false,
collapseDisplay = false,
Expand Down Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions GatheringTracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion GatheringTracker.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 4 additions & 27 deletions Utilities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]]

0 comments on commit 4d030d6

Please sign in to comment.