perf: add arrow performance controls
This commit is contained in:
@@ -37,9 +37,9 @@ local ARROW_SHEET_ROWS = 12
|
||||
local ARROW_TOTAL_CELLS = ARROW_SHEET_COLS * ARROW_SHEET_ROWS
|
||||
local ARROW_DEFAULT_STYLE = "arrow1"
|
||||
|
||||
local UPDATE_THROTTLE_SECONDS = 0.05
|
||||
local RECALC_NEAREST_SECONDS = 1.0
|
||||
local TRACKER_REFRESH_THROTTLE_SECONDS = 0.5
|
||||
local DEFAULT_UPDATE_THROTTLE_SECONDS = 0.05
|
||||
local DEFAULT_RECALC_NEAREST_SECONDS = 1.0
|
||||
local DEFAULT_TRACKER_REFRESH_THROTTLE_SECONDS = 0.5
|
||||
|
||||
---@type Frame?
|
||||
local arrowFrame = nil
|
||||
@@ -74,6 +74,36 @@ local function _IsArrowEnabled()
|
||||
return Questie.db.profile.arrowEnabled ~= false
|
||||
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()
|
||||
if not Questie or not Questie.db or not Questie.db.profile then
|
||||
return 1
|
||||
@@ -798,7 +828,7 @@ EnsureArrowFrame = function()
|
||||
objectiveFrame:Show()
|
||||
end
|
||||
|
||||
if (self._lastUpdate or 0) + UPDATE_THROTTLE_SECONDS > now then
|
||||
if (self._lastUpdate or 0) + _GetArrowUpdateThrottle() > now then
|
||||
return
|
||||
end
|
||||
self._lastUpdate = now
|
||||
@@ -924,7 +954,7 @@ local function EnsureDriverFrame()
|
||||
|
||||
driverFrame:SetScript("OnUpdate", function(self)
|
||||
local now = GetTime()
|
||||
if (self._lastRecalc or 0) + RECALC_NEAREST_SECONDS < now then
|
||||
if (self._lastRecalc or 0) + _GetArrowRecalcInterval() < now then
|
||||
self._lastRecalc = now
|
||||
if not _IsArrowEnabled() then
|
||||
if arrowFrame then
|
||||
@@ -1505,7 +1535,7 @@ function QuestieArrow:Initialize()
|
||||
end
|
||||
|
||||
local now = GetTime()
|
||||
if (lastTrackerRefresh + TRACKER_REFRESH_THROTTLE_SECONDS) > now then
|
||||
if (lastTrackerRefresh + _GetArrowTrackerRefreshThrottle()) > now then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -354,7 +354,57 @@ function QuestieOptions.tabs.arrow:Initialize()
|
||||
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 = {
|
||||
type = "execute",
|
||||
order = 10,
|
||||
|
||||
@@ -64,6 +64,9 @@ function QuestieOptionsDefaults:Load()
|
||||
arrowCustomIsSheet = false,
|
||||
arrowFontSize = 10,
|
||||
arrowFont = 'Friz Quadrata TT',
|
||||
arrowUpdateThrottle = 0.05,
|
||||
arrowRecalcInterval = 1.0,
|
||||
arrowTrackerRefreshThrottle = 0.5,
|
||||
debugArrow = false,
|
||||
enableObjectives = true,
|
||||
enableTurnins = true,
|
||||
|
||||
Reference in New Issue
Block a user