perf: add arrow performance controls

This commit is contained in:
Xurkon
2026-06-04 16:53:21 -05:00
parent 71a77b39d0
commit a1424bdd53
3 changed files with 90 additions and 7 deletions
+36 -6
View File
@@ -37,9 +37,9 @@ local ARROW_SHEET_ROWS = 12
local ARROW_TOTAL_CELLS = ARROW_SHEET_COLS * ARROW_SHEET_ROWS local ARROW_TOTAL_CELLS = ARROW_SHEET_COLS * ARROW_SHEET_ROWS
local ARROW_DEFAULT_STYLE = "arrow1" local ARROW_DEFAULT_STYLE = "arrow1"
local UPDATE_THROTTLE_SECONDS = 0.05 local DEFAULT_UPDATE_THROTTLE_SECONDS = 0.05
local RECALC_NEAREST_SECONDS = 1.0 local DEFAULT_RECALC_NEAREST_SECONDS = 1.0
local TRACKER_REFRESH_THROTTLE_SECONDS = 0.5 local DEFAULT_TRACKER_REFRESH_THROTTLE_SECONDS = 0.5
---@type Frame? ---@type Frame?
local arrowFrame = nil local arrowFrame = nil
@@ -74,6 +74,36 @@ local function _IsArrowEnabled()
return Questie.db.profile.arrowEnabled ~= false return Questie.db.profile.arrowEnabled ~= false
end end
local function _GetProfileNumber(key, defaultValue, minValue, maxValue)
if not Questie or not Questie.db or not Questie.db.profile then
return defaultValue
end
local value = Questie.db.profile[key]
if type(value) ~= "number" then
return defaultValue
end
if value < minValue then
return minValue
end
if value > maxValue then
return maxValue
end
return value
end
local function _GetArrowUpdateThrottle()
return _GetProfileNumber("arrowUpdateThrottle", DEFAULT_UPDATE_THROTTLE_SECONDS, 0.03, 0.5)
end
local function _GetArrowRecalcInterval()
return _GetProfileNumber("arrowRecalcInterval", DEFAULT_RECALC_NEAREST_SECONDS, 0.5, 10.0)
end
local function _GetArrowTrackerRefreshThrottle()
return _GetProfileNumber("arrowTrackerRefreshThrottle", DEFAULT_TRACKER_REFRESH_THROTTLE_SECONDS, 0.25, 5.0)
end
local function _GetArrowScale() local function _GetArrowScale()
if not Questie or not Questie.db or not Questie.db.profile then if not Questie or not Questie.db or not Questie.db.profile then
return 1 return 1
@@ -798,7 +828,7 @@ EnsureArrowFrame = function()
objectiveFrame:Show() objectiveFrame:Show()
end end
if (self._lastUpdate or 0) + UPDATE_THROTTLE_SECONDS > now then if (self._lastUpdate or 0) + _GetArrowUpdateThrottle() > now then
return return
end end
self._lastUpdate = now self._lastUpdate = now
@@ -924,7 +954,7 @@ local function EnsureDriverFrame()
driverFrame:SetScript("OnUpdate", function(self) driverFrame:SetScript("OnUpdate", function(self)
local now = GetTime() local now = GetTime()
if (self._lastRecalc or 0) + RECALC_NEAREST_SECONDS < now then if (self._lastRecalc or 0) + _GetArrowRecalcInterval() < now then
self._lastRecalc = now self._lastRecalc = now
if not _IsArrowEnabled() then if not _IsArrowEnabled() then
if arrowFrame then if arrowFrame then
@@ -1505,7 +1535,7 @@ function QuestieArrow:Initialize()
end end
local now = GetTime() local now = GetTime()
if (lastTrackerRefresh + TRACKER_REFRESH_THROTTLE_SECONDS) > now then if (lastTrackerRefresh + _GetArrowTrackerRefreshThrottle()) > now then
return return
end end
@@ -354,7 +354,57 @@ function QuestieOptions.tabs.arrow:Initialize()
end end
end, end,
}, },
arrow_spacer_4 = QuestieOptionsUtils:Spacer(9.5), arrowPerformanceHeader = {
type = "header",
order = 9.4,
name = function() return l10n("Arrow Performance") end,
},
arrowUpdateThrottle = {
type = "range",
order = 9.5,
width = 1.5,
name = function() return l10n("Arrow Movement Update Interval") end,
desc = function() return l10n("Seconds between arrow rotation and distance updates. Higher values reduce CPU usage but make the arrow feel less smooth.") end,
min = 0.03,
max = 0.5,
step = 0.01,
get = function() return Questie.db.profile.arrowUpdateThrottle or optionsDefaults.profile.arrowUpdateThrottle end,
set = function(_, value)
Questie.db.profile.arrowUpdateThrottle = value
end,
},
arrowRecalcInterval = {
type = "range",
order = 9.6,
width = 1.5,
name = function() return l10n("Target Scan Interval") end,
desc = function() return l10n("Seconds between full nearest-objective scans. Higher values reduce HBD and ZoneDB work in large quest logs.") end,
min = 0.5,
max = 10,
step = 0.5,
get = function() return Questie.db.profile.arrowRecalcInterval or optionsDefaults.profile.arrowRecalcInterval end,
set = function(_, value)
Questie.db.profile.arrowRecalcInterval = value
if QuestieArrow and QuestieArrow.Refresh then
QuestieArrow:Refresh()
end
end,
},
arrowTrackerRefreshThrottle = {
type = "range",
order = 9.7,
width = 1.5,
name = function() return l10n("Tracker Refresh Throttle") end,
desc = function() return l10n("Minimum seconds between arrow refreshes triggered by tracker updates. Higher values reduce refresh bursts during quest progress changes.") end,
min = 0.25,
max = 5,
step = 0.25,
get = function() return Questie.db.profile.arrowTrackerRefreshThrottle or optionsDefaults.profile.arrowTrackerRefreshThrottle end,
set = function(_, value)
Questie.db.profile.arrowTrackerRefreshThrottle = value
end,
},
arrow_spacer_4 = QuestieOptionsUtils:Spacer(9.8),
resetArrowPosition = { resetArrowPosition = {
type = "execute", type = "execute",
order = 10, order = 10,
@@ -64,6 +64,9 @@ function QuestieOptionsDefaults:Load()
arrowCustomIsSheet = false, arrowCustomIsSheet = false,
arrowFontSize = 10, arrowFontSize = 10,
arrowFont = 'Friz Quadrata TT', arrowFont = 'Friz Quadrata TT',
arrowUpdateThrottle = 0.05,
arrowRecalcInterval = 1.0,
arrowTrackerRefreshThrottle = 0.5,
debugArrow = false, debugArrow = false,
enableObjectives = true, enableObjectives = true,
enableTurnins = true, enableTurnins = true,