diff --git a/BagSync.toc b/BagSync.toc index 9c098b3..a50ceda 100644 --- a/BagSync.toc +++ b/BagSync.toc @@ -13,12 +13,11 @@ libs\LibItemSearch-1.0\LibItemSearch-1.0.lua libs\LibDataBroker-1.1\LibDataBroker-1.1.lua libs\LibSimpleOptions-1.0\LibSimpleOptions-1.0.lua libs\tekKonfigScroll.lua - -BagSync_Minimap.lua -BagSync_Search.lua -BagSync_Tokens.lua -BagSync_Crafts.lua -BagSync_Blacklist.lua -BagSync_Profiles.lua -BagSync_Config.lua -BagSync.lua +modules\minimap.lua +modules\search.lua +modules\tokens.lua +modules\professions.lua +modules\blacklist.lua +modules\profiles.lua +modules\config.lua +BagSync.lua \ No newline at end of file diff --git a/BagSync_Blacklist.lua b/BagSync_Blacklist.lua deleted file mode 100644 index 36b8681..0000000 --- a/BagSync_Blacklist.lua +++ /dev/null @@ -1,217 +0,0 @@ -local L = BAGSYNC_L -local blacklistTable = {} -local tRows, tAnchor = {} -local currentPlayer = UnitName("player") -local currentRealm = select(2, UnitFullName("player")) --get shortend realm name with no spaces and dashes -local storedBarCount = 0 -local prevClickedBar - -local bgBlackList = CreateFrame("Frame","BagSync_BlackListFrame", UIParent) - ---itemid popup -StaticPopupDialogs["BAGSYNC_BLACKLIST"] = { - text = L["Please enter an itemid. (Use Wowhead.com)"], - button1 = "Yes", - button2 = "No", - hasEditBox = true, - hasWideEditBox = true, - timeout = 0, - exclusive = 1, - hideOnEscape = 1, - EditBoxOnEscapePressed = function(self) self:GetParent():Hide() end, - OnAccept = function (self, data, data2) - local text = self.editBox:GetText() - if BagSync_BlackListFrame then - BagSync_BlackListFrame:processAdd(text) - end - end, - whileDead = 1, - maxLetters = 255, -} - -local function LoadSlider() - - local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 16, 20, 2, 4 - local FRAME_HEIGHT = bgBlackList:GetHeight() - 90 - local SCROLL_TOP_POSITION = -80 - local totaltRows = math.floor((FRAME_HEIGHT-22)/(ROWHEIGHT + ROWGAP)) - - for i=1, totaltRows do - if not tRows[i] then - local row = CreateFrame("Button", nil, bgBlackList) - if not tAnchor then row:SetPoint("BOTTOMLEFT", bgBlackList, "TOPLEFT", 0, SCROLL_TOP_POSITION) - else row:SetPoint("TOP", tAnchor, "BOTTOM", 0, -ROWGAP) end - row:SetPoint("LEFT", EDGEGAP, 0) - row:SetPoint("RIGHT", -EDGEGAP*2-8, 0) - row:SetHeight(ROWHEIGHT) - row:EnableMouse(true) - row:SetBackdrop({ - bgFile = "Interface\\Buttons\\WHITE8x8", - }) - row:SetBackdropColor(0,0,0,0) - tAnchor = row - tRows[i] = row - - local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal") - title:SetPoint("LEFT") - title:SetJustifyH("LEFT") - title:SetWidth(row:GetWidth()) - title:SetHeight(ROWHEIGHT) - row.title = title - - row:SetScript("OnClick", function (self, button, down) - if prevClickedBar then - prevClickedBar:SetBackdropColor(0,0,0,0) - end - prevClickedBar = self - self:SetBackdropColor(0,1,0,0.25) - end) - end - end - - local offset = 0 - local RefreshBlackList = function() - if not BagSync_BlackListFrame:IsVisible() then return end - for i,row in ipairs(tRows) do - if (i + offset) <= #blacklistTable then - if blacklistTable[i + offset] then - row.title:SetText(blacklistTable[i + offset]) - row:Show() - end - else - row:Hide() - end - end - end - - RefreshBlackList() - - if not bgBlackList.scrollbar then - bgBlackList.scrollbar = LibStub("tekKonfig-Scroll").new(bgBlackList, nil, #tRows/2) - bgBlackList.scrollbar:ClearAllPoints() - bgBlackList.scrollbar:SetPoint("TOP", tRows[1], 0, -16) - bgBlackList.scrollbar:SetPoint("BOTTOM", tRows[#tRows], 0, 16) - bgBlackList.scrollbar:SetPoint("RIGHT", -16, 0) - end - - if #blacklistTable > 0 then - bgBlackList.scrollbar:SetMinMaxValues(0, math.max(0, #blacklistTable - #tRows)) - bgBlackList.scrollbar:SetValue(0) - bgBlackList.scrollbar:Show() - else - bgBlackList.scrollbar:Hide() - end - - local f = bgBlackList.scrollbar:GetScript("OnValueChanged") - bgBlackList.scrollbar:SetScript("OnValueChanged", function(self, value, ...) - offset = math.floor(value) - RefreshBlackList() - return f(self, value, ...) - end) - - bgBlackList:EnableMouseWheel() - bgBlackList:SetScript("OnMouseWheel", function(self, val) - bgBlackList.scrollbar:SetValue(bgBlackList.scrollbar:GetValue() - val*#tRows/2) - end) -end - -local function DoBlackList() - if not BagSync or not BagSyncBLACKLIST_DB then return end - if not BagSyncBLACKLIST_DB[currentRealm] then return end - - blacklistTable = {} --reset - local tmp = {} - - --loop through our blacklist - ----------------------------------- - if BagSyncBLACKLIST_DB[currentRealm] then - for k, v in pairs(BagSyncBLACKLIST_DB[currentRealm]) do - table.insert(blacklistTable, k) - end - end - ----------------------------------- - - --sort it - table.sort(blacklistTable) - - LoadSlider() -end - -bgBlackList:SetFrameStrata("HIGH") -bgBlackList:SetToplevel(true) -bgBlackList:EnableMouse(true) -bgBlackList:SetMovable(true) -bgBlackList:SetClampedToScreen(true) -bgBlackList:SetWidth(380) -bgBlackList:SetHeight(490) - -bgBlackList:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 16, - edgeSize = 32, - insets = { left = 5, right = 5, top = 5, bottom = 5 } -}) - -bgBlackList:SetBackdropColor(0,0,0,1) -bgBlackList:SetPoint("CENTER", UIParent, "CENTER", 0, 0) - -local addonTitle = bgBlackList:CreateFontString(nil, "BACKGROUND", "GameFontNormal") -addonTitle:SetPoint("CENTER", bgBlackList, "TOP", 0, -20) -addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Blacklist"]..")|r") - -local closeButton = CreateFrame("Button", nil, bgBlackList, "UIPanelCloseButton"); -closeButton:SetPoint("TOPRIGHT", bgBlackList, -15, -8); - ---Add ItemID -local addItemButton = CreateFrame("Button", nil, bgBlackList, "UIPanelButtonTemplate") -addItemButton:SetWidth(130) -addItemButton:SetHeight(25) -addItemButton:SetPoint("BOTTOMLEFT", bgBlackList, "BOTTOMLEFT", 20, 15) -addItemButton:SetText(L["Add ItemID"]) -addItemButton:SetScript("OnClick", function() StaticPopup_Show("BAGSYNC_BLACKLIST") end) - ---Remove ItemID -local removeItemButton = CreateFrame("Button", nil, bgBlackList, "UIPanelButtonTemplate") -removeItemButton:SetWidth(130) -removeItemButton:SetHeight(25) -removeItemButton:SetPoint("BOTTOMRIGHT", bgBlackList, "BOTTOMRIGHT", -20, 15) -removeItemButton:SetText(L["Remove ItemID"]) -removeItemButton:SetScript("OnClick", function() - if not BagSync or not BagSyncBLACKLIST_DB then return end - if not BagSyncBLACKLIST_DB[currentRealm] then return end - if not prevClickedBar or not prevClickedBar.title or not prevClickedBar.title:GetText() then return end - if not tonumber(prevClickedBar.title:GetText()) then return end - BagSyncBLACKLIST_DB[currentRealm][tonumber(prevClickedBar.title:GetText())] = nil - DoBlackList() -end) - -bgBlackList:SetScript("OnShow", function(self) DoBlackList(); LoadSlider(); end) -bgBlackList:SetScript("OnHide", function(self) - blacklistTable = {} -end) - -bgBlackList:SetScript("OnMouseDown", function(frame, button) - if frame:IsMovable() then - frame.isMoving = true - frame:StartMoving() - end -end) - -bgBlackList:SetScript("OnMouseUp", function(frame, button) - if( frame.isMoving ) then - frame.isMoving = nil - frame:StopMovingOrSizing() - end -end) - -function bgBlackList:processAdd(itemid) - if not BagSync or not BagSyncBLACKLIST_DB then return end - if not BagSyncBLACKLIST_DB[currentRealm] then return end - if not tonumber(itemid) then return end - BagSyncBLACKLIST_DB[currentRealm][tonumber(itemid)] = true - DoBlackList() -end - -bgBlackList:Hide() diff --git a/BagSync_Config.lua b/BagSync_Config.lua deleted file mode 100644 index d35c525..0000000 --- a/BagSync_Config.lua +++ /dev/null @@ -1,246 +0,0 @@ -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 title, subText = panel:MakeTitleTextAndSubText("|cFF99CC33BagSync|r [|cFFDF2B2B"..ver.."|r]", "These options allow you to customize the BagSync displays data.") - - --toggle BagSync tooltips - panel:MakeToggle( - "name", L["Enable BagSync Tooltips"], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableTooltips"] end, - "setFunc", function(value) - BagSyncOpt["enableTooltips"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -16) - - --tooltip seperator - panel:MakeToggle( - "name", L["Enable empty line seperator above BagSync tooltip display."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableTooltipSeperator"] end, - "setFunc", function(value) - BagSyncOpt["enableTooltipSeperator"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -41) - - --total - panel:MakeToggle( - "name", L["Display [Total] in tooltips and gold display."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["showTotal"] end, - "setFunc", function(value) - BagSyncOpt["showTotal"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -66) - - --guild names - panel:MakeToggle( - "name", L["Display [Guild Name] display in tooltips."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["showGuildNames"] end, - "setFunc", function(value) - BagSyncOpt["showGuildNames"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -91) - - --factions - panel:MakeToggle( - "name", L["Display items for both factions (Alliance/Horde)."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableFaction"] end, - "setFunc", function(value) - BagSyncOpt["enableFaction"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -116) - - --class colors - panel:MakeToggle( - "name", L["Display class colors for characters."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableUnitClass"] end, - "setFunc", function(value) - BagSyncOpt["enableUnitClass"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -141) - - --minimap - panel:MakeToggle( - "name", L["Display BagSync minimap button."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableMinimap"] end, - "setFunc", function(value) - BagSyncOpt["enableMinimap"] = value - if value then BagSync_MinimapButton:Show() else BagSync_MinimapButton:Hide() end - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -166) - - --guild info - panel:MakeToggle( - "name", L["Enable guild bank items."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableGuild"] end, - "setFunc", function(value) - BagSyncOpt["enableGuild"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -191) - - --mailbox info - panel:MakeToggle( - "name", L["Enable mailbox items."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableMailbox"] end, - "setFunc", function(value) - BagSyncOpt["enableMailbox"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -216) - - --auction house - panel:MakeToggle( - "name", L["Enable auction house items."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableAuction"] end, - "setFunc", function(value) - BagSyncOpt["enableAuction"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -241) - - --tooltip only on bagsync search window - panel:MakeToggle( - "name", L["Display modified tooltips ONLY in the BagSync Search window."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["tooltipOnlySearch"] end, - "setFunc", function(value) - BagSyncOpt["tooltipOnlySearch"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -266) - - --cross realms - panel:MakeToggle( - "name", L["Enable items for Cross-Realms characters."], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableCrossRealmsItems"] end, - "setFunc", function(value) - BagSyncOpt["enableCrossRealmsItems"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -291) - - --battle.net account characters - panel:MakeToggle( - "name", L["Enable items for current Battle.Net Account characters. |cFFDF2B2B((Not Recommended))|r"], - "description", "", - "default", false, - "getFunc", function() return BagSyncOpt["enableBNetAccountItems"] end, - "setFunc", function(value) - BagSyncOpt["enableBNetAccountItems"] = value - BagSync:resetTooltip() - end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -316) - - --first color (default moss) - panel:MakeColorPicker( - "name", L["Primary BagSync tooltip color."], - "description", "", - "hasAlpha", false, - "defaultR", 128/255, - "defaultG", 1, - "defaultB", 0, - "getFunc", function() return BagSyncOpt.colors.FIRST.r, BagSyncOpt.colors.FIRST.g, BagSyncOpt.colors.FIRST.b end, - "setFunc", function(r, g, b) BagSyncOpt.colors.FIRST.r, BagSyncOpt.colors.FIRST.g, BagSyncOpt.colors.FIRST.b = r, g, b end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -341) - - --second color (default silver) - panel:MakeColorPicker( - "name", L["Secondary BagSync tooltip color."], - "description", "", - "hasAlpha", false, - "defaultR", 199/255, - "defaultG", 199/255, - "defaultB", 207/255, - "getFunc", function() return BagSyncOpt.colors.SECOND.r, BagSyncOpt.colors.SECOND.g, BagSyncOpt.colors.SECOND.b end, - "setFunc", function(r, g, b) BagSyncOpt.colors.SECOND.r, BagSyncOpt.colors.SECOND.g, BagSyncOpt.colors.SECOND.b = r, g, b end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -366) - - --total color - panel:MakeColorPicker( - "name", L["BagSync [Total] tooltip color."], - "description", "", - "hasAlpha", false, - "defaultR", 244/255, - "defaultG", 164/255, - "defaultB", 96/255, - "getFunc", function() return BagSyncOpt.colors.TOTAL.r, BagSyncOpt.colors.TOTAL.g, BagSyncOpt.colors.TOTAL.b end, - "setFunc", function(r, g, b) BagSyncOpt.colors.TOTAL.r, BagSyncOpt.colors.TOTAL.g, BagSyncOpt.colors.TOTAL.b = r, g, b end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -391) - - --guild color - panel:MakeColorPicker( - "name", L["BagSync [Guild] tooltip color."], - "description", "", - "hasAlpha", false, - "defaultR", 101/255, - "defaultG", 184/255, - "defaultB", 192/255, - "getFunc", function() return BagSyncOpt.colors.GUILD.r, BagSyncOpt.colors.GUILD.g, BagSyncOpt.colors.GUILD.b end, - "setFunc", function(r, g, b) BagSyncOpt.colors.GUILD.r, BagSyncOpt.colors.GUILD.g, BagSyncOpt.colors.GUILD.b = r, g, b end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -416) - - --cross realm color - panel:MakeColorPicker( - "name", L["BagSync [Cross-Realms] tooltip color."], - "description", "", - "hasAlpha", false, - "defaultR", 1, - "defaultG", 125/255, - "defaultB", 10/255, - "getFunc", function() return BagSyncOpt.colors.CROSS.r, BagSyncOpt.colors.CROSS.g, BagSyncOpt.colors.CROSS.b end, - "setFunc", function(r, g, b) BagSyncOpt.colors.CROSS.r, BagSyncOpt.colors.CROSS.g, BagSyncOpt.colors.CROSS.b = r, g, b end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -441) - - --bnet color - panel:MakeColorPicker( - "name", L["BagSync [Battle.Net] tooltip color."], - "description", "", - "hasAlpha", false, - "defaultR", 53/255, - "defaultG", 136/255, - "defaultB", 1, - "getFunc", function() return BagSyncOpt.colors.BNET.r, BagSyncOpt.colors.BNET.g, BagSyncOpt.colors.BNET.b end, - "setFunc", function(r, g, b) BagSyncOpt.colors.BNET.r, BagSyncOpt.colors.BNET.g, BagSyncOpt.colors.BNET.b = r, g, b end - ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -466) - - - --i'm calling a refresh for the panel, because sometimes (like the color picker) some of the items aren't refreshed on the screen due to a /reload - --so instead I'm just going to force the getFunc for all the controls - panel:Refresh() - -end \ No newline at end of file diff --git a/BagSync_Crafts.lua b/BagSync_Crafts.lua deleted file mode 100644 index 675dfe3..0000000 --- a/BagSync_Crafts.lua +++ /dev/null @@ -1,238 +0,0 @@ -local L = BAGSYNC_L -local craftsTable = {} -local tRows, tAnchor = {} -local currentPlayer = UnitName("player") -local currentRealm = select(2, UnitFullName("player")) - -local bgCrafts = CreateFrame("Frame","BagSync_CraftsFrame", UIParent) - -local function LoadSlider() - - local function OnEnter(self) - if self.canLink and self.owner then - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:AddLine(format("|cFF99CC33%s|r", self.owner)) - GameTooltip:AddLine(L["Left Click = Link to view tradeskill."]) - GameTooltip:AddLine(L["Right Click = Insert tradeskill link."]) - GameTooltip:Show() - end - end - - local function OnLeave() GameTooltip:Hide() end - - local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 16, 20, 2, 4 - local FRAME_HEIGHT = bgCrafts:GetHeight() - 50 - local SCROLL_TOP_POSITION = -80 - local totaltRows = math.floor((FRAME_HEIGHT-22)/(ROWHEIGHT + ROWGAP)) - - for i=1, totaltRows do - if not tRows[i] then - local row = CreateFrame("Button", nil, bgCrafts) - if not tAnchor then row:SetPoint("BOTTOMLEFT", bgCrafts, "TOPLEFT", 0, SCROLL_TOP_POSITION) - else row:SetPoint("TOP", tAnchor, "BOTTOM", 0, -ROWGAP) end - row:SetPoint("LEFT", EDGEGAP, 0) - row:SetPoint("RIGHT", -EDGEGAP*2-8, 0) - row:SetHeight(ROWHEIGHT) - row:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") - tAnchor = row - tRows[i] = row - - local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal") - title:SetPoint("LEFT") - title:SetJustifyH("LEFT") - title:SetWidth(row:GetWidth()) - title:SetHeight(ROWHEIGHT) - row.title = title - - row:RegisterForClicks("LeftButtonUp", "RightButtonUp") - row:SetScript("OnEnter", OnEnter) - row:SetScript("OnLeave", OnLeave) - row:SetScript("OnClick", function (self, button, down) - if self.link then - if button == "LeftButton" then - DEFAULT_CHAT_FRAME:AddMessage(format("%s|cFF99CC33%s|r ==> %s", L["Click to view profession: "], self.owner, self.link)) - else - local editBox = ChatEdit_ChooseBoxForSend() - - if editBox then - editBox:Insert(self.link) - ChatFrame_OpenChat(editBox:GetText()) - end - end - end - end) - end - end - - local offset = 0 - local RefreshCrafts = function() - if not BagSync_CraftsFrame:IsVisible() then return end - - for i,row in ipairs(tRows) do - if (i + offset) <= #craftsTable then - if craftsTable[i + offset] then - - if craftsTable[i + offset].isHeader then - row.title:SetText("|cFFFFFFFF"..craftsTable[i + offset].name.."|r") - else - if craftsTable[i + offset].isLink then - row.title:SetText( format("|cFF99CC33%s|r |cFFFFFFFF(%s)|r", craftsTable[i + offset].name, craftsTable[i + offset].level)) - else - row.title:SetText( format("|cFF6699FF%s|r |cFFFFFFFF(%s)|r", craftsTable[i + offset].name, craftsTable[i + offset].level)) - end - end - - --header texture and parameters - if craftsTable[i + offset].isHeader then - row:LockHighlight() - row.title:SetJustifyH("CENTER") - row.canLink = nil - else - row:UnlockHighlight() - row.title:SetJustifyH("LEFT") - row.canLink = craftsTable[i + offset].isLink - row.link = craftsTable[i + offset].link - row.owner = craftsTable[i + offset].owner - end - - end - else - row:Hide() - end - end - end - - RefreshCrafts() - - if not bgCrafts.scrollbar then - bgCrafts.scrollbar = LibStub("tekKonfig-Scroll").new(bgCrafts, nil, #tRows/2) - bgCrafts.scrollbar:ClearAllPoints() - bgCrafts.scrollbar:SetPoint("TOP", tRows[1], 0, -16) - bgCrafts.scrollbar:SetPoint("BOTTOM", tRows[#tRows], 0, 16) - bgCrafts.scrollbar:SetPoint("RIGHT", -16, 0) - end - - if #craftsTable > 0 then - bgCrafts.scrollbar:SetMinMaxValues(0, math.max(0, #craftsTable - #tRows)) - bgCrafts.scrollbar:SetValue(0) - bgCrafts.scrollbar:Show() - else - bgCrafts.scrollbar:Hide() - end - - local f = bgCrafts.scrollbar:GetScript("OnValueChanged") - bgCrafts.scrollbar:SetScript("OnValueChanged", function(self, value, ...) - offset = math.floor(value) - RefreshCrafts() - return f(self, value, ...) - end) - - bgCrafts:EnableMouseWheel() - bgCrafts:SetScript("OnMouseWheel", function(self, val) - bgCrafts.scrollbar:SetValue(bgCrafts.scrollbar:GetValue() - val*#tRows/2) - end) -end - -local function DoCrafts() - if not BagSync or not BagSyncCRAFT_DB then return end - if not BagSyncCRAFT_DB[currentRealm] then return end - - craftsTable = {} --reset - local tmp = {} - - --loop through our characters - ----------------------------------- - if BagSyncCRAFT_DB[currentRealm] then - for k, v in pairs(BagSyncCRAFT_DB[currentRealm]) do - - tmp = {} - for q, r in pairs(v) do - if type(r) == "string" then - local trName, trSkillLevel = strsplit(",", r) - if trName and trSkillLevel then - table.insert(tmp, { name=trName, level=trSkillLevel, isLink=false, owner=k} ) - end - elseif type(r) == "table" and r[1] and r[2] and r[3] then - table.insert(tmp, { name=r[1], link=r[2], level=r[3], isLink=true, owner=k} ) - end - end - table.sort(tmp, function(a,b) return (a.name < b.name) end) - - --now add it to master table to sort later, only add if we have something to add - if #tmp > 0 then - table.insert(craftsTable, {header=k, info=tmp}) - end - end - end - ----------------------------------- - - --sort it - table.sort(craftsTable, function(a,b) - if a.header < b.header then - return true; - end - end) - - --now that the header names are sorted lets add all headers and info to master table - tmp = {} --reset - - for i=1, #craftsTable do - --insert header - table.insert(tmp, { name=craftsTable[i].header, isHeader=true } ) - --insert sub information :) - for y=1, #craftsTable[i].info do - table.insert(tmp, craftsTable[i].info[y]) - end - end - craftsTable = tmp - - LoadSlider() -end - -bgCrafts:SetFrameStrata("HIGH") -bgCrafts:SetToplevel(true) -bgCrafts:EnableMouse(true) -bgCrafts:SetMovable(true) -bgCrafts:SetClampedToScreen(true) -bgCrafts:SetWidth(380) -bgCrafts:SetHeight(500) - -bgCrafts:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 16, - edgeSize = 32, - insets = { left = 5, right = 5, top = 5, bottom = 5 } -}) - -bgCrafts:SetBackdropColor(0,0,0,1) -bgCrafts:SetPoint("CENTER", UIParent, "CENTER", 0, 0) - -local addonTitle = bgCrafts:CreateFontString(nil, "BACKGROUND", "GameFontNormal") -addonTitle:SetPoint("CENTER", bgCrafts, "TOP", 0, -20) -addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Professions"]..")|r") - -local closeButton = CreateFrame("Button", nil, bgCrafts, "UIPanelCloseButton"); -closeButton:SetPoint("TOPRIGHT", bgCrafts, -15, -8); - -bgCrafts:SetScript("OnShow", function(self) DoCrafts(); LoadSlider(); end) -bgCrafts:SetScript("OnHide", function(self) - craftsTable = {} -end) - -bgCrafts:SetScript("OnMouseDown", function(frame, button) - if frame:IsMovable() then - frame.isMoving = true - frame:StartMoving() - end -end) - -bgCrafts:SetScript("OnMouseUp", function(frame, button) - if( frame.isMoving ) then - frame.isMoving = nil - frame:StopMovingOrSizing() - end -end) - -bgCrafts:Hide() \ No newline at end of file diff --git a/BagSync_Minimap.lua b/BagSync_Minimap.lua deleted file mode 100644 index 9da8a1e..0000000 --- a/BagSync_Minimap.lua +++ /dev/null @@ -1,118 +0,0 @@ ---Minimap Button for BagSync ---So people can stop PESTERING me about a dang button, why can't they just use DataBroker sheesh - -local L = BAGSYNC_L - -local bgMinimapButton = CreateFrame("Frame","BagSync_MinimapButton", Minimap) - -bgMinimapButton:SetHeight(32) -bgMinimapButton:SetWidth(32) -bgMinimapButton:SetMovable(1) -bgMinimapButton:SetUserPlaced(1) -bgMinimapButton:EnableMouse(1) -bgMinimapButton:RegisterForDrag('LeftButton') -bgMinimapButton:SetFrameStrata('MEDIUM') -bgMinimapButton:SetPoint('CENTER', Minimap:GetWidth()/3*-0.9, Minimap:GetHeight()/2*-1); -bgMinimapButton:CreateTexture('bgMinimapButtonTexture', 'BACKGROUND') -bgMinimapButton:SetClampedToScreen(true) - -bgMinimapButtonTexture:SetWidth(32) -bgMinimapButtonTexture:SetHeight(32) -bgMinimapButtonTexture:SetTexture('Interface\\AddOns\\BagSync\\media\\minimap.tga') -bgMinimapButtonTexture:SetPoint('CENTER') - ---lets do the dropdown menu of DOOM -local bgsMinimapDD = CreateFrame("Frame", "bgsMinimapDD") -bgsMinimapDD.displayMode = 'MENU' - -local function addButton(level, text, isTitle, notCheckable, hasArrow, value, func) - local info = UIDropDownMenu_CreateInfo() - info.text = text - info.isTitle = isTitle - info.notCheckable = notCheckable - info.hasArrow = hasArrow - info.value = value - info.func = func - UIDropDownMenu_AddButton(info, level) -end - -bgsMinimapDD.initialize = function(self, level) - - if level == 1 then - PlaySound('gsTitleOptionExit') - addButton(level, 'BagSync ', 1, 1) - addButton(level, L["Search"], nil, 1, nil, 'search', function(frame, ...) - if BagSync_SearchFrame then BagSync_SearchFrame:Show() end - end) - addButton(level, L["Tokens"], nil, 1, nil, 'tokens', function(frame, ...) - if BagSync_TokensFrame then BagSync_TokensFrame:Show() end - end) - addButton(level, L["Profiles"], nil, 1, nil, 'profiles', function(frame, ...) - if BagSync_ProfilesFrame then BagSync_ProfilesFrame:Show() end - end) - addButton(level, L["Professions"], nil, 1, nil, 'professions', function(frame, ...) - if BagSync_CraftsFrame then BagSync_CraftsFrame:Show() end - end) - addButton(level, L["Blacklist"], nil, 1, nil, 'blacklist', function(frame, ...) - if BagSync_BlackListFrame then BagSync_BlackListFrame:Show() end - end) - addButton(level, L["Gold"], nil, 1, nil, 'gold', function(frame, ...) - if BagSync then BagSync:ShowMoneyTooltip() end - end) - addButton(level, L["FixDB"], nil, 1, nil, 'fixdb', function(frame, ...) - if BagSync then BagSync:FixDB_Data() end - end) - addButton(level, L["Config"], nil, 1, nil, 'config', function(frame, ...) - InterfaceOptionsFrame_OpenToCategory("BagSync") - end) - addButton(level, "", nil, 1) --space ;) - addButton(level, L["Close"], nil, 1) - - end - -end - -bgMinimapButton:SetScript('OnMouseUp', function(self, button) - if button == 'LeftButton' and BagSync_SearchFrame then - if BagSync_SearchFrame:IsVisible() then - BagSync_SearchFrame:Hide() - else - BagSync_SearchFrame:Show() - end - elseif button == 'RightButton' and BagSync_TokensFrame then - ToggleDropDownMenu(1, nil, bgsMinimapDD, 'cursor', 0, 0) - end -end) - -bgMinimapButton:SetScript('OnDragStart', function(self, button) - if IsShiftKeyDown() then - bgMinimapButton:SetScript('OnUpdate', function(self, elapsed) - local x, y = Minimap:GetCenter() - local cx, cy = GetCursorPosition() - x, y = cx / self:GetEffectiveScale() - x, cy / self:GetEffectiveScale() - y - if x > Minimap:GetWidth()/2+bgMinimapButton:GetWidth()/2 then x = Minimap:GetWidth()/2+bgMinimapButton:GetWidth()/2 end - if x < Minimap:GetWidth()/2*-1-bgMinimapButton:GetWidth()/2 then x = Minimap:GetWidth()/2*-1-bgMinimapButton:GetWidth()/2 end - if y > Minimap:GetHeight()/2+bgMinimapButton:GetHeight()/2 then y = Minimap:GetHeight()/2+bgMinimapButton:GetHeight()/2 end - if y < Minimap:GetHeight()/2*-1-bgMinimapButton:GetHeight()/2 then y = Minimap:GetHeight()/2*-1-bgMinimapButton:GetHeight()/2 end - bgMinimapButton:ClearAllPoints() - bgMinimapButton:SetPoint('CENTER', x, y) - end) - end -end) - -bgMinimapButton:SetScript('OnDragStop', function(self, button) - bgMinimapButton:SetScript('OnUpdate', nil) -end) - -bgMinimapButton:SetScript('OnEnter', function(self) - GameTooltip:SetOwner(self, "ANCHOR_LEFT") - GameTooltip:AddLine("BagSync") - GameTooltip:AddLine(L["Left Click = Search Window"]) - GameTooltip:AddLine(L["Right Click = BagSync Menu"]) - GameTooltip:Show() -end) - -bgMinimapButton:SetScript('OnLeave', function(self) - GameTooltip:Hide() -end) - diff --git a/BagSync_Profiles.lua b/BagSync_Profiles.lua deleted file mode 100644 index 665043d..0000000 --- a/BagSync_Profiles.lua +++ /dev/null @@ -1,158 +0,0 @@ -local L = BAGSYNC_L -local currentPlayer = UnitName("player") -local currentRealm = select(2, UnitFullName("player")) -local bgProfiles = CreateFrame("Frame","BagSync_ProfilesFrame", UIParent) - ---lets do the dropdown menu of DOOM -local bgsProfilesDD = CreateFrame("Frame", "bgsProfilesDD") -bgsProfilesDD.displayMode = "MENU" - -local function addButton(level, text, isTitle, notCheckable, hasArrow, value, func) - local info = UIDropDownMenu_CreateInfo() - info.text = text - info.isTitle = isTitle - info.notCheckable = notCheckable - info.hasArrow = hasArrow - info.value = value - info.func = func - UIDropDownMenu_AddButton(info, level) -end - -bgsProfilesDD.initialize = function(self, level) - if not BagSync or not BagSyncDB then return end - - local tmp = {} - - --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[1] < b[1]) end) - - if level == 1 then - PlaySound("gsTitleOptionExit") - - for i=1, #tmp do - 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][1].." - "..tmp[i][3]) - end - end) - end - - addButton(level, "", nil, 1) --space ;) - addButton(level, L["Close"], nil, 1) - - end - -end - -bgProfiles:SetFrameStrata("HIGH") -bgProfiles:SetToplevel(true) -bgProfiles:EnableMouse(true) -bgProfiles:SetMovable(true) -bgProfiles:SetClampedToScreen(true) -bgProfiles:SetWidth(280) -bgProfiles:SetHeight(150) - -bgProfiles:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 16, - edgeSize = 32, - insets = { left = 5, right = 5, top = 5, bottom = 5 } -}) - -bgProfiles:SetBackdropColor(0,0,0,1) -bgProfiles:SetPoint("CENTER", UIParent, "CENTER", 0, 0) - -local addonTitle = bgProfiles:CreateFontString(nil, "BACKGROUND", "GameFontNormal") -addonTitle:SetPoint("CENTER", bgProfiles, "TOP", 0, -20) -addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Profiles"]..")|r") - -local closeButton = CreateFrame("Button", nil, bgProfiles, "UIPanelCloseButton"); -closeButton:SetPoint("TOPRIGHT", bgProfiles, -15, -8); - -local warningLabel = bgProfiles:CreateFontString(nil, "BACKGROUND", "GameFontNormal") -warningLabel:SetPoint("CENTER", bgProfiles, 0, 29) -warningLabel:SetText("|cFFDF2B2B"..L["Select a profile to delete.\nNOTE: This is irreversible!"].."|r") -bgProfiles.warningLabel = warningLabel - -local buttonText = bgProfiles:CreateFontString("BagSyncProfilesToonNameText", nil, "GameFontNormal") -buttonText:SetText(L["Click Here"]) -buttonText:SetPoint("CENTER") - -bgProfiles.toonName = CreateFrame("Button", "BagSyncProfilesToonName", bgProfiles); -bgProfiles.toonName:SetPoint("CENTER", bgProfiles, 0, 0) -bgProfiles.toonName:SetHeight(21); -bgProfiles.toonName:SetWidth(266); -bgProfiles.toonName:SetFontString(buttonText) -bgProfiles.toonName:SetBackdrop({ - bgFile = "Interface\\Buttons\\WHITE8x8", -}) -bgProfiles.toonName:SetBackdropColor(0,1,0,0.25) -bgProfiles.toonName:SetScript("OnClick", function() ToggleDropDownMenu(1, nil, bgsProfilesDD, "cursor", 0, 0) end) -bgProfiles.toonName.text = buttonText - -bgProfiles.deleteButton = CreateFrame("Button", nil, bgProfiles, "UIPanelButtonTemplate"); -bgProfiles.deleteButton:SetPoint("BOTTOM", bgProfiles, "BOTTOM", -70, 20); -bgProfiles.deleteButton:SetHeight(21); -bgProfiles.deleteButton:SetWidth(100); -bgProfiles.deleteButton:SetText(L["Delete"]); -bgProfiles.deleteButton:SetScript("OnClick", function() BagSync_ProfilesFrame.confirmButton:Enable() end) - -bgProfiles.confirmButton = CreateFrame("Button", nil, bgProfiles, "UIPanelButtonTemplate"); -bgProfiles.confirmButton:SetPoint("BOTTOM", bgProfiles, "BOTTOM", 70, 20); -bgProfiles.confirmButton:SetHeight(21); -bgProfiles.confirmButton:SetWidth(100); -bgProfiles.confirmButton:SetText(L["Confirm"]); -bgProfiles.confirmButton:Disable() - -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 - - bgProfiles.confirmButton:Disable() -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 - frame.isMoving = true - frame:StartMoving() - end -end) - -bgProfiles:SetScript("OnMouseUp", function(frame, button) - if( frame.isMoving ) then - frame.isMoving = nil - frame:StopMovingOrSizing() - end -end) - -bgProfiles:Hide() \ No newline at end of file diff --git a/BagSync_Search.lua b/BagSync_Search.lua deleted file mode 100644 index 48e3d2a..0000000 --- a/BagSync_Search.lua +++ /dev/null @@ -1,372 +0,0 @@ -local L = BAGSYNC_L -local searchTable = {} -local rows, anchor = {} -local currentRealm = select(2, UnitFullName("player")) -local GetItemInfo = _G["GetItemInfo"] -local currentPlayer = UnitName("player") - -local ItemSearch = LibStub("LibItemSearch-1.0") -local bgSearch = CreateFrame("Frame","BagSync_SearchFrame", UIParent) - ---add class search -local tooltipScanner = _G["LibItemSearchTooltipScanner"] or CreateFrame("GameTooltip", "LibItemSearchTooltipScanner", UIParent, "GameTooltipTemplate") -local tooltipCache = setmetatable({}, {__index = function(t, k) local v = {} t[k] = v return v end}) - -ItemSearch:RegisterTypedSearch{ - id = "classRestriction", - tags = {"c", "class"}, - - canSearch = function(self, _, search) - return search - end, - - findItem = function(self, link, _, search) - if link:find("battlepet") then return false end - - local itemID = link:match("item:(%d+)") - if not itemID then - return - end - - local cachedResult = tooltipCache[search][itemID] - if cachedResult ~= nil then - return cachedResult - end - - tooltipScanner:SetOwner(UIParent, "ANCHOR_NONE") - tooltipScanner:SetHyperlink(link) - - local result = false - - local pattern = string.gsub(ITEM_CLASSES_ALLOWED:lower(), "%%s", "(.+)") - - for i = 1, tooltipScanner:NumLines() do - local text = _G[tooltipScanner:GetName() .. "TextLeft" .. i]:GetText():lower() - local textChk = string.find(text, pattern) - - if textChk and tostring(text):find(search) then - result = true - end - end - - tooltipCache[search][itemID] = result - return result - end, -} - -local function LoadSlider() - - local function OnEnter(self) - if self.link then - GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT") - GameTooltip:SetHyperlink(self.link) - GameTooltip:Show() - end - end - local function OnLeave() GameTooltip:Hide() end - - local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 16, 20, 2, 4 - local FRAME_HEIGHT = bgSearch:GetHeight() - 60 - local SCROLL_TOP_POSITION = -90 - local totalRows = math.floor((FRAME_HEIGHT-22)/(ROWHEIGHT + ROWGAP)) - - for i=1, totalRows do - if not rows[i] then - local row = CreateFrame("Button", "BagSyncSearchRow"..i, bgSearch) - if not anchor then row:SetPoint("BOTTOMLEFT", bgSearch, "TOPLEFT", 0, SCROLL_TOP_POSITION) - else row:SetPoint("TOP", anchor, "BOTTOM", 0, -ROWGAP) end - row:SetPoint("LEFT", EDGEGAP, 0) - row:SetPoint("RIGHT", -EDGEGAP*2-8, 0) - row:SetHeight(ROWHEIGHT) - row:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") - anchor = row - rows[i] = row - - local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal") - title:SetPoint("LEFT") - title:SetJustifyH("LEFT") - title:SetWidth(row:GetWidth()) - title:SetHeight(ROWHEIGHT) - row.title = title - - row:SetScript("OnEnter", OnEnter) - row:SetScript("OnLeave", OnLeave) - row:SetScript("OnClick", function(self) - if self.link then - if HandleModifiedItemClick(self.link) then - return - end - if IsModifiedClick("CHATLINK") then - local editBox = ChatEdit_ChooseBoxForSend() - if editBox then - editBox:Insert(self.link) - ChatFrame_OpenChat(editBox:GetText()) - end - end - end - end) - end - end - - local offset = 0 - local RefreshSearch = function() - if not BagSync_SearchFrame:IsVisible() then return end - for i,row in ipairs(rows) do - if (i + offset) <= #searchTable then - if searchTable[i + offset] then - if searchTable[i + offset].rarity then - --local hex = (select(4, GetItemQualityColor(searchTable[i + offset].rarity))) - local hex = (select(4, GetItemQualityColor(searchTable[i + offset].rarity))) - row.title:SetText(format("|c%s%s|r", hex, searchTable[i + offset].name) or searchTable[i + offset].name) - else - row.title:SetText(searchTable[i + offset].name) - end - row.link = searchTable[i + offset].link - row:Show() - end - else - row.title:SetText(nil) - row:Hide() - end - end - end - - RefreshSearch() - - if not bgSearch.scrollbar then - bgSearch.scrollbar = LibStub("tekKonfig-Scroll").new(bgSearch, nil, #rows/2) - bgSearch.scrollbar:ClearAllPoints() - bgSearch.scrollbar:SetPoint("TOP", rows[1], 0, -16) - bgSearch.scrollbar:SetPoint("BOTTOM", rows[#rows], 0, 16) - bgSearch.scrollbar:SetPoint("RIGHT", -16, 0) - end - - if #searchTable > 0 then - bgSearch.scrollbar:SetMinMaxValues(0, math.max(0, #searchTable - #rows)) - bgSearch.scrollbar:SetValue(0) - bgSearch.scrollbar:Show() - else - bgSearch.scrollbar:Hide() - end - - local f = bgSearch.scrollbar:GetScript("OnValueChanged") - bgSearch.scrollbar:SetScript("OnValueChanged", function(self, value, ...) - offset = math.floor(value) - RefreshSearch() - return f(self, value, ...) - end) - - bgSearch:EnableMouseWheel() - bgSearch:SetScript("OnMouseWheel", function(self, val) - bgSearch.scrollbar:SetValue(bgSearch.scrollbar:GetValue() - val*#rows/2) - end) -end - ---do search routine -local function DoSearch() - if not BagSync or not BagSyncDB then return end - local searchStr = bgSearch.SEARCHBTN:GetText() - - searchStr = searchStr:lower() - - searchTable = {} --reset - - local tempList = {} - local previousGuilds = {} - local count = 0 - local playerSearch = false - - if strlen(searchStr) > 0 then - - local playerFaction = UnitFactionGroup("player") - local allowList = { - ["bag"] = 0, - ["bank"] = 0, - ["equip"] = 0, - ["mailbox"] = 0, - ["void"] = 0, - ["auction"] = 0, - ["guild"] = 0, - ["reagentbank"] = 0, - } - - if string.len(searchStr) > 1 and string.find(searchStr, "@") and allowList[string.sub(searchStr, 2)] ~= nil then playerSearch = true end - - local xDB = BagSync:getFilteredDB() - - --loop through our characters - --k = player, v = stored data for player - for k, v in pairs(xDB) do - - local pFaction = v.faction or playerFaction --just in case ;) if we dont know the faction yet display it anyways - local yName, yRealm = strsplit("^", k) - - --check if we should show both factions or not - if BagSyncOpt.enableFaction or pFaction == playerFaction then - - --now count the stuff for the user - --q = bag name, r = stored data for bag name - for q, r in pairs(v) do - --only loop through table items we want - if allowList[q] and type(r) == "table" then - --bagID = bag name bagID, bagInfo = data of specific bag with bagID - for bagID, bagInfo in pairs(r) do - --slotID = slotid for specific bagid, itemValue = data of specific slotid - if type(bagInfo) == "table" then - for slotID, itemValue in pairs(bagInfo) do - local dblink, dbcount = strsplit(",", itemValue) - if dblink then - local dName, dItemLink, dRarity = GetItemInfo(dblink) - if dName and dItemLink then - --are we checking in our bank,void, etc? - if playerSearch and string.sub(searchStr, 2) == q and string.sub(searchStr, 2) ~= "guild" and yName == currentPlayer and not tempList[dblink] then - table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) - tempList[dblink] = dName - count = count + 1 - --we found a match - elseif not playerSearch and not tempList[dblink] and ItemSearch:Find(dItemLink, searchStr) then - table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) - tempList[dblink] = dName - count = count + 1 - end - end - end - end - end - end - end - end - - if BagSyncOpt.enableGuild then - local guildN = v.guild or nil - - --check the guild bank if the character is in a guild - if BagSyncGUILD_DB and guildN and BagSyncGUILD_DB[v.realm][guildN] then - --check to see if this guild has already been done through this run (so we don't do it multiple times) - --check for XR/B.Net support - local gName = BagSync:getGuildRealmInfo(guildN, v.realm) - - if not previousGuilds[gName] then - --we only really need to see this information once per guild - for q, r in pairs(BagSyncGUILD_DB[v.realm][guildN]) do - local dblink, dbcount = strsplit(",", r) - if dblink then - local dName, dItemLink, dRarity = GetItemInfo(dblink) - if dName then - if playerSearch and string.sub(searchStr, 2) == "guild" and GetGuildInfo("player") and guildN == GetGuildInfo("player") and not tempList[dblink] then - table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) - tempList[dblink] = dName - count = count + 1 - --we found a match - elseif not playerSearch and not tempList[dblink] and ItemSearch:Find(dItemLink, searchStr) then - table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) - tempList[dblink] = dName - count = count + 1 - end - end - end - end - previousGuilds[gName] = true - end - end - end - - end - - end - - table.sort(searchTable, function(a,b) return (a.name < b.name) end) - end - - bgSearch.totalC:SetText("|cFFFFFFFF"..L["Total:"].." "..count.."|r") - - LoadSlider() -end - -local function escapeEditBox(self) - self:SetAutoFocus(false) -end - -local function enterEditBox(self) - self:ClearFocus() - --self:GetParent():DoSearch() - DoSearch() -end - -local function createEditBox(name, labeltext, obj, x, y) - local editbox = CreateFrame("EditBox", name, obj, "InputBoxTemplate") - editbox:SetAutoFocus(false) - editbox:SetWidth(180) - editbox:SetHeight(16) - editbox:SetPoint("TOPLEFT", obj, "TOPLEFT", x or 0, y or 0) - local label = editbox:CreateFontString(nil, "ARTWORK", "GameFontNormal") - label:SetPoint("BOTTOMLEFT", editbox, "TOPLEFT", -6, 4) - label:SetText(labeltext) - editbox:SetScript("OnEnterPressed", enterEditBox) - editbox:HookScript("OnEscapePressed", escapeEditBox) - return editbox -end - -bgSearch:SetFrameStrata("HIGH") -bgSearch:SetToplevel(true) -bgSearch:EnableMouse(true) -bgSearch:SetMovable(true) -bgSearch:SetClampedToScreen(true) -bgSearch:SetWidth(380) -bgSearch:SetHeight(500) - -bgSearch:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 16, - edgeSize = 32, - insets = { left = 5, right = 5, top = 5, bottom = 5 } -}) - -bgSearch:SetBackdropColor(0,0,0,1) -bgSearch:SetPoint("CENTER", UIParent, "CENTER", 0, 0) - -bgSearch.SEARCHBTN = createEditBox("$parentEdit1", (L["Search"]..":"), bgSearch, 60, -50) - -local addonTitle = bgSearch:CreateFontString(nil, "BACKGROUND", "GameFontNormal") -addonTitle:SetPoint("CENTER", bgSearch, "TOP", 0, -20) -addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Search"]..")|r") - -local totalC = bgSearch:CreateFontString(nil, "BACKGROUND", "GameFontNormal") -totalC:SetPoint("RIGHT", bgSearch.SEARCHBTN, 70, 0) -totalC:SetText("|cFFFFFFFF"..L["Total:"].." 0|r") -bgSearch.totalC = totalC - -local closeButton = CreateFrame("Button", nil, bgSearch, "UIPanelCloseButton"); -closeButton:SetPoint("TOPRIGHT", bgSearch, -15, -8); - -bgSearch:SetScript("OnShow", function(self) - LoadSlider() - self.SEARCHBTN:SetFocus() -end) -bgSearch:SetScript("OnHide", function(self) - searchTable = {} - self.SEARCHBTN:SetText("") - self.totalC:SetText("|cFFFFFFFF"..L["Total:"].." 0|r") -end) - -bgSearch:SetScript("OnMouseDown", function(frame, button) - if frame:IsMovable() then - frame.isMoving = true - frame:StartMoving() - end -end) - -bgSearch:SetScript("OnMouseUp", function(frame, button) - if( frame.isMoving ) then - frame.isMoving = nil - frame:StopMovingOrSizing() - end -end) - -function bgSearch:initSearch() - DoSearch() -end - -bgSearch:Hide() diff --git a/BagSync_Tokens.lua b/BagSync_Tokens.lua deleted file mode 100644 index 626ba3f..0000000 --- a/BagSync_Tokens.lua +++ /dev/null @@ -1,238 +0,0 @@ -local L = BAGSYNC_L -local tokensTable = {} -local tRows, tAnchor = {} -local currentPlayer = UnitName("player") -local currentRealm = select(2, UnitFullName("player")) -local GetItemInfo = _G["GetItemInfo"] - -local bgTokens = CreateFrame("Frame","BagSync_TokensFrame", UIParent) - -local function tooltipColor(color, str) - return string.format("|cff%02x%02x%02x%s|r", (color.r or 1) * 255, (color.g or 1) * 255, (color.b or 1) * 255, str) -end - -local function LoadSlider() - - local function OnEnter(self) - if self.name and self.tooltip then - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:AddLine(self.name) - GameTooltip:AddLine(" ") - for i=1, #self.tooltip do - GameTooltip:AddDoubleLine(tooltipColor(BagSyncOpt.colors.FIRST, self.tooltip[i].name), tooltipColor(BagSyncOpt.colors.SECOND, self.tooltip[i].count)) - end - GameTooltip:Show() - end - end - - local function OnLeave() GameTooltip:Hide() end - - local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 40, 20, 2, 4 - local FRAME_HEIGHT = bgTokens:GetHeight() - 50 - local SCROLL_TOP_POSITION = -80 - local totaltRows = math.floor((FRAME_HEIGHT-22)/(ROWHEIGHT + ROWGAP)) - - for i=1, totaltRows do - if not tRows[i] then - local row = CreateFrame("Button", nil, bgTokens) - if not tAnchor then row:SetPoint("BOTTOMLEFT", bgTokens, "TOPLEFT", 0, SCROLL_TOP_POSITION) - else row:SetPoint("TOP", tAnchor, "BOTTOM", 0, -ROWGAP) end - row:SetPoint("LEFT", EDGEGAP, 0) - row:SetPoint("RIGHT", -EDGEGAP*1-8, 0) - row:SetHeight(ROWHEIGHT) - row:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") - tAnchor = row - tRows[i] = row - - local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal") - title:SetPoint("LEFT") - title:SetJustifyH("LEFT") - title:SetWidth(row:GetWidth()) - title:SetHeight(ROWHEIGHT) - row.title = title - - local icon = row:CreateTexture(nil,"OVERLAY") - icon:SetPoint("LEFT", (ROWHEIGHT * -1) -3, 0) - icon:SetWidth(ROWHEIGHT) - icon:SetHeight(ROWHEIGHT) - icon:SetTexture("Interface\\Icons\\Spell_Shadow_Shadowbolt") - icon:Hide() - row.icon = icon - - row:SetScript("OnEnter", OnEnter) - row:SetScript("OnLeave", OnLeave) - end - end - - local offset = 0 - local RefreshTokens = function() - if not BagSync_TokensFrame:IsVisible() then return end - - for i,row in ipairs(tRows) do - if (i + offset) <= #tokensTable then - if tokensTable[i + offset] then - - if tokensTable[i + offset].isHeader then - row.title:SetText("|cFFFFFFFF"..tokensTable[i + offset].name.."|r") - else - row.title:SetText(tokensTable[i + offset].name) - end - - --header texture and parameters - if tokensTable[i + offset].isHeader then - row:LockHighlight() - row.title:SetJustifyH("CENTER") - row.tooltip = nil - else - row:UnlockHighlight() - row.title:SetJustifyH("LEFT") - row.name = row.title:GetText() - row.tooltip = tokensTable[i + offset].tooltip - end - - row.icon:SetTexture(tokensTable[i + offset].icon or nil) - row.icon:Show() - row:Show() - end - else - row.icon:SetTexture(nil) - row.icon:Hide() - row:Hide() - end - end - end - - RefreshTokens() - - if not bgTokens.scrollbar then - bgTokens.scrollbar = LibStub("tekKonfig-Scroll").new(bgTokens, nil, #tRows/2) - bgTokens.scrollbar:ClearAllPoints() - bgTokens.scrollbar:SetPoint("TOP", tRows[1], 0, -16) - bgTokens.scrollbar:SetPoint("BOTTOM", tRows[#tRows], 0, 16) - bgTokens.scrollbar:SetPoint("RIGHT", -16, 0) - end - - if #tokensTable > 0 then - bgTokens.scrollbar:SetMinMaxValues(0, math.max(0, #tokensTable - #tRows)) - bgTokens.scrollbar:SetValue(0) - bgTokens.scrollbar:Show() - else - bgTokens.scrollbar:Hide() - end - - local f = bgTokens.scrollbar:GetScript("OnValueChanged") - bgTokens.scrollbar:SetScript("OnValueChanged", function(self, value, ...) - offset = math.floor(value) - RefreshTokens() - return f(self, value, ...) - end) - - bgTokens:EnableMouseWheel() - bgTokens:SetScript("OnMouseWheel", function(self, val) - bgTokens.scrollbar:SetValue(bgTokens.scrollbar:GetValue() - val*#tRows/2) - end) -end - -local function DoTokens() - if not BagSync or not BagSyncTOKEN_DB then return end - if not BagSyncTOKEN_DB[currentRealm] then return end - - tokensTable = {} --reset - local tmp = {} - - --loop through our characters - ----------------------------------- - if BagSyncTOKEN_DB[currentRealm] then - for k, v in pairs(BagSyncTOKEN_DB[currentRealm]) do - - tmp = {} - --this will loop and store all characters whom have counts greater then zero, - --ignoring the icon and header table entry, then it sorts it by character name - for q, r in pairs(v) do - if q ~= "icon" and q ~= "header" and r > 0 then - --only show counts that are greater then zero - table.insert(tmp, { name=q, count=r} ) - end - end - table.sort(tmp, function(a,b) return (a.name < b.name) end) - - --now add it to master table to sort later - table.insert(tokensTable, {name=k, icon=v.icon, header=v.header, tooltip=tmp}) - end - end - ----------------------------------- - - --sort it - table.sort(tokensTable, function(a,b) - if a.header < b.header then - return true; - elseif a.header == b.header then - return (a.name < b.name); - end - end) - - --add headers - local lastHeader = "" - tmp = {} --reset - - for i=1, #tokensTable do - if tokensTable[i].header ~= lastHeader then - lastHeader = tokensTable[i].header - table.insert(tmp, { name=lastHeader, header=lastHeader, isHeader=true } ) - table.insert(tmp, tokensTable[i]) - else - table.insert(tmp, tokensTable[i]) - end - end - tokensTable = tmp - - LoadSlider() -end - -bgTokens:SetFrameStrata("HIGH") -bgTokens:SetToplevel(true) -bgTokens:EnableMouse(true) -bgTokens:SetMovable(true) -bgTokens:SetClampedToScreen(true) -bgTokens:SetWidth(380) -bgTokens:SetHeight(500) - -bgTokens:SetBackdrop({ - bgFile = "Interface/Tooltips/UI-Tooltip-Background", - edgeFile = "Interface/Tooltips/UI-Tooltip-Border", - tile = true, - tileSize = 16, - edgeSize = 32, - insets = { left = 5, right = 5, top = 5, bottom = 5 } -}) - -bgTokens:SetBackdropColor(0,0,0,1) -bgTokens:SetPoint("CENTER", UIParent, "CENTER", 0, 0) - -local addonTitle = bgTokens:CreateFontString(nil, "BACKGROUND", "GameFontNormal") -addonTitle:SetPoint("CENTER", bgTokens, "TOP", 0, -20) -addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Tokens"]..")|r") - -local closeButton = CreateFrame("Button", nil, bgTokens, "UIPanelCloseButton"); -closeButton:SetPoint("TOPRIGHT", bgTokens, -15, -8); - -bgTokens:SetScript("OnShow", function(self) DoTokens(); LoadSlider(); end) -bgTokens:SetScript("OnHide", function(self) - tokensTable = {} -end) - -bgTokens:SetScript("OnMouseDown", function(frame, button) - if frame:IsMovable() then - frame.isMoving = true - frame:StartMoving() - end -end) - -bgTokens:SetScript("OnMouseUp", function(frame, button) - if( frame.isMoving ) then - frame.isMoving = nil - frame:StopMovingOrSizing() - end -end) - -bgTokens:Hide() \ No newline at end of file diff --git a/modules/blacklist.lua b/modules/blacklist.lua new file mode 100644 index 0000000..36b8681 --- /dev/null +++ b/modules/blacklist.lua @@ -0,0 +1,217 @@ +local L = BAGSYNC_L +local blacklistTable = {} +local tRows, tAnchor = {} +local currentPlayer = UnitName("player") +local currentRealm = select(2, UnitFullName("player")) --get shortend realm name with no spaces and dashes +local storedBarCount = 0 +local prevClickedBar + +local bgBlackList = CreateFrame("Frame","BagSync_BlackListFrame", UIParent) + +--itemid popup +StaticPopupDialogs["BAGSYNC_BLACKLIST"] = { + text = L["Please enter an itemid. (Use Wowhead.com)"], + button1 = "Yes", + button2 = "No", + hasEditBox = true, + hasWideEditBox = true, + timeout = 0, + exclusive = 1, + hideOnEscape = 1, + EditBoxOnEscapePressed = function(self) self:GetParent():Hide() end, + OnAccept = function (self, data, data2) + local text = self.editBox:GetText() + if BagSync_BlackListFrame then + BagSync_BlackListFrame:processAdd(text) + end + end, + whileDead = 1, + maxLetters = 255, +} + +local function LoadSlider() + + local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 16, 20, 2, 4 + local FRAME_HEIGHT = bgBlackList:GetHeight() - 90 + local SCROLL_TOP_POSITION = -80 + local totaltRows = math.floor((FRAME_HEIGHT-22)/(ROWHEIGHT + ROWGAP)) + + for i=1, totaltRows do + if not tRows[i] then + local row = CreateFrame("Button", nil, bgBlackList) + if not tAnchor then row:SetPoint("BOTTOMLEFT", bgBlackList, "TOPLEFT", 0, SCROLL_TOP_POSITION) + else row:SetPoint("TOP", tAnchor, "BOTTOM", 0, -ROWGAP) end + row:SetPoint("LEFT", EDGEGAP, 0) + row:SetPoint("RIGHT", -EDGEGAP*2-8, 0) + row:SetHeight(ROWHEIGHT) + row:EnableMouse(true) + row:SetBackdrop({ + bgFile = "Interface\\Buttons\\WHITE8x8", + }) + row:SetBackdropColor(0,0,0,0) + tAnchor = row + tRows[i] = row + + local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal") + title:SetPoint("LEFT") + title:SetJustifyH("LEFT") + title:SetWidth(row:GetWidth()) + title:SetHeight(ROWHEIGHT) + row.title = title + + row:SetScript("OnClick", function (self, button, down) + if prevClickedBar then + prevClickedBar:SetBackdropColor(0,0,0,0) + end + prevClickedBar = self + self:SetBackdropColor(0,1,0,0.25) + end) + end + end + + local offset = 0 + local RefreshBlackList = function() + if not BagSync_BlackListFrame:IsVisible() then return end + for i,row in ipairs(tRows) do + if (i + offset) <= #blacklistTable then + if blacklistTable[i + offset] then + row.title:SetText(blacklistTable[i + offset]) + row:Show() + end + else + row:Hide() + end + end + end + + RefreshBlackList() + + if not bgBlackList.scrollbar then + bgBlackList.scrollbar = LibStub("tekKonfig-Scroll").new(bgBlackList, nil, #tRows/2) + bgBlackList.scrollbar:ClearAllPoints() + bgBlackList.scrollbar:SetPoint("TOP", tRows[1], 0, -16) + bgBlackList.scrollbar:SetPoint("BOTTOM", tRows[#tRows], 0, 16) + bgBlackList.scrollbar:SetPoint("RIGHT", -16, 0) + end + + if #blacklistTable > 0 then + bgBlackList.scrollbar:SetMinMaxValues(0, math.max(0, #blacklistTable - #tRows)) + bgBlackList.scrollbar:SetValue(0) + bgBlackList.scrollbar:Show() + else + bgBlackList.scrollbar:Hide() + end + + local f = bgBlackList.scrollbar:GetScript("OnValueChanged") + bgBlackList.scrollbar:SetScript("OnValueChanged", function(self, value, ...) + offset = math.floor(value) + RefreshBlackList() + return f(self, value, ...) + end) + + bgBlackList:EnableMouseWheel() + bgBlackList:SetScript("OnMouseWheel", function(self, val) + bgBlackList.scrollbar:SetValue(bgBlackList.scrollbar:GetValue() - val*#tRows/2) + end) +end + +local function DoBlackList() + if not BagSync or not BagSyncBLACKLIST_DB then return end + if not BagSyncBLACKLIST_DB[currentRealm] then return end + + blacklistTable = {} --reset + local tmp = {} + + --loop through our blacklist + ----------------------------------- + if BagSyncBLACKLIST_DB[currentRealm] then + for k, v in pairs(BagSyncBLACKLIST_DB[currentRealm]) do + table.insert(blacklistTable, k) + end + end + ----------------------------------- + + --sort it + table.sort(blacklistTable) + + LoadSlider() +end + +bgBlackList:SetFrameStrata("HIGH") +bgBlackList:SetToplevel(true) +bgBlackList:EnableMouse(true) +bgBlackList:SetMovable(true) +bgBlackList:SetClampedToScreen(true) +bgBlackList:SetWidth(380) +bgBlackList:SetHeight(490) + +bgBlackList:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 16, + edgeSize = 32, + insets = { left = 5, right = 5, top = 5, bottom = 5 } +}) + +bgBlackList:SetBackdropColor(0,0,0,1) +bgBlackList:SetPoint("CENTER", UIParent, "CENTER", 0, 0) + +local addonTitle = bgBlackList:CreateFontString(nil, "BACKGROUND", "GameFontNormal") +addonTitle:SetPoint("CENTER", bgBlackList, "TOP", 0, -20) +addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Blacklist"]..")|r") + +local closeButton = CreateFrame("Button", nil, bgBlackList, "UIPanelCloseButton"); +closeButton:SetPoint("TOPRIGHT", bgBlackList, -15, -8); + +--Add ItemID +local addItemButton = CreateFrame("Button", nil, bgBlackList, "UIPanelButtonTemplate") +addItemButton:SetWidth(130) +addItemButton:SetHeight(25) +addItemButton:SetPoint("BOTTOMLEFT", bgBlackList, "BOTTOMLEFT", 20, 15) +addItemButton:SetText(L["Add ItemID"]) +addItemButton:SetScript("OnClick", function() StaticPopup_Show("BAGSYNC_BLACKLIST") end) + +--Remove ItemID +local removeItemButton = CreateFrame("Button", nil, bgBlackList, "UIPanelButtonTemplate") +removeItemButton:SetWidth(130) +removeItemButton:SetHeight(25) +removeItemButton:SetPoint("BOTTOMRIGHT", bgBlackList, "BOTTOMRIGHT", -20, 15) +removeItemButton:SetText(L["Remove ItemID"]) +removeItemButton:SetScript("OnClick", function() + if not BagSync or not BagSyncBLACKLIST_DB then return end + if not BagSyncBLACKLIST_DB[currentRealm] then return end + if not prevClickedBar or not prevClickedBar.title or not prevClickedBar.title:GetText() then return end + if not tonumber(prevClickedBar.title:GetText()) then return end + BagSyncBLACKLIST_DB[currentRealm][tonumber(prevClickedBar.title:GetText())] = nil + DoBlackList() +end) + +bgBlackList:SetScript("OnShow", function(self) DoBlackList(); LoadSlider(); end) +bgBlackList:SetScript("OnHide", function(self) + blacklistTable = {} +end) + +bgBlackList:SetScript("OnMouseDown", function(frame, button) + if frame:IsMovable() then + frame.isMoving = true + frame:StartMoving() + end +end) + +bgBlackList:SetScript("OnMouseUp", function(frame, button) + if( frame.isMoving ) then + frame.isMoving = nil + frame:StopMovingOrSizing() + end +end) + +function bgBlackList:processAdd(itemid) + if not BagSync or not BagSyncBLACKLIST_DB then return end + if not BagSyncBLACKLIST_DB[currentRealm] then return end + if not tonumber(itemid) then return end + BagSyncBLACKLIST_DB[currentRealm][tonumber(itemid)] = true + DoBlackList() +end + +bgBlackList:Hide() diff --git a/modules/config.lua b/modules/config.lua new file mode 100644 index 0000000..d35c525 --- /dev/null +++ b/modules/config.lua @@ -0,0 +1,246 @@ +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 title, subText = panel:MakeTitleTextAndSubText("|cFF99CC33BagSync|r [|cFFDF2B2B"..ver.."|r]", "These options allow you to customize the BagSync displays data.") + + --toggle BagSync tooltips + panel:MakeToggle( + "name", L["Enable BagSync Tooltips"], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableTooltips"] end, + "setFunc", function(value) + BagSyncOpt["enableTooltips"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -16) + + --tooltip seperator + panel:MakeToggle( + "name", L["Enable empty line seperator above BagSync tooltip display."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableTooltipSeperator"] end, + "setFunc", function(value) + BagSyncOpt["enableTooltipSeperator"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -41) + + --total + panel:MakeToggle( + "name", L["Display [Total] in tooltips and gold display."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["showTotal"] end, + "setFunc", function(value) + BagSyncOpt["showTotal"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -66) + + --guild names + panel:MakeToggle( + "name", L["Display [Guild Name] display in tooltips."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["showGuildNames"] end, + "setFunc", function(value) + BagSyncOpt["showGuildNames"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -91) + + --factions + panel:MakeToggle( + "name", L["Display items for both factions (Alliance/Horde)."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableFaction"] end, + "setFunc", function(value) + BagSyncOpt["enableFaction"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -116) + + --class colors + panel:MakeToggle( + "name", L["Display class colors for characters."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableUnitClass"] end, + "setFunc", function(value) + BagSyncOpt["enableUnitClass"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -141) + + --minimap + panel:MakeToggle( + "name", L["Display BagSync minimap button."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableMinimap"] end, + "setFunc", function(value) + BagSyncOpt["enableMinimap"] = value + if value then BagSync_MinimapButton:Show() else BagSync_MinimapButton:Hide() end + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -166) + + --guild info + panel:MakeToggle( + "name", L["Enable guild bank items."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableGuild"] end, + "setFunc", function(value) + BagSyncOpt["enableGuild"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -191) + + --mailbox info + panel:MakeToggle( + "name", L["Enable mailbox items."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableMailbox"] end, + "setFunc", function(value) + BagSyncOpt["enableMailbox"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -216) + + --auction house + panel:MakeToggle( + "name", L["Enable auction house items."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableAuction"] end, + "setFunc", function(value) + BagSyncOpt["enableAuction"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -241) + + --tooltip only on bagsync search window + panel:MakeToggle( + "name", L["Display modified tooltips ONLY in the BagSync Search window."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["tooltipOnlySearch"] end, + "setFunc", function(value) + BagSyncOpt["tooltipOnlySearch"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -266) + + --cross realms + panel:MakeToggle( + "name", L["Enable items for Cross-Realms characters."], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableCrossRealmsItems"] end, + "setFunc", function(value) + BagSyncOpt["enableCrossRealmsItems"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -291) + + --battle.net account characters + panel:MakeToggle( + "name", L["Enable items for current Battle.Net Account characters. |cFFDF2B2B((Not Recommended))|r"], + "description", "", + "default", false, + "getFunc", function() return BagSyncOpt["enableBNetAccountItems"] end, + "setFunc", function(value) + BagSyncOpt["enableBNetAccountItems"] = value + BagSync:resetTooltip() + end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -316) + + --first color (default moss) + panel:MakeColorPicker( + "name", L["Primary BagSync tooltip color."], + "description", "", + "hasAlpha", false, + "defaultR", 128/255, + "defaultG", 1, + "defaultB", 0, + "getFunc", function() return BagSyncOpt.colors.FIRST.r, BagSyncOpt.colors.FIRST.g, BagSyncOpt.colors.FIRST.b end, + "setFunc", function(r, g, b) BagSyncOpt.colors.FIRST.r, BagSyncOpt.colors.FIRST.g, BagSyncOpt.colors.FIRST.b = r, g, b end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -341) + + --second color (default silver) + panel:MakeColorPicker( + "name", L["Secondary BagSync tooltip color."], + "description", "", + "hasAlpha", false, + "defaultR", 199/255, + "defaultG", 199/255, + "defaultB", 207/255, + "getFunc", function() return BagSyncOpt.colors.SECOND.r, BagSyncOpt.colors.SECOND.g, BagSyncOpt.colors.SECOND.b end, + "setFunc", function(r, g, b) BagSyncOpt.colors.SECOND.r, BagSyncOpt.colors.SECOND.g, BagSyncOpt.colors.SECOND.b = r, g, b end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -366) + + --total color + panel:MakeColorPicker( + "name", L["BagSync [Total] tooltip color."], + "description", "", + "hasAlpha", false, + "defaultR", 244/255, + "defaultG", 164/255, + "defaultB", 96/255, + "getFunc", function() return BagSyncOpt.colors.TOTAL.r, BagSyncOpt.colors.TOTAL.g, BagSyncOpt.colors.TOTAL.b end, + "setFunc", function(r, g, b) BagSyncOpt.colors.TOTAL.r, BagSyncOpt.colors.TOTAL.g, BagSyncOpt.colors.TOTAL.b = r, g, b end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -391) + + --guild color + panel:MakeColorPicker( + "name", L["BagSync [Guild] tooltip color."], + "description", "", + "hasAlpha", false, + "defaultR", 101/255, + "defaultG", 184/255, + "defaultB", 192/255, + "getFunc", function() return BagSyncOpt.colors.GUILD.r, BagSyncOpt.colors.GUILD.g, BagSyncOpt.colors.GUILD.b end, + "setFunc", function(r, g, b) BagSyncOpt.colors.GUILD.r, BagSyncOpt.colors.GUILD.g, BagSyncOpt.colors.GUILD.b = r, g, b end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -416) + + --cross realm color + panel:MakeColorPicker( + "name", L["BagSync [Cross-Realms] tooltip color."], + "description", "", + "hasAlpha", false, + "defaultR", 1, + "defaultG", 125/255, + "defaultB", 10/255, + "getFunc", function() return BagSyncOpt.colors.CROSS.r, BagSyncOpt.colors.CROSS.g, BagSyncOpt.colors.CROSS.b end, + "setFunc", function(r, g, b) BagSyncOpt.colors.CROSS.r, BagSyncOpt.colors.CROSS.g, BagSyncOpt.colors.CROSS.b = r, g, b end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -441) + + --bnet color + panel:MakeColorPicker( + "name", L["BagSync [Battle.Net] tooltip color."], + "description", "", + "hasAlpha", false, + "defaultR", 53/255, + "defaultG", 136/255, + "defaultB", 1, + "getFunc", function() return BagSyncOpt.colors.BNET.r, BagSyncOpt.colors.BNET.g, BagSyncOpt.colors.BNET.b end, + "setFunc", function(r, g, b) BagSyncOpt.colors.BNET.r, BagSyncOpt.colors.BNET.g, BagSyncOpt.colors.BNET.b = r, g, b end + ):SetPoint("TOPLEFT", subText, "BOTTOMLEFT", 0, -466) + + + --i'm calling a refresh for the panel, because sometimes (like the color picker) some of the items aren't refreshed on the screen due to a /reload + --so instead I'm just going to force the getFunc for all the controls + panel:Refresh() + +end \ No newline at end of file diff --git a/modules/minimap.lua b/modules/minimap.lua new file mode 100644 index 0000000..9da8a1e --- /dev/null +++ b/modules/minimap.lua @@ -0,0 +1,118 @@ +--Minimap Button for BagSync +--So people can stop PESTERING me about a dang button, why can't they just use DataBroker sheesh + +local L = BAGSYNC_L + +local bgMinimapButton = CreateFrame("Frame","BagSync_MinimapButton", Minimap) + +bgMinimapButton:SetHeight(32) +bgMinimapButton:SetWidth(32) +bgMinimapButton:SetMovable(1) +bgMinimapButton:SetUserPlaced(1) +bgMinimapButton:EnableMouse(1) +bgMinimapButton:RegisterForDrag('LeftButton') +bgMinimapButton:SetFrameStrata('MEDIUM') +bgMinimapButton:SetPoint('CENTER', Minimap:GetWidth()/3*-0.9, Minimap:GetHeight()/2*-1); +bgMinimapButton:CreateTexture('bgMinimapButtonTexture', 'BACKGROUND') +bgMinimapButton:SetClampedToScreen(true) + +bgMinimapButtonTexture:SetWidth(32) +bgMinimapButtonTexture:SetHeight(32) +bgMinimapButtonTexture:SetTexture('Interface\\AddOns\\BagSync\\media\\minimap.tga') +bgMinimapButtonTexture:SetPoint('CENTER') + +--lets do the dropdown menu of DOOM +local bgsMinimapDD = CreateFrame("Frame", "bgsMinimapDD") +bgsMinimapDD.displayMode = 'MENU' + +local function addButton(level, text, isTitle, notCheckable, hasArrow, value, func) + local info = UIDropDownMenu_CreateInfo() + info.text = text + info.isTitle = isTitle + info.notCheckable = notCheckable + info.hasArrow = hasArrow + info.value = value + info.func = func + UIDropDownMenu_AddButton(info, level) +end + +bgsMinimapDD.initialize = function(self, level) + + if level == 1 then + PlaySound('gsTitleOptionExit') + addButton(level, 'BagSync ', 1, 1) + addButton(level, L["Search"], nil, 1, nil, 'search', function(frame, ...) + if BagSync_SearchFrame then BagSync_SearchFrame:Show() end + end) + addButton(level, L["Tokens"], nil, 1, nil, 'tokens', function(frame, ...) + if BagSync_TokensFrame then BagSync_TokensFrame:Show() end + end) + addButton(level, L["Profiles"], nil, 1, nil, 'profiles', function(frame, ...) + if BagSync_ProfilesFrame then BagSync_ProfilesFrame:Show() end + end) + addButton(level, L["Professions"], nil, 1, nil, 'professions', function(frame, ...) + if BagSync_CraftsFrame then BagSync_CraftsFrame:Show() end + end) + addButton(level, L["Blacklist"], nil, 1, nil, 'blacklist', function(frame, ...) + if BagSync_BlackListFrame then BagSync_BlackListFrame:Show() end + end) + addButton(level, L["Gold"], nil, 1, nil, 'gold', function(frame, ...) + if BagSync then BagSync:ShowMoneyTooltip() end + end) + addButton(level, L["FixDB"], nil, 1, nil, 'fixdb', function(frame, ...) + if BagSync then BagSync:FixDB_Data() end + end) + addButton(level, L["Config"], nil, 1, nil, 'config', function(frame, ...) + InterfaceOptionsFrame_OpenToCategory("BagSync") + end) + addButton(level, "", nil, 1) --space ;) + addButton(level, L["Close"], nil, 1) + + end + +end + +bgMinimapButton:SetScript('OnMouseUp', function(self, button) + if button == 'LeftButton' and BagSync_SearchFrame then + if BagSync_SearchFrame:IsVisible() then + BagSync_SearchFrame:Hide() + else + BagSync_SearchFrame:Show() + end + elseif button == 'RightButton' and BagSync_TokensFrame then + ToggleDropDownMenu(1, nil, bgsMinimapDD, 'cursor', 0, 0) + end +end) + +bgMinimapButton:SetScript('OnDragStart', function(self, button) + if IsShiftKeyDown() then + bgMinimapButton:SetScript('OnUpdate', function(self, elapsed) + local x, y = Minimap:GetCenter() + local cx, cy = GetCursorPosition() + x, y = cx / self:GetEffectiveScale() - x, cy / self:GetEffectiveScale() - y + if x > Minimap:GetWidth()/2+bgMinimapButton:GetWidth()/2 then x = Minimap:GetWidth()/2+bgMinimapButton:GetWidth()/2 end + if x < Minimap:GetWidth()/2*-1-bgMinimapButton:GetWidth()/2 then x = Minimap:GetWidth()/2*-1-bgMinimapButton:GetWidth()/2 end + if y > Minimap:GetHeight()/2+bgMinimapButton:GetHeight()/2 then y = Minimap:GetHeight()/2+bgMinimapButton:GetHeight()/2 end + if y < Minimap:GetHeight()/2*-1-bgMinimapButton:GetHeight()/2 then y = Minimap:GetHeight()/2*-1-bgMinimapButton:GetHeight()/2 end + bgMinimapButton:ClearAllPoints() + bgMinimapButton:SetPoint('CENTER', x, y) + end) + end +end) + +bgMinimapButton:SetScript('OnDragStop', function(self, button) + bgMinimapButton:SetScript('OnUpdate', nil) +end) + +bgMinimapButton:SetScript('OnEnter', function(self) + GameTooltip:SetOwner(self, "ANCHOR_LEFT") + GameTooltip:AddLine("BagSync") + GameTooltip:AddLine(L["Left Click = Search Window"]) + GameTooltip:AddLine(L["Right Click = BagSync Menu"]) + GameTooltip:Show() +end) + +bgMinimapButton:SetScript('OnLeave', function(self) + GameTooltip:Hide() +end) + diff --git a/modules/professions.lua b/modules/professions.lua new file mode 100644 index 0000000..675dfe3 --- /dev/null +++ b/modules/professions.lua @@ -0,0 +1,238 @@ +local L = BAGSYNC_L +local craftsTable = {} +local tRows, tAnchor = {} +local currentPlayer = UnitName("player") +local currentRealm = select(2, UnitFullName("player")) + +local bgCrafts = CreateFrame("Frame","BagSync_CraftsFrame", UIParent) + +local function LoadSlider() + + local function OnEnter(self) + if self.canLink and self.owner then + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:AddLine(format("|cFF99CC33%s|r", self.owner)) + GameTooltip:AddLine(L["Left Click = Link to view tradeskill."]) + GameTooltip:AddLine(L["Right Click = Insert tradeskill link."]) + GameTooltip:Show() + end + end + + local function OnLeave() GameTooltip:Hide() end + + local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 16, 20, 2, 4 + local FRAME_HEIGHT = bgCrafts:GetHeight() - 50 + local SCROLL_TOP_POSITION = -80 + local totaltRows = math.floor((FRAME_HEIGHT-22)/(ROWHEIGHT + ROWGAP)) + + for i=1, totaltRows do + if not tRows[i] then + local row = CreateFrame("Button", nil, bgCrafts) + if not tAnchor then row:SetPoint("BOTTOMLEFT", bgCrafts, "TOPLEFT", 0, SCROLL_TOP_POSITION) + else row:SetPoint("TOP", tAnchor, "BOTTOM", 0, -ROWGAP) end + row:SetPoint("LEFT", EDGEGAP, 0) + row:SetPoint("RIGHT", -EDGEGAP*2-8, 0) + row:SetHeight(ROWHEIGHT) + row:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") + tAnchor = row + tRows[i] = row + + local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal") + title:SetPoint("LEFT") + title:SetJustifyH("LEFT") + title:SetWidth(row:GetWidth()) + title:SetHeight(ROWHEIGHT) + row.title = title + + row:RegisterForClicks("LeftButtonUp", "RightButtonUp") + row:SetScript("OnEnter", OnEnter) + row:SetScript("OnLeave", OnLeave) + row:SetScript("OnClick", function (self, button, down) + if self.link then + if button == "LeftButton" then + DEFAULT_CHAT_FRAME:AddMessage(format("%s|cFF99CC33%s|r ==> %s", L["Click to view profession: "], self.owner, self.link)) + else + local editBox = ChatEdit_ChooseBoxForSend() + + if editBox then + editBox:Insert(self.link) + ChatFrame_OpenChat(editBox:GetText()) + end + end + end + end) + end + end + + local offset = 0 + local RefreshCrafts = function() + if not BagSync_CraftsFrame:IsVisible() then return end + + for i,row in ipairs(tRows) do + if (i + offset) <= #craftsTable then + if craftsTable[i + offset] then + + if craftsTable[i + offset].isHeader then + row.title:SetText("|cFFFFFFFF"..craftsTable[i + offset].name.."|r") + else + if craftsTable[i + offset].isLink then + row.title:SetText( format("|cFF99CC33%s|r |cFFFFFFFF(%s)|r", craftsTable[i + offset].name, craftsTable[i + offset].level)) + else + row.title:SetText( format("|cFF6699FF%s|r |cFFFFFFFF(%s)|r", craftsTable[i + offset].name, craftsTable[i + offset].level)) + end + end + + --header texture and parameters + if craftsTable[i + offset].isHeader then + row:LockHighlight() + row.title:SetJustifyH("CENTER") + row.canLink = nil + else + row:UnlockHighlight() + row.title:SetJustifyH("LEFT") + row.canLink = craftsTable[i + offset].isLink + row.link = craftsTable[i + offset].link + row.owner = craftsTable[i + offset].owner + end + + end + else + row:Hide() + end + end + end + + RefreshCrafts() + + if not bgCrafts.scrollbar then + bgCrafts.scrollbar = LibStub("tekKonfig-Scroll").new(bgCrafts, nil, #tRows/2) + bgCrafts.scrollbar:ClearAllPoints() + bgCrafts.scrollbar:SetPoint("TOP", tRows[1], 0, -16) + bgCrafts.scrollbar:SetPoint("BOTTOM", tRows[#tRows], 0, 16) + bgCrafts.scrollbar:SetPoint("RIGHT", -16, 0) + end + + if #craftsTable > 0 then + bgCrafts.scrollbar:SetMinMaxValues(0, math.max(0, #craftsTable - #tRows)) + bgCrafts.scrollbar:SetValue(0) + bgCrafts.scrollbar:Show() + else + bgCrafts.scrollbar:Hide() + end + + local f = bgCrafts.scrollbar:GetScript("OnValueChanged") + bgCrafts.scrollbar:SetScript("OnValueChanged", function(self, value, ...) + offset = math.floor(value) + RefreshCrafts() + return f(self, value, ...) + end) + + bgCrafts:EnableMouseWheel() + bgCrafts:SetScript("OnMouseWheel", function(self, val) + bgCrafts.scrollbar:SetValue(bgCrafts.scrollbar:GetValue() - val*#tRows/2) + end) +end + +local function DoCrafts() + if not BagSync or not BagSyncCRAFT_DB then return end + if not BagSyncCRAFT_DB[currentRealm] then return end + + craftsTable = {} --reset + local tmp = {} + + --loop through our characters + ----------------------------------- + if BagSyncCRAFT_DB[currentRealm] then + for k, v in pairs(BagSyncCRAFT_DB[currentRealm]) do + + tmp = {} + for q, r in pairs(v) do + if type(r) == "string" then + local trName, trSkillLevel = strsplit(",", r) + if trName and trSkillLevel then + table.insert(tmp, { name=trName, level=trSkillLevel, isLink=false, owner=k} ) + end + elseif type(r) == "table" and r[1] and r[2] and r[3] then + table.insert(tmp, { name=r[1], link=r[2], level=r[3], isLink=true, owner=k} ) + end + end + table.sort(tmp, function(a,b) return (a.name < b.name) end) + + --now add it to master table to sort later, only add if we have something to add + if #tmp > 0 then + table.insert(craftsTable, {header=k, info=tmp}) + end + end + end + ----------------------------------- + + --sort it + table.sort(craftsTable, function(a,b) + if a.header < b.header then + return true; + end + end) + + --now that the header names are sorted lets add all headers and info to master table + tmp = {} --reset + + for i=1, #craftsTable do + --insert header + table.insert(tmp, { name=craftsTable[i].header, isHeader=true } ) + --insert sub information :) + for y=1, #craftsTable[i].info do + table.insert(tmp, craftsTable[i].info[y]) + end + end + craftsTable = tmp + + LoadSlider() +end + +bgCrafts:SetFrameStrata("HIGH") +bgCrafts:SetToplevel(true) +bgCrafts:EnableMouse(true) +bgCrafts:SetMovable(true) +bgCrafts:SetClampedToScreen(true) +bgCrafts:SetWidth(380) +bgCrafts:SetHeight(500) + +bgCrafts:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 16, + edgeSize = 32, + insets = { left = 5, right = 5, top = 5, bottom = 5 } +}) + +bgCrafts:SetBackdropColor(0,0,0,1) +bgCrafts:SetPoint("CENTER", UIParent, "CENTER", 0, 0) + +local addonTitle = bgCrafts:CreateFontString(nil, "BACKGROUND", "GameFontNormal") +addonTitle:SetPoint("CENTER", bgCrafts, "TOP", 0, -20) +addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Professions"]..")|r") + +local closeButton = CreateFrame("Button", nil, bgCrafts, "UIPanelCloseButton"); +closeButton:SetPoint("TOPRIGHT", bgCrafts, -15, -8); + +bgCrafts:SetScript("OnShow", function(self) DoCrafts(); LoadSlider(); end) +bgCrafts:SetScript("OnHide", function(self) + craftsTable = {} +end) + +bgCrafts:SetScript("OnMouseDown", function(frame, button) + if frame:IsMovable() then + frame.isMoving = true + frame:StartMoving() + end +end) + +bgCrafts:SetScript("OnMouseUp", function(frame, button) + if( frame.isMoving ) then + frame.isMoving = nil + frame:StopMovingOrSizing() + end +end) + +bgCrafts:Hide() \ No newline at end of file diff --git a/modules/profiles.lua b/modules/profiles.lua new file mode 100644 index 0000000..665043d --- /dev/null +++ b/modules/profiles.lua @@ -0,0 +1,158 @@ +local L = BAGSYNC_L +local currentPlayer = UnitName("player") +local currentRealm = select(2, UnitFullName("player")) +local bgProfiles = CreateFrame("Frame","BagSync_ProfilesFrame", UIParent) + +--lets do the dropdown menu of DOOM +local bgsProfilesDD = CreateFrame("Frame", "bgsProfilesDD") +bgsProfilesDD.displayMode = "MENU" + +local function addButton(level, text, isTitle, notCheckable, hasArrow, value, func) + local info = UIDropDownMenu_CreateInfo() + info.text = text + info.isTitle = isTitle + info.notCheckable = notCheckable + info.hasArrow = hasArrow + info.value = value + info.func = func + UIDropDownMenu_AddButton(info, level) +end + +bgsProfilesDD.initialize = function(self, level) + if not BagSync or not BagSyncDB then return end + + local tmp = {} + + --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[1] < b[1]) end) + + if level == 1 then + PlaySound("gsTitleOptionExit") + + for i=1, #tmp do + 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][1].." - "..tmp[i][3]) + end + end) + end + + addButton(level, "", nil, 1) --space ;) + addButton(level, L["Close"], nil, 1) + + end + +end + +bgProfiles:SetFrameStrata("HIGH") +bgProfiles:SetToplevel(true) +bgProfiles:EnableMouse(true) +bgProfiles:SetMovable(true) +bgProfiles:SetClampedToScreen(true) +bgProfiles:SetWidth(280) +bgProfiles:SetHeight(150) + +bgProfiles:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 16, + edgeSize = 32, + insets = { left = 5, right = 5, top = 5, bottom = 5 } +}) + +bgProfiles:SetBackdropColor(0,0,0,1) +bgProfiles:SetPoint("CENTER", UIParent, "CENTER", 0, 0) + +local addonTitle = bgProfiles:CreateFontString(nil, "BACKGROUND", "GameFontNormal") +addonTitle:SetPoint("CENTER", bgProfiles, "TOP", 0, -20) +addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Profiles"]..")|r") + +local closeButton = CreateFrame("Button", nil, bgProfiles, "UIPanelCloseButton"); +closeButton:SetPoint("TOPRIGHT", bgProfiles, -15, -8); + +local warningLabel = bgProfiles:CreateFontString(nil, "BACKGROUND", "GameFontNormal") +warningLabel:SetPoint("CENTER", bgProfiles, 0, 29) +warningLabel:SetText("|cFFDF2B2B"..L["Select a profile to delete.\nNOTE: This is irreversible!"].."|r") +bgProfiles.warningLabel = warningLabel + +local buttonText = bgProfiles:CreateFontString("BagSyncProfilesToonNameText", nil, "GameFontNormal") +buttonText:SetText(L["Click Here"]) +buttonText:SetPoint("CENTER") + +bgProfiles.toonName = CreateFrame("Button", "BagSyncProfilesToonName", bgProfiles); +bgProfiles.toonName:SetPoint("CENTER", bgProfiles, 0, 0) +bgProfiles.toonName:SetHeight(21); +bgProfiles.toonName:SetWidth(266); +bgProfiles.toonName:SetFontString(buttonText) +bgProfiles.toonName:SetBackdrop({ + bgFile = "Interface\\Buttons\\WHITE8x8", +}) +bgProfiles.toonName:SetBackdropColor(0,1,0,0.25) +bgProfiles.toonName:SetScript("OnClick", function() ToggleDropDownMenu(1, nil, bgsProfilesDD, "cursor", 0, 0) end) +bgProfiles.toonName.text = buttonText + +bgProfiles.deleteButton = CreateFrame("Button", nil, bgProfiles, "UIPanelButtonTemplate"); +bgProfiles.deleteButton:SetPoint("BOTTOM", bgProfiles, "BOTTOM", -70, 20); +bgProfiles.deleteButton:SetHeight(21); +bgProfiles.deleteButton:SetWidth(100); +bgProfiles.deleteButton:SetText(L["Delete"]); +bgProfiles.deleteButton:SetScript("OnClick", function() BagSync_ProfilesFrame.confirmButton:Enable() end) + +bgProfiles.confirmButton = CreateFrame("Button", nil, bgProfiles, "UIPanelButtonTemplate"); +bgProfiles.confirmButton:SetPoint("BOTTOM", bgProfiles, "BOTTOM", 70, 20); +bgProfiles.confirmButton:SetHeight(21); +bgProfiles.confirmButton:SetWidth(100); +bgProfiles.confirmButton:SetText(L["Confirm"]); +bgProfiles.confirmButton:Disable() + +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 + + bgProfiles.confirmButton:Disable() +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 + frame.isMoving = true + frame:StartMoving() + end +end) + +bgProfiles:SetScript("OnMouseUp", function(frame, button) + if( frame.isMoving ) then + frame.isMoving = nil + frame:StopMovingOrSizing() + end +end) + +bgProfiles:Hide() \ No newline at end of file diff --git a/modules/search.lua b/modules/search.lua new file mode 100644 index 0000000..48e3d2a --- /dev/null +++ b/modules/search.lua @@ -0,0 +1,372 @@ +local L = BAGSYNC_L +local searchTable = {} +local rows, anchor = {} +local currentRealm = select(2, UnitFullName("player")) +local GetItemInfo = _G["GetItemInfo"] +local currentPlayer = UnitName("player") + +local ItemSearch = LibStub("LibItemSearch-1.0") +local bgSearch = CreateFrame("Frame","BagSync_SearchFrame", UIParent) + +--add class search +local tooltipScanner = _G["LibItemSearchTooltipScanner"] or CreateFrame("GameTooltip", "LibItemSearchTooltipScanner", UIParent, "GameTooltipTemplate") +local tooltipCache = setmetatable({}, {__index = function(t, k) local v = {} t[k] = v return v end}) + +ItemSearch:RegisterTypedSearch{ + id = "classRestriction", + tags = {"c", "class"}, + + canSearch = function(self, _, search) + return search + end, + + findItem = function(self, link, _, search) + if link:find("battlepet") then return false end + + local itemID = link:match("item:(%d+)") + if not itemID then + return + end + + local cachedResult = tooltipCache[search][itemID] + if cachedResult ~= nil then + return cachedResult + end + + tooltipScanner:SetOwner(UIParent, "ANCHOR_NONE") + tooltipScanner:SetHyperlink(link) + + local result = false + + local pattern = string.gsub(ITEM_CLASSES_ALLOWED:lower(), "%%s", "(.+)") + + for i = 1, tooltipScanner:NumLines() do + local text = _G[tooltipScanner:GetName() .. "TextLeft" .. i]:GetText():lower() + local textChk = string.find(text, pattern) + + if textChk and tostring(text):find(search) then + result = true + end + end + + tooltipCache[search][itemID] = result + return result + end, +} + +local function LoadSlider() + + local function OnEnter(self) + if self.link then + GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT") + GameTooltip:SetHyperlink(self.link) + GameTooltip:Show() + end + end + local function OnLeave() GameTooltip:Hide() end + + local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 16, 20, 2, 4 + local FRAME_HEIGHT = bgSearch:GetHeight() - 60 + local SCROLL_TOP_POSITION = -90 + local totalRows = math.floor((FRAME_HEIGHT-22)/(ROWHEIGHT + ROWGAP)) + + for i=1, totalRows do + if not rows[i] then + local row = CreateFrame("Button", "BagSyncSearchRow"..i, bgSearch) + if not anchor then row:SetPoint("BOTTOMLEFT", bgSearch, "TOPLEFT", 0, SCROLL_TOP_POSITION) + else row:SetPoint("TOP", anchor, "BOTTOM", 0, -ROWGAP) end + row:SetPoint("LEFT", EDGEGAP, 0) + row:SetPoint("RIGHT", -EDGEGAP*2-8, 0) + row:SetHeight(ROWHEIGHT) + row:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") + anchor = row + rows[i] = row + + local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal") + title:SetPoint("LEFT") + title:SetJustifyH("LEFT") + title:SetWidth(row:GetWidth()) + title:SetHeight(ROWHEIGHT) + row.title = title + + row:SetScript("OnEnter", OnEnter) + row:SetScript("OnLeave", OnLeave) + row:SetScript("OnClick", function(self) + if self.link then + if HandleModifiedItemClick(self.link) then + return + end + if IsModifiedClick("CHATLINK") then + local editBox = ChatEdit_ChooseBoxForSend() + if editBox then + editBox:Insert(self.link) + ChatFrame_OpenChat(editBox:GetText()) + end + end + end + end) + end + end + + local offset = 0 + local RefreshSearch = function() + if not BagSync_SearchFrame:IsVisible() then return end + for i,row in ipairs(rows) do + if (i + offset) <= #searchTable then + if searchTable[i + offset] then + if searchTable[i + offset].rarity then + --local hex = (select(4, GetItemQualityColor(searchTable[i + offset].rarity))) + local hex = (select(4, GetItemQualityColor(searchTable[i + offset].rarity))) + row.title:SetText(format("|c%s%s|r", hex, searchTable[i + offset].name) or searchTable[i + offset].name) + else + row.title:SetText(searchTable[i + offset].name) + end + row.link = searchTable[i + offset].link + row:Show() + end + else + row.title:SetText(nil) + row:Hide() + end + end + end + + RefreshSearch() + + if not bgSearch.scrollbar then + bgSearch.scrollbar = LibStub("tekKonfig-Scroll").new(bgSearch, nil, #rows/2) + bgSearch.scrollbar:ClearAllPoints() + bgSearch.scrollbar:SetPoint("TOP", rows[1], 0, -16) + bgSearch.scrollbar:SetPoint("BOTTOM", rows[#rows], 0, 16) + bgSearch.scrollbar:SetPoint("RIGHT", -16, 0) + end + + if #searchTable > 0 then + bgSearch.scrollbar:SetMinMaxValues(0, math.max(0, #searchTable - #rows)) + bgSearch.scrollbar:SetValue(0) + bgSearch.scrollbar:Show() + else + bgSearch.scrollbar:Hide() + end + + local f = bgSearch.scrollbar:GetScript("OnValueChanged") + bgSearch.scrollbar:SetScript("OnValueChanged", function(self, value, ...) + offset = math.floor(value) + RefreshSearch() + return f(self, value, ...) + end) + + bgSearch:EnableMouseWheel() + bgSearch:SetScript("OnMouseWheel", function(self, val) + bgSearch.scrollbar:SetValue(bgSearch.scrollbar:GetValue() - val*#rows/2) + end) +end + +--do search routine +local function DoSearch() + if not BagSync or not BagSyncDB then return end + local searchStr = bgSearch.SEARCHBTN:GetText() + + searchStr = searchStr:lower() + + searchTable = {} --reset + + local tempList = {} + local previousGuilds = {} + local count = 0 + local playerSearch = false + + if strlen(searchStr) > 0 then + + local playerFaction = UnitFactionGroup("player") + local allowList = { + ["bag"] = 0, + ["bank"] = 0, + ["equip"] = 0, + ["mailbox"] = 0, + ["void"] = 0, + ["auction"] = 0, + ["guild"] = 0, + ["reagentbank"] = 0, + } + + if string.len(searchStr) > 1 and string.find(searchStr, "@") and allowList[string.sub(searchStr, 2)] ~= nil then playerSearch = true end + + local xDB = BagSync:getFilteredDB() + + --loop through our characters + --k = player, v = stored data for player + for k, v in pairs(xDB) do + + local pFaction = v.faction or playerFaction --just in case ;) if we dont know the faction yet display it anyways + local yName, yRealm = strsplit("^", k) + + --check if we should show both factions or not + if BagSyncOpt.enableFaction or pFaction == playerFaction then + + --now count the stuff for the user + --q = bag name, r = stored data for bag name + for q, r in pairs(v) do + --only loop through table items we want + if allowList[q] and type(r) == "table" then + --bagID = bag name bagID, bagInfo = data of specific bag with bagID + for bagID, bagInfo in pairs(r) do + --slotID = slotid for specific bagid, itemValue = data of specific slotid + if type(bagInfo) == "table" then + for slotID, itemValue in pairs(bagInfo) do + local dblink, dbcount = strsplit(",", itemValue) + if dblink then + local dName, dItemLink, dRarity = GetItemInfo(dblink) + if dName and dItemLink then + --are we checking in our bank,void, etc? + if playerSearch and string.sub(searchStr, 2) == q and string.sub(searchStr, 2) ~= "guild" and yName == currentPlayer and not tempList[dblink] then + table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) + tempList[dblink] = dName + count = count + 1 + --we found a match + elseif not playerSearch and not tempList[dblink] and ItemSearch:Find(dItemLink, searchStr) then + table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) + tempList[dblink] = dName + count = count + 1 + end + end + end + end + end + end + end + end + + if BagSyncOpt.enableGuild then + local guildN = v.guild or nil + + --check the guild bank if the character is in a guild + if BagSyncGUILD_DB and guildN and BagSyncGUILD_DB[v.realm][guildN] then + --check to see if this guild has already been done through this run (so we don't do it multiple times) + --check for XR/B.Net support + local gName = BagSync:getGuildRealmInfo(guildN, v.realm) + + if not previousGuilds[gName] then + --we only really need to see this information once per guild + for q, r in pairs(BagSyncGUILD_DB[v.realm][guildN]) do + local dblink, dbcount = strsplit(",", r) + if dblink then + local dName, dItemLink, dRarity = GetItemInfo(dblink) + if dName then + if playerSearch and string.sub(searchStr, 2) == "guild" and GetGuildInfo("player") and guildN == GetGuildInfo("player") and not tempList[dblink] then + table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) + tempList[dblink] = dName + count = count + 1 + --we found a match + elseif not playerSearch and not tempList[dblink] and ItemSearch:Find(dItemLink, searchStr) then + table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) + tempList[dblink] = dName + count = count + 1 + end + end + end + end + previousGuilds[gName] = true + end + end + end + + end + + end + + table.sort(searchTable, function(a,b) return (a.name < b.name) end) + end + + bgSearch.totalC:SetText("|cFFFFFFFF"..L["Total:"].." "..count.."|r") + + LoadSlider() +end + +local function escapeEditBox(self) + self:SetAutoFocus(false) +end + +local function enterEditBox(self) + self:ClearFocus() + --self:GetParent():DoSearch() + DoSearch() +end + +local function createEditBox(name, labeltext, obj, x, y) + local editbox = CreateFrame("EditBox", name, obj, "InputBoxTemplate") + editbox:SetAutoFocus(false) + editbox:SetWidth(180) + editbox:SetHeight(16) + editbox:SetPoint("TOPLEFT", obj, "TOPLEFT", x or 0, y or 0) + local label = editbox:CreateFontString(nil, "ARTWORK", "GameFontNormal") + label:SetPoint("BOTTOMLEFT", editbox, "TOPLEFT", -6, 4) + label:SetText(labeltext) + editbox:SetScript("OnEnterPressed", enterEditBox) + editbox:HookScript("OnEscapePressed", escapeEditBox) + return editbox +end + +bgSearch:SetFrameStrata("HIGH") +bgSearch:SetToplevel(true) +bgSearch:EnableMouse(true) +bgSearch:SetMovable(true) +bgSearch:SetClampedToScreen(true) +bgSearch:SetWidth(380) +bgSearch:SetHeight(500) + +bgSearch:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 16, + edgeSize = 32, + insets = { left = 5, right = 5, top = 5, bottom = 5 } +}) + +bgSearch:SetBackdropColor(0,0,0,1) +bgSearch:SetPoint("CENTER", UIParent, "CENTER", 0, 0) + +bgSearch.SEARCHBTN = createEditBox("$parentEdit1", (L["Search"]..":"), bgSearch, 60, -50) + +local addonTitle = bgSearch:CreateFontString(nil, "BACKGROUND", "GameFontNormal") +addonTitle:SetPoint("CENTER", bgSearch, "TOP", 0, -20) +addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Search"]..")|r") + +local totalC = bgSearch:CreateFontString(nil, "BACKGROUND", "GameFontNormal") +totalC:SetPoint("RIGHT", bgSearch.SEARCHBTN, 70, 0) +totalC:SetText("|cFFFFFFFF"..L["Total:"].." 0|r") +bgSearch.totalC = totalC + +local closeButton = CreateFrame("Button", nil, bgSearch, "UIPanelCloseButton"); +closeButton:SetPoint("TOPRIGHT", bgSearch, -15, -8); + +bgSearch:SetScript("OnShow", function(self) + LoadSlider() + self.SEARCHBTN:SetFocus() +end) +bgSearch:SetScript("OnHide", function(self) + searchTable = {} + self.SEARCHBTN:SetText("") + self.totalC:SetText("|cFFFFFFFF"..L["Total:"].." 0|r") +end) + +bgSearch:SetScript("OnMouseDown", function(frame, button) + if frame:IsMovable() then + frame.isMoving = true + frame:StartMoving() + end +end) + +bgSearch:SetScript("OnMouseUp", function(frame, button) + if( frame.isMoving ) then + frame.isMoving = nil + frame:StopMovingOrSizing() + end +end) + +function bgSearch:initSearch() + DoSearch() +end + +bgSearch:Hide() diff --git a/modules/tokens.lua b/modules/tokens.lua new file mode 100644 index 0000000..626ba3f --- /dev/null +++ b/modules/tokens.lua @@ -0,0 +1,238 @@ +local L = BAGSYNC_L +local tokensTable = {} +local tRows, tAnchor = {} +local currentPlayer = UnitName("player") +local currentRealm = select(2, UnitFullName("player")) +local GetItemInfo = _G["GetItemInfo"] + +local bgTokens = CreateFrame("Frame","BagSync_TokensFrame", UIParent) + +local function tooltipColor(color, str) + return string.format("|cff%02x%02x%02x%s|r", (color.r or 1) * 255, (color.g or 1) * 255, (color.b or 1) * 255, str) +end + +local function LoadSlider() + + local function OnEnter(self) + if self.name and self.tooltip then + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:AddLine(self.name) + GameTooltip:AddLine(" ") + for i=1, #self.tooltip do + GameTooltip:AddDoubleLine(tooltipColor(BagSyncOpt.colors.FIRST, self.tooltip[i].name), tooltipColor(BagSyncOpt.colors.SECOND, self.tooltip[i].count)) + end + GameTooltip:Show() + end + end + + local function OnLeave() GameTooltip:Hide() end + + local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 40, 20, 2, 4 + local FRAME_HEIGHT = bgTokens:GetHeight() - 50 + local SCROLL_TOP_POSITION = -80 + local totaltRows = math.floor((FRAME_HEIGHT-22)/(ROWHEIGHT + ROWGAP)) + + for i=1, totaltRows do + if not tRows[i] then + local row = CreateFrame("Button", nil, bgTokens) + if not tAnchor then row:SetPoint("BOTTOMLEFT", bgTokens, "TOPLEFT", 0, SCROLL_TOP_POSITION) + else row:SetPoint("TOP", tAnchor, "BOTTOM", 0, -ROWGAP) end + row:SetPoint("LEFT", EDGEGAP, 0) + row:SetPoint("RIGHT", -EDGEGAP*1-8, 0) + row:SetHeight(ROWHEIGHT) + row:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") + tAnchor = row + tRows[i] = row + + local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal") + title:SetPoint("LEFT") + title:SetJustifyH("LEFT") + title:SetWidth(row:GetWidth()) + title:SetHeight(ROWHEIGHT) + row.title = title + + local icon = row:CreateTexture(nil,"OVERLAY") + icon:SetPoint("LEFT", (ROWHEIGHT * -1) -3, 0) + icon:SetWidth(ROWHEIGHT) + icon:SetHeight(ROWHEIGHT) + icon:SetTexture("Interface\\Icons\\Spell_Shadow_Shadowbolt") + icon:Hide() + row.icon = icon + + row:SetScript("OnEnter", OnEnter) + row:SetScript("OnLeave", OnLeave) + end + end + + local offset = 0 + local RefreshTokens = function() + if not BagSync_TokensFrame:IsVisible() then return end + + for i,row in ipairs(tRows) do + if (i + offset) <= #tokensTable then + if tokensTable[i + offset] then + + if tokensTable[i + offset].isHeader then + row.title:SetText("|cFFFFFFFF"..tokensTable[i + offset].name.."|r") + else + row.title:SetText(tokensTable[i + offset].name) + end + + --header texture and parameters + if tokensTable[i + offset].isHeader then + row:LockHighlight() + row.title:SetJustifyH("CENTER") + row.tooltip = nil + else + row:UnlockHighlight() + row.title:SetJustifyH("LEFT") + row.name = row.title:GetText() + row.tooltip = tokensTable[i + offset].tooltip + end + + row.icon:SetTexture(tokensTable[i + offset].icon or nil) + row.icon:Show() + row:Show() + end + else + row.icon:SetTexture(nil) + row.icon:Hide() + row:Hide() + end + end + end + + RefreshTokens() + + if not bgTokens.scrollbar then + bgTokens.scrollbar = LibStub("tekKonfig-Scroll").new(bgTokens, nil, #tRows/2) + bgTokens.scrollbar:ClearAllPoints() + bgTokens.scrollbar:SetPoint("TOP", tRows[1], 0, -16) + bgTokens.scrollbar:SetPoint("BOTTOM", tRows[#tRows], 0, 16) + bgTokens.scrollbar:SetPoint("RIGHT", -16, 0) + end + + if #tokensTable > 0 then + bgTokens.scrollbar:SetMinMaxValues(0, math.max(0, #tokensTable - #tRows)) + bgTokens.scrollbar:SetValue(0) + bgTokens.scrollbar:Show() + else + bgTokens.scrollbar:Hide() + end + + local f = bgTokens.scrollbar:GetScript("OnValueChanged") + bgTokens.scrollbar:SetScript("OnValueChanged", function(self, value, ...) + offset = math.floor(value) + RefreshTokens() + return f(self, value, ...) + end) + + bgTokens:EnableMouseWheel() + bgTokens:SetScript("OnMouseWheel", function(self, val) + bgTokens.scrollbar:SetValue(bgTokens.scrollbar:GetValue() - val*#tRows/2) + end) +end + +local function DoTokens() + if not BagSync or not BagSyncTOKEN_DB then return end + if not BagSyncTOKEN_DB[currentRealm] then return end + + tokensTable = {} --reset + local tmp = {} + + --loop through our characters + ----------------------------------- + if BagSyncTOKEN_DB[currentRealm] then + for k, v in pairs(BagSyncTOKEN_DB[currentRealm]) do + + tmp = {} + --this will loop and store all characters whom have counts greater then zero, + --ignoring the icon and header table entry, then it sorts it by character name + for q, r in pairs(v) do + if q ~= "icon" and q ~= "header" and r > 0 then + --only show counts that are greater then zero + table.insert(tmp, { name=q, count=r} ) + end + end + table.sort(tmp, function(a,b) return (a.name < b.name) end) + + --now add it to master table to sort later + table.insert(tokensTable, {name=k, icon=v.icon, header=v.header, tooltip=tmp}) + end + end + ----------------------------------- + + --sort it + table.sort(tokensTable, function(a,b) + if a.header < b.header then + return true; + elseif a.header == b.header then + return (a.name < b.name); + end + end) + + --add headers + local lastHeader = "" + tmp = {} --reset + + for i=1, #tokensTable do + if tokensTable[i].header ~= lastHeader then + lastHeader = tokensTable[i].header + table.insert(tmp, { name=lastHeader, header=lastHeader, isHeader=true } ) + table.insert(tmp, tokensTable[i]) + else + table.insert(tmp, tokensTable[i]) + end + end + tokensTable = tmp + + LoadSlider() +end + +bgTokens:SetFrameStrata("HIGH") +bgTokens:SetToplevel(true) +bgTokens:EnableMouse(true) +bgTokens:SetMovable(true) +bgTokens:SetClampedToScreen(true) +bgTokens:SetWidth(380) +bgTokens:SetHeight(500) + +bgTokens:SetBackdrop({ + bgFile = "Interface/Tooltips/UI-Tooltip-Background", + edgeFile = "Interface/Tooltips/UI-Tooltip-Border", + tile = true, + tileSize = 16, + edgeSize = 32, + insets = { left = 5, right = 5, top = 5, bottom = 5 } +}) + +bgTokens:SetBackdropColor(0,0,0,1) +bgTokens:SetPoint("CENTER", UIParent, "CENTER", 0, 0) + +local addonTitle = bgTokens:CreateFontString(nil, "BACKGROUND", "GameFontNormal") +addonTitle:SetPoint("CENTER", bgTokens, "TOP", 0, -20) +addonTitle:SetText("|cFF99CC33BagSync|r |cFFFFFFFF("..L["Tokens"]..")|r") + +local closeButton = CreateFrame("Button", nil, bgTokens, "UIPanelCloseButton"); +closeButton:SetPoint("TOPRIGHT", bgTokens, -15, -8); + +bgTokens:SetScript("OnShow", function(self) DoTokens(); LoadSlider(); end) +bgTokens:SetScript("OnHide", function(self) + tokensTable = {} +end) + +bgTokens:SetScript("OnMouseDown", function(frame, button) + if frame:IsMovable() then + frame.isMoving = true + frame:StartMoving() + end +end) + +bgTokens:SetScript("OnMouseUp", function(frame, button) + if( frame.isMoving ) then + frame.isMoving = nil + frame:StopMovingOrSizing() + end +end) + +bgTokens:Hide() \ No newline at end of file