From 40dd46a2629a830d9987ec365677824e67415c45 Mon Sep 17 00:00:00 2001 From: Anch Date: Wed, 21 Sep 2022 01:38:46 +1200 Subject: [PATCH] wishlist reset -fixed wishlist reset --- AtlasLoot/Core/AtlasLoot.lua | 37 ++++-------------------------- AtlasLoot/Core/WishList.lua | 29 ++++++++++++++--------- AtlasLoot/Locales/constants.en.lua | 1 + 3 files changed, 23 insertions(+), 44 deletions(-) diff --git a/AtlasLoot/Core/AtlasLoot.lua b/AtlasLoot/Core/AtlasLoot.lua index e9247b8..5d8dfa8 100644 --- a/AtlasLoot/Core/AtlasLoot.lua +++ b/AtlasLoot/Core/AtlasLoot.lua @@ -130,7 +130,6 @@ function AtlasLoot:OnEnable() AtlasLoot.db = LibStub("AceDB-3.0"):New("AtlasLootDB"); AtlasLoot.db:RegisterDefaults(AtlasLootDBDefaults); if not AtlasLootCharDB then AtlasLootCharDB = {} end - if not AtlasLootCharDB["WishList"] then AtlasLootCharDB["WishList"] = {} end if not AtlasLootCharDB["QuickLooks"] then AtlasLootCharDB["QuickLooks"] = {} end if not AtlasLootCharDB["SearchResult"] then AtlasLootCharDB["SearchResult"] = {} end if AtlasLoot_Data then @@ -175,36 +174,6 @@ function AtlasLoot:OnEnable() AtlasLootItemsFrame:Hide(); - --Check and migrate old WishList entry format to the newer one - if(((AtlasLootCharDB.AtlasLootVersion == nil) or (tonumber(AtlasLootCharDB.AtlasLootVersion) < 40301)) and AtlasLootCharDB and AtlasLootCharDB["WishList"] and #AtlasLootCharDB["WishList"]~=0) then - --Check if we really need to do a migration since it will load all modules - --We also create a helper table here which store IDs that need to search for - local idsToSearch = {}; - for i = 1, #AtlasLootCharDB["WishList"] do - if (AtlasLootCharDB["WishList"][i][1] > 0 and not AtlasLootCharDB["WishList"][i][5]) then - tinsert(idsToSearch, i, AtlasLootCharDB["WishList"][i][1]); - end - end - if #idsToSearch > 0 then - --Let's do this - AtlasLoot:LoadAllModules(); - for _, dataSource in ipairs(AtlasLoot_SearchTables) do - if AtlasLoot_Data[dataSource] then - for dataID, lootTable in pairs(AtlasLoot_Data[dataSource]) do - for _, entry in ipairs(lootTable) do - for k, v in pairs(idsToSearch) do - if(entry[1] == v)then - AtlasLootCharDB["WishList"][k][5] = dataID.."|"..dataSource; - break; - end - end - end - end - end - end - end - AtlasLootCharDB.AtlasLootVersion = VERSION_MAJOR..VERSION_MINOR..VERSION_BOSSES; - end if((AtlasLootCharDB.AtlasLootVersion == nil) or (tonumber(AtlasLootCharDB.AtlasLootVersion) < 40301)) then AtlasLootCharDB.AtlasLootVersion = VERSION_MAJOR..VERSION_MINOR..VERSION_BOSSES; AtlasLootOptions_Init(); @@ -277,7 +246,8 @@ function AtlasLoot_Reset(data) AtlasLootCharDB["QuickLooks"] = {}; AtlasLoot:RefreshQuickLookButtons(); elseif data == "wishlist" then - AtlasLootCharDB["WishList"] = {}; + AtlasLootWishList = {}; + AtlasLoot:WishlistSetup(); AtlasLootCharDB["SearchResult"] = {}; AtlasLootCharDB.LastSearchedText = ""; elseif data == "all" then @@ -292,9 +262,10 @@ function AtlasLoot_Reset(data) AtlasLoot_UpdateLootBrowserScale(); AtlasLootCharDB["QuickLooks"] = {}; AtlasLoot:RefreshQuickLookButtons(); - AtlasLootCharDB["WishList"] = {}; AtlasLootCharDB["SearchResult"] = {}; AtlasLootCharDB.LastSearchedText = ""; + AtlasLootWishList = {}; + AtlasLoot:WishlistSetup(); end DEFAULT_CHAT_FRAME:AddMessage(BLUE..AL["AtlasLoot"]..": "..RED..AL["Reset complete!"]); end diff --git a/AtlasLoot/Core/WishList.lua b/AtlasLoot/Core/WishList.lua index f6da4a6..1a33977 100644 --- a/AtlasLoot/Core/WishList.lua +++ b/AtlasLoot/Core/WishList.lua @@ -141,7 +141,11 @@ function AtlasLoot:WishListButton(xitemID, xitemTexture, xitemName, xlootPage, x if buttonclick == "RightButton" then AtlasLoot_ShowWishListDropDown(xitemID, xitemTexture, xitemName, xlootPage, xsourcePage, button, show, "Enable") elseif buttonclick == "LeftButton" then - AtlasLoot_WishListAddDropClick("addOwn", AtlasLootWishList["Options"][playerName]["DefaultWishList"][3] or 1, "", show) + if AtlasLootWishList["Own"][1] then + AtlasLoot_WishListAddDropClick("addOwn", AtlasLootWishList["Options"][playerName]["DefaultWishList"][3] or 1, "", show) + else + DEFAULT_CHAT_FRAME:AddMessage(RED..AL["AtlasLoot"]..": "..AL["Please Create a Wishlist First."]); + end end end @@ -486,18 +490,26 @@ local function AddTexture(par, num) xpos = xpos + 20 end end +function AtlasLoot:WishlistSetup() + if not AtlasLootWishList["Own"] then AtlasLootWishList["Own"] = {Name = "Wishlists"} end + if not AtlasLootWishList["Shared"] then AtlasLootWishList["Shared"] = {Name = "Shared Wishlists"} end + if not AtlasLootWishList["Options"] then AtlasLootWishList["Options"] = {} end + if not AtlasLootWishList["Options"][playerName] then AtlasLootWishList["Options"][playerName] = {} end + if AtlasLootWishList["Options"][playerName]["Mark"] ~= true and AtlasLootWishList["Options"][playerName]["Mark"] ~= false then AtlasLootWishList["Options"][playerName]["Mark"] = true end + if not AtlasLootWishList["Options"][playerName]["markInTable"] then AtlasLootWishList["Options"][playerName]["markInTable"] = "own" end + if AtlasLootWishList["Options"][playerName]["AllowShareWishlist"] ~= true and AtlasLootWishList["Options"][playerName]["AllowShareWishlist"] ~= false then AtlasLootWishList["Options"][playerName]["AllowShareWishlist"] = true end + if AtlasLootWishList["Options"][playerName]["AllowShareWishlistInCombat"] ~= true and AtlasLootWishList["Options"][playerName]["AllowShareWishlistInCombat"] ~= false then AtlasLootWishList["Options"][playerName]["AllowShareWishlistInCombat"] = true end + if AtlasLootWishList["Options"][playerName]["UseDefaultWishlist"] ~= true and AtlasLootWishList["Options"][playerName]["UseDefaultWishlist"] ~= false then AtlasLootWishList["Options"][playerName]["UseDefaultWishlist"] = false end + if AtlasLootWishList["Options"][playerName]["DefaultWishList"] ~= true then AtlasLootWishList["Options"][playerName]["DefaultWishList"] = {"Own", "AtlasLootWishList", 1} end +end --[[ AtlasLoot_CreateWishlistOptions() Create the Options for the Wishlists(called on variables loadet) ]] function AtlasLoot_CreateWishlistOptions() if OptionsLoadet then return end - if not AtlasLootWishList["Own"] then AtlasLootWishList["Own"] = {} end - if not AtlasLootWishList["Shared"] then AtlasLootWishList["Shared"] = {} end - if not AtlasLootWishList["Options"] then AtlasLootWishList["Options"] = {} end - if not AtlasLootWishList["Options"][playerName] then AtlasLootWishList["Options"][playerName] = {} end - + AtlasLoot:WishlistSetup(); -- Add wishlistframe -- local WishListAddFrame = CreateFrame("FRAME","AtlasLootWishList_AddFrame",UIParent) WishListAddFrame:Hide() @@ -624,11 +636,6 @@ function AtlasLoot_CreateWishlistOptions() -- Add wishlistframe -- local framewidht = InterfaceOptionsFramePanelContainer:GetWidth() - if AtlasLootWishList["Options"][playerName]["Mark"] ~= true and AtlasLootWishList["Options"][playerName]["Mark"] ~= false then AtlasLootWishList["Options"][playerName]["Mark"] = true end - if not AtlasLootWishList["Options"][playerName]["markInTable"] then AtlasLootWishList["Options"][playerName]["markInTable"] = "own" end - if AtlasLootWishList["Options"][playerName]["AllowShareWishlist"] ~= true and AtlasLootWishList["Options"][playerName]["AllowShareWishlist"] ~= false then AtlasLootWishList["Options"][playerName]["AllowShareWishlist"] = true end - if AtlasLootWishList["Options"][playerName]["AllowShareWishlistInCombat"] ~= true and AtlasLootWishList["Options"][playerName]["AllowShareWishlistInCombat"] ~= false then AtlasLootWishList["Options"][playerName]["AllowShareWishlistInCombat"] = true end - if AtlasLootWishList["Options"][playerName]["UseDefaultWishlist"] ~= true and AtlasLootWishList["Options"][playerName]["UseDefaultWishlist"] ~= false then AtlasLootWishList["Options"][playerName]["UseDefaultWishlist"] = false end local WishlistOptionsFrame = CreateFrame("FRAME", nil) WishlistOptionsFrame.name = AL["Wishlist"] diff --git a/AtlasLoot/Locales/constants.en.lua b/AtlasLoot/Locales/constants.en.lua index da8981b..6fb59dd 100644 --- a/AtlasLoot/Locales/constants.en.lua +++ b/AtlasLoot/Locales/constants.en.lua @@ -323,6 +323,7 @@ if AL then AL["You can't send Wishlists to yourself"] = true; AL["Please set a default Wishlist."] = true; AL["Set as default Wishlist"] = true; + AL["Please Create a Wishlist First."] = true; -- Misc Inventory related words AL["Enchant"] = true;