-Search works with difficulty
-Fixed what I borked
This commit is contained in:
@@ -2,6 +2,7 @@ local AL = LibStub("AceLocale-3.0"):GetLocale("AtlasLoot");
|
||||
|
||||
AtlasLoot_Difficulty = {
|
||||
-- table of difficulties and there itemID references
|
||||
|
||||
["ClassicDungeon"] = {
|
||||
{"Normal", 2,},
|
||||
{"Bloodforged", 1,},
|
||||
@@ -112,3 +113,15 @@ AtlasLoot_Difficulty = {
|
||||
MIN_DIF = 18;
|
||||
MAX_DIF = 19;
|
||||
}
|
||||
|
||||
function AtlasLoot_Difficulty:getMaxDifficulty(difficultyKey)
|
||||
if(difficultyKey == "ClassicDungeon" or difficultyKey == "PVP") then
|
||||
return 2;
|
||||
elseif (difficultyKey == "ClassicDungeonExt" or difficultyKey == "BCDungeon" or difficultyKey == "WrathDungeon") then
|
||||
return 44;
|
||||
elseif (difficultyKey == "ClassicRaid" or difficultyKey == "BCRaid" or difficultyKey == "WrathRaid") then
|
||||
return 4;
|
||||
else
|
||||
return 0;
|
||||
end
|
||||
end
|
||||
|
||||
@@ -521,28 +521,29 @@ function AtlasLoot_ShowItemsFrame(dataID, dataSource, boss, pFrame, tablenum)
|
||||
for i = 1, 30, 1 do
|
||||
--Check for a valid object (that it exists, and that it has a name
|
||||
if(dataSource[dataID][tablenum][i] ~= nil and dataSource[dataID][tablenum][i][4] ~= "") then
|
||||
IDfound = AL_FindId(dataSource[dataID][tablenum][i][2], ItemindexID) or dataSource[dataID][tablenum][i][2];
|
||||
local itemDif = ItemindexID;
|
||||
IDfound = AL_FindId(dataSource[dataID][tablenum][i][2], min(AtlasLoot_Difficulty:getMaxDifficulty(dataSource[dataID].Type), itemDif)) or dataSource[dataID][tablenum][i][2];
|
||||
if string.sub(IDfound, 1, 1) == "s" then
|
||||
isItem = false;
|
||||
IDfound = AL_FindId(dataSource[dataID][tablenum][i][2], ItemindexID) or dataSource[dataID][tablenum][i][2];
|
||||
IDfound = AL_FindId(dataSource[dataID][tablenum][i][2], itemDif) or dataSource[dataID][tablenum][i][2];
|
||||
else
|
||||
isItem = true;
|
||||
end
|
||||
|
||||
if isItem then
|
||||
--Sets ItemindexID to normal(2) if it is nil for min/max difficulties.
|
||||
if not tonumber(ItemindexID) then ItemindexID = AtlasLoot_Difficulty.Normal end;
|
||||
if not tonumber(itemDif) then itemDif = AtlasLoot_Difficulty.Normal end;
|
||||
|
||||
--Checks if an item has a Maximum difficulty, this is to correct some items that have an entry for higher difficulties then they really do
|
||||
if dataSource[dataID][tablenum][i][AtlasLoot_Difficulty.MAX_DIF] then
|
||||
if tonumber(dataSource[dataID][tablenum][i][AtlasLoot_Difficulty.MAX_DIF]) < ItemindexID then ItemindexID = dataSource[dataID][tablenum][i][AtlasLoot_Difficulty.MAX_DIF] end;
|
||||
end
|
||||
--If something was found in itemID database show that if not show default table item
|
||||
IDfound = AL_FindId(dataSource[dataID][tablenum][i][2], ItemindexID) or dataSource[dataID][tablenum][i][2];
|
||||
--Checks if an item has a Maximum difficulty, this is to correct some items that have an entry for higher difficulties then they really do
|
||||
if dataSource[dataID][tablenum][i][AtlasLoot_Difficulty.MAX_DIF] then
|
||||
if tonumber(dataSource[dataID][tablenum][i][AtlasLoot_Difficulty.MAX_DIF]) < itemDif then itemDif = dataSource[dataID][tablenum][i][AtlasLoot_Difficulty.MAX_DIF] end;
|
||||
end
|
||||
--If something was found in itemID database show that if not show default table item
|
||||
IDfound = AL_FindId(dataSource[dataID][tablenum][i][2], itemDif) or dataSource[dataID][tablenum][i][2];
|
||||
|
||||
if ItemindexID ~= "" and dataID == "SearchResult" then
|
||||
IDfound = AL_FindId(dataSource[dataID][tablenum][i][9], ItemindexID) or dataSource[dataID][tablenum][i][2];
|
||||
end
|
||||
if ItemindexID ~= "" and dataID == "SearchResult" then
|
||||
IDfound = AL_FindId(dataSource[dataID][tablenum][i][9], itemDif) or dataSource[dataID][tablenum][i][2];
|
||||
end
|
||||
|
||||
itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemCount, itemEquipLoc, itemTexture = GetItemInfo(IDfound);
|
||||
--If the client has the name of the item in cache, use that instead.
|
||||
@@ -572,7 +573,8 @@ function AtlasLoot_ShowItemsFrame(dataID, dataSource, boss, pFrame, tablenum)
|
||||
|
||||
--Store data about the state of the items frame to allow minor tweaks or a recall of the current loot page
|
||||
AtlasLootItemsFrame.refresh = {dataID, dataSource_backup, boss, pFrame, tablenum};
|
||||
if dataID ~= "FilterList" and dataSource[dataID].Back ~= true then
|
||||
--and dataSource[dataID].Back ~= true
|
||||
if dataID ~= "FilterList" then
|
||||
AtlasLootItemsFrame.refreshOri = {dataID, dataSource_backup, boss, pFrame, tablenum};
|
||||
end
|
||||
|
||||
@@ -683,7 +685,8 @@ function AtlasLoot_ShowItemsFrame(dataID, dataSource, boss, pFrame, tablenum)
|
||||
end
|
||||
|
||||
AtlasLootItemsFrame.refresh = {dataID, dataSource, boss, pFrame, tablenum};
|
||||
if dataID ~= "WishList" and dataID ~= "FilterList" and dataID ~= "SearchResult" and dataSource[dataID].Back ~= true then
|
||||
--and dataID ~= "SearchResult"
|
||||
if dataID ~= "WishList" and dataID ~= "FilterList" and dataSource[dataID].Back ~= true then
|
||||
AtlasLootItemsFrame.refreshOri = {dataID, dataSource, boss, pFrame, tablenum};
|
||||
AtlasLoot.db.profile.LastBoss = {dataID, dataSource, boss, pFrame, tablenum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE};
|
||||
end
|
||||
@@ -983,13 +986,11 @@ function AtlasLoot_QueryLootPage()
|
||||
local queryitem = button.itemID;
|
||||
if (queryitem) and (queryitem ~= nil) and (queryitem ~= "") and (queryitem ~= 0) and (string.sub(queryitem, 1, 1) ~= "s") then
|
||||
local item = Item:CreateFromID(queryitem);
|
||||
item:ContinueOnLoad(function(itemId)
|
||||
AtlasLoot:CancelTimer(AtlasLoot.refreshTimer);
|
||||
if item:GetInfo() then
|
||||
AtlasLootTooltip:SetHyperlink("item:"..itemId..":0:0:0:0:0:0:0");
|
||||
end
|
||||
AtlasLoot.refreshTimer = AtlasLoot:ScheduleTimer("callShowloot", .5);
|
||||
end)
|
||||
if not (item:GetInfo()) then
|
||||
item:ContinueOnLoad(function(itemId)
|
||||
AtlasLoot:callShowloot();
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+38
-38
@@ -623,7 +623,7 @@ local function GetSpellName(itemId, atlasName)
|
||||
end
|
||||
|
||||
local function DoSearch(searchText)
|
||||
AtlasLootCharDB["SearchResult"] = {Name = "Search Result" , Type = "Search", Back = true};
|
||||
AtlasLootCharDB["SearchResult"] = {Name = "Search Result" , Type = "ClassicDungeonExt", Back = true};
|
||||
AtlasLootCharDB.LastSearchedText = searchText;
|
||||
local count = 1;
|
||||
local tablenum = 1;
|
||||
@@ -631,6 +631,30 @@ local function DoSearch(searchText)
|
||||
local searchTerms = ParseQuery(searchText);
|
||||
local equipableFilterOn = AtlasLoot.db.profile.EquipableFilter;
|
||||
|
||||
local function GetItemDetails(itemId, atlasName)
|
||||
-- Name, Link, Quality(num), iLvl(num), minLvl(num), itemType(localized string), itemSubType(localized string), stackCount(num), itemEquipLoc(enum), texture(link to a local file), displayId(num)
|
||||
local itemName, _, itemQuality, itemLvl, minLvl, _, itemSubType, _, itemEquipLoc = GetItemInfo(itemId);
|
||||
if not itemName then
|
||||
itemName = gsub(atlasName, "=q%d=", "")
|
||||
end
|
||||
return itemName, itemQuality, itemLvl, minLvl, itemEquipLoc, itemSubType, GetItemStats("item:" .. itemId)
|
||||
end
|
||||
|
||||
local function AddItemToSearchResult(itemId, itemType, itemName, dataID, itemIdBackup, difCap)
|
||||
local lootPage = AtlasLoot_Data[dataID].Name or "Argh!";
|
||||
if AtlasLootCharDB["SearchResult"][tablenum] == nil then
|
||||
AtlasLootCharDB["SearchResult"][tablenum] = {Name = "Page "..tablenum};
|
||||
end
|
||||
if count == 30 then
|
||||
table.insert(AtlasLootCharDB["SearchResult"][tablenum], {count, itemId, itemType, itemName, lootPage, "", "", dataID .. "|" .. "\"\"", itemIdBackup, [AtlasLoot_Difficulty.MAX_DIF] = difCap});
|
||||
tablenum = tablenum + 1
|
||||
count = 1;
|
||||
else
|
||||
table.insert(AtlasLootCharDB["SearchResult"][tablenum], {count, itemId, itemType, itemName, lootPage, "", "", dataID .. "|" .. "\"\"", itemIdBackup, [AtlasLoot_Difficulty.MAX_DIF] = difCap});
|
||||
count = count + 1;
|
||||
end
|
||||
end
|
||||
|
||||
for dataID, data in pairs(AtlasLoot_Data) do
|
||||
for _, t in ipairs(data) do
|
||||
for _, v in ipairs(t) do
|
||||
@@ -638,47 +662,23 @@ local function DoSearch(searchText)
|
||||
local _, itemId, itemType, atlasName = unpack(v)
|
||||
if type(itemId) == "number" and itemId > 0 then
|
||||
local itemIdBackup = itemId;
|
||||
itemId = AL_FindId(itemId, ItemindexID) or 2;
|
||||
local difficultyCap = min(AtlasLoot_Difficulty:getMaxDifficulty(data.Type), ItemindexID);
|
||||
itemId = AL_FindId(itemId, difficultyCap) or 2;
|
||||
|
||||
local item = Item:CreateFromID(itemId);
|
||||
item:ContinueOnLoad(function(itemId)
|
||||
local function GetItemDetails(itemId, atlasName)
|
||||
-- Name, Link, Quality(num), iLvl(num), minLvl(num), itemType(localized string), itemSubType(localized string), stackCount(num), itemEquipLoc(enum), texture(link to a local file), displayId(num)
|
||||
local itemName, _, itemQuality, itemLvl, minLvl, _, itemSubType, _, itemEquipLoc = GetItemInfo(itemId);
|
||||
if not itemName then
|
||||
itemName = gsub(atlasName, "=q%d=", "")
|
||||
end
|
||||
return itemName, itemQuality, itemLvl, minLvl, itemEquipLoc, itemSubType, GetItemStats("item:" .. itemId)
|
||||
end
|
||||
|
||||
local itemDetails = {GetItemDetails(itemId, atlasName)};
|
||||
local function AddItemToSearchResult(itemId, itemType, itemName, dataID, itemIdBackup)
|
||||
local lootPage = AtlasLoot_Data[dataID].Name or "Argh!";
|
||||
if AtlasLootCharDB["SearchResult"][tablenum] == nil then
|
||||
AtlasLootCharDB["SearchResult"][tablenum] = {Name = "Page "..tablenum};
|
||||
end
|
||||
if count == 30 then
|
||||
table.insert(AtlasLootCharDB["SearchResult"][tablenum], {count, itemId, itemType, itemName, lootPage, "", "", dataID .. "|" .. "\"\"", itemIdBackup});
|
||||
tablenum = tablenum + 1
|
||||
count = 1;
|
||||
else
|
||||
table.insert(AtlasLootCharDB["SearchResult"][tablenum], {count, itemId, itemType, itemName, lootPage, "", "", dataID .. "|" .. "\"\"", itemIdBackup});
|
||||
count = count + 1;
|
||||
item:ContinueOnLoad(function()
|
||||
if item:GetInfo() then
|
||||
local itemDetails = {GetItemDetails(item.itemID, atlasName)};
|
||||
if #searchTerms == 1 and searchTerms[1].name then
|
||||
if nameMatches(atlasName, searchTerms[1].name) then
|
||||
AddItemToSearchResult(itemId, itemType, atlasName, dataID, itemIdBackup, AtlasLoot_Difficulty:getMaxDifficulty(data.Type));
|
||||
end
|
||||
elseif ItemMatchesAllTerms(searchTerms, itemDetails) then
|
||||
AddItemToSearchResult(itemId, itemType, atlasName, dataID, itemIdBackup, AtlasLoot_Difficulty:getMaxDifficulty(data.Type));
|
||||
end
|
||||
AtlasLoot:CancelTimer(AtlasLoot.refreshTimer);
|
||||
if item:GetInfo() then
|
||||
if #searchTerms == 1 and searchTerms[1].name then
|
||||
if nameMatches(atlasName, searchTerms[1].name) then
|
||||
AddItemToSearchResult(itemId, itemType, atlasName, dataID, itemIdBackup);
|
||||
end
|
||||
elseif ItemMatchesAllTerms(searchTerms, itemDetails) then
|
||||
AddItemToSearchResult(itemId, itemType, atlasName, dataID, itemIdBackup);
|
||||
end
|
||||
end
|
||||
AtlasLoot.refreshTimer = AtlasLoot:ScheduleTimer("callShowloot", .5);
|
||||
end)
|
||||
|
||||
|
||||
end
|
||||
end)
|
||||
elseif not equipableFilterOn and itemId and itemId ~= "" and string.sub(itemId, 1, 1) == "s" then
|
||||
local spellName = GetSpellName(itemId, atlasName)
|
||||
if nameMatches(spellName, searchText) then
|
||||
|
||||
Reference in New Issue
Block a user