formatting
This commit is contained in:
+97
-97
@@ -1,17 +1,17 @@
|
||||
local GREY = "|cff999999";
|
||||
local RED = "|cffff0000";
|
||||
local WHITE = "|cffFFFFFF";
|
||||
local GREEN = "|cff1eff00";
|
||||
local PURPLE = "|cff9F3FFF";
|
||||
local BLUE = "|cff0070dd";
|
||||
local ORANGE = "|cffFF8400";
|
||||
local GREY = "|cff999999"
|
||||
local RED = "|cffff0000"
|
||||
local WHITE = "|cffFFFFFF"
|
||||
local GREEN = "|cff1eff00"
|
||||
local PURPLE = "|cff9F3FFF"
|
||||
local BLUE = "|cff0070dd"
|
||||
local ORANGE = "|cffFF8400"
|
||||
|
||||
local AL = AceLibrary("AceLocale-2.2"):new("AtlasLoot");
|
||||
local currentPage = 1;
|
||||
local SearchResult = nil;
|
||||
local AL = AceLibrary("AceLocale-2.2"):new("AtlasLoot")
|
||||
local currentPage = 1
|
||||
local SearchResult = nil
|
||||
|
||||
function AtlasLoot:ShowSearchResult()
|
||||
AtlasLoot_ShowItemsFrame("SearchResult", "SearchResultPage"..currentPage, string.format((AL["Search Result: %s"]), AtlasLootCharDB.LastSearchedText or ""));
|
||||
AtlasLoot_ShowItemsFrame("SearchResult", "SearchResultPage"..currentPage, string.format((AL["Search Result: %s"]), AtlasLootCharDB.LastSearchedText or ""))
|
||||
end
|
||||
|
||||
local function strtrim(s)
|
||||
@@ -20,116 +20,116 @@ end
|
||||
|
||||
function AtlasLoot:Search(Text)
|
||||
if not Text then return end
|
||||
Text = strtrim(Text);
|
||||
Text = strtrim(Text)
|
||||
if Text == "" then return end
|
||||
local text = string.lower(Text);
|
||||
local text = string.lower(Text)
|
||||
local search = function(dataSource)
|
||||
if dataSource == "AtlasLootFallback" then return end
|
||||
local partial = AtlasLootCharDB.PartialMatching;
|
||||
local partial = AtlasLootCharDB.PartialMatching
|
||||
for dataID, data in pairs(AtlasLoot_Data[dataSource]) do
|
||||
if type(data) == "table" then
|
||||
for _, v in ipairs(data) do
|
||||
if type(v[1]) ~= "table" then
|
||||
-- item
|
||||
if type(v[1]) == "number" and v[1] > 0 then
|
||||
local itemName = GetItemInfo(v[1]);
|
||||
if not itemName then itemName = gsub(v[3], "=q%d=", "") end
|
||||
local found;
|
||||
if partial then
|
||||
found = string.find(string.lower(itemName), text);
|
||||
else
|
||||
found = string.lower(itemName) == text;
|
||||
end
|
||||
if found then
|
||||
local _, _, quality = string.find(v[3], "=q(%d)=");
|
||||
if quality then itemName = "=q"..quality.."="..itemName end
|
||||
table.insert(AtlasLootCharDB["SearchResult"], { v[1], v[2], itemName, v[4], dataID.."|"..dataSource });
|
||||
end
|
||||
-- spell
|
||||
elseif (v[1] ~= nil) and (v[1] ~= "") and (string.sub(v[1], 1, 1) == "s") then
|
||||
local spellName
|
||||
if not spellName then
|
||||
if (string.sub(v[3], 1, 2) == "=d") then
|
||||
spellName = gsub(v[3], "=ds=", "");
|
||||
else
|
||||
spellName = gsub(v[3], "=q%d=", "");
|
||||
end
|
||||
end
|
||||
local found;
|
||||
if partial then
|
||||
found = string.find(string.lower(spellName), text);
|
||||
else
|
||||
found = string.lower(spellName) == text;
|
||||
end
|
||||
if found then
|
||||
spellName = string.sub(v[3], 1, 4)..spellName;
|
||||
table.insert(AtlasLootCharDB["SearchResult"], { v[1], v[2], spellName, v[4], dataID.."|"..dataSource });
|
||||
end
|
||||
-- enchant
|
||||
elseif (v[1] ~= nil) and (v[1] ~= "") and (string.sub(v[1], 1, 1) == "e") then
|
||||
local spellName
|
||||
if not spellName then
|
||||
if (string.sub(v[3], 1, 2) == "=d") then
|
||||
spellName = gsub(v[3], "=ds=", "");
|
||||
else
|
||||
spellName = gsub(v[3], "=q%d=", "");
|
||||
end
|
||||
end
|
||||
local found;
|
||||
if partial then
|
||||
found = string.find(string.lower(spellName), text);
|
||||
else
|
||||
found = string.lower(spellName) == text;
|
||||
end
|
||||
if found then
|
||||
spellName = string.sub(v[3], 1, 4)..spellName;
|
||||
table.insert(AtlasLootCharDB["SearchResult"], { v[1], v[2], spellName, v[4], dataID.."|"..dataSource });
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if type(data) == "table" then
|
||||
for _, v in ipairs(data) do
|
||||
if type(v[1]) ~= "table" then
|
||||
-- item
|
||||
if type(v[1]) == "number" and v[1] > 0 then
|
||||
local itemName = GetItemInfo(v[1])
|
||||
if not itemName then itemName = gsub(v[3], "=q%d=", "") end
|
||||
local found
|
||||
if partial then
|
||||
found = string.find(string.lower(itemName), text)
|
||||
else
|
||||
found = string.lower(itemName) == text
|
||||
end
|
||||
if found then
|
||||
local _, _, quality = string.find(v[3], "=q(%d)=")
|
||||
if quality then itemName = "=q"..quality.."="..itemName end
|
||||
table.insert(AtlasLootCharDB["SearchResult"], { v[1], v[2], itemName, v[4], dataID.."|"..dataSource })
|
||||
end
|
||||
-- spell
|
||||
elseif (v[1] ~= nil) and (v[1] ~= "") and (string.sub(v[1], 1, 1) == "s") then
|
||||
local spellName
|
||||
if not spellName then
|
||||
if (string.sub(v[3], 1, 2) == "=d") then
|
||||
spellName = gsub(v[3], "=ds=", "")
|
||||
else
|
||||
spellName = gsub(v[3], "=q%d=", "")
|
||||
end
|
||||
end
|
||||
local found
|
||||
if partial then
|
||||
found = string.find(string.lower(spellName), text)
|
||||
else
|
||||
found = string.lower(spellName) == text
|
||||
end
|
||||
if found then
|
||||
spellName = string.sub(v[3], 1, 4)..spellName
|
||||
table.insert(AtlasLootCharDB["SearchResult"], { v[1], v[2], spellName, v[4], dataID.."|"..dataSource })
|
||||
end
|
||||
-- enchant
|
||||
elseif (v[1] ~= nil) and (v[1] ~= "") and (string.sub(v[1], 1, 1) == "e") then
|
||||
local spellName
|
||||
if not spellName then
|
||||
if (string.sub(v[3], 1, 2) == "=d") then
|
||||
spellName = gsub(v[3], "=ds=", "")
|
||||
else
|
||||
spellName = gsub(v[3], "=q%d=", "")
|
||||
end
|
||||
end
|
||||
local found
|
||||
if partial then
|
||||
found = string.find(string.lower(spellName), text)
|
||||
else
|
||||
found = string.lower(spellName) == text
|
||||
end
|
||||
if found then
|
||||
spellName = string.sub(v[3], 1, 4)..spellName
|
||||
table.insert(AtlasLootCharDB["SearchResult"], { v[1], v[2], spellName, v[4], dataID.."|"..dataSource })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
AtlasLootCharDB["SearchResult"] = {};
|
||||
AtlasLootCharDB.LastSearchedText = Text;
|
||||
|
||||
AtlasLootCharDB["SearchResult"] = {}
|
||||
AtlasLootCharDB.LastSearchedText = Text
|
||||
for dataSource in pairs(AtlasLoot_Data) do search(dataSource) end
|
||||
|
||||
|
||||
if getn(AtlasLootCharDB["SearchResult"]) == 0 then
|
||||
DEFAULT_CHAT_FRAME:AddMessage(RED..AL["AtlasLoot"]..": "..WHITE..AL["No match found for"].." \""..Text.."\".");
|
||||
DEFAULT_CHAT_FRAME:AddMessage(RED..AL["AtlasLoot"]..": "..WHITE..AL["No match found for"].." \""..Text.."\".")
|
||||
else
|
||||
currentPage = 1;
|
||||
SearchResult = AtlasLoot_CategorizeWishList(AtlasLootCharDB["SearchResult"]);
|
||||
AtlasLoot_ShowItemsFrame("SearchResult", "SearchResultPage1", string.format((AL["Search Result: %s"]), AtlasLootCharDB.LastSearchedText or ""));
|
||||
currentPage = 1
|
||||
SearchResult = AtlasLoot_CategorizeWishList(AtlasLootCharDB["SearchResult"])
|
||||
AtlasLoot_ShowItemsFrame("SearchResult", "SearchResultPage1", string.format((AL["Search Result: %s"]), AtlasLootCharDB.LastSearchedText or ""))
|
||||
end
|
||||
end
|
||||
|
||||
function AtlasLoot:ShowSearchOptions(button)
|
||||
local Hewdrop = AceLibrary("Hewdrop-2.0");
|
||||
local Hewdrop = AceLibrary("Hewdrop-2.0")
|
||||
if Hewdrop:IsOpen(button) then
|
||||
Hewdrop:Close(1);
|
||||
Hewdrop:Close(1)
|
||||
else
|
||||
local setOptions = function()
|
||||
Hewdrop:AddLine(
|
||||
"text", AL["Search options"],
|
||||
"isTitle", true,
|
||||
"notCheckable", true
|
||||
);
|
||||
)
|
||||
Hewdrop:AddLine(
|
||||
"text", AL["Partial matching"],
|
||||
"checked", AtlasLootCharDB.PartialMatching,
|
||||
"tooltipTitle", AL["Partial matching"],
|
||||
"tooltipText", AL["If checked, AtlasLoot searches item names for a partial match."],
|
||||
"func", function() AtlasLootCharDB.PartialMatching = not AtlasLootCharDB.PartialMatching end
|
||||
);
|
||||
end;
|
||||
)
|
||||
end
|
||||
Hewdrop:Open(button,
|
||||
'point', function(parent)
|
||||
return "BOTTOMLEFT", "BOTTOMRIGHT";
|
||||
return "BOTTOMLEFT", "BOTTOMRIGHT"
|
||||
end,
|
||||
"children", setOptions
|
||||
);
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -143,17 +143,17 @@ end
|
||||
function AtlasLoot:GetSearchResultPage(page)
|
||||
if not SearchResult then SearchResult = AtlasLoot_CategorizeWishList(AtlasLootCharDB["SearchResult"]) end
|
||||
-- Calc for maximal pages
|
||||
local pageMax = math.ceil(getn(SearchResult) / 30);
|
||||
local pageMax = math.ceil(getn(SearchResult) / 30)
|
||||
if page < 1 then page = 1 end
|
||||
if page > pageMax then page = pageMax end
|
||||
currentPage = page;
|
||||
currentPage = page
|
||||
|
||||
-- Table copy
|
||||
local result = {};
|
||||
local start = (page - 1) * 30 + 1;
|
||||
local result = {}
|
||||
local start = (page - 1) * 30 + 1
|
||||
for i = start, start + 29 do
|
||||
if not SearchResult[i] then break end
|
||||
table.insert(result, SearchResult[i]);
|
||||
table.insert(result, SearchResult[i])
|
||||
end
|
||||
return result, pageMax;
|
||||
return result, pageMax
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user