Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a525a7ebd | |||
| b250f0e653 | |||
| b83b6179a6 |
@@ -1,5 +1,5 @@
|
|||||||
<img src="https://cdn.discordapp.com/attachments/1158418666883395656/1526206321010147368/l.gif?ex=6a562de6&is=6a54dc66&hm=cd94c5a6c622a6bc738e4526cd44c5b9ce9eeeeb2ad8481311ca875a3630dd33&"/>
|
<img src="https://i.postimg.cc/15cJh6y2/hfgh.gif"/>
|
||||||
<img src="https://cdn.discordapp.com/attachments/1158418666883395656/1526206333282549850/i.gif?ex=6a562de9&is=6a54dc69&hm=e05805bee98bbc5fa5315a7d3e295cf1908a965e5840fbd315c26d180b28157d&"/>
|
<img src="https://i.postimg.cc/7ZHXx66D/sdfsdf.gif"/>
|
||||||
|
|
||||||
# Relationships Quest And Item Browser
|
# Relationships Quest And Item Browser
|
||||||
|
|
||||||
|
|||||||
@@ -2484,23 +2484,153 @@ local function RQL_ProcessChatFrame(frame)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local RQL_PLUS_TIMER = 0
|
-- Event-driven [+] scanning.
|
||||||
|
--
|
||||||
|
-- The old implementation ran a full chat-frame scan ~33 times per second
|
||||||
|
-- (every 0.03s) regardless of whether chat had changed. On busy zones /
|
||||||
|
-- raids that constant `frame:GetRegions()` + regex work was a real source
|
||||||
|
-- of random lag spikes (GC pressure from throwaway region tables).
|
||||||
|
--
|
||||||
|
-- Now we scan only when:
|
||||||
|
-- * a CHAT_MSG_* event arrives (with a tiny delay so the chat frame has
|
||||||
|
-- laid out the new region before we measure it), or
|
||||||
|
-- * the user scrolls / resizes a chat frame (hooked below), or
|
||||||
|
-- * the addon just finished loading (initial pass over existing chat).
|
||||||
|
--
|
||||||
|
-- Scans are rate-limited to at most one every RQL_SCAN_MIN_INTERVAL.
|
||||||
|
-- Near-instant update: [+] icons must track new chat lines the same frame
|
||||||
|
-- they render. A 0.25s throttle was visibly slow when messages scrolled up
|
||||||
|
-- and the old [+] drifted with them. We now scan on the very next frame.
|
||||||
|
-- Tiny throttle: enough to coalesce bursts of chat events (raids, spammy
|
||||||
|
-- channels) into a single rescan per frame-ish window, but small enough
|
||||||
|
-- that the [+] still tracks new lines effectively instantly to the eye.
|
||||||
|
local RQL_SCAN_MIN_INTERVAL = 0.03
|
||||||
|
local RQL_SCAN_DELAY = 0.01
|
||||||
|
local RQL_SCAN_PENDING_AT = nil
|
||||||
|
local RQL_SCAN_LAST_AT = 0
|
||||||
|
|
||||||
|
function RQL_SchedulePlusScan(delay)
|
||||||
|
local now = GetTime()
|
||||||
|
local at = now + (delay or RQL_SCAN_DELAY)
|
||||||
|
local earliest = RQL_SCAN_LAST_AT + RQL_SCAN_MIN_INTERVAL
|
||||||
|
if at < earliest then at = earliest end
|
||||||
|
if not RQL_SCAN_PENDING_AT or at < RQL_SCAN_PENDING_AT then
|
||||||
|
RQL_SCAN_PENDING_AT = at
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Called every frame from the main OnUpdate. Cheap when idle: two compares
|
||||||
|
-- and an early return. Only does real work when a scan is due.
|
||||||
function RQL_PlusTick(elapsed)
|
function RQL_PlusTick(elapsed)
|
||||||
RQL_PLUS_TIMER = RQL_PLUS_TIMER + (elapsed or 0)
|
if not RQL_SCAN_PENDING_AT then return end
|
||||||
if RQL_PLUS_TIMER < 0.03 then return end
|
if GetTime() < RQL_SCAN_PENDING_AT then return end
|
||||||
RQL_PLUS_TIMER = 0
|
RQL_SCAN_PENDING_AT = nil
|
||||||
|
RQL_SCAN_LAST_AT = GetTime()
|
||||||
|
|
||||||
RQL_PoolIndex = 0
|
RQL_PoolIndex = 0
|
||||||
local maxFrames = NUM_CHAT_WINDOWS or 7
|
local maxFrames = NUM_CHAT_WINDOWS or 7
|
||||||
for i = 1, maxFrames do
|
for i = 1, maxFrames do
|
||||||
local f = getglobal("ChatFrame" .. i)
|
local f = getglobal("ChatFrame" .. i)
|
||||||
if f then RQL_ProcessChatFrame(f) end
|
-- IsVisible() is false for docked tabs that aren't the front tab
|
||||||
|
-- and for hidden / minimized chat windows, so we naturally skip
|
||||||
|
-- all of those.
|
||||||
|
if f and f.IsVisible and f:IsVisible() then
|
||||||
|
RQL_ProcessChatFrame(f)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
RQL_HideUnusedButtons()
|
RQL_HideUnusedButtons()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Watcher frame that listens for chat traffic and requests a rescan.
|
||||||
|
local RQL_ChatWatch = CreateFrame("Frame", "RQL_ChatWatch")
|
||||||
|
local RQL_CHAT_EVENTS = {
|
||||||
|
"CHAT_MSG_SAY", "CHAT_MSG_YELL", "CHAT_MSG_EMOTE", "CHAT_MSG_TEXT_EMOTE",
|
||||||
|
"CHAT_MSG_WHISPER", "CHAT_MSG_WHISPER_INFORM",
|
||||||
|
"CHAT_MSG_PARTY", "CHAT_MSG_RAID", "CHAT_MSG_RAID_LEADER", "CHAT_MSG_RAID_WARNING",
|
||||||
|
"CHAT_MSG_GUILD", "CHAT_MSG_OFFICER",
|
||||||
|
"CHAT_MSG_CHANNEL",
|
||||||
|
"CHAT_MSG_SYSTEM", "CHAT_MSG_LOOT", "CHAT_MSG_TRADESKILLS",
|
||||||
|
"CHAT_MSG_BATTLEGROUND", "CHAT_MSG_BATTLEGROUND_LEADER",
|
||||||
|
}
|
||||||
|
for i = 1, table.getn(RQL_CHAT_EVENTS) do
|
||||||
|
RQL_ChatWatch:RegisterEvent(RQL_CHAT_EVENTS[i])
|
||||||
|
end
|
||||||
|
RQL_ChatWatch:SetScript("OnEvent", function()
|
||||||
|
RQL_SchedulePlusScan()
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Immediately hide every [+] button in the pool. Used on tab-switch so a
|
||||||
|
-- stale icon from the previous tab disappears the instant the user clicks
|
||||||
|
-- a new tab, without waiting for the next scan tick.
|
||||||
|
local function RQL_HideAllPlusButtons()
|
||||||
|
local i = 1
|
||||||
|
while RQL_PLUS_POOL[i] do
|
||||||
|
RQL_PLUS_POOL[i]:Hide()
|
||||||
|
RQL_PLUS_POOL[i].rqlEntry = nil
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
RQL_PoolIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
local function RQL_HookChatLinks()
|
local function RQL_HookChatLinks()
|
||||||
-- Nothing to hook up-front; the OnUpdate ticker in the event handler
|
-- Chat scrolling / paging moves existing linked lines but doesn't fire
|
||||||
-- calls RQL_PlusTick() every frame and it drives everything else.
|
-- an event. Wrap the standard scroll helpers so [+] follows the text.
|
||||||
|
local names = { "ScrollUp", "ScrollDown", "ScrollToTop",
|
||||||
|
"ScrollToBottom", "PageUp", "PageDown" }
|
||||||
|
local maxFrames = NUM_CHAT_WINDOWS or 7
|
||||||
|
for i = 1, maxFrames do
|
||||||
|
local f = getglobal("ChatFrame" .. i)
|
||||||
|
if f then
|
||||||
|
for j = 1, table.getn(names) do
|
||||||
|
local n = names[j]
|
||||||
|
local flag = "_rql_hooked_" .. n
|
||||||
|
if f[n] and not f[flag] then
|
||||||
|
local orig = f[n]
|
||||||
|
f[flag] = orig
|
||||||
|
f[n] = function()
|
||||||
|
orig(f)
|
||||||
|
RQL_SchedulePlusScan()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Hook chat tab clicks so switching tabs instantly clears any stale [+]
|
||||||
|
-- from the previously-visible tab and re-scans the newly-visible one.
|
||||||
|
-- Also hook OnShow/OnHide on the frames themselves as a safety net for
|
||||||
|
-- undock/dock and other visibility changes.
|
||||||
|
for i = 1, maxFrames do
|
||||||
|
local tab = getglobal("ChatFrame" .. i .. "Tab")
|
||||||
|
if tab and not tab._rql_hooked_click then
|
||||||
|
local origClick = tab:GetScript("OnClick")
|
||||||
|
tab._rql_hooked_click = true
|
||||||
|
tab:SetScript("OnClick", function()
|
||||||
|
if origClick then origClick() end
|
||||||
|
RQL_HideAllPlusButtons()
|
||||||
|
RQL_SchedulePlusScan(0)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
local f = getglobal("ChatFrame" .. i)
|
||||||
|
if f and not f._rql_hooked_vis then
|
||||||
|
f._rql_hooked_vis = true
|
||||||
|
local origShow = f:GetScript("OnShow")
|
||||||
|
f:SetScript("OnShow", function()
|
||||||
|
if origShow then origShow() end
|
||||||
|
RQL_HideAllPlusButtons()
|
||||||
|
RQL_SchedulePlusScan(0)
|
||||||
|
end)
|
||||||
|
local origHide = f:GetScript("OnHide")
|
||||||
|
f:SetScript("OnHide", function()
|
||||||
|
if origHide then origHide() end
|
||||||
|
RQL_HideAllPlusButtons()
|
||||||
|
RQL_SchedulePlusScan(0)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Do one pass shortly after login so already-visible chat gets [+].
|
||||||
|
RQL_SchedulePlusScan(0.3)
|
||||||
end
|
end
|
||||||
-- ---------- events / slash ----------
|
-- ---------- events / slash ----------
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
## Title: Relationships Quest And Item Browser
|
## Title: Relationships Quest And Item Browser
|
||||||
## Notes: Click quest and item links in chat, browse and search the full quest and item database.
|
## Notes: Click quest and item links in chat, browse and search the full quest and item database.
|
||||||
## Author: Relationship
|
## Author: Relationship
|
||||||
## Version: 1.0
|
## Version: 1.1
|
||||||
## SavedVariables: RelationshipsQuestAndItemBrowserDB
|
## SavedVariables: RelationshipsQuestAndItemBrowserDB
|
||||||
RelationshipsQuestAndItemBrowser.xml
|
RelationshipsQuestAndItemBrowser.xml
|
||||||
RelationshipsQuestAndItemBrowserData_Init.lua
|
RelationshipsQuestAndItemBrowserData_Init.lua
|
||||||
|
|||||||
Reference in New Issue
Block a user