From a573920375cd3389db11f2df53784d4474676451 Mon Sep 17 00:00:00 2001 From: Xruptor Date: Sun, 21 Aug 2016 10:22:48 -0400 Subject: [PATCH] Profiles Window Updated -I updated the profiles window and now you can delete whatever profile for BagSync you want. No reload is required either. -Fixed the interaction between the FixDB() and Profiles window. -Added BlackList filtering to the FixDB() -Fixed several issues where the DropDown menu wasn't populating or displaying properly. Thanks Blizzard :P -Fixed an issue where the BagSync config wouldn't show up the first time you typed /bgs config. Had to call it twice due to a Blizzard bug. -Updated LibSimpleOptions-1.0 to use the Blizzard built in refresh function for panels. It was missing for some reason. --- BagSync.lua | 14 +++--- BagSync_Config.lua | 7 ++- BagSync_Profiles.lua | 53 +++++++++++++------- libs/LibSimpleOptions-1.0/LibSimpleOptions-1.0.lua | 4 ++ 4 files changed, 49 insertions(+), 29 deletions(-) diff --git a/BagSync.lua b/BagSync.lua index 70c8590..c643816 100644 --- a/BagSync.lua +++ b/BagSync.lua @@ -186,6 +186,7 @@ function BagSync:FixDB_Data(onlyChkGuild) --Removes obsolete guild information --Removes obsolete characters from tokens db --Removes obsolete profession information + --removes obsolete blacklist information --Will only check guild related information if the paramater is passed as true --Adds realm name to characters profiles if missing, v8.6 @@ -289,6 +290,12 @@ function BagSync:FixDB_Data(onlyChkGuild) if string.find(realm, " ") then --get rid of old realm names with whitespaces, we aren't going to use it anymore BagSyncBLACKLIST_DB[realm] = nil + else + --realm + if not storeUsers[realm] then + --if it's not a realm that ANY users are on then delete it + BagSyncBLACKLIST_DB[realm] = nil + end end end @@ -1434,6 +1441,7 @@ function BagSync:PLAYER_LOGIN() return true elseif c and c:lower() == L["config"] then InterfaceOptionsFrame_OpenToCategory("BagSync") + InterfaceOptionsFrame_OpenToCategory("BagSync") --calling it twice because sometimes it doesn't always work, it's a bug with blizzard return true elseif c and c:lower() ~= "" then --do an item search @@ -1461,12 +1469,6 @@ function BagSync:PLAYER_LOGIN() DEFAULT_CHAT_FRAME:AddMessage("|cFF99CC33BagSync|r [v|cFFDF2B2B"..ver.."|r] /bgs, /bagsync") - --we deleted someone with the Profile Window, display name of user deleted - if BagSyncOpt.delName then - print("|cFFFF0000BagSync: "..L["Profiles"].." "..L["Delete"].." ["..BagSyncOpt.delName.."]!|r") - BagSyncOpt.delName = nil - end - self:UnregisterEvent("PLAYER_LOGIN") self.PLAYER_LOGIN = nil diff --git a/BagSync_Config.lua b/BagSync_Config.lua index 412850d..d35c525 100644 --- a/BagSync_Config.lua +++ b/BagSync_Config.lua @@ -2,13 +2,12 @@ local L = BAGSYNC_L local currentPlayer = UnitName("player") local currentRealm = select(2, UnitFullName("player")) local ver = GetAddOnMetadata("BagSync","Version") or 0 - + local SO = LibStub("LibSimpleOptions-1.0") - +local panel = SO.AddOptionsPanel("BagSync", function() end) + function BSOpt_Startup() - local panel = SO.AddOptionsPanel("BagSync", function() end) - local title, subText = panel:MakeTitleTextAndSubText("|cFF99CC33BagSync|r [|cFFDF2B2B"..ver.."|r]", "These options allow you to customize the BagSync displays data.") --toggle BagSync tooltips diff --git a/BagSync_Profiles.lua b/BagSync_Profiles.lua index 8a92d9f..665043d 100644 --- a/BagSync_Profiles.lua +++ b/BagSync_Profiles.lua @@ -20,23 +20,28 @@ end bgsProfilesDD.initialize = function(self, level) if not BagSync or not BagSyncDB then return end - if not BagSyncDB[currentRealm] then return end - + local tmp = {} - --freaking LUA table.sort is terrible, you can't sort non-numeric keys.. - for k, v in pairs(BagSyncDB[currentRealm]) do - table.insert(tmp, k) + --add all the accounts, who cares if it's the current user + for realm, rd in pairs(BagSyncDB) do + for k, v in pairs(rd) do + table.insert(tmp, {k, realm, (BagSync_REALMKEY[realm] or realm)} ) --name, shortrealm name, realrealm name + end end - table.sort(tmp, function(a,b) return (a < b) end) - + + table.sort(tmp, function(a,b) return (a[1] < b[1]) end) + if level == 1 then PlaySound("gsTitleOptionExit") for i=1, #tmp do - addButton(level, tmp[i], nil, 1, nil, tmp[i], function(frame, ...) + addButton(level, tmp[i][1].." - "..tmp[i][3], nil, 1, nil, tmp[i][1].." - "..tmp[i][3], function(frame, ...) + bgProfiles.charName = tmp[i][1] + bgProfiles.charRealm = tmp[i][2] + bgProfiles.realRealm = tmp[i][3] if BagSyncProfilesToonNameText then - BagSyncProfilesToonNameText:SetText(tmp[i]) + BagSyncProfilesToonNameText:SetText(tmp[i][1].." - "..tmp[i][3]) end end) end @@ -110,21 +115,31 @@ bgProfiles.confirmButton:SetWidth(100); bgProfiles.confirmButton:SetText(L["Confirm"]); bgProfiles.confirmButton:Disable() -bgProfiles.confirmButton:SetScript("OnClick", function() - local name = BagSyncProfilesToonNameText:GetText() - if name and BagSyncDB and BagSyncDB[currentRealm] and BagSyncDB[currentRealm][name] then - BagSyncDB[currentRealm][name] = nil - BagSyncOpt.delName = name - BagSync:FixDB_Data() - BagSync_ProfilesFrame:Hide() - ReloadUI() +bgProfiles.confirmButton:SetScript("OnClick", function(self) + + --call me paranoid but I want to make sure we have something to work with before we even think of deleting... double checking everything + if bgProfiles.charName and string.len(bgProfiles.charName) > 0 and bgProfiles.charRealm and string.len(bgProfiles.charRealm) > 0 then + + BagSyncDB[bgProfiles.charRealm][bgProfiles.charName] = nil --remove it + BagSyncProfilesToonNameText:SetText(L["Click Here"]) --reset + UIDropDownMenu_Initialize(bgsProfilesDD, bgsProfilesDD.initialize) --repopulate the dropdown + BagSync:FixDB_Data() --remove all associated tables from the user + print("|cFFFF0000BagSync: "..L["Profiles"].." "..L["Delete"].." ["..bgProfiles.charName.." - "..bgProfiles.charRealm.."]!|r") + bgProfiles.charName = nil + bgProfiles.charRealm = nil + bgProfiles.realRealm = nil + bgProfiles:Hide() + else print(L["BagSync: Error user not found!"]) end - BagSync_ProfilesFrame.confirmButton:Disable() + + bgProfiles.confirmButton:Disable() end) -bgProfiles:SetScript("OnHide", function(self) bgsProfilesDD:Hide() end) +bgProfiles:SetScript("OnShow", function(self) self.confirmButton:Disable() UIDropDownMenu_Initialize(bgsProfilesDD, bgsProfilesDD.initialize) end) +bgProfiles:SetScript("OnHide", function(self) if DropDownList1:IsVisible() then DropDownList1:Hide() end end) +bgsProfilesDD:SetScript('OnHide', function(self) if DropDownList1:IsVisible() then DropDownList1:Hide() end end) bgProfiles:SetScript("OnMouseDown", function(frame, button) if frame:IsMovable() then diff --git a/libs/LibSimpleOptions-1.0/LibSimpleOptions-1.0.lua b/libs/LibSimpleOptions-1.0/LibSimpleOptions-1.0.lua index 38f81a5..f14a600 100644 --- a/libs/LibSimpleOptions-1.0/LibSimpleOptions-1.0.lua +++ b/libs/LibSimpleOptions-1.0/LibSimpleOptions-1.0.lua @@ -96,6 +96,9 @@ do self:refreshFunc() end end + local function panel_refresh(self) + self:Refresh() + end local function panel_OnShow(self) self:SetScript("OnShow", self.Refresh) self:controlCreationFunc() @@ -142,6 +145,7 @@ do panel.okay = panel_okay panel.cancel = panel_cancel panel.default = panel_default + panel.refresh = panel_refresh InterfaceOptions_AddCategory(panel) -- 1.7.9.5