Rework query saving to only write strings instead of tables
This commit is contained in:
@@ -108,7 +108,7 @@ local function init()
|
||||
---@field ttl number
|
||||
---@field doWhisper boolean
|
||||
---@field zoneNotifyFor table<string, boolean>
|
||||
---@field queries WHOQuery[]
|
||||
---@field queries string
|
||||
|
||||
---@class HeimdallMessengerConfig
|
||||
---@field enabled boolean
|
||||
@@ -313,6 +313,7 @@ local function init()
|
||||
ignored = {},
|
||||
}
|
||||
|
||||
--/run Heimdall_Data.config.who.queries="g-\"БеспредеЛ\"|ally"
|
||||
Heimdall_Data.config = {
|
||||
spotter = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true),
|
||||
@@ -340,7 +341,7 @@ local function init()
|
||||
["Echo Isles"] = true,
|
||||
["Valley of Trials"] = true,
|
||||
}),
|
||||
queries = shared.GetOrDefault(Heimdall_Data, { "config", "who", "queries" }, {}),
|
||||
queries = shared.GetOrDefault(Heimdall_Data, { "config", "who", "queries" }, ""),
|
||||
},
|
||||
messenger = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "enabled" }, true),
|
||||
|
@@ -657,7 +657,7 @@ function shared.Config.Init()
|
||||
local whoerConfigFrame = GridFrame.new("HeimdallWhoerConfig",
|
||||
UIParent, 12, 20)
|
||||
whoerConfigFrame.frame:SetBackdropColor(r, g, b, 0.3)
|
||||
configFrame:Add(whoerConfigFrame, 16, 6)
|
||||
configFrame:Add(whoerConfigFrame, 19, 6)
|
||||
|
||||
local title = CreateFancyText("HeimdallWhoerConfigTitle", whoerConfigFrame.frame,
|
||||
shared.L[Heimdall_Data.config.locale].config.whoer, { r, g, b, a })
|
||||
@@ -736,12 +736,12 @@ function shared.Config.Init()
|
||||
|
||||
local whoQueries = CreateBasicBigEditBox("HeimdallWhoerConfigQueries",
|
||||
whoerConfigFrame.frame, shared.L[Heimdall_Data.config.locale].config.queries,
|
||||
shared.WhoQueryService.WhoQueriesToString(Heimdall_Data.config.who.queries or {}),
|
||||
shared.WhoQueryService.WhoQueriesToString(shared.WhoQueryService.queries or {}),
|
||||
function(self)
|
||||
local queries = shared.WhoQueryService.WhoQueriesFromString(self:GetText())
|
||||
Heimdall_Data.config.who.queries = queries
|
||||
Heimdall_Data.config.who.queries = self:GetText()
|
||||
shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(self:GetText())
|
||||
end)
|
||||
whoerConfigFrame:Add(whoQueries, 4, 6)
|
||||
whoerConfigFrame:Add(whoQueries, 5, 6)
|
||||
end
|
||||
|
||||
-- Messenger
|
||||
|
@@ -145,6 +145,7 @@ function shared.Whoer.Init()
|
||||
}
|
||||
|
||||
---@class WhoQueryService
|
||||
---@field queries WHOQuery[]
|
||||
---@field filters WHOFilter[]
|
||||
---@field getFilter fun(key: string): WHOFilter?
|
||||
---@field WhoQueryToString fun(query: WHOQuery): string
|
||||
@@ -152,6 +153,7 @@ function shared.Whoer.Init()
|
||||
---@field WhoQueriesToString fun(queries: WHOQuery[]): string
|
||||
---@field WhoQueriesFromString fun(queries: string): WHOQuery[]
|
||||
shared.WhoQueryService = {
|
||||
queries = {},
|
||||
filters = {
|
||||
NotSiegeOfOrgrimmarFilter,
|
||||
AllianceFilter
|
||||
@@ -208,6 +210,7 @@ function shared.Whoer.Init()
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters))
|
||||
end
|
||||
shared.dumpTable(filters)
|
||||
return WHOQuery.new(queryParts[1], filters)
|
||||
end,
|
||||
---@param queries string
|
||||
@@ -221,8 +224,7 @@ function shared.Whoer.Init()
|
||||
return ret
|
||||
end
|
||||
}
|
||||
local query = shared.WhoQueryService.WhoQueryFromString("g-\"БеспредеЛ\";ally")
|
||||
Heimdall_Data.config.who.queries[1] = query
|
||||
shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(Heimdall_Data.config.who.queries)
|
||||
|
||||
-----@type WHOQuery[]
|
||||
--local whoQueries = {
|
||||
@@ -498,6 +500,9 @@ function shared.Whoer.Init()
|
||||
---@type WHOFilter[]
|
||||
local filters = query.filters
|
||||
for _, filter in pairs(filters) do
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Running filter %s on %s/%s/%s", ModuleName, filter.key, name, class, zone))
|
||||
end
|
||||
if not filter.Run(name, guild, level, race, class, zone) then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Player %s filtered out by WHO filter %s", ModuleName, name, filter.key))
|
||||
@@ -606,7 +611,7 @@ function shared.Whoer.Init()
|
||||
local function DoQuery()
|
||||
if not Heimdall_Data.config.who.enabled then return end
|
||||
|
||||
local query = Heimdall_Data.config.who.queries[whoQueryIdx]
|
||||
local query = shared.WhoQueryService.queries[whoQueryIdx]
|
||||
if not query then
|
||||
if Heimdall_Data.config.who.debug then
|
||||
print(string.format("[%s] Error: No WHO query found to run", ModuleName))
|
||||
@@ -614,7 +619,7 @@ function shared.Whoer.Init()
|
||||
return
|
||||
end
|
||||
whoQueryIdx = whoQueryIdx + 1
|
||||
if whoQueryIdx > #Heimdall_Data.config.who.queries then
|
||||
if whoQueryIdx > #shared.WhoQueryService.queries then
|
||||
whoQueryIdx = 1
|
||||
end
|
||||
lastQuery = query
|
||||
|
Reference in New Issue
Block a user