fix: refresh learner settings live
This commit is contained in:
@@ -90,6 +90,13 @@ local function ApplyLearnerPerformancePreset(mode)
|
||||
end
|
||||
end
|
||||
|
||||
local function RefreshLearnerRuntime()
|
||||
local QuestieLearner = QuestieLoader:ImportModule("QuestieLearner")
|
||||
if QuestieLearner and QuestieLearner.RefreshLiveState then
|
||||
QuestieLearner:RefreshLiveState()
|
||||
end
|
||||
end
|
||||
|
||||
function QuestieOptions.tabs.advanced:Initialize()
|
||||
-- This needs to be called inside of the Init process for l10n to be fully loaded
|
||||
StaticPopupDialogs["QUESTIE_LANG_CHANGED_RELOAD"] = {
|
||||
@@ -260,6 +267,7 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
get = function() return GetLearnerSettings().performanceMode or "balanced" end,
|
||||
set = function(_, value)
|
||||
ApplyLearnerPerformancePreset(value)
|
||||
RefreshLearnerRuntime()
|
||||
end,
|
||||
},
|
||||
learnerPinRefreshMode = {
|
||||
@@ -278,6 +286,7 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
local settings = GetLearnerSettings()
|
||||
settings.pinRefreshMode = value
|
||||
settings.performanceMode = "manual"
|
||||
RefreshLearnerRuntime()
|
||||
end,
|
||||
},
|
||||
learnerPinRefreshDelay = {
|
||||
@@ -294,6 +303,7 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
local settings = GetLearnerSettings()
|
||||
settings.pinRefreshDelay = value
|
||||
settings.performanceMode = "manual"
|
||||
RefreshLearnerRuntime()
|
||||
end,
|
||||
},
|
||||
learnerPinRefreshMaxWait = {
|
||||
@@ -310,6 +320,7 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
local settings = GetLearnerSettings()
|
||||
settings.pinRefreshMaxWait = value
|
||||
settings.performanceMode = "manual"
|
||||
RefreshLearnerRuntime()
|
||||
end,
|
||||
},
|
||||
learnerLiveNpcUpdateDelay = {
|
||||
@@ -326,6 +337,7 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
local settings = GetLearnerSettings()
|
||||
settings.liveNpcUpdateDelay = value
|
||||
settings.performanceMode = "manual"
|
||||
RefreshLearnerRuntime()
|
||||
end,
|
||||
},
|
||||
learnerMinConfidencePins = {
|
||||
@@ -342,6 +354,7 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
local settings = GetLearnerSettings()
|
||||
settings.minConfidencePins = value
|
||||
settings.performanceMode = "manual"
|
||||
RefreshLearnerRuntime()
|
||||
end,
|
||||
},
|
||||
learnerSpawnDedupRadius = {
|
||||
@@ -386,6 +399,7 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
elseif Questie.db.profile.learnerBroadcast == false then
|
||||
Questie.db.profile.learnerBroadcast = true
|
||||
end
|
||||
RefreshLearnerRuntime()
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -407,6 +421,10 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
get = function() return Questie.db.profile.arrowUpdateThrottle or optionsDefaults.profile.arrowUpdateThrottle end,
|
||||
set = function(_, value)
|
||||
Questie.db.profile.arrowUpdateThrottle = value
|
||||
local QuestieArrow = QuestieLoader:ImportModule("QuestieArrow")
|
||||
if QuestieArrow and QuestieArrow.Refresh then
|
||||
QuestieArrow:Refresh()
|
||||
end
|
||||
end,
|
||||
},
|
||||
arrowRecalcInterval = {
|
||||
@@ -439,6 +457,10 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
get = function() return Questie.db.profile.arrowTrackerRefreshThrottle or optionsDefaults.profile.arrowTrackerRefreshThrottle end,
|
||||
set = function(_, value)
|
||||
Questie.db.profile.arrowTrackerRefreshThrottle = value
|
||||
local QuestieArrow = QuestieLoader:ImportModule("QuestieArrow")
|
||||
if QuestieArrow and QuestieArrow.Refresh then
|
||||
QuestieArrow:Refresh()
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -457,6 +479,10 @@ function QuestieOptions.tabs.advanced:Initialize()
|
||||
get = function() return Questie.db.profile.questieCommsEnabled ~= false end,
|
||||
set = function(_, value)
|
||||
Questie.db.profile.questieCommsEnabled = value
|
||||
local QuestieComms = QuestieLoader:ImportModule("QuestieComms")
|
||||
if QuestieComms and QuestieComms.ResetAll then
|
||||
QuestieComms:ResetAll()
|
||||
end
|
||||
end,
|
||||
},
|
||||
questieCommsQuestListPacketSize = {
|
||||
|
||||
@@ -316,6 +316,7 @@ function QuestieOptions.tabs.database:Initialize()
|
||||
set = function(_, v)
|
||||
if Questie.dbLearner.global and Questie.dbLearner.global.settings then
|
||||
Questie.dbLearner.global.settings.learnNpcs = v
|
||||
ApplyLearnerMode()
|
||||
end
|
||||
end,
|
||||
},
|
||||
@@ -329,6 +330,7 @@ function QuestieOptions.tabs.database:Initialize()
|
||||
set = function(_, v)
|
||||
if Questie.dbLearner.global and Questie.dbLearner.global.settings then
|
||||
Questie.dbLearner.global.settings.learnQuests = v
|
||||
ApplyLearnerMode()
|
||||
end
|
||||
end,
|
||||
},
|
||||
@@ -342,6 +344,7 @@ function QuestieOptions.tabs.database:Initialize()
|
||||
set = function(_, v)
|
||||
if Questie.dbLearner.global and Questie.dbLearner.global.settings then
|
||||
Questie.dbLearner.global.settings.learnObjects = v
|
||||
ApplyLearnerMode()
|
||||
end
|
||||
end,
|
||||
},
|
||||
@@ -355,6 +358,7 @@ function QuestieOptions.tabs.database:Initialize()
|
||||
set = function(_, v)
|
||||
if Questie.dbLearner.global and Questie.dbLearner.global.settings then
|
||||
Questie.dbLearner.global.settings.learnItems = v
|
||||
ApplyLearnerMode()
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -578,6 +578,28 @@ function QuestieLearner:ApplyDataSourceMode()
|
||||
QuestieLearner.data = Questie.dbLearner.global
|
||||
end
|
||||
|
||||
function QuestieLearner:RefreshLiveState()
|
||||
if not EnsureLearnedData() then return end
|
||||
|
||||
self:ApplyDataSourceMode()
|
||||
|
||||
-- Re-evaluate any pending learner-driven redraws immediately so option
|
||||
-- changes (confidence, dedup, batching, and mode switches) take effect in
|
||||
-- the active session instead of waiting for stale timers to expire.
|
||||
if _Learner.pendingNpcLiveUpdates and next(_Learner.pendingNpcLiveUpdates) then
|
||||
_FlushNpcLiveUpdates()
|
||||
end
|
||||
if _pendingQuestPinRefreshes and next(_pendingQuestPinRefreshes) then
|
||||
_FlushActiveQuestPins()
|
||||
end
|
||||
|
||||
if QuestieQuest and QuestieQuest.SmoothReset then
|
||||
QuestieQuest:SmoothReset()
|
||||
elseif QuestieTracker and QuestieTracker.Update then
|
||||
QuestieTracker:Update()
|
||||
end
|
||||
end
|
||||
|
||||
local function GetLearnerSetting(key, defaultValue)
|
||||
if Questie and Questie.dbLearner and Questie.dbLearner.global and Questie.dbLearner.global.settings then
|
||||
local value = Questie.dbLearner.global.settings[key]
|
||||
|
||||
@@ -12,6 +12,7 @@ end
|
||||
describe("QuestieLearner data source mode", function()
|
||||
it("adds a mode selector and explicit fallback options in the database tab", function()
|
||||
local dbOptions = read("Modules/Options/DatabaseTab/QuestieOptionsDatabase.lua")
|
||||
local advanced = read("Modules/Options/AdvancedTab/QuestieOptionsAdvanced.lua")
|
||||
assert.is_true(has(dbOptions, "Data Source Mode"))
|
||||
assert.is_true(has(dbOptions, "auto = l10n(\"Auto (current behavior)\")"))
|
||||
assert.is_true(has(dbOptions, "learner = l10n(\"Learner Only\")"))
|
||||
@@ -20,6 +21,8 @@ describe("QuestieLearner data source mode", function()
|
||||
assert.is_true(has(dbOptions, "local function GetLearnerSelectedMode()"))
|
||||
assert.is_true(has(dbOptions, "get = function() return GetLearnerSelectedMode() end"))
|
||||
assert.is_true(has(dbOptions, "Runtime mode:"))
|
||||
assert.is_true(has(advanced, "local function RefreshLearnerRuntime()"))
|
||||
assert.is_true(has(advanced, "RefreshLearnerRuntime()"))
|
||||
end)
|
||||
|
||||
it("defaults the learner mode to auto and exposes the live refresh hook", function()
|
||||
@@ -29,6 +32,7 @@ describe("QuestieLearner data source mode", function()
|
||||
assert.is_true(has(learner, "function QuestieLearner:GetDataSourceMode()"))
|
||||
assert.is_true(has(learner, "function QuestieLearner:IsLearnerLiveEnabled()"))
|
||||
assert.is_true(has(learner, "function QuestieLearner:ApplyDataSourceMode()"))
|
||||
assert.is_true(has(learner, "function QuestieLearner:RefreshLiveState()"))
|
||||
end)
|
||||
|
||||
it("gates static suppression and tooltip fallback on the selected mode", function()
|
||||
@@ -107,6 +111,23 @@ describe("QuestieLearner learner mode activation", function()
|
||||
assert.is_true(Questie.dbLearner.global.settings.enabled)
|
||||
assert.is_true(QuestieLearner:IsEnabled())
|
||||
end)
|
||||
|
||||
it("refreshes live learner caches and quest pins when runtime settings change", function()
|
||||
local clearCount = 0
|
||||
local resetCount = 0
|
||||
|
||||
QuestieDB.ClearModeCaches = function()
|
||||
clearCount = clearCount + 1
|
||||
end
|
||||
QuestieQuest.SmoothReset = function()
|
||||
resetCount = resetCount + 1
|
||||
end
|
||||
|
||||
QuestieLearner:RefreshLiveState()
|
||||
|
||||
assert.is_true(clearCount >= 1)
|
||||
assert.is_true(resetCount >= 1)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("QuestieDB learner mode merges learner overrides", function()
|
||||
|
||||
Reference in New Issue
Block a user