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