mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
remove temp folder structure
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
--[[
|
||||
Copyright 2013 João Cardoso
|
||||
CustomSearch is distributed under the terms of the GNU General Public License (Version 3).
|
||||
As a special exception, the copyright holders of this library give you permission to embed it
|
||||
with independent modules to produce an addon, regardless of the license terms of these
|
||||
independent modules, and to copy and distribute the resulting software under terms of your
|
||||
choice, provided that you also meet, for each embedded independent module, the terms and
|
||||
conditions of the license of that module. Permission is not granted to modify this library.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the library. If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
This file is part of CustomSearch.
|
||||
--]]
|
||||
|
||||
local Lib = LibStub:NewLibrary('CustomSearch-1.0', 9)
|
||||
if not Lib then
|
||||
return
|
||||
end
|
||||
|
||||
local find, gmatch, lower, match = string.find, string.gmatch, string.lower, string.match
|
||||
|
||||
--[[ Parsing ]]--
|
||||
|
||||
function Lib:Matches(object, search, filters)
|
||||
if object then
|
||||
self.filters = filters
|
||||
self.object = object
|
||||
|
||||
return self:MatchAll(search or '')
|
||||
end
|
||||
end
|
||||
|
||||
function Lib:MatchAll(search)
|
||||
for phrase in gmatch(self:Clean(search), '[^&]+') do
|
||||
if not self:MatchAny(phrase) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function Lib:MatchAny(search)
|
||||
for phrase in gmatch(search, '[^|]+') do
|
||||
if self:Match(phrase) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Lib:Match(search)
|
||||
local tag, rest = match(search, '^%s*(%S+):(.*)$')
|
||||
if tag then
|
||||
tag = '^' .. tag
|
||||
search = rest
|
||||
end
|
||||
|
||||
local words = gmatch(search, '%S+')
|
||||
local failed
|
||||
|
||||
for word in words do
|
||||
if word == self.OR then
|
||||
if failed then
|
||||
failed = false
|
||||
else
|
||||
break
|
||||
end
|
||||
|
||||
else
|
||||
local negate, rest = match(word, '^([!~]=*)(.*)$')
|
||||
if negate or word == self.NOT_MATCH then
|
||||
word = rest and rest ~= '' and rest or words() or ''
|
||||
negate = -1
|
||||
else
|
||||
negate = 1
|
||||
end
|
||||
|
||||
local operator, rest = match(word, '^(=*[<>]=*)(.*)$')
|
||||
if operator then
|
||||
word = rest ~= '' and rest or words()
|
||||
end
|
||||
|
||||
local result = self:Filter(tag, operator, word) and 1 or -1
|
||||
if result * negate ~= 1 then
|
||||
failed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return not failed
|
||||
end
|
||||
|
||||
|
||||
--[[ Filtering ]]--
|
||||
|
||||
function Lib:Filter(tag, operator, search)
|
||||
if not search then
|
||||
return true
|
||||
end
|
||||
|
||||
if tag then
|
||||
for _, filter in pairs(self.filters) do
|
||||
for _, value in pairs(filter.tags or {}) do
|
||||
if find(value, tag) then
|
||||
return self:UseFilter(filter, operator, search)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for _, filter in pairs(self.filters) do
|
||||
if not filter.onlyTags and self:UseFilter(filter, operator, search) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Lib:UseFilter(filter, operator, search)
|
||||
local data = {filter:canSearch(operator, search, self.object)}
|
||||
if data[1] then
|
||||
return match(filter, self.object, operator, unpack(data))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--[[ Utilities ]]--
|
||||
|
||||
function Lib:Find(search, ...)
|
||||
for i = 1, getn(arg) do
|
||||
local text = arg[i]
|
||||
if text and find(self:Clean(text), search) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Lib:Clean(string)
|
||||
string = lower(string)
|
||||
string = gsub(string, '[%(%)%.%%%+%-%*%?%[%]%^%$]', function(c) return '%'..c end)
|
||||
|
||||
for accent, char in pairs(self.ACCENTS) do
|
||||
string = gsub(string, accent, char)
|
||||
end
|
||||
|
||||
return string
|
||||
end
|
||||
|
||||
function Lib:Compare(op, a, b)
|
||||
if op then
|
||||
if find(op, '<') then
|
||||
if find(op, '=') then
|
||||
return a <= b
|
||||
end
|
||||
|
||||
return a < b
|
||||
end
|
||||
|
||||
if find(op, '>')then
|
||||
if find(op, '=') then
|
||||
return a >= b
|
||||
end
|
||||
|
||||
return a > b
|
||||
end
|
||||
end
|
||||
|
||||
return a == b
|
||||
end
|
||||
|
||||
|
||||
--[[ Localization ]]--
|
||||
|
||||
do
|
||||
local no = {enUS = 'Not', frFR = 'Pas', deDE = 'Nicht', ruRU = 'Нет'}
|
||||
local just_or = {enUS = 'Or', frFR = 'Ou', deDE = 'Oder', ruRU = 'Или'}
|
||||
local accents = {
|
||||
a = {'à','â','ã','å'},
|
||||
e = {'è','é','ê','ê','ë'},
|
||||
i = {'ì', 'í', 'î', 'ï'},
|
||||
o = {'ó','ò','ô','õ'},
|
||||
u = {'ù', 'ú', 'û', 'ü'},
|
||||
c = {'ç'}, n = {'ñ'}
|
||||
}
|
||||
|
||||
Lib.ACCENTS = {}
|
||||
for char, accents in pairs(accents) do
|
||||
for _, accent in ipairs(accents) do
|
||||
Lib.ACCENTS[accent] = char
|
||||
end
|
||||
end
|
||||
|
||||
Lib.OR = Lib:Clean(just_or[GetLocale()] or "")
|
||||
Lib.NOT = no[GetLocale()] or NO
|
||||
Lib.NOT_MATCH = Lib:Clean(Lib.NOT)
|
||||
setmetatable(Lib, {__call = Lib.Matches})
|
||||
end
|
||||
|
||||
return Lib
|
||||
@@ -0,0 +1,4 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="CustomSearch-1.0.lua"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,212 @@
|
||||
--[[
|
||||
ItemSearch
|
||||
An item text search engine of some sort
|
||||
--]]
|
||||
|
||||
local Search = LibStub("CustomSearch-1.0");
|
||||
local Unfit = LibStub("Unfit-1.0");
|
||||
local Lib = LibStub:NewLibrary("LibItemSearch-1.2", 11);
|
||||
if Lib then
|
||||
Lib.Filters = {}
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
local tonumber = tonumber
|
||||
local find, strmatch, lower = string.find, string.match, string.lower
|
||||
|
||||
--[[ User API ]]--
|
||||
|
||||
function Lib:Matches(link, search)
|
||||
return Search(link, search, self.Filters)
|
||||
end
|
||||
|
||||
function Lib:Tooltip(link, search)
|
||||
return link and strmatch(self.Filters.tip, link, nil, search)
|
||||
end
|
||||
|
||||
function Lib:TooltipPhrase(link, search)
|
||||
return link and strmatch(self.Filters.tipPhrases, link, nil, search)
|
||||
end
|
||||
|
||||
--[[ Basics ]]--
|
||||
|
||||
Lib.Filters.name = {
|
||||
tags = {"n", "name"},
|
||||
|
||||
canSearch = function(self, operator, search)
|
||||
return not operator and search
|
||||
end,
|
||||
|
||||
match = function(self, item, _, search)
|
||||
local name = strmatch(item, "%[(.-)%]")
|
||||
return Search:Find(search, name)
|
||||
end
|
||||
}
|
||||
|
||||
Lib.Filters.type = {
|
||||
tags = {"t", "type", "s", "slot"},
|
||||
|
||||
canSearch = function(self, operator, search)
|
||||
return not operator and search
|
||||
end,
|
||||
|
||||
match = function(self, item, _, search)
|
||||
local type, subType, _, equipSlot = select(6, GetItemInfo(item))
|
||||
return Search:Find(search, type, subType, _G[equipSlot])
|
||||
end
|
||||
}
|
||||
|
||||
Lib.Filters.level = {
|
||||
tags = {"l", "level", "lvl", "ilvl"},
|
||||
|
||||
canSearch = function(self, _, search)
|
||||
return tonumber(search)
|
||||
end,
|
||||
|
||||
match = function(self, link, operator, num)
|
||||
local _, _, _, lvl = GetItemInfo(link)
|
||||
if lvl then
|
||||
return Search:Compare(operator, lvl, num)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
Lib.Filters.requiredlevel = {
|
||||
tags = {"r", "req", "rl", "reql", "reqlvl"},
|
||||
|
||||
canSearch = function(self, _, search)
|
||||
return tonumber(search)
|
||||
end,
|
||||
|
||||
match = function(self, link, operator, num)
|
||||
local _, _, _, _, lvl = GetItemInfo(link)
|
||||
if lvl then
|
||||
return Search:Compare(operator, lvl, num)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
--[[ Quality ]]--
|
||||
|
||||
local qualities = {}
|
||||
for i = 0, getn(ITEM_QUALITY_COLORS) do
|
||||
qualities[i] = lower(_G["ITEM_QUALITY"..i.."_DESC"])
|
||||
end
|
||||
|
||||
Lib.Filters.quality = {
|
||||
tags = {"q", "quality"},
|
||||
|
||||
canSearch = function(self, _, search)
|
||||
for i, name in pairs(qualities) do
|
||||
if find(namesearch) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
match = function(self, link, operator, num)
|
||||
local _, _, quality = GetItemInfo(link)
|
||||
return Search:Compare(operator, quality, num)
|
||||
end
|
||||
}
|
||||
|
||||
--[[ Usable ]]--
|
||||
|
||||
Lib.Filters.usable = {
|
||||
tags = {},
|
||||
|
||||
canSearch = function(self, operator, search)
|
||||
return not operator and search == "usable"
|
||||
end,
|
||||
|
||||
match = function(self, link)
|
||||
if(not Unfit:IsItemUnusable(link)) then
|
||||
local _, _, _, _, lvl = GetItemInfo(link)
|
||||
return lvl and (lvl ~= 0 and lvl <= UnitLevel("player"))
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
--[[ Tooltip Searches ]]--
|
||||
|
||||
local scanner = LibItemSearchTooltipScanner or CreateFrame("GameTooltip", "LibItemSearchTooltipScanner", UIParent, "GameTooltipTemplate")
|
||||
|
||||
Lib.Filters.tip = {
|
||||
tags = {"tt", "tip", "tooltip"},
|
||||
|
||||
onlyTags = true,
|
||||
|
||||
canSearch = function(self, _, search)
|
||||
return search
|
||||
end,
|
||||
|
||||
match = function(self, link, _, search)
|
||||
if find(link, "item:") then
|
||||
scanner:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
scanner:SetHyperlink(link)
|
||||
|
||||
for i = 1, scanner:NumLines() do
|
||||
if Search:Find(search, _G[scanner:GetName().."TextLeft"..i]:GetText()) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
local escapes = {
|
||||
["|c%x%x%x%x%x%x%x%x"] = "",
|
||||
["|r"] = ""
|
||||
}
|
||||
|
||||
local function CleanString(str)
|
||||
for k, v in pairs(escapes) do
|
||||
str = string.gsub(str, k, v)
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
Lib.Filters.tipPhrases = {
|
||||
canSearch = function(self, _, search)
|
||||
return self.keywords[search]
|
||||
end,
|
||||
|
||||
match = function(self, link, _, search)
|
||||
local id = strmatch(link, "item:(%d+)")
|
||||
if not id then
|
||||
return
|
||||
end
|
||||
|
||||
local cached = self.cache[search][id]
|
||||
if cached ~= nil then
|
||||
return cached
|
||||
end
|
||||
|
||||
scanner:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
scanner:SetHyperlink(link)
|
||||
|
||||
local matches = false
|
||||
for i = 1, scanner:NumLines() do
|
||||
local text = _G["LibItemSearchTooltipScannerTextLeft"..i]:GetText()
|
||||
text = CleanString(text)
|
||||
if search == text then
|
||||
matches = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
self.cache[search][id] = matches
|
||||
return matches
|
||||
end,
|
||||
|
||||
cache = setmetatable({}, {__index = function(t, k) local v = {} t[k] = v return v end}),
|
||||
|
||||
keywords = {
|
||||
[lower(ITEM_SOULBOUND)] = ITEM_BIND_ON_PICKUP,
|
||||
["bound"] = ITEM_BIND_ON_PICKUP,
|
||||
["bop"] = ITEM_BIND_ON_PICKUP,
|
||||
["boe"] = ITEM_BIND_ON_EQUIP,
|
||||
["bou"] = ITEM_BIND_ON_USE
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Include file="CustomSearch-1.0\CustomSearch-1.0.xml"/>
|
||||
<Include file="Unfit-1.0\Unfit-1.0.xml"/>
|
||||
<Script file="LibItemSearch-1.2.lua"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,111 @@
|
||||
--[[
|
||||
Copyright 2011-2016 João Cardoso
|
||||
Unfit is distributed under the terms of the GNU General Public License (Version 3).
|
||||
As a special exception, the copyright holders of this library give you permission to embed it
|
||||
with independent modules to produce an addon, regardless of the license terms of these
|
||||
independent modules, and to copy and distribute the resulting software under terms of your
|
||||
choice, provided that you also meet, for each embedded independent module, the terms and
|
||||
conditions of the license of that module. Permission is not granted to modify this library.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the library. If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
This file is part of Unfit.
|
||||
--]]
|
||||
|
||||
local Lib = LibStub:NewLibrary('Unfit-1.0', 9)
|
||||
if not Lib then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--[[ Data ]]--
|
||||
|
||||
do
|
||||
local _, Class = UnitClass('player')
|
||||
local Unusable
|
||||
|
||||
if Class == 'DRUID' then
|
||||
Unusable = {
|
||||
{1, 2, 3, 4, 8, 9, 14, 15, 16},
|
||||
{4, 5, 7},
|
||||
true
|
||||
}
|
||||
elseif Class == 'HUNTER' then
|
||||
Unusable = {
|
||||
{5, 6, 16},
|
||||
{5, 6}
|
||||
}
|
||||
elseif Class == 'MAGE' then
|
||||
Unusable = {
|
||||
{1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15},
|
||||
{3, 4, 5, 7},
|
||||
true
|
||||
}
|
||||
elseif Class == 'PALADIN' then
|
||||
Unusable = {
|
||||
{3, 4, 10, 11, 13, 14, 15, 16},
|
||||
{},
|
||||
true
|
||||
}
|
||||
elseif Class == 'PRIEST' then
|
||||
Unusable = {
|
||||
{1, 2, 3, 4, 6, 7, 8, 9, 11, 14, 15},
|
||||
{3, 4, 5, 7},
|
||||
true
|
||||
}
|
||||
elseif Class == 'ROGUE' then
|
||||
Unusable = {
|
||||
{2, 6, 7, 9, 10, 16},
|
||||
{4, 5, 6}
|
||||
}
|
||||
elseif Class == 'SHAMAN' then
|
||||
Unusable = {
|
||||
{3, 4, 7, 8, 9, 14, 15, 16},
|
||||
{5}
|
||||
}
|
||||
elseif Class == 'WARLOCK' then
|
||||
Unusable = {
|
||||
{1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15},
|
||||
{3, 4, 5, 7},
|
||||
true
|
||||
}
|
||||
elseif Class == 'WARRIOR' then
|
||||
Unusable = {{16}, {}}
|
||||
else
|
||||
Unusable = {{}, {}}
|
||||
end
|
||||
|
||||
for class = 1, 2 do
|
||||
local subs = {GetAuctionItemSubClasses(class)}
|
||||
for i, subclass in ipairs(Unusable[class]) do
|
||||
Unusable[subs[subclass]] = true
|
||||
end
|
||||
|
||||
Unusable[class] = nil
|
||||
subs = nil
|
||||
end
|
||||
|
||||
Lib.unusable = Unusable
|
||||
Lib.cannotDual = Unusable[3]
|
||||
end
|
||||
|
||||
--[[ API ]]--
|
||||
|
||||
function Lib:IsItemUnusable(arg1)
|
||||
if arg1 then
|
||||
local subclass, _, slot = select(7, GetItemInfo(arg1))
|
||||
return Lib:IsClassUnusable(subclass, slot)
|
||||
end
|
||||
end
|
||||
|
||||
function Lib:IsClassUnusable(subclass, slot)
|
||||
if subclass then
|
||||
return slot ~= '' and Unusable[subclass] or slot == 'INVTYPE_WEAPONOFFHAND' and Lib.cannotDual
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="Unfit-1.0.lua"/>
|
||||
</Ui>
|
||||
Reference in New Issue
Block a user