- "time played" spam fixed (again)...
urnati [05-05-26 - 17:02]
- "time played" spam fixed (again)...
diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua
index 506c84e..f62653a 100644
--- a/Titan/TitanUtils.lua
+++ b/Titan/TitanUtils.lua
@@ -1897,25 +1897,46 @@ function TitanUtils_DecompressData(data, dataType)
end
--====== Overload the 'time played' text to Chat to not show 'time played' to Chat
-local requesting = 0
+local orig_ChatFrame_DisplayTimePlayed = function(...) end -- place holder
--- Save orignal output to Chat
-local orig_ChatFrame_DisplayTimePlayed = function(...) end
+local requesting = 0
+local function ChatPlayedHelper(...)
+ -- A little clunky but calls done rapidly should sort themselves
+ -- even if the exact call to event does not match.
+ if requesting > 0 then
+ -- Titan requested time played, do not spam Chat
+ requesting = requesting - 1
+ else
+ -- Did not request time played so output
+ ---@diagnostic disable-next-line: need-check-nil
+ orig_ChatFrame_DisplayTimePlayed(...)
+ end
+end
+if ChatFrameUtil.DisplayTimePlayed then
+ -- Newer API
+ -- Check new first; Old routine exists (deprecated) in new...
orig_ChatFrame_DisplayTimePlayed = ChatFrameUtil.DisplayTimePlayed
- ChatFrameUtil.DisplayTimePlayed = function(...) --TimePlayed(...)
- -- A little clunky but calls done rapidly should sort themselves
- -- even if the exact call to event does not match.
- if requesting > 0 then
- -- Titan requested time played, do not spam Chat
- requesting = requesting - 1
- else
- -- Did not request time played so output
- ---@diagnostic disable-next-line: need-check-nil
- orig_ChatFrame_DisplayTimePlayed(...)
+ ChatFrameUtil.DisplayTimePlayed = function(...)
+ ChatPlayedHelper(...)
end
- end
+else
+ -- Old Classic
+ orig_ChatFrame_DisplayTimePlayed = ChatFrame_DisplayTimePlayed
+
+ ChatFrame_DisplayTimePlayed = function(...)
+ ChatPlayedHelper(...)
+ end
+end
+
+---Titan Get time played in a general way to not spam Chat
+---@param reason string For debug
+function TitanUtils_GetTimePlayed(reason)
+ requesting = requesting + 1
+
+ RequestTimePlayed()
+end
---Titan Get time played in a general way to not spam Chat
---@param reason string For debug