Merge branch 'new-wishlist-functions'

This commit is contained in:
Anch
2022-10-14 21:30:42 +13:00
6 changed files with 409 additions and 117 deletions
+87 -26
View File
@@ -143,8 +143,8 @@ function AtlasLoot:OnEnable()
if IsAddOnLoaded("Atlas") then
AtlasLoot:LoadMapData();
ATLASLOOT_ATLASLOADED = true;
AtlasLootDefaultFrame_MapButton:Show();
AtlasLootDefaultFrame_MapSelectButton:Show();
AtlasLootDefaultFrame_MapButton:Enable();
AtlasLootDefaultFrame_MapSelectButton:Enable();
end
--Add the loot browser to the special frames tables to enable closing wih the ESC key
@@ -230,6 +230,12 @@ function AtlasLoot:OnEnable()
LibStub("LibAboutPanel").new(AL["AtlasLoot"], "AtlasLoot");
end
AtlasLoot_UpdateLootBrowserScale();
local playerName = UnitName("player");
if AtlasLootWishList["Options"][playerName]["AutoSortWishlist"] then
AtlasLootItemsFrame_Wishlist_UnLock:Disable();
else
AtlasLootItemsFrame_Wishlist_UnLock:Enable();
end
end
function AtlasLoot_Reset(data)
@@ -405,7 +411,6 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
local spellName, spellIcon;
SearchPrevData = {dataID, dataSource_backup, tablenum};
--If the loot table name has not been passed, throw up a debugging statement
if dataID == nil then
@@ -450,6 +455,13 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
AtlasLootDefaultFrame_MapButton:Disable();
AtlasLootDefaultFrame_MapSelectButton:SetText("No Map");
end
if dataSource_backup == "AtlasLoot_CurrentWishList" then
ATLASLOOT_CURRENT_WISHLIST_NUM = AtlasLoot_CurrentWishList["Show"].ListNum;
else
ATLASLOOT_ITEM_UNLOCK = false;
end
local difType = false;
-- Checks to see if type is the same
if ATLASLOOT_CURRENTTYPE ~= dataSource[dataID].Type then
@@ -471,15 +483,33 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
ATLASLOOT_CURRENTTYPE = dataSource[dataID].Type or "Default";
-- Loads the difficultys into the scrollFrame
AtlasLoot:ScrollFrameUpdate();
if dataSource[dataID].ListType then
AtlasLoot:ScrollFrameUpdate(nil,dataSource[dataID].ListType);
else
AtlasLoot:ScrollFrameUpdate();
end
-- Sets the main page lable
AtlasLoot_BossName:SetText(dataSource[dataID][tablenum].Name);
-- Finds the tablenumber to set where the difficulty slider should be.
local typeNumber = 1;
local function findTypeNumber()
for i,v in ipairs(AtlasLoot_Difficulty[dataSource[dataID].Type]) do
if v[2] == ItemindexID then
typeNumber = i;
return i;
end
end
end
-- Moves the difficulty scrollslider if the difficulty has changed
if dataSource[dataID].Type and difType and #AtlasLoot_Difficulty[dataSource[dataID].Type] > 5 then
if dataSource[dataID].Type and difType and #AtlasLoot_Difficulty[dataSource[dataID].Type] > 5 and findTypeNumber() > 5 then
local min, max = AtlasLootDefaultFrameScrollScrollBar:GetMinMaxValues();
AtlasLootDefaultFrameScrollScrollBar:SetValue(ItemindexID * (max / #AtlasLoot_Difficulty[dataSource[dataID].Type]));
AtlasLootDefaultFrameScrollScrollBar:SetValue(typeNumber * (max / #AtlasLoot_Difficulty[dataSource[dataID].Type]));
end
-- Moves the difficulty scrollslider if wishlist
if dataSource_backup == "AtlasLoot_CurrentWishList" and dataSource[dataID].ListNum > 5 then
local min, max = AtlasLootDefaultFrameScrollScrollBar:GetMinMaxValues();
AtlasLootDefaultFrameScrollScrollBar:SetValue(dataSource[dataID].ListNum * (max / #AtlasLootWishList[dataSource[dataID].ListType][dataSource[dataID].ListNum]));
end
--For stopping the subtable from changing if its a token table
@@ -500,6 +530,14 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
_G["AtlasLootItem_"..i].spellitemID = 0;
end
-- Sets the main page lable
if dataSource[dataID][tablenum] and dataSource[dataID][tablenum].Name then
AtlasLoot_BossName:SetText(dataSource[dataID][tablenum].Name);
else
AtlasLoot_BossName:SetText("This Is Empty");
return
end
local function getProperItemConditionals(item)
isValid = false;
toShow = true;
@@ -548,7 +586,7 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
end
-- Create the loottable
if (dataID == "SearchResult") or (dataID == "WishList") or dataSource[dataID][tablenum] then
if (dataID == "SearchResult") or (dataSource_backup == "AtlasLoot_CurrentWishList") or dataSource[dataID][tablenum] then
--Iterate through each item object and set its properties
for i = 1, 30, 1 do
--Check for a valid object (that it exists, and that it has a name
@@ -589,7 +627,7 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
AtlasLootItemsFrame.refreshFilter = {dataID, dataSource_backup, tablenum};
end
if dataID ~= "WishList" and dataID ~= "FilterList" and dataSource[dataID].Back ~= true then
if dataID ~= "FilterList" and dataSource[dataID].Back ~= true then
AtlasLootItemsFrame.refreshOri = {dataID, dataSource_backup, tablenum};
end
@@ -610,7 +648,9 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
extraFrame = _G["AtlasLootItem_"..dataSource[dataID][tablenum][i][1].."_Extra"];
--If there is no data on the texture an item should have, show a big red question mark
if dataSource[dataID][tablenum][i][3] == "?" then
if dataSource[dataID][tablenum][i][3] == "Blank" then
iconFrame:SetTexture(nil);
elseif dataSource[dataID][tablenum][i][3] == "?" then
iconFrame:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark");
elseif dataSource[dataID][tablenum][i][3] == "" then
iconFrame:SetTexture(GetItemIcon(IDfound));
@@ -629,14 +669,14 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
iconFrame:SetTexture("Interface\\Icons\\"..dataSource[dataID][tablenum][i][3]);
end
itemButton.itemTexture = dataSource[dataID][tablenum][i][3];
if iconFrame:GetTexture() == nil then
if iconFrame:GetTexture() == nil and dataSource[dataID][tablenum][i][3] ~= "Blank" then
iconFrame:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark");
end
itemButton.name = text;
itemButton.extra = extra;
--Highlight items in the wishlist
if IDfound ~= "" and IDfound ~= 0 and dataSource_backup ~= "AtlasLootWishList" and AtlasLootWishList["Options"][UnitName("player")]["Mark"] == true then
if IDfound ~= "" and IDfound ~= 0 and dataSource_backup ~= "AtlasLoot_CurrentWishList" and AtlasLootWishList["Options"][UnitName("player")]["Mark"] == true then
local xitemexistwish, itemwishicons = AtlasLoot_WishListCheck(IDfound, true)
if xitemexistwish then
text = itemwishicons.." "..text;
@@ -681,7 +721,7 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
itemButton.price = dataSource[dataID][tablenum][i][6] or nil;
itemButton.droprate = dataSource[dataID][tablenum][i][7] or nil;
if (dataID == "SearchResult" or dataSource_backup == "AtlasLootWishList") and dataSource[dataID][tablenum][i][8] then
if (dataID == "SearchResult" or dataSource_backup == "AtlasLoot_CurrentWishList") and dataSource[dataID][tablenum][i][8] then
itemButton.sourcePage = dataSource[dataID][tablenum][i][8];
elseif dataSource[dataID][tablenum][i][8] ~= nil and dataSource[dataID][tablenum][i][8]:match("=LT=") then
itemButton.sourcePage = string.sub(dataSource[dataID][tablenum][i][8], 5);
@@ -708,8 +748,11 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
AtlasLootItemsFrame.refreshFilter = {dataID, dataSource_backup, tablenum};
end
if dataSource_backup ~= "AtlasLootWishList" and dataID ~= "FilterList" and dataSource[dataID].Back ~= true and dataID ~= "EmptyTable" then
if dataID ~= "FilterList" and dataSource[dataID].Back ~= true and dataID ~= "EmptyTable" then
AtlasLootItemsFrame.refreshOri = {dataID, dataSource_backup, tablenum};
end
if dataSource_backup ~= "AtlasLoot_CurrentWishList" and dataID ~= "FilterList" and dataSource[dataID].Back ~= true and dataID ~= "EmptyTable" then
AtlasLoot.db.profile.LastBoss = {dataID, dataSource_backup, tablenum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE};
AtlasLoot.db.profile[ATLASLOOT_CURRENTTABLE] = {dataID, dataSource_backup, tablenum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE};
end
@@ -730,7 +773,7 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
end
-- Show the Filter Check-Box
if dataID ~= "SearchResult" and filterCheck(dataID) ~= true and dataSource_backup ~= "AtlasLoot_TokenData" and dataSource_backup ~= "AtlasLootWishList" then
if dataID ~= "SearchResult" and filterCheck(dataID) ~= true and dataSource_backup ~= "AtlasLoot_TokenData" and dataSource_backup ~= "AtlasLoot_CurrentWishList" then
AtlasLootFilterCheck:Show();
end
@@ -741,15 +784,17 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource_backup, tablenum)
_G["AtlasLootItemsFrame_Wishlist_Options"]:Hide();
_G["AtlasLootItemsFrame_Wishlist_Share"]:Hide();
_G["AtlasLootItemsFrame_Wishlist_Swap"]:Hide();
_G["AtlasLootItemsFrame_Wishlist_UnLock"]:Hide();
-- Show Wishlist buttons when a wishlist in showing
if dataSource_backup == "AtlasLootWishList" then
if dataSource_backup == "AtlasLoot_CurrentWishList" then
_G["AtlasLootItemsFrame_Wishlist_Options"]:Show();
_G["AtlasLootItemsFrame_Wishlist_Share"]:Show();
_G["AtlasLootItemsFrame_Wishlist_Swap"]:Show();
if dataID == "Shared" then
_G["AtlasLootItemsFrame_Wishlist_UnLock"]:Show();
if dataSource[dataID].ListType == "Shared" then
AtlasLootItemsFrame_Wishlist_Swap:SetText("Own");
elseif dataID == "Own" then
elseif dataSource[dataID].ListType == "Own" then
AtlasLootItemsFrame_Wishlist_Swap:SetText("Shared");
end
end
@@ -898,7 +943,11 @@ function AtlasLoot:ShowQuickLooks(button)
"tooltipTitle", AL["QuickLook"].." 1",
"tooltipText", AL["Assign this loot table\n to QuickLook"].." 1",
"func", function()
AtlasLootCharDB["QuickLooks"][1]={AtlasLootItemsFrame.refreshOri[1], AtlasLootItemsFrame.refreshOri[2], AtlasLootItemsFrame.refreshOri[3], ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G[AtlasLootItemsFrame.refreshOri[2]][AtlasLootItemsFrame.refreshOri[1]][AtlasLootItemsFrame.refreshOri[3]].Name};
if AtlasLootItemsFrame.refresh[2] == "AtlasLoot_CurrentWishList" then
AtlasLootCharDB["QuickLooks"][1]={AtlasLoot_CurrentWishList["Show"].ListType, "AtlasLootWishList", AtlasLoot_CurrentWishList["Show"].ListNum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G["AtlasLootWishList"][AtlasLoot_CurrentWishList["Show"].ListType][AtlasLoot_CurrentWishList["Show"].ListNum].Name};
else
AtlasLootCharDB["QuickLooks"][1]={AtlasLootItemsFrame.refreshOri[1], AtlasLootItemsFrame.refreshOri[2], AtlasLootItemsFrame.refreshOri[3], ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G[AtlasLootItemsFrame.refreshOri[2]][AtlasLootItemsFrame.refreshOri[1]][AtlasLootItemsFrame.refreshOri[3]].Name};
end
AtlasLoot:RefreshQuickLookButtons();
dewdrop:Close(1);
end
@@ -908,8 +957,12 @@ function AtlasLoot:ShowQuickLooks(button)
"tooltipTitle", AL["QuickLook"].." 2",
"tooltipText", AL["Assign this loot table\n to QuickLook"].." 2",
"func", function()
AtlasLootCharDB["QuickLooks"][2]={AtlasLootItemsFrame.refreshOri[1], AtlasLootItemsFrame.refreshOri[2], AtlasLootItemsFrame.refreshOri[3], ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G[AtlasLootItemsFrame.refreshOri[2]][AtlasLootItemsFrame.refreshOri[1]][AtlasLootItemsFrame.refreshOri[3]].Name};
AtlasLoot:RefreshQuickLookButtons();
if AtlasLootItemsFrame.refresh[2] == "AtlasLoot_CurrentWishList" then
AtlasLootCharDB["QuickLooks"][2]={AtlasLoot_CurrentWishList["Show"].ListType, "AtlasLootWishList", AtlasLoot_CurrentWishList["Show"].ListNum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G["AtlasLootWishList"][AtlasLoot_CurrentWishList["Show"].ListType][AtlasLoot_CurrentWishList["Show"].ListNum].Name};
else
AtlasLootCharDB["QuickLooks"][2]={AtlasLootItemsFrame.refreshOri[1], AtlasLootItemsFrame.refreshOri[2], AtlasLootItemsFrame.refreshOri[3], ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G[AtlasLootItemsFrame.refreshOri[2]][AtlasLootItemsFrame.refreshOri[1]][AtlasLootItemsFrame.refreshOri[3]].Name};
end
AtlasLoot:RefreshQuickLookButtons();
dewdrop:Close(1);
end
);
@@ -918,8 +971,12 @@ function AtlasLoot:ShowQuickLooks(button)
"tooltipTitle", AL["QuickLook"].." 3",
"tooltipText", AL["Assign this loot table\n to QuickLook"].." 3",
"func", function()
AtlasLootCharDB["QuickLooks"][3]={AtlasLootItemsFrame.refreshOri[1], AtlasLootItemsFrame.refreshOri[2], AtlasLootItemsFrame.refreshOri[3], ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G[AtlasLootItemsFrame.refreshOri[2]][AtlasLootItemsFrame.refreshOri[1]][AtlasLootItemsFrame.refreshOri[3]].Name};
AtlasLoot:RefreshQuickLookButtons();
if AtlasLootItemsFrame.refresh[2] == "AtlasLoot_CurrentWishList" then
AtlasLootCharDB["QuickLooks"][3]={AtlasLoot_CurrentWishList["Show"].ListType, "AtlasLootWishList", AtlasLoot_CurrentWishList["Show"].ListNum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G["AtlasLootWishList"][AtlasLoot_CurrentWishList["Show"].ListType][AtlasLoot_CurrentWishList["Show"].ListNum].Name};
else
AtlasLootCharDB["QuickLooks"][3]={AtlasLootItemsFrame.refreshOri[1], AtlasLootItemsFrame.refreshOri[2], AtlasLootItemsFrame.refreshOri[3], ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G[AtlasLootItemsFrame.refreshOri[2]][AtlasLootItemsFrame.refreshOri[1]][AtlasLootItemsFrame.refreshOri[3]].Name};
end
AtlasLoot:RefreshQuickLookButtons();
dewdrop:Close(1);
end
);
@@ -928,8 +985,12 @@ function AtlasLoot:ShowQuickLooks(button)
"tooltipTitle", AL["QuickLook"].." 4",
"tooltipText", AL["Assign this loot table\n to QuickLook"].." 4",
"func", function()
AtlasLootCharDB["QuickLooks"][4]={AtlasLootItemsFrame.refreshOri[1], AtlasLootItemsFrame.refreshOri[2], AtlasLootItemsFrame.refreshOri[3], ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G[AtlasLootItemsFrame.refreshOri[2]][AtlasLootItemsFrame.refreshOri[1]][AtlasLootItemsFrame.refreshOri[3]].Name};
AtlasLoot:RefreshQuickLookButtons();
if AtlasLootItemsFrame.refresh[2] == "AtlasLoot_CurrentWishList" then
AtlasLootCharDB["QuickLooks"][4]={AtlasLoot_CurrentWishList["Show"].ListType, "AtlasLootWishList", AtlasLoot_CurrentWishList["Show"].ListNum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G["AtlasLootWishList"][AtlasLoot_CurrentWishList["Show"].ListType][AtlasLoot_CurrentWishList["Show"].ListNum].Name};
else
AtlasLootCharDB["QuickLooks"][4]={AtlasLootItemsFrame.refreshOri[1], AtlasLootItemsFrame.refreshOri[2], AtlasLootItemsFrame.refreshOri[3], ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE, _G[AtlasLootItemsFrame.refreshOri[2]][AtlasLootItemsFrame.refreshOri[1]][AtlasLootItemsFrame.refreshOri[3]].Name};
end
AtlasLoot:RefreshQuickLookButtons();
dewdrop:Close(1);
end
);