From 7709b8a208218fce2f18220357103df5939f2ba0 Mon Sep 17 00:00:00 2001 From: Anch Date: Wed, 17 Aug 2022 17:03:06 +1200 Subject: [PATCH] made it so the dataSource is stored as a string --- AtlasLoot/Core/AtlasLoot.lua | 41 ++++++++++--------- AtlasLoot/Core/Atlasloot_Maps.lua | 4 +- AtlasLoot/Core/LootButtons.lua | 6 +-- AtlasLoot/Core/Search.lua | 4 +- AtlasLoot/Core/SearchAdvanced.lua | 2 +- AtlasLoot/Core/WishList.lua | 6 +-- .../DefaultFrame/AtlaslootDefaultFrame.lua | 10 ++--- .../AtlaslootDefaultFrameCreate.lua | 16 ++++---- 8 files changed, 45 insertions(+), 44 deletions(-) diff --git a/AtlasLoot/Core/AtlasLoot.lua b/AtlasLoot/Core/AtlasLoot.lua index 4935c85..0f9751c 100644 --- a/AtlasLoot/Core/AtlasLoot.lua +++ b/AtlasLoot/Core/AtlasLoot.lua @@ -68,6 +68,7 @@ SearchPrevData = {"", "", ""}; AtlasLootCharDB = {}; AtlasLoot_TokenData = {}; + local AtlasLootDBDefaults = { profile = { SavedTooltips = {}, @@ -100,15 +101,6 @@ local AtlasLootDBDefaults = { } } -AtlasLoot_MenuList = { - "PVPSET", - "PVP70RepSET", - "ARENASET", - "ARENA2SET", - "ARENA3SET", - "ARENA4SET", -}; - -- Popup Box for first time users StaticPopupDialogs["ATLASLOOT_SETUP"] = { text = AL["Welcome to Atlasloot Enhanced. Please take a moment to set your preferences."], @@ -435,6 +427,7 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource, tablenum) local spellName, spellIcon; SearchPrevData = {dataID, dataSource, tablenum}; + --If the loot table name has not been passed, throw up a debugging statement if dataID == nil then @@ -459,8 +452,16 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource, tablenum) -- Hide the map header lable Atlasloot_HeaderLabel:Hide(); - if dataID == "SearchResult" then + local dataSource_backup = dataSource; + + if dataID == "SearchResult" or dataSource == " AtlasLootCharDB" then dataSource = AtlasLootCharDB; + elseif dataSource == "AtlasLoot_TokenData" then + dataSource = AtlasLoot_TokenData; + elseif dataSource == "AtlasLootWishList" then + dataSource = AtlasLootWishList; + else + dataSource = AtlasLoot_Data; end -- Check to see if Atlas is loaded and the table has a map @@ -501,7 +502,7 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource, tablenum) --For stopping the subtable from changing if its a token table if dataSource[dataID].NoSubt == nil and dataID ~= "FilterList" then AtlasLootDefaultFrame_SubMenuText:SetText(dataSource[dataID].Name); - AtlasLoot:SubTableScrollFrameUpdate(dataID, dataSource, tablenum); + AtlasLoot:SubTableScrollFrameUpdate(dataID, dataSource_backup, tablenum); end --Hide UI objects so that only needed ones are shown @@ -684,7 +685,7 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource, tablenum) itemButton.tablenum = tablenum; itemButton.dataID = dataID; - itemButton.dataSource = dataSource; + itemButton.dataSource = dataSource_backup; itemButton.desc = dataSource[dataID][tablenum][i][5] or nil; itemButton.price = dataSource[dataID][tablenum][i][6] or nil; itemButton.droprate = dataSource[dataID][tablenum][i][7] or nil; @@ -710,12 +711,12 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource, tablenum) end end - AtlasLootItemsFrame.refresh = {dataID, dataSource, tablenum}; + AtlasLootItemsFrame.refresh = {dataID, dataSource_backup, tablenum}; if dataID ~= "WishList" and dataID ~= "FilterList" and dataSource[dataID].Back ~= true and dataID ~= "EmptyTable" then - AtlasLootItemsFrame.refreshOri = {dataID, dataSource, tablenum}; - AtlasLoot.db.profile.LastBoss = {dataID, dataSource, tablenum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE}; - AtlasLoot.db.profile[ATLASLOOT_CURRENTTABLE] = {dataID, dataSource, tablenum, ATLASLOOT_LASTMODULE, ATLASLOOT_CURRENTTABLE}; + AtlasLootItemsFrame.refreshOri = {dataID, dataSource_backup, tablenum}; + 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 --This is a valid QuickLook, so show the UI objects @@ -742,12 +743,12 @@ function AtlasLoot:ShowItemsFrame(dataID, dataSource, tablenum) _G["AtlasLootItemsFrame_BACK"]:Hide(); _G["AtlasLootItemsFrame_NEXT"]:Hide(); _G["AtlasLootItemsFrame_PREV"]:Hide(); - local tablebase = {dataID, dataSource}; + local tablebase = {dataID, dataSource_backup}; if dataID == "FilterList" then tablebase = {AtlasLootItemsFrame.refreshOri[1],AtlasLootItemsFrame.refreshOri[2]}; tablenum = AtlasLootItemsFrame.refreshOri[3]; end - if tablenum ~= #tablebase[2][tablebase[1]] then + if tablenum ~= #dataSource[dataID] then _G["AtlasLootItemsFrame_NEXT"]:Show(); _G["AtlasLootItemsFrame_NEXT"].tablenum = tablenum + 1; _G["AtlasLootItemsFrame_NEXT"].tablebase = tablebase; @@ -778,9 +779,9 @@ Called when <-, -> are pressed and calls up the appropriate loot page ]] function AtlasLoot:NavButton_OnClick(self) local tablenum, dataID, dataSource = self.tablenum, self.tablebase[1], self.tablebase[2]; - if #dataSource[dataID] > 26 then + if #_G[dataSource][dataID] > 26 then local min, max = AtlasLootDefaultFrameSubTableScrollScrollBar:GetMinMaxValues(); - AtlasLootDefaultFrameSubTableScrollScrollBar:SetValue(tablenum * (max / #dataSource[dataID])); + AtlasLootDefaultFrameSubTableScrollScrollBar:SetValue(tablenum * (max / #_G[dataSource][dataID])); end AtlasLoot:ShowItemsFrame(dataID, dataSource, tablenum); end diff --git a/AtlasLoot/Core/Atlasloot_Maps.lua b/AtlasLoot/Core/Atlasloot_Maps.lua index 53a81f5..6c054ce 100644 --- a/AtlasLoot/Core/Atlasloot_Maps.lua +++ b/AtlasLoot/Core/Atlasloot_Maps.lua @@ -55,7 +55,7 @@ function AtlasLoot:MapOnShow() Atlasloot_HeaderLabel:Show(); AtlasLoot:ScrollFrameUpdate(true); AtlasLootDefaultFrameScroll:Hide(); - AtlasLoot:SubTableScrollFrameUpdate(ATLASLOOT_CURRENT_MAP, AtlasLoot_MapData); + AtlasLoot:SubTableScrollFrameUpdate(ATLASLOOT_CURRENT_MAP, "AtlasLoot_MapData"); end end end @@ -74,7 +74,7 @@ end function AtlasLoot:MapMenuClick(mapID) if AtlasLootDefaultFrame_Map:IsVisible() then - AtlasLoot:SubTableScrollFrameUpdate(mapID, AtlasLoot_MapData); + AtlasLoot:SubTableScrollFrameUpdate(mapID, "AtlasLoot_MapData"); end AtlasLoot:MapSelect(mapID); AtlasLootDefaultFrame_MapSelectButton:SetText(AtlasLoot_MapData[mapID].ZoneName[1]); diff --git a/AtlasLoot/Core/LootButtons.lua b/AtlasLoot/Core/LootButtons.lua index 1014822..e3dbb43 100644 --- a/AtlasLoot/Core/LootButtons.lua +++ b/AtlasLoot/Core/LootButtons.lua @@ -255,7 +255,7 @@ function AtlasLootItem_OnClick(self ,arg1) elseif((AtlasLootItemsFrame.refresh[1] == "SearchResult" or AtlasLootItemsFrame.refresh[1] == "WishList") and self.sourcePage) then local dataID, dataSource, dataPage = strsplit("|", self.sourcePage); if(dataID and dataSource) then - AtlasLoot:ShowItemsFrame(dataID, AtlasLoot_Data, tonumber(dataPage)); + AtlasLoot:ShowItemsFrame(dataID, "AtlasLoot_Data", tonumber(dataPage)); end elseif (arg1=="LeftButton") and self.sourcePage then --Create token table if there isnt one @@ -263,7 +263,7 @@ function AtlasLootItem_OnClick(self ,arg1) AtlasLoot:CreateToken(self.sourcePage) end --Show token table - AtlasLoot:ShowItemsFrame(self.sourcePage, AtlasLoot_TokenData, 1); + AtlasLoot:ShowItemsFrame(self.sourcePage, "AtlasLoot_TokenData", 1); end else if IsShiftKeyDown() then @@ -288,7 +288,7 @@ function AtlasLootItem_OnClick(self ,arg1) elseif((AtlasLootItemsFrame.refresh[1] == "SearchResult" or AtlasLootItemsFrame.refresh[1] == "WishList") and self.sourcePage) then local dataID, dataSource, dataPage = strsplit("|", self.sourcePage); if(dataID and dataSource) then - AtlasLoot:ShowItemsFrame(dataID, AtlasLoot_Data, tonumber(dataPage)); + AtlasLoot:ShowItemsFrame(dataID, "AtlasLoot_Data", tonumber(dataPage)); end end end diff --git a/AtlasLoot/Core/Search.lua b/AtlasLoot/Core/Search.lua index f9ab73f..65c5c35 100644 --- a/AtlasLoot/Core/Search.lua +++ b/AtlasLoot/Core/Search.lua @@ -704,7 +704,7 @@ local function DoSearch(searchText) end function AtlasLoot:ShowSearchResult() - AtlasLoot:ShowItemsFrame("SearchResult", AtlasLootCharDB, 1); + AtlasLoot:ShowItemsFrame("SearchResult", "AtlasLootCharDB", 1); end function AtlasLoot:Search(Text) @@ -755,7 +755,7 @@ function AtlasLoot:Search(Text) end DEFAULT_CHAT_FRAME:AddMessage(RED .. AL["AtlasLoot"] .. ": " .. WHITE .. AL["No match found for"] .. " \"" .. Text .. "\"." .. itemFilterErrorMessage); else - AtlasLoot:ShowItemsFrame("SearchResult", AtlasLootCharDB, 1); + AtlasLoot:ShowItemsFrame("SearchResult", "AtlasLootCharDB", 1); end end diff --git a/AtlasLoot/Core/SearchAdvanced.lua b/AtlasLoot/Core/SearchAdvanced.lua index a50d9c4..57d11c1 100644 --- a/AtlasLoot/Core/SearchAdvanced.lua +++ b/AtlasLoot/Core/SearchAdvanced.lua @@ -229,7 +229,7 @@ function AtlasLoot_AdvancedSearchShow() ATLASLOOT_CURRENTTYPE = "Search"; AtlasLoot:ScrollFrameUpdate(); - AtlasLoot:SubTableScrollFrameUpdate("EmptyTable",AtlasLoot_Data); + AtlasLoot:SubTableScrollFrameUpdate("EmptyTable","AtlasLoot_Data"); end function AtlasLoot_AdvancedSearchClose() diff --git a/AtlasLoot/Core/WishList.lua b/AtlasLoot/Core/WishList.lua index d520ce2..d6106ad 100644 --- a/AtlasLoot/Core/WishList.lua +++ b/AtlasLoot/Core/WishList.lua @@ -68,21 +68,21 @@ function AtlasLoot_ShowWishList() AtlasLootWishList["WishList"].Name = "Wish List"; AtlasLootWishList["WishList"].Back = true; AtlasLootWishList["WishList"][1].Name = AtlasLootWishList["Own"][playerName][lastWishListarg2]["info"][1]; - AtlasLoot:ShowItemsFrame("WishList", AtlasLootWishList, 1); + AtlasLoot:ShowItemsFrame("WishList", "AtlasLootWishList", 1); elseif lastWishListtyp == "addOther" then AtlasLootWishList["WishList"] = AtlasLootWishList["Own"][lastWishListarg2]; sort(); AtlasLootWishList["WishList"].Name = "Wish List"; AtlasLootWishList["WishList"].Back = true; AtlasLootWishList["WishList"][1].Name = AtlasLootWishList["Own"][lastWishListarg2][lastWishListarg3]["info"][1]; - AtlasLoot:ShowItemsFrame("WishList", AtlasLootWishList, 1); + AtlasLoot:ShowItemsFrame("WishList", "AtlasLootWishList", 1); elseif lastWishListtyp == "addShared" then AtlasLootWishList["WishList"] = AtlasLootWishList["Shared"][lastWishListarg2]; sort(); AtlasLootWishList["WishList"].Name = "Wish List"; AtlasLootWishList["WishList"].Back = true; AtlasLootWishList["WishList"][1].Name = AtlasLootWishList["Shared"][lastWishListarg2][lastWishListarg3]["info"][1]; - AtlasLoot:ShowItemsFrame("WishList", AtlasLootWishList, 1); + AtlasLoot:ShowItemsFrame("WishList", "AtlasLootWishList", 1); end end diff --git a/AtlasLoot/DefaultFrame/AtlaslootDefaultFrame.lua b/AtlasLoot/DefaultFrame/AtlaslootDefaultFrame.lua index 906433c..ae23bf6 100644 --- a/AtlasLoot/DefaultFrame/AtlaslootDefaultFrame.lua +++ b/AtlasLoot/DefaultFrame/AtlaslootDefaultFrame.lua @@ -44,11 +44,11 @@ function AtlasLootDefaultFrame_OnShow() ATLASLOOT_CURRENTTABLE = lastboss[5]; ATLASLOOT_LASTMODULE = lastboss[4]; AtlasLoot:IsLootTableAvailable(lastboss[4]); - AtlasLoot:ShowItemsFrame(lastboss[1], AtlasLoot_Data, lastboss[3]); + AtlasLoot:ShowItemsFrame(lastboss[1], "AtlasLoot_Data", lastboss[3]); AtlasLoot_DewdropSubMenu:Unregister(AtlasLootDefaultFrame_SubMenu); AtlasLoot:DewdropSubMenuRegister(AtlasLoot_SubMenus[lastboss[5]]); else - AtlasLoot:ShowItemsFrame("EmptyTable", AtlasLoot_Data, 1); + AtlasLoot:ShowItemsFrame("EmptyTable", "AtlasLoot_Data", 1); end end @@ -84,7 +84,7 @@ function AtlasLoot:DewDropClick(tablename, text, tablenum) if lasttable then AtlasLoot:ShowItemsFrame(lasttable[1], lasttable[2], lasttable[3]); else - AtlasLoot:ShowItemsFrame(AtlasLoot_SubMenus[tablename][tablenum][2], AtlasLoot_Data, tablenum); + AtlasLoot:ShowItemsFrame(AtlasLoot_SubMenus[tablename][tablenum][2], "AtlasLoot_Data", tablenum); end AtlasLoot_Dewdrop:Close(1); end @@ -99,7 +99,7 @@ function AtlasLoot:DewDropSubMenuClick(tablename) --Show the select loot table local tablenum = AtlasLoot_Data[tablename].Loadfirst or 1; --Show the table that has been selected - AtlasLoot:ShowItemsFrame(tablename, AtlasLoot_Data, tablenum); + AtlasLoot:ShowItemsFrame(tablename, "AtlasLoot_Data", tablenum); AtlasLoot_DewdropSubMenu:Close(1); end @@ -124,7 +124,7 @@ function AtlasLoot:DewdropExpansionMenuClick(expansion, name) AtlasLoot:ShowItemsFrame(lasttable[1], lasttable[2], lasttable[3]); else local tablenum = AtlasLoot_Data[tablename].Loadfirst or 1; - AtlasLoot:ShowItemsFrame(tablename, AtlasLoot_Data, tablenum); + AtlasLoot:ShowItemsFrame(tablename, "AtlasLoot_Data", tablenum); end end diff --git a/AtlasLoot/DefaultFrame/AtlaslootDefaultFrameCreate.lua b/AtlasLoot/DefaultFrame/AtlaslootDefaultFrameCreate.lua index b9b0b02..4584a87 100644 --- a/AtlasLoot/DefaultFrame/AtlaslootDefaultFrameCreate.lua +++ b/AtlasLoot/DefaultFrame/AtlaslootDefaultFrameCreate.lua @@ -490,7 +490,7 @@ local subtableFrame = CreateFrame("Frame", "Atlasloot_SubTableFrame", AtlasLootD }); function AtlasLoot:SubTableScrollFrameUpdate(tablename, dataSource, tablenum) - local maxValue = #dataSource[tablename]; + local maxValue = #_G[dataSource][tablename]; subtableFrame.tablename = tablename; subtableFrame.dataSource = dataSource; subtableFrame.tablenum = tablenum; @@ -500,25 +500,25 @@ function AtlasLoot:SubTableScrollFrameUpdate(tablename, dataSource, tablenum) local value = i + offset subtableFrame.rows[i]:SetChecked(false); subtableFrame.rows[i]:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD"); - if value <= maxValue and dataSource[tablename][value] and tablename ~= "SearchMENU" then + if value <= maxValue and _G[dataSource][tablename][value] and tablename ~= "SearchMENU" then local row = subtableFrame.rows[i] row.dataSource = dataSource; row.tablename = tablename; row.tablenum = value; - if dataSource == AtlasLoot_MapData then - row.Text:SetText(dataSource[tablename][value][1]); + if dataSource == "AtlasLoot_MapData" then + row.Text:SetText(_G[dataSource][tablename][value][1]); row:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_TOP"); - GameTooltip:SetText(dataSource[tablename][value][1]); + GameTooltip:SetText(_G[dataSource][tablename][value][1]); GameTooltip:Show(); end) row:SetScript("OnLeave", function() GameTooltip:Hide() end) else - row.Text:SetText("|cffFFd200"..dataSource[tablename][value].Name); + row.Text:SetText("|cffFFd200".._G[dataSource][tablename][value].Name); row:SetScript("OnEnter", function(self) GameTooltip:Hide(); end) - if tablenum == value and dataSource ~= AtlasLoot_MapData then + if tablenum == value and dataSource ~= "AtlasLoot_MapData" then row:SetChecked(true); end end @@ -549,7 +549,7 @@ local rows2 = setmetatable({}, { __index = function(t, i) row.Text:SetPoint("LEFT",row); row.Text:SetJustifyH("LEFT"); row:SetScript("OnClick", function() - if row.dataSource ~= AtlasLoot_MapData then + if row.dataSource ~= "AtlasLoot_MapData" then AtlasLoot:ShowItemsFrame(row.tablename, row.dataSource, row.tablenum); else row:SetChecked(false);