diff --git a/BagSync.lua b/BagSync.lua index 62944a5..1819a6d 100644 --- a/BagSync.lua +++ b/BagSync.lua @@ -837,7 +837,7 @@ function BagSync:IsInBG() return true end local status, mapName, instanceID, minlevel, maxlevel - for i=1, MAX_BATTLEFIELD_QUEUES do + for i=1, GetMaxBattlefieldID() do status, mapName, instanceID, minlevel, maxlevel, teamSize = GetBattlefieldStatus(i) if status == "active" then return true diff --git a/BagSync.toc b/BagSync.toc index 8d8f46d..8ab9ef7 100644 --- a/BagSync.toc +++ b/BagSync.toc @@ -1,8 +1,8 @@ -## Interface: 40200 +## Interface: 40300 ## Title: BagSync ## Notes: BagSync tracks your characters items and displays it within tooltips. ## Author: Xruptor -## Version: 6.5.1 +## Version: 6.5.2 ## SavedVariables: BagSyncDB, BagSyncOpt, BagSyncGUILD_DB, BagSyncTOKEN_DB localization\localization.lua diff --git a/BagSync_Profiles.lua b/BagSync_Profiles.lua index f70bfe5..7024e87 100644 --- a/BagSync_Profiles.lua +++ b/BagSync_Profiles.lua @@ -4,6 +4,51 @@ local currentRealm = GetRealmName() local bgProfiles = CreateFrame("Frame","BagSync_ProfilesFrame", UIParent) +local function LoadProfiles() + if not BagSync or not BagSyncDB then return end + if not BagSyncDB[currentRealm] then return end + + local profile_DD, profile_DD_text, profile_DD_container, profile_DD_label = LibStub("tekKonfig-Dropdown").new(bgProfiles, L["Profiles"], "CENTER", bgProfiles, "CENTER", -25, 0) + + profile_DD_container:SetHeight(28) + profile_DD:SetWidth(180) + profile_DD:ClearAllPoints() + profile_DD:SetPoint("LEFT", profile_DD_label, "RIGHT", -8, -2) + profile_DD_text:SetText(' ') + profile_DD.tiptext = L["Select a profile to delete.\nNOTE: This is irreversible!"] + + bgProfiles.DDText = profile_DD_text + + local function OnClick(self) + profile_DD_text:SetText(self.value) + GameTooltip:Hide() + end + + local tmp = {} + + --freaking LUA table.sort is terrible, you can't sort non-numeric keys.. + for k, v in pairs(BagSyncDB[currentRealm]) do + table.insert(tmp, k) + end + table.sort(tmp, function(a,b) return (a < b) end) + + UIDropDownMenu_Initialize(profile_DD, function() + local info = UIDropDownMenu_CreateInfo() + + info.func = OnClick + + --display sorted listed of names + for i=1, #tmp do + info.text = tmp[i] + info.value = tmp[i] + info.notCheckable = true + UIDropDownMenu_AddButton(info) + end + + end) + +end + bgProfiles:SetFrameStrata("HIGH") bgProfiles:SetToplevel(true) bgProfiles:EnableMouse(true) @@ -60,7 +105,7 @@ bgProfiles.confirmButton:SetScript("OnClick", function() end) -bgProfiles:SetScript("OnShow", function(self) self:LoadProfiles() end) +bgProfiles:SetScript("OnShow", function(self) LoadProfiles() end) bgProfiles:SetScript("OnHide", function(self) GameTooltip:Hide() end) bgProfiles:SetScript("OnMouseDown", function(frame, button) @@ -77,49 +122,4 @@ bgProfiles:SetScript("OnMouseUp", function(frame, button) end end) -function bgProfiles:LoadProfiles() - if not BagSync or not BagSyncDB then return end - if not BagSyncDB[currentRealm] then return end - - local profile_DD, profile_DD_text, profile_DD_container, profile_DD_label = LibStub("tekKonfig-Dropdown").new(bgProfiles, L["Profiles"], "CENTER", bgProfiles, "CENTER", -25, 0) - - profile_DD_container:SetHeight(28) - profile_DD:SetWidth(180) - profile_DD:ClearAllPoints() - profile_DD:SetPoint("LEFT", profile_DD_label, "RIGHT", -8, -2) - profile_DD_text:SetText(' ') - profile_DD.tiptext = L["Select a profile to delete.\nNOTE: This is irreversible!"] - - bgProfiles.DDText = profile_DD_text - - local function OnClick(self) - profile_DD_text:SetText(self.value) - GameTooltip:Hide() - end - - local tmp = {} - - --freaking LUA table.sort is terrible, you can't sort non-numeric keys.. - for k, v in pairs(BagSyncDB[currentRealm]) do - table.insert(tmp, k) - end - table.sort(tmp, function(a,b) return (a < b) end) - - UIDropDownMenu_Initialize(profile_DD, function() - local info = UIDropDownMenu_CreateInfo() - - info.func = OnClick - - --display sorted listed of names - for i=1, #tmp do - info.text = tmp[i] - info.value = tmp[i] - info.notCheckable = true - UIDropDownMenu_AddButton(info) - end - - end) - -end - bgProfiles:Hide() \ No newline at end of file diff --git a/BagSync_Search.lua b/BagSync_Search.lua index ce10f9b..b96efbe 100644 --- a/BagSync_Search.lua +++ b/BagSync_Search.lua @@ -5,91 +5,9 @@ local currentRealm = GetRealmName() local GetItemInfo = _G['GetItemInfo'] local ItemSearch = LibStub('LibItemSearch-1.0') - local bgSearch = CreateFrame("Frame","BagSync_SearchFrame", UIParent) -local function escapeEditBox(self) - self:SetAutoFocus(false) -end - -local function enterEditBox(self) - self:ClearFocus() - self:GetParent():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) - 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:LoadSlider() +local function LoadSlider() local function OnEnter(self) if self.link then @@ -198,7 +116,7 @@ function bgSearch:LoadSlider() end --do search routine -function bgSearch:DoSearch() +local function DoSearch() if not BagSync or not BagSyncDB then return end local searchStr = bgSearch.SEARCHBTN:GetText() @@ -277,7 +195,89 @@ function bgSearch:DoSearch() bgSearch.totalC:SetText("|cFFFFFFFF"..L["Total:"].." "..count.."|r") - bgSearch:LoadSlider() + 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) + bgSearch:Hide() diff --git a/BagSync_Tokens.lua b/BagSync_Tokens.lua index b30e653..f9d7e28 100644 --- a/BagSync_Tokens.lua +++ b/BagSync_Tokens.lua @@ -4,60 +4,12 @@ local tRows, tAnchor = {} local currentPlayer = UnitName('player') local currentRealm = GetRealmName() local GetItemInfo = _G['GetItemInfo'] - -local bgTokens = CreateFrame("Frame","BagSync_TokensFrame", UIParent) - -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) self:DoTokens() self: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) - - local SILVER = '|cffc7c7cf%s|r' local MOSS = '|cFF80FF00%s|r' -function bgTokens:LoadSlider() +local bgTokens = CreateFrame("Frame","BagSync_TokensFrame", UIParent) + +local function LoadSlider() local function OnEnter(self) if self.name and self.tooltip then @@ -178,7 +130,7 @@ function bgTokens:LoadSlider() end) end -function bgTokens:DoTokens() +local function DoTokens() if not BagSync or not BagSyncTOKEN_DB then return end if not BagSyncTOKEN_DB[currentRealm] then return end @@ -231,7 +183,53 @@ function bgTokens:DoTokens() end tokensTable = tmp - bgTokens:LoadSlider() + 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