mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
revert code style changes in LibItemSearch & LibWho
This commit is contained in:
@@ -3,13 +3,13 @@
|
|||||||
An item text search engine of some sort
|
An item text search engine of some sort
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local Search = LibStub("CustomSearch-1.0")
|
local Search = LibStub("CustomSearch-1.0");
|
||||||
local Unfit = LibStub("Unfit-1.0")
|
local Unfit = LibStub("Unfit-1.0");
|
||||||
local Lib = LibStub:NewLibrary("LibItemSearch-1.2", 11)
|
local Lib = LibStub:NewLibrary("LibItemSearch-1.2", 11);
|
||||||
if Lib then
|
if(Lib) then
|
||||||
Lib.Filters = {}
|
Lib.Filters = {};
|
||||||
else
|
else
|
||||||
return
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
local pairs, select, tonumber = pairs, select, tonumber
|
local pairs, select, tonumber = pairs, select, tonumber
|
||||||
@@ -21,15 +21,15 @@ local GetItemInfo = GetItemInfo
|
|||||||
--[[ User API ]]--
|
--[[ User API ]]--
|
||||||
|
|
||||||
function Lib:Matches(link, search)
|
function Lib:Matches(link, search)
|
||||||
return Search(link, search, self.Filters)
|
return Search(link, search, self.Filters);
|
||||||
end
|
end
|
||||||
|
|
||||||
function Lib:Tooltip(link, search)
|
function Lib:Tooltip(link, search)
|
||||||
return link and self.Filters.tip:match(link, nil, search)
|
return link and match(self.Filters.tip, link, nil, search);
|
||||||
end
|
end
|
||||||
|
|
||||||
function Lib:TooltipPhrase(link, search)
|
function Lib:TooltipPhrase(link, search)
|
||||||
return link and self.Filters.tipPhrases:match(link, nil, search)
|
return link and match(self.Filters.tipPhrases, link, nil, search);
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ Basics ]]--
|
--[[ Basics ]]--
|
||||||
@@ -38,63 +38,63 @@ Lib.Filters.name = {
|
|||||||
tags = {"n", "name"},
|
tags = {"n", "name"},
|
||||||
|
|
||||||
canSearch = function(self, operator, search)
|
canSearch = function(self, operator, search)
|
||||||
return not operator and search
|
return not operator and search;
|
||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, item, _, search)
|
match = function(self, item, _, search)
|
||||||
local name = match(item, "%[(.-)%]")
|
local name = match(item, "%[(.-)%]");
|
||||||
return Search:Find(search, name)
|
return Search:Find(search, name);
|
||||||
end
|
end
|
||||||
}
|
};
|
||||||
|
|
||||||
Lib.Filters.type = {
|
Lib.Filters.type = {
|
||||||
tags = {"t", "type", "s", "slot"},
|
tags = {"t", "type", "s", "slot"},
|
||||||
|
|
||||||
canSearch = function(self, operator, search)
|
canSearch = function(self, operator, search)
|
||||||
return not operator and search
|
return not operator and search;
|
||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, item, _, search)
|
match = function(self, item, _, search)
|
||||||
local type, subType, _, equipSlot = select(6, GetItemInfo(match(item, "item:(%d+)")))
|
local type, subType, _, equipSlot = select(6, GetItemInfo(match(item, "item:(%d+)")));
|
||||||
return Search:Find(search, type, subType, _G[equipSlot])
|
return Search:Find(search, type, subType, _G[equipSlot]);
|
||||||
end
|
end
|
||||||
}
|
};
|
||||||
|
|
||||||
Lib.Filters.level = {
|
Lib.Filters.level = {
|
||||||
tags = {"l", "level", "lvl", "ilvl"},
|
tags = {"l", "level", "lvl", "ilvl"},
|
||||||
|
|
||||||
canSearch = function(self, _, search)
|
canSearch = function(self, _, search)
|
||||||
return tonumber(search)
|
return tonumber(search);
|
||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, operator, num)
|
match = function(self, link, operator, num)
|
||||||
local _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"))
|
local _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"));
|
||||||
if lvl then
|
if(lvl) then
|
||||||
return Search:Compare(operator, lvl, num)
|
return Search:Compare(operator, lvl, num);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
};
|
||||||
|
|
||||||
Lib.Filters.requiredlevel = {
|
Lib.Filters.requiredlevel = {
|
||||||
tags = {"r", "req", "rl", "reql", "reqlvl"},
|
tags = {"r", "req", "rl", "reql", "reqlvl"},
|
||||||
|
|
||||||
canSearch = function(self, _, search)
|
canSearch = function(self, _, search)
|
||||||
return tonumber(search)
|
return tonumber(search);
|
||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, operator, num)
|
match = function(self, link, operator, num)
|
||||||
local _, _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"))
|
local _, _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"));
|
||||||
if lvl then
|
if(lvl) then
|
||||||
return Search:Compare(operator, lvl, num)
|
return Search:Compare(operator, lvl, num);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
};
|
||||||
|
|
||||||
--[[ Quality ]]--
|
--[[ Quality ]]--
|
||||||
|
|
||||||
local qualities = {}
|
local qualities = {};
|
||||||
for i = 0, getn(ITEM_QUALITY_COLORS) do
|
for i = 0, getn(ITEM_QUALITY_COLORS) do
|
||||||
qualities[i] = lower(_G["ITEM_QUALITY"..i.."_DESC"])
|
qualities[i] = lower(_G["ITEM_QUALITY" .. i .. "_DESC"]);
|
||||||
end
|
end
|
||||||
|
|
||||||
Lib.Filters.quality = {
|
Lib.Filters.quality = {
|
||||||
@@ -103,16 +103,16 @@ Lib.Filters.quality = {
|
|||||||
canSearch = function(self, _, search)
|
canSearch = function(self, _, search)
|
||||||
for i, name in pairs(qualities) do
|
for i, name in pairs(qualities) do
|
||||||
if find(namesearch) then
|
if find(namesearch) then
|
||||||
return i
|
return i;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, operator, num)
|
match = function(self, link, operator, num)
|
||||||
local _, _, quality = GetItemInfo(match(link, "item:(%d+)"))
|
local _, _, quality = GetItemInfo(match(link, "item:(%d+)"));
|
||||||
return Search:Compare(operator, quality, num)
|
return Search:Compare(operator, quality, num);
|
||||||
end
|
end,
|
||||||
}
|
};
|
||||||
|
|
||||||
--[[ Usable ]]--
|
--[[ Usable ]]--
|
||||||
|
|
||||||
@@ -120,20 +120,20 @@ Lib.Filters.usable = {
|
|||||||
tags = {},
|
tags = {},
|
||||||
|
|
||||||
canSearch = function(self, operator, search)
|
canSearch = function(self, operator, search)
|
||||||
return not operator and search == "usable"
|
return not operator and search == "usable";
|
||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link)
|
match = function(self, link)
|
||||||
if(not Unfit:IsItemUnusable(link)) then
|
if(not Unfit:IsItemUnusable(link)) then
|
||||||
local _, _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"))
|
local _, _, _, _, lvl = GetItemInfo(match(link, "item:(%d+)"));
|
||||||
return lvl and (lvl ~= 0 and lvl <= UnitLevel("player"))
|
return lvl and (lvl ~= 0 and lvl <= UnitLevel("player"));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
};
|
||||||
|
|
||||||
--[[ Tooltip Searches ]]--
|
--[[ Tooltip Searches ]]--
|
||||||
|
|
||||||
local scanner = LibItemSearchTooltipScanner or CreateFrame("GameTooltip", "LibItemSearchTooltipScanner", UIParent, "GameTooltipTemplate")
|
local scanner = LibItemSearchTooltipScanner or CreateFrame("GameTooltip", "LibItemSearchTooltipScanner", UIParent, "GameTooltipTemplate");
|
||||||
|
|
||||||
Lib.Filters.tip = {
|
Lib.Filters.tip = {
|
||||||
tags = {"tt", "tip", "tooltip"},
|
tags = {"tt", "tip", "tooltip"},
|
||||||
@@ -141,66 +141,66 @@ Lib.Filters.tip = {
|
|||||||
onlyTags = true,
|
onlyTags = true,
|
||||||
|
|
||||||
canSearch = function(self, _, search)
|
canSearch = function(self, _, search)
|
||||||
return search
|
return search;
|
||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, _, search)
|
match = function(self, link, _, search)
|
||||||
if find(link, "item:") then
|
if find(link, "item:") then
|
||||||
scanner:SetOwner(UIParent, "ANCHOR_NONE")
|
scanner:SetOwner(UIParent, "ANCHOR_NONE");
|
||||||
scanner:SetHyperlink(link)
|
scanner:SetHyperlink(link)
|
||||||
|
|
||||||
for i = 1, scanner:NumLines() do
|
for i = 1, scanner:NumLines() do
|
||||||
if Search:Find(search, _G[scanner:GetName().."TextLeft"..i]:GetText()) then
|
if(Search:Find(search, _G[scanner:GetName() .. "TextLeft" .. i]:GetText())) then
|
||||||
return true
|
return true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
};
|
||||||
|
|
||||||
local escapes = {
|
local escapes = {
|
||||||
["|c%x%x%x%x%x%x%x%x"] = "",
|
["|c%x%x%x%x%x%x%x%x"] = "",
|
||||||
["|r"] = ""
|
["|r"] = ""
|
||||||
}
|
};
|
||||||
|
|
||||||
local function CleanString(str)
|
local function CleanString(str)
|
||||||
for k, v in pairs(escapes) do
|
for k, v in pairs(escapes) do
|
||||||
str = gsub(str, k, v)
|
str = gsub(str, k, v);
|
||||||
end
|
end
|
||||||
return str
|
return str;
|
||||||
end
|
end
|
||||||
|
|
||||||
Lib.Filters.tipPhrases = {
|
Lib.Filters.tipPhrases = {
|
||||||
canSearch = function(self, _, search)
|
canSearch = function(self, _, search)
|
||||||
return self.keywords[search]
|
return self.keywords[search];
|
||||||
end,
|
end,
|
||||||
|
|
||||||
match = function(self, link, _, search)
|
match = function(self, link, _, search)
|
||||||
local id = match(link, "item:(%d+)")
|
local id = match(link, "item:(%d+)");
|
||||||
if not id then
|
if(not id) then
|
||||||
return
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
local cached = self.cache[search][id]
|
local cached = self.cache[search][id];
|
||||||
if cached ~= nil then
|
if(cached ~= nil) then
|
||||||
return cached
|
return cached;
|
||||||
end
|
end
|
||||||
|
|
||||||
scanner:SetOwner(UIParent, "ANCHOR_NONE")
|
scanner:SetOwner(UIParent, "ANCHOR_NONE");
|
||||||
scanner:SetHyperlink(link)
|
scanner:SetHyperlink(link);
|
||||||
|
|
||||||
local matches = false
|
local matches = false
|
||||||
for i = 1, scanner:NumLines() do
|
for i = 1, scanner:NumLines() do
|
||||||
local text = _G["LibItemSearchTooltipScannerTextLeft"..i]:GetText()
|
local text = _G["LibItemSearchTooltipScannerTextLeft" .. i]:GetText();
|
||||||
text = CleanString(text)
|
text = CleanString(text);
|
||||||
if search == text then
|
if(search == text) then
|
||||||
matches = true
|
matches = true;
|
||||||
break
|
break;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.cache[search][id] = matches
|
self.cache[search][id] = matches;
|
||||||
return matches
|
return matches;
|
||||||
end,
|
end,
|
||||||
|
|
||||||
cache = setmetatable({}, {__index = function(t, k) local v = {} t[k] = v return v end}),
|
cache = setmetatable({}, {__index = function(t, k) local v = {} t[k] = v return v end}),
|
||||||
@@ -211,5 +211,5 @@ Lib.Filters.tipPhrases = {
|
|||||||
["bop"] = ITEM_BIND_ON_PICKUP,
|
["bop"] = ITEM_BIND_ON_PICKUP,
|
||||||
["boe"] = ITEM_BIND_ON_EQUIP,
|
["boe"] = ITEM_BIND_ON_EQUIP,
|
||||||
["bou"] = ITEM_BIND_ON_USE
|
["bou"] = ITEM_BIND_ON_USE
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
---
|
---
|
||||||
--- check for an already loaded old WhoLib
|
--- check for an already loaded old WhoLib
|
||||||
---
|
---
|
||||||
|
------------------------CheckCallback
|
||||||
if WhoLibByALeX or WhoLib then
|
if WhoLibByALeX or WhoLib then
|
||||||
-- the WhoLib-1.0 (WhoLibByALeX) or WhoLib (by Malex) is loaded -> fail!
|
-- the WhoLib-1.0 (WhoLibByALeX) or WhoLib (by Malex) is loaded -> fail!
|
||||||
error("an other WhoLib is already running - disable them first!\n")
|
error("an other WhoLib is already running - disable them first!\n")
|
||||||
return
|
return
|
||||||
end
|
end -- if
|
||||||
|
|
||||||
---
|
---
|
||||||
--- check version
|
--- check version
|
||||||
@@ -14,6 +14,7 @@ end
|
|||||||
|
|
||||||
assert(LibStub, "LibWho-2.0 requires LibStub")
|
assert(LibStub, "LibWho-2.0 requires LibStub")
|
||||||
|
|
||||||
|
|
||||||
local major_version = 'LibWho-2.0'
|
local major_version = 'LibWho-2.0'
|
||||||
local minor_version = tonumber("154") or 99999
|
local minor_version = tonumber("154") or 99999
|
||||||
|
|
||||||
@@ -27,10 +28,8 @@ end
|
|||||||
lib.callbacks = lib.callbacks or LibStub("CallbackHandler-1.0"):New(lib)
|
lib.callbacks = lib.callbacks or LibStub("CallbackHandler-1.0"):New(lib)
|
||||||
local callbacks = lib.callbacks
|
local callbacks = lib.callbacks
|
||||||
|
|
||||||
local band = bit.band
|
local find, format, gsub, len = string.find, string.format, string.gsub, string.len
|
||||||
local find, format, gsub, len, sub = string.find, string.format, string.gsub, string.len, string.sub
|
local tinsert, getn = table.insert, table.getn
|
||||||
local insert, getn = table.insert, table.getn
|
|
||||||
local random = math.random
|
|
||||||
|
|
||||||
local am = {}
|
local am = {}
|
||||||
local om = getmetatable(lib)
|
local om = getmetatable(lib)
|
||||||
@@ -50,26 +49,26 @@ local dbg = NOP
|
|||||||
|
|
||||||
if type(lib['hooked']) ~= 'table' then
|
if type(lib['hooked']) ~= 'table' then
|
||||||
lib['hooked'] = {}
|
lib['hooked'] = {}
|
||||||
end
|
end -- if
|
||||||
|
|
||||||
if type(lib['hook']) ~= 'table' then
|
if type(lib['hook']) ~= 'table' then
|
||||||
lib['hook'] = {}
|
lib['hook'] = {}
|
||||||
end
|
end -- if
|
||||||
|
|
||||||
if type(lib['events']) ~= 'table' then
|
if type(lib['events']) ~= 'table' then
|
||||||
lib['events'] = {}
|
lib['events'] = {}
|
||||||
end
|
end -- if
|
||||||
|
|
||||||
if type(lib['embeds']) ~= 'table' then
|
if type(lib['embeds']) ~= 'table' then
|
||||||
lib['embeds'] = {}
|
lib['embeds'] = {}
|
||||||
end
|
end -- if
|
||||||
|
|
||||||
if type(lib['frame']) ~= 'table' then
|
if type(lib['frame']) ~= 'table' then
|
||||||
lib['frame'] = CreateFrame('Frame', major_version)
|
lib['frame'] = CreateFrame('Frame', major_version);
|
||||||
end
|
end -- if
|
||||||
lib['frame']:Hide()
|
lib['frame']:Hide()
|
||||||
|
|
||||||
lib.Queue = {[1] = {}, [2] = {}, [3] = {}}
|
lib.Queue = {[1]={}, [2]={}, [3]={}}
|
||||||
lib.WhoInProgress = false
|
lib.WhoInProgress = false
|
||||||
lib.Result = nil
|
lib.Result = nil
|
||||||
lib.Args = nil
|
lib.Args = nil
|
||||||
@@ -101,7 +100,7 @@ else
|
|||||||
['console_query'] = 'Result of "/who %s"',
|
['console_query'] = 'Result of "/who %s"',
|
||||||
['gui_wait'] = '- Please Wait -',
|
['gui_wait'] = '- Please Wait -',
|
||||||
}
|
}
|
||||||
end
|
end -- if
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -143,7 +142,7 @@ local queue_quiet = {
|
|||||||
lib['WHOLIB_FLAG_ALWAYS_CALLBACK'] = 1
|
lib['WHOLIB_FLAG_ALWAYS_CALLBACK'] = 1
|
||||||
|
|
||||||
function lib:Reset()
|
function lib:Reset()
|
||||||
self.Queue = {[1] = {}, [2] = {}, [3] = {}}
|
self.Queue = {[1]={}, [2]={}, [3]={}}
|
||||||
self.Cache = {}
|
self.Cache = {}
|
||||||
self.CacheQueue = {}
|
self.CacheQueue = {}
|
||||||
end
|
end
|
||||||
@@ -188,23 +187,23 @@ function lib.UserInfo(defhandler, name, opts)
|
|||||||
-- now args - copied and verified from opts
|
-- now args - copied and verified from opts
|
||||||
local cachedName = self.Cache[args.name]
|
local cachedName = self.Cache[args.name]
|
||||||
|
|
||||||
if cachedName ~= nil then
|
if(cachedName ~= nil)then
|
||||||
-- user is in cache
|
-- user is in cache
|
||||||
if cachedName.valid == true and (args.timeout < 0 or cachedName.last + args.timeout*60 > now) then
|
if(cachedName.valid == true and (args.timeout < 0 or cachedName.last + args.timeout*60 > now))then
|
||||||
-- cache is valid and timeout is in range
|
-- cache is valid and timeout is in range
|
||||||
--dbg('Info('..args.name ..') returned immedeatly')
|
--dbg('Info(' .. args.name ..') returned immedeatly')
|
||||||
if band(args.flags, self.WHOLIB_FLAG_ALWAYS_CALLBACK) ~= 0 then
|
if(bit.band(args.flags, self.WHOLIB_FLAG_ALWAYS_CALLBACK) ~= 0)then
|
||||||
self:RaiseCallback(args, cachedName.data)
|
self:RaiseCallback(args, cachedName.data)
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
return self:DupAll(self:ReturnUserInfo(args.name))
|
return self:DupAll(self:ReturnUserInfo(args.name))
|
||||||
end
|
end
|
||||||
elseif cachedName.valid == false then
|
elseif(cachedName.valid == false)then
|
||||||
-- query is already running (first try)
|
-- query is already running (first try)
|
||||||
if args.callback ~= nil then
|
if(args.callback ~= nil)then
|
||||||
insert(cachedName.callback, args)
|
tinsert(cachedName.callback, args)
|
||||||
end
|
end
|
||||||
--dbg('Info('..args.name ..') returned cause it\'s already searching')
|
--dbg('Info(' .. args.name ..') returned cause it\'s already searching')
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -213,34 +212,34 @@ function lib.UserInfo(defhandler, name, opts)
|
|||||||
|
|
||||||
local cachedName = self.Cache[args.name]
|
local cachedName = self.Cache[args.name]
|
||||||
|
|
||||||
if cachedName.inqueue then
|
if(cachedName.inqueue)then
|
||||||
-- query is running!
|
-- query is running!
|
||||||
if args.callback ~= nil then
|
if(args.callback ~= nil)then
|
||||||
insert(cachedName.callback, args)
|
tinsert(cachedName.callback, args)
|
||||||
end
|
end
|
||||||
dbg('Info('..args.name..') returned cause it\'s already searching')
|
dbg('Info(' .. args.name ..') returned cause it\'s already searching')
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
if GetLocale() == "ruRU" then -- in ruRU with n- not show information about player in WIM addon
|
if (GetLocale() == "ruRU") then -- in ruRU with n- not show information about player in WIM addon
|
||||||
if args.name and len(args.name) > 0 then
|
if args.name and len(args.name) > 0 then
|
||||||
local query = 'и-"'..args.name..'"'
|
local query = 'и-"' .. args.name .. '"'
|
||||||
cachedName.inqueue = true
|
cachedName.inqueue = true
|
||||||
if args.callback ~= nil then
|
if(args.callback ~= nil)then
|
||||||
insert(cachedName.callback, args)
|
tinsert(cachedName.callback, args)
|
||||||
end
|
end
|
||||||
self.CacheQueue[query] = args.name
|
self.CacheQueue[query] = args.name
|
||||||
dbg('Info('..args.name ..') added to queue')
|
dbg('Info(' .. args.name ..') added to queue')
|
||||||
self:AskWho( { query = query, queue = args.queue, flags = 0, info = args.name } )
|
self:AskWho( { query = query, queue = args.queue, flags = 0, info = args.name } )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if args.name and len(args.name) > 0 then
|
if args.name and len(args.name) > 0 then
|
||||||
local query = 'n-"'..args.name..'"'
|
local query = 'n-"' .. args.name .. '"'
|
||||||
cachedName.inqueue = true
|
cachedName.inqueue = true
|
||||||
if args.callback ~= nil then
|
if(args.callback ~= nil)then
|
||||||
insert(cachedName.callback, args)
|
tinsert(cachedName.callback, args)
|
||||||
end
|
end
|
||||||
self.CacheQueue[query] = args.name
|
self.CacheQueue[query] = args.name
|
||||||
dbg('Info('..args.name..') added to queue')
|
dbg('Info(' .. args.name ..') added to queue')
|
||||||
self:AskWho( { query = query, queue = args.queue, flags = 0, info = args.name } )
|
self:AskWho( { query = query, queue = args.queue, flags = 0, info = args.name } )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -273,7 +272,7 @@ end
|
|||||||
--
|
--
|
||||||
-- self:CheckPreset(usage, 'event', self.events, event)
|
-- self:CheckPreset(usage, 'event', self.events, event)
|
||||||
-- local callback, handler = self:CheckCallback(usage, '', callback, handler, defhandler, true)
|
-- local callback, handler = self:CheckCallback(usage, '', callback, handler, defhandler, true)
|
||||||
-- insert(self.events[event], {callback=callback, handler=handler})
|
-- table.insert(self.events[event], {callback=callback, handler=handler})
|
||||||
--end
|
--end
|
||||||
|
|
||||||
-- non-embedded externals
|
-- non-embedded externals
|
||||||
@@ -283,9 +282,9 @@ function lib.Embed(_, handler)
|
|||||||
|
|
||||||
self:CheckArgument(usage, 'handler', 'table', handler)
|
self:CheckArgument(usage, 'handler', 'table', handler)
|
||||||
|
|
||||||
for _, name in pairs(self.external) do
|
for _,name in pairs(self.external) do
|
||||||
handler[name] = self[name]
|
handler[name] = self[name]
|
||||||
end
|
end -- do
|
||||||
self['embeds'][handler] = true
|
self['embeds'][handler] = true
|
||||||
|
|
||||||
return handler
|
return handler
|
||||||
@@ -333,8 +332,8 @@ lib['frame']:SetScript("OnUpdate", function()
|
|||||||
if lib.Timeout_time <= 0 then
|
if lib.Timeout_time <= 0 then
|
||||||
lib['frame']:Hide()
|
lib['frame']:Hide()
|
||||||
lib:AskWhoNext()
|
lib:AskWhoNext()
|
||||||
end
|
end -- if
|
||||||
end)
|
end);
|
||||||
|
|
||||||
|
|
||||||
-- queue scheduler
|
-- queue scheduler
|
||||||
@@ -347,19 +346,19 @@ local INSTANT_QUERY_MIN_INTERVAL = 60 -- only once every 1 min
|
|||||||
|
|
||||||
function lib:UpdateWeights()
|
function lib:UpdateWeights()
|
||||||
local weightsum, sum, count = 0, 0, 0
|
local weightsum, sum, count = 0, 0, 0
|
||||||
for k, v in pairs(queue_weights) do
|
for k,v in pairs(queue_weights) do
|
||||||
sum = sum + v
|
sum = sum + v
|
||||||
weightsum = weightsum + v * getn(self.Queue[k])
|
weightsum = weightsum + v * getn(self.Queue[k])
|
||||||
end
|
end
|
||||||
|
|
||||||
if weightsum == 0 then
|
if weightsum == 0 then
|
||||||
for k, v in pairs(queue_weights) do queue_bounds[k] = v end
|
for k,v in pairs(queue_weights) do queue_bounds[k] = v end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local adjust = sum / weightsum
|
local adjust = sum / weightsum
|
||||||
|
|
||||||
for k, v in pairs(queue_bounds) do
|
for k,v in pairs(queue_bounds) do
|
||||||
queue_bounds[k] = queue_weights[k] * adjust * getn(self.Queue[k])
|
queue_bounds[k] = queue_weights[k] * adjust * getn(self.Queue[k])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -378,9 +377,9 @@ function lib:GetNextFromScheduler()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local n,i = random(),0
|
local n,i = math.random(),0
|
||||||
repeat
|
repeat
|
||||||
i = i + 1
|
i=i+1
|
||||||
n = n - queue_bounds[i]
|
n = n - queue_bounds[i]
|
||||||
until i >= getn(self.Queue) or n <= 0
|
until i >= getn(self.Queue) or n <= 0
|
||||||
|
|
||||||
@@ -411,7 +410,7 @@ function lib:AskWhoNext()
|
|||||||
self.Args = nil
|
self.Args = nil
|
||||||
if args.info and self.CacheQueue[args.query] ~= nil then
|
if args.info and self.CacheQueue[args.query] ~= nil then
|
||||||
dbg("Requeing "..args.query)
|
dbg("Requeing "..args.query)
|
||||||
insert(self.Queue[args.queue], args)
|
tinsert(self.Queue[args.queue], args)
|
||||||
if args.console_show ~= nil then
|
if args.console_show ~= nil then
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(format("Timeout on result of '%s' - retrying...", args.query),1,1,0)
|
DEFAULT_CHAT_FRAME:AddMessage(format("Timeout on result of '%s' - retrying...", args.query),1,1,0)
|
||||||
args.console_show = true
|
args.console_show = true
|
||||||
@@ -420,19 +419,19 @@ function lib:AskWhoNext()
|
|||||||
|
|
||||||
if queryInterval < lib.MaxInterval then
|
if queryInterval < lib.MaxInterval then
|
||||||
queryInterval = queryInterval + 0.5
|
queryInterval = queryInterval + 0.5
|
||||||
dbg("--Throttling down to 1 who per "..queryInterval.."s")
|
dbg("--Throttling down to 1 who per " .. queryInterval .. "s")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self.WhoInProgress = false
|
self.WhoInProgress = false
|
||||||
|
|
||||||
local v, k, args = nil
|
local v,k,args = nil
|
||||||
local kludge = 10
|
local kludge = 10
|
||||||
repeat
|
repeat
|
||||||
k,v = self:GetNextFromScheduler()
|
k,v = self:GetNextFromScheduler()
|
||||||
if not k then break end
|
if not k then break end
|
||||||
if WhoFrame:IsShown() and k > self.WHOLIB_QUEUE_QUIET then
|
if(WhoFrame:IsShown() and k > self.WHOLIB_QUEUE_QUIET)then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if getn(v) > 0 then
|
if getn(v) > 0 then
|
||||||
@@ -447,7 +446,7 @@ function lib:AskWhoNext()
|
|||||||
self.Result = {}
|
self.Result = {}
|
||||||
self.Args = args
|
self.Args = args
|
||||||
self.Total = -1
|
self.Total = -1
|
||||||
if args.console_show == true then
|
if(args.console_show == true)then
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(format(self.L['console_query'], args.query), 1, 1, 0)
|
DEFAULT_CHAT_FRAME:AddMessage(format(self.L['console_query'], args.query), 1, 1, 0)
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -482,8 +481,8 @@ function lib:AskWhoNext()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function lib:AskWho(args)
|
function lib:AskWho(args)
|
||||||
insert(self.Queue[args.queue], args)
|
tinsert(self.Queue[args.queue], args)
|
||||||
dbg('['..args.queue..'] added "'..args.query..'", queues='..getn(self.Queue[1])..'/'.. getn(self.Queue[2])..'/'.. getn(self.Queue[3]))
|
dbg('[' .. args.queue .. '] added "' .. args.query .. '", queues=' .. getn(self.Queue[1]) .. '/' .. getn(self.Queue[2]) .. '/' .. getn(self.Queue[3]))
|
||||||
self:TriggerEvent('WHOLIB_QUERY_ADDED')
|
self:TriggerEvent('WHOLIB_QUERY_ADDED')
|
||||||
|
|
||||||
self:AskWhoNext()
|
self:AskWhoNext()
|
||||||
@@ -495,23 +494,23 @@ function lib:ReturnWho()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Args.queue == self.WHOLIB_QUEUE_QUIET or self.Args.queue == self.WHOLIB_QUEUE_SCANNING then
|
if(self.Args.queue == self.WHOLIB_QUEUE_QUIET or self.Args.queue == self.WHOLIB_QUEUE_SCANNING)then
|
||||||
self.Quiet = nil
|
self.Quiet = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if queryInterval > self.MinInterval then
|
if queryInterval > self.MinInterval then
|
||||||
queryInterval = queryInterval - 0.5
|
queryInterval = queryInterval - 0.5
|
||||||
dbg("--Throttling up to 1 who per "..queryInterval.."s")
|
dbg("--Throttling up to 1 who per " .. queryInterval .. "s")
|
||||||
end
|
end
|
||||||
|
|
||||||
self.WhoInProgress = false
|
self.WhoInProgress = false
|
||||||
dbg("RESULT: "..self.Args.query)
|
dbg("RESULT: "..self.Args.query)
|
||||||
dbg('['..self.Args.queue..'] returned "'..self.Args.query..'", total='..self.Total ..' , queues='..getn(self.Queue[1])..'/'.. getn(self.Queue[2])..'/'.. getn(self.Queue[3]))
|
dbg('[' .. self.Args.queue .. '] returned "' .. self.Args.query .. '", total=' .. self.Total .. ' , queues='..getn(self.Queue[1]) .. '/' .. getn(self.Queue[2]) .. '/' .. getn(self.Queue[3]))
|
||||||
local now = time()
|
local now = time()
|
||||||
local complete = (self.Total == getn(self.Result)) and (self.Total < MAX_WHOS_FROM_SERVER)
|
local complete = (self.Total == getn(self.Result)) and (self.Total < MAX_WHOS_FROM_SERVER)
|
||||||
for _, v in pairs(self.Result)do
|
for _,v in pairs(self.Result)do
|
||||||
if v.Name then
|
if v.Name then
|
||||||
if self.Cache[v.Name] == nil then
|
if(self.Cache[v.Name] == nil)then
|
||||||
self.Cache[v.Name] = { inqueue = false, callback = {} }
|
self.Cache[v.Name] = { inqueue = false, callback = {} }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -521,17 +520,17 @@ function lib:ReturnWho()
|
|||||||
cachedName.data = v -- update data
|
cachedName.data = v -- update data
|
||||||
cachedName.data.Online = true -- player is online
|
cachedName.data.Online = true -- player is online
|
||||||
cachedName.last = now -- update timestamp
|
cachedName.last = now -- update timestamp
|
||||||
if cachedName.inqueue then
|
if(cachedName.inqueue)then
|
||||||
if self.Args.info and self.CacheQueue[self.Args.query] == v.Name then
|
if(self.Args.info and self.CacheQueue[self.Args.query] == v.Name)then
|
||||||
-- found by the query which was created to -> remove us from query
|
-- found by the query which was created to -> remove us from query
|
||||||
self.CacheQueue[self.Args.query] = nil
|
self.CacheQueue[self.Args.query] = nil
|
||||||
else
|
else
|
||||||
-- found by another query
|
-- found by another query
|
||||||
for k2,v2 in pairs(self.CacheQueue) do
|
for k2,v2 in pairs(self.CacheQueue) do
|
||||||
if v2 == v.Name then
|
if(v2 == v.Name)then
|
||||||
for i = self.WHOLIB_QUEUE_QUIET, self.WHOLIB_QUEUE_SCANNING do
|
for i=self.WHOLIB_QUEUE_QUIET, self.WHOLIB_QUEUE_SCANNING do
|
||||||
for k3,v3 in pairs(self.Queue[i]) do
|
for k3,v3 in pairs(self.Queue[i]) do
|
||||||
if v3.query == k2 and v3.info then
|
if(v3.query == k2 and v3.info)then
|
||||||
-- remove the query which was generated for this user, cause another query was faster...
|
-- remove the query which was generated for this user, cause another query was faster...
|
||||||
dbg("Found '"..v.Name.."' early via query '"..self.Args.query.."'")
|
dbg("Found '"..v.Name.."' early via query '"..self.Args.query.."'")
|
||||||
table.remove(self.Queue[i], k3)
|
table.remove(self.Queue[i], k3)
|
||||||
@@ -542,8 +541,8 @@ function lib:ReturnWho()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
dbg('Info('..v.Name ..') returned: on')
|
dbg('Info(' .. v.Name ..') returned: on')
|
||||||
for _, v2 in pairs(cachedName.callback) do
|
for _,v2 in pairs(cachedName.callback) do
|
||||||
self:RaiseCallback(v2, self:ReturnUserInfo(v.Name))
|
self:RaiseCallback(v2, self:ReturnUserInfo(v.Name))
|
||||||
end
|
end
|
||||||
cachedName.callback = {}
|
cachedName.callback = {}
|
||||||
@@ -551,22 +550,22 @@ function lib:ReturnWho()
|
|||||||
cachedName.inqueue = false -- query is done
|
cachedName.inqueue = false -- query is done
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.Args.info and self.CacheQueue[self.Args.query] then
|
if(self.Args.info and self.CacheQueue[self.Args.query])then
|
||||||
-- the query did not deliver the result => not online!
|
-- the query did not deliver the result => not online!
|
||||||
local name = self.CacheQueue[self.Args.query]
|
local name = self.CacheQueue[self.Args.query]
|
||||||
local cachedName = self.Cache[name]
|
local cachedName = self.Cache[name]
|
||||||
if cachedName.inqueue then
|
if (cachedName.inqueue)then
|
||||||
-- nothing found (yet)
|
-- nothing found (yet)
|
||||||
cachedName.valid = true -- is now valid
|
cachedName.valid = true -- is now valid
|
||||||
cachedName.inqueue = false -- query is done?
|
cachedName.inqueue = false -- query is done?
|
||||||
cachedName.last = now -- update timestamp
|
cachedName.last = now -- update timestamp
|
||||||
if complete then
|
if(complete)then
|
||||||
cachedName.data.Online = false -- player is offline
|
cachedName.data.Online = false -- player is offline
|
||||||
else
|
else
|
||||||
cachedName.data.Online = nil -- player is unknown (more results from who than can be displayed)
|
cachedName.data.Online = nil -- player is unknown (more results from who than can be displayed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
dbg('Info('..name ..') returned: '..(cachedName.data.Online == false and 'off' or 'unkn'))
|
dbg('Info(' .. name ..') returned: ' .. (cachedName.data.Online == false and 'off' or 'unkn'))
|
||||||
for _,v in pairs(cachedName.callback) do
|
for _,v in pairs(cachedName.callback) do
|
||||||
self:RaiseCallback(v, self:ReturnUserInfo(name))
|
self:RaiseCallback(v, self:ReturnUserInfo(name))
|
||||||
end
|
end
|
||||||
@@ -582,21 +581,21 @@ function lib:ReturnWho()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function lib:GuiWho(msg)
|
function lib:GuiWho(msg)
|
||||||
if msg == self.L['gui_wait'] then
|
if(msg == self.L['gui_wait'])then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,v in pairs(self.Queue[self.WHOLIB_QUEUE_USER]) do
|
for _,v in pairs(self.Queue[self.WHOLIB_QUEUE_USER]) do
|
||||||
if v.gui == true then
|
if(v.gui == true)then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.WhoInProgress then
|
if(self.WhoInProgress)then
|
||||||
WhoFrameEditBox:SetText(self.L['gui_wait'])
|
WhoFrameEditBox:SetText(self.L['gui_wait'])
|
||||||
end
|
end
|
||||||
self.savedText = msg
|
self.savedText = msg
|
||||||
self:AskWho({query = msg, queue = self.WHOLIB_QUEUE_USER, flags = 0, gui = true})
|
self:AskWho({query = msg, queue = self.WHOLIB_QUEUE_USER, flags = 0, gui = true})
|
||||||
WhoFrameEditBox:ClearFocus()
|
WhoFrameEditBox:ClearFocus();
|
||||||
end
|
end
|
||||||
|
|
||||||
function lib:ConsoleWho(msg)
|
function lib:ConsoleWho(msg)
|
||||||
@@ -605,16 +604,16 @@ function lib:ConsoleWho(msg)
|
|||||||
local q1 = self.Queue[self.WHOLIB_QUEUE_USER]
|
local q1 = self.Queue[self.WHOLIB_QUEUE_USER]
|
||||||
local q1count = getn(q1)
|
local q1count = getn(q1)
|
||||||
|
|
||||||
if q1count > 0 and q1[q1count].query == msg then -- last query is itdenical: drop
|
if(q1count > 0 and q1[q1count].query == msg)then -- last query is itdenical: drop
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if q1count > 0 and q1[q1count].console_show == false then -- display 'queued' if console and not yet shown
|
if(q1count > 0 and q1[q1count].console_show == false)then -- display 'queued' if console and not yet shown
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(format(self.L['console_queued'], q1[q1count].query), 1, 1, 0)
|
DEFAULT_CHAT_FRAME:AddMessage(string.format(self.L['console_queued'], q1[q1count].query), 1, 1, 0)
|
||||||
q1[q1count].console_show = true
|
q1[q1count].console_show = true
|
||||||
end
|
end
|
||||||
if q1count > 0 or self.WhoInProgress then
|
if(q1count > 0 or self.WhoInProgress)then
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(format(self.L['console_queued'], msg), 1, 1, 0)
|
DEFAULT_CHAT_FRAME:AddMessage(string.format(self.L['console_queued'], msg), 1, 1, 0)
|
||||||
console_show = true
|
console_show = true
|
||||||
end
|
end
|
||||||
self:AskWho({query = msg, queue = self.WHOLIB_QUEUE_USER, flags = 0, console_show = console_show})
|
self:AskWho({query = msg, queue = self.WHOLIB_QUEUE_USER, flags = 0, console_show = console_show})
|
||||||
@@ -631,7 +630,7 @@ function lib:RaiseCallback(args, ...)
|
|||||||
args.callback(self:DupAll(unpack(arg)))
|
args.callback(self:DupAll(unpack(arg)))
|
||||||
elseif args.callback then -- must be a string
|
elseif args.callback then -- must be a string
|
||||||
args.handler[args.callback](args.handler, self:DupAll(unpack(arg)))
|
args.handler[args.callback](args.handler, self:DupAll(unpack(arg)))
|
||||||
end
|
end -- if
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Argument checking
|
-- Argument checking
|
||||||
@@ -642,8 +641,8 @@ function lib:CheckArgument(func, name, argtype, arg, defarg)
|
|||||||
elseif type(arg) == argtype then
|
elseif type(arg) == argtype then
|
||||||
return arg
|
return arg
|
||||||
else
|
else
|
||||||
error(format("%s: '%s' - %s%s expected got %s", func, name, (defarg ~= nil) and 'nil or ' or '', argtype, type(arg)), 3)
|
error(string.format("%s: '%s' - %s%s expected got %s", func, name, (defarg ~= nil) and 'nil or ' or '', argtype, type(arg)), 3)
|
||||||
end
|
end -- if
|
||||||
end
|
end
|
||||||
|
|
||||||
function lib:CheckPreset(func, name, preset, arg, defarg)
|
function lib:CheckPreset(func, name, preset, arg, defarg)
|
||||||
@@ -655,13 +654,13 @@ function lib:CheckPreset(func, name, preset, arg, defarg)
|
|||||||
local p = {}
|
local p = {}
|
||||||
for k,v in pairs(preset) do
|
for k,v in pairs(preset) do
|
||||||
if type(v) ~= 'string' then
|
if type(v) ~= 'string' then
|
||||||
insert(p, k)
|
table.insert(p, k)
|
||||||
else
|
else
|
||||||
insert(p, v)
|
table.insert(p, v)
|
||||||
end
|
end -- if
|
||||||
end
|
end -- for
|
||||||
error(format("%s: '%s' - one of %s%s expected got %s", func, name, (defarg ~= nil) and 'nil, ' or '', table.concat(p, ', '), self:simple_dump(arg)), 3)
|
error(string.format("%s: '%s' - one of %s%s expected got %s", func, name, (defarg ~= nil) and 'nil, ' or '', table.concat(p, ', '), self:simple_dump(arg)), 3)
|
||||||
end
|
end -- if
|
||||||
end
|
end
|
||||||
|
|
||||||
function lib:CheckCallback(func, prefix, callback, handler, defhandler, nonil)
|
function lib:CheckCallback(func, prefix, callback, handler, defhandler, nonil)
|
||||||
@@ -671,19 +670,19 @@ function lib:CheckCallback(func, prefix, callback, handler, defhandler, nonil)
|
|||||||
elseif type(callback) == 'function' then
|
elseif type(callback) == 'function' then
|
||||||
-- simple function
|
-- simple function
|
||||||
if handler ~= nil then
|
if handler ~= nil then
|
||||||
error(format("%s: '%shandler' - nil expected got %s", func, prefix, type(arg)), 3)
|
error(string.format("%s: '%shandler' - nil expected got %s", func, prefix, type(arg)), 3)
|
||||||
end
|
end -- if
|
||||||
elseif type(callback) == 'string' then
|
elseif type(callback) == 'string' then
|
||||||
-- method
|
-- method
|
||||||
if handler == nil then
|
if handler == nil then
|
||||||
handler = defhandler
|
handler = defhandler
|
||||||
end
|
end -- if
|
||||||
if type(handler) ~= 'table' or type(handler[callback]) ~= 'function' or handler == self then
|
if type(handler) ~= 'table' or type(handler[callback]) ~= 'function' or handler == self then
|
||||||
error(format("%s: '%shandler' - nil or function expected got %s", func, prefix, type(arg)), 3)
|
error(string.format("%s: '%shandler' - nil or function expected got %s", func, prefix, type(arg)), 3)
|
||||||
end
|
end -- if
|
||||||
else
|
else
|
||||||
error(format("%s: '%scallback' - %sfunction or string expected got %s", func, prefix, nonil and 'nil or ' or '', type(arg)), 3)
|
error(string.format("%s: '%scallback' - %sfunction or string expected got %s", func, prefix, nonil and 'nil or ' or '', type(arg)), 3)
|
||||||
end
|
end -- if
|
||||||
|
|
||||||
return callback, handler
|
return callback, handler
|
||||||
end
|
end
|
||||||
@@ -708,8 +707,8 @@ function lib:Dup(from)
|
|||||||
to[k] = self:Dup(v)
|
to[k] = self:Dup(v)
|
||||||
else
|
else
|
||||||
to[k] = v
|
to[k] = v
|
||||||
end
|
end -- if
|
||||||
end
|
end -- for
|
||||||
|
|
||||||
return to
|
return to
|
||||||
end
|
end
|
||||||
@@ -721,7 +720,7 @@ function lib:DupAll(x, ...)
|
|||||||
return x, self:DupAll(unpack(arg))
|
return x, self:DupAll(unpack(arg))
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end -- if
|
||||||
end
|
end
|
||||||
|
|
||||||
local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
|
local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
|
||||||
@@ -749,9 +748,12 @@ end
|
|||||||
|
|
||||||
SlashCmdList['WHO'] = function(msg)
|
SlashCmdList['WHO'] = function(msg)
|
||||||
dbg("console /who: "..msg)
|
dbg("console /who: "..msg)
|
||||||
if msg == '' then
|
-- new /who function
|
||||||
|
--local self = lib
|
||||||
|
|
||||||
|
if(msg == '')then
|
||||||
lib:GuiWho(WhoFrame_GetDefaultWhoCommand())
|
lib:GuiWho(WhoFrame_GetDefaultWhoCommand())
|
||||||
elseif WhoFrame:IsVisible()then
|
elseif(WhoFrame:IsVisible())then
|
||||||
lib:GuiWho(msg)
|
lib:GuiWho(msg)
|
||||||
else
|
else
|
||||||
lib:ConsoleWho(msg)
|
lib:ConsoleWho(msg)
|
||||||
@@ -787,27 +789,28 @@ for _, name in pairs(hooks) do
|
|||||||
lib['hooked'][name] = _G[name]
|
lib['hooked'][name] = _G[name]
|
||||||
_G[name] = function()
|
_G[name] = function()
|
||||||
lib.hook[name](lib, arg1, arg2, arg3)
|
lib.hook[name](lib, arg1, arg2, arg3)
|
||||||
end
|
end -- function
|
||||||
end
|
end -- if
|
||||||
end
|
end -- for
|
||||||
|
|
||||||
-- fake 'WhoFrame:Hide' as hooked
|
-- fake 'WhoFrame:Hide' as hooked
|
||||||
insert(hooks, 'WhoFrame_Hide')
|
table.insert(hooks, 'WhoFrame_Hide')
|
||||||
|
|
||||||
-- check for unused hooks -> remove function
|
-- check for unused hooks -> remove function
|
||||||
for name, _ in pairs(lib['hook']) do
|
for name, _ in pairs(lib['hook']) do
|
||||||
if not hooks[name] then
|
if not hooks[name] then
|
||||||
lib['hook'][name] = function() end
|
lib['hook'][name] = function() end
|
||||||
end
|
end -- if
|
||||||
end
|
end -- for
|
||||||
|
|
||||||
-- secure hook 'WhoFrame:Hide'
|
-- secure hook 'WhoFrame:Hide'
|
||||||
if not lib['hooked']['WhoFrame_Hide'] then
|
if not lib['hooked']['WhoFrame_Hide'] then
|
||||||
lib['hooked']['WhoFrame_Hide'] = true
|
lib['hooked']['WhoFrame_Hide'] = true
|
||||||
hooksecurefunc(WhoFrame, 'Hide', function(...)
|
hooksecurefunc(WhoFrame, 'Hide', function(...)
|
||||||
lib['hook']['WhoFrame_Hide'](lib)
|
lib['hook']['WhoFrame_Hide'](lib)
|
||||||
end)
|
end -- function
|
||||||
end
|
)
|
||||||
|
end -- if
|
||||||
|
|
||||||
---
|
---
|
||||||
--- hook replacements
|
--- hook replacements
|
||||||
@@ -830,26 +833,28 @@ function lib.hook.FriendsFrame_OnEvent()
|
|||||||
end
|
end
|
||||||
|
|
||||||
hooksecurefunc(FriendsFrame, 'RegisterEvent', function()
|
hooksecurefunc(FriendsFrame, 'RegisterEvent', function()
|
||||||
if event == "WHO_LIST_UPDATE" then
|
if(event == "WHO_LIST_UPDATE") then
|
||||||
self:UnregisterEvent("WHO_LIST_UPDATE")
|
self:UnregisterEvent("WHO_LIST_UPDATE");
|
||||||
end
|
end
|
||||||
end)
|
end);
|
||||||
|
|
||||||
function lib.hook.SetWhoToUI(_, state)
|
function lib.hook.SetWhoToUI(self, state)
|
||||||
lib.SetWhoToUIState = state
|
lib.SetWhoToUIState = state
|
||||||
end
|
end
|
||||||
|
|
||||||
function lib.hook.WhoFrame_Hide()
|
function lib.hook.WhoFrame_Hide()
|
||||||
if not lib.WhoInProgress then
|
if(not lib.WhoInProgress)then
|
||||||
lib:AskWhoNextIn5sec()
|
lib:AskWhoNextIn5sec()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
--- WoW events
|
--- WoW events
|
||||||
---
|
---
|
||||||
|
|
||||||
local who_pattern = gsub(WHO_NUM_RESULTS, '%%d', '%%d%+')
|
local who_pattern = string.gsub(WHO_NUM_RESULTS, '%%d', '%%d%+')
|
||||||
|
|
||||||
function lib:CHAT_MSG_SYSTEM()
|
function lib:CHAT_MSG_SYSTEM()
|
||||||
if arg1 and find(arg1, who_pattern) then
|
if arg1 and find(arg1, who_pattern) then
|
||||||
lib:ProcessWhoResults()
|
lib:ProcessWhoResults()
|
||||||
@@ -857,6 +862,7 @@ function lib:CHAT_MSG_SYSTEM()
|
|||||||
end
|
end
|
||||||
|
|
||||||
FriendsFrame:UnregisterEvent("WHO_LIST_UPDATE")
|
FriendsFrame:UnregisterEvent("WHO_LIST_UPDATE")
|
||||||
|
|
||||||
function lib:WHO_LIST_UPDATE()
|
function lib:WHO_LIST_UPDATE()
|
||||||
if not lib.Quiet then
|
if not lib.Quiet then
|
||||||
WhoList_Update()
|
WhoList_Update()
|
||||||
@@ -871,9 +877,9 @@ function lib:ProcessWhoResults()
|
|||||||
|
|
||||||
local num
|
local num
|
||||||
self.Total, num = GetNumWhoResults()
|
self.Total, num = GetNumWhoResults()
|
||||||
for i = 1, num do
|
for i=1, num do
|
||||||
local charname, guildname, level, race, class, zone, nonlocalclass, sex = GetWhoInfo(i)
|
local charname, guildname, level, race, class, zone, nonlocalclass, sex = GetWhoInfo(i)
|
||||||
self.Result[i] = {Name = charname, Guild = guildname, Level = level, Race = race, Class = class, Zone = zone, NoLocaleClass = nonlocalclass, Sex = sex }
|
self.Result[i] = {Name=charname, Guild=guildname, Level=level, Race=race, Class=class, Zone=zone, NoLocaleClass=nonlocalclass, Sex=sex }
|
||||||
end
|
end
|
||||||
|
|
||||||
self:ReturnWho()
|
self:ReturnWho()
|
||||||
@@ -883,25 +889,26 @@ end
|
|||||||
--- event activation
|
--- event activation
|
||||||
---
|
---
|
||||||
|
|
||||||
lib['frame']:UnregisterAllEvents()
|
lib['frame']:UnregisterAllEvents();
|
||||||
|
|
||||||
lib['frame']:SetScript("OnEvent", function(...)
|
lib['frame']:SetScript("OnEvent", function(...)
|
||||||
lib[event](lib, unpack(arg))
|
lib[event](lib, unpack(arg))
|
||||||
end)
|
end);
|
||||||
|
|
||||||
for _, name in pairs({
|
for _,name in pairs({
|
||||||
'CHAT_MSG_SYSTEM',
|
'CHAT_MSG_SYSTEM',
|
||||||
'WHO_LIST_UPDATE',
|
'WHO_LIST_UPDATE',
|
||||||
}) do
|
}) do
|
||||||
lib['frame']:RegisterEvent(name)
|
lib['frame']:RegisterEvent(name);
|
||||||
end
|
end -- for
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
--- re-embed
|
--- re-embed
|
||||||
---
|
---
|
||||||
|
|
||||||
for target, _ in pairs(lib['embeds']) do
|
for target,_ in pairs(lib['embeds']) do
|
||||||
if type(target) == 'table' then
|
if type(target) == 'table' then
|
||||||
lib:Embed(target)
|
lib:Embed(target)
|
||||||
end
|
end -- if
|
||||||
end
|
end -- for
|
||||||
|
|||||||
Reference in New Issue
Block a user