diff --git a/Locales/Locales.xml b/Locales/Locales.xml
index 30f6201..afcb44a 100644
--- a/Locales/Locales.xml
+++ b/Locales/Locales.xml
@@ -1,4 +1,4 @@
-
-
-
+
+
+
diff --git a/Locales/enUS.lua b/Locales/enUS.lua
index 126bf6c..de58547 100644
--- a/Locales/enUS.lua
+++ b/Locales/enUS.lua
@@ -1,8 +1,8 @@
--- SafeQueue Locale
--- https://www.curseforge.com/wow/addons/safequeue/localization
-
-local L = LibStub("AceLocale-3.0"):NewLocale("SafeQueue", "enUS", true)
-
-L["Queue popped after %s"] = true
-L["Queue popped instantly!"] = true
-L["SafeQueue expires in |cff%s%s|r"] = true
+-- SafeQueue Locale
+-- https://www.curseforge.com/wow/addons/safequeue/localization
+
+local L = LibStub("AceLocale-3.0"):NewLocale("SafeQueue", "enUS", true)
+
+L["Queue popped after %s"] = true
+L["Queue popped instantly!"] = true
+L["SafeQueue expires in |cff%s%s|r"] = true
diff --git a/Media/Textures/ablogo.png b/Media/Textures/ablogo.png
new file mode 100644
index 0000000..c4d9a52
Binary files /dev/null and b/Media/Textures/ablogo.png differ
diff --git a/Media/Textures/avlogo.png b/Media/Textures/avlogo.png
new file mode 100644
index 0000000..28136fb
Binary files /dev/null and b/Media/Textures/avlogo.png differ
diff --git a/Media/Textures/test.png b/Media/Textures/test.png
new file mode 100644
index 0000000..d392f7e
Binary files /dev/null and b/Media/Textures/test.png differ
diff --git a/Media/Textures/wsglogo.png b/Media/Textures/wsglogo.png
new file mode 100644
index 0000000..82ce37b
Binary files /dev/null and b/Media/Textures/wsglogo.png differ
diff --git a/SafeQueue.lua b/SafeQueue.lua
index 80c7a16..da93281 100644
--- a/SafeQueue.lua
+++ b/SafeQueue.lua
@@ -1,112 +1,112 @@
-
--- SafeQueue by Jordon
-
-local SafeQueue = SafeQueue
-local L = LibStub("AceLocale-3.0"):GetLocale("SafeQueue")
-
-local CreateFrame = CreateFrame
-local DEFAULT_CHAT_FRAME = DEFAULT_CHAT_FRAME
-local GetBattlefieldPortExpiration = GetBattlefieldPortExpiration
-local GetBattlefieldStatus = GetBattlefieldStatus
-local GetBattlefieldTimeWaited = GetBattlefieldTimeWaited
-local GetMaxBattlefieldID = GetMaxBattlefieldID
-local GetTime = GetTime
-local PVPReadyDialog = PVPReadyDialog
-local PVPReadyDialog_Display = PVPReadyDialog_Display
-local SecondsToTime = SecondsToTime
-local TOOLTIP_UPDATE_TIME = TOOLTIP_UPDATE_TIME
-local WOW_PROJECT_ID = WOW_PROJECT_ID
-local WOW_PROJECT_MAINLINE = WOW_PROJECT_MAINLINE
-local format = format
-local hooksecurefunc = hooksecurefunc
-
-function SafeQueue:SetExpiresText()
- local battlefieldId = self.battlefieldId
- if (not battlefieldId) then return end
- local secs = GetBattlefieldPortExpiration(battlefieldId)
- if secs <= 0 then secs = 1 end
- local color
- if secs > 20 then
- color = "20ff20"
- elseif secs > 10 then
- color = "ffff00"
- else
- color = "ff0000"
- end
- local text = L["SafeQueue expires in |cff%s%s|r"]:format(color, SecondsToTime(secs))
- self.text:SetText(text)
- if PVPReadyDialog then
- if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
- -- retail: just show expiration
- PVPReadyDialog.label:SetText(text)
- elseif PVPReadyDialog.text and self.color and self.battleground then
- text = format("\n%s\n\n|cff%s%s|r", text, self.color, self.battleground)
- PVPReadyDialog.text:SetText(text)
- end
- end
-end
-
-function SafeQueue:Print(message)
- DEFAULT_CHAT_FRAME:AddMessage("|cff33ff99SafeQueue|r: " .. message)
-end
-
-local update = CreateFrame("Frame")
-update.timer = TOOLTIP_UPDATE_TIME
-update:SetScript("OnUpdate", function(self, elapsed)
- local battlefieldId = SafeQueue.battlefieldId
- if (not battlefieldId) then return end
- local timer = self.timer
- timer = timer - elapsed
- if timer <= 0 then
- if GetBattlefieldStatus(battlefieldId) ~= "confirm" then
- SafeQueue.battlefieldId = nil
- if SafeQueue.HidePopup then SafeQueue:HidePopup() end
- return
- end
- SafeQueue:SetExpiresText()
- end
- self.timer = timer
-end)
-
-function SafeQueue:UPDATE_BATTLEFIELD_STATUS()
- local isConfirm = nil
- for i = 1, GetMaxBattlefieldID() do
- local status = GetBattlefieldStatus(i)
- if status == "queued" then
- self.queues[i] = self.queues[i] or GetTime() - (GetBattlefieldTimeWaited(i) / 1000)
- elseif status == "confirm" then
- if self.queues[i] then
- local secs = GetTime() - self.queues[i]
- local message
- if secs < 1 then
- message = L["Queue popped instantly!"]
- else
- message = L["Queue popped after %s"]:format(SecondsToTime(secs))
- end
- self:Print(message)
- self.queues[i] = nil
- end
- isConfirm = true
- else
- self.queues[i] = nil
- end
- end
- if (not isConfirm) then
- self.battlefieldId = nil
- if self.HidePopup then self:HidePopup() end
- end
-end
-
-if PVPReadyDialog_Display then
- if PVPReadyDialog.label then PVPReadyDialog.label:SetWidth(250) end
- hooksecurefunc("PVPReadyDialog_Display", function(self, i)
- self = self or PVPReadyDialog
- if self.hideButton then self.hideButton:Hide() end
- if self.leaveButton then self.leaveButton:Hide() end
- self.enterButton:ClearAllPoints()
- self.enterButton:SetPoint("BOTTOM", self, "BOTTOM", 0, 25)
- SafeQueue.battlefieldId = i
- if SafeQueue.ShowPopup then SafeQueue:ShowPopup() end
- SafeQueue:SetExpiresText()
- end)
-end
+-- SafeQueue by Jordon
+
+local SafeQueue = SafeQueue
+local L = LibStub("AceLocale-3.0"):GetLocale("SafeQueue")
+
+local CreateFrame = CreateFrame
+local DEFAULT_CHAT_FRAME = DEFAULT_CHAT_FRAME
+local GetBattlefieldPortExpiration = GetBattlefieldPortExpiration
+local GetBattlefieldStatus = GetBattlefieldStatus
+local GetBattlefieldTimeWaited = GetBattlefieldTimeWaited
+local GetMaxBattlefieldID = GetMaxBattlefieldID
+local GetTime = GetTime
+local PVPReadyDialog = PVPReadyDialog
+local PVPReadyDialog_Display = PVPReadyDialog_Display
+local SecondsToTime = SecondsToTime
+local TOOLTIP_UPDATE_TIME = TOOLTIP_UPDATE_TIME
+local WOW_PROJECT_ID = WOW_PROJECT_ID
+local WOW_PROJECT_MAINLINE = WOW_PROJECT_MAINLINE
+local format = format
+local hooksecurefunc = hooksecurefunc
+
+function SafeQueue:SetExpiresText()
+ local battlefieldId = self.battlefieldId
+ if (not battlefieldId) then return end
+ local secs = GetBattlefieldPortExpiration(battlefieldId)
+ if secs <= 0 then secs = 1 end
+ local color
+ if secs > 20 then
+ color = "20ff20"
+ elseif secs > 10 then
+ color = "ffff00"
+ else
+ color = "ff0000"
+ end
+ -- Corrected syntax for text formatting
+ local text = ("Expires in |cff%s%s|r"):format(color, SecondsToTime(secs))
+ self.text:SetText(text)
+ if PVPReadyDialog then
+ if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
+ -- retail: just show expiration
+ PVPReadyDialog.label:SetText(text)
+ elseif PVPReadyDialog.text and self.color and self.battleground then
+ text = format("\n%s\n\n|cff%s%s|r", text, self.color, self.battleground)
+ PVPReadyDialog.text:SetText(text)
+ end
+ end
+end
+
+function SafeQueue:Print(message)
+ DEFAULT_CHAT_FRAME:AddMessage("|cff33ff99SafeQueue|r: " .. message)
+end
+
+local update = CreateFrame("Frame")
+update.timer = TOOLTIP_UPDATE_TIME
+update:SetScript("OnUpdate", function(self, elapsed)
+ local battlefieldId = SafeQueue.battlefieldId
+ if (not battlefieldId) then return end
+ local timer = self.timer
+ timer = timer - elapsed
+ if timer <= 0 then
+ if GetBattlefieldStatus(battlefieldId) ~= "confirm" then
+ SafeQueue.battlefieldId = nil
+ if SafeQueue.HidePopup then SafeQueue:HidePopup() end
+ return
+ end
+ SafeQueue:SetExpiresText()
+ end
+ self.timer = timer
+end)
+
+function SafeQueue:UPDATE_BATTLEFIELD_STATUS()
+ local isConfirm = nil
+ for i = 1, GetMaxBattlefieldID() do
+ local status = GetBattlefieldStatus(i)
+ if status == "queued" then
+ self.queues[i] = self.queues[i] or GetTime() - (GetBattlefieldTimeWaited(i) / 1000)
+ elseif status == "confirm" then
+ if self.queues[i] then
+ local secs = GetTime() - self.queues[i]
+ local message
+ if secs < 1 then
+ message = L["Queue popped instantly!"]
+ else
+ message = L["Queue popped after %s"]:format(SecondsToTime(secs))
+ end
+ self:Print(message)
+ self.queues[i] = nil
+ end
+ isConfirm = true
+ else
+ self.queues[i] = nil
+ end
+ end
+ if (not isConfirm) then
+ self.battlefieldId = nil
+ if self.HidePopup then self:HidePopup() end
+ end
+end
+
+if PVPReadyDialog_Display then
+ if PVPReadyDialog.label then PVPReadyDialog.label:SetWidth(250) end
+ hooksecurefunc("PVPReadyDialog_Display", function(self, i)
+ self = self or PVPReadyDialog
+ if self.hideButton then self.hideButton:Hide() end
+ if self.leaveButton then self.leaveButton:Hide() end
+ self.enterButton:ClearAllPoints()
+ self.enterButton:SetPoint("BOTTOM", self, "BOTTOM", 0, 25)
+ SafeQueue.battlefieldId = i
+ if SafeQueue.ShowPopup then SafeQueue:ShowPopup() end
+ SafeQueue:SetExpiresText()
+ end)
+end
diff --git a/SafeQueue.xml b/SafeQueue.xml
index b0023b5..339e20e 100644
--- a/SafeQueue.xml
+++ b/SafeQueue.xml
@@ -1,82 +1,97 @@
-
-
-
-
-
-
-
- self[event](self, ...)
-
-
- self.queues = {}
- self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
- local BACKDROP_DIALOG_32_32 = BACKDROP_DIALOG_32_32 or {
- bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
- edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
- tile = true,
- tileSize = 32,
- edgeSize = 32,
- insets = { left = 11, right = 12, top = 12, bottom = 11 },
- }
- if BackdropTemplateMixin then Mixin(self, BackdropTemplateMixin) end
- self:SetBackdrop(BACKDROP_DIALOG_32_32)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ self[event](self, ...)
+
+
+ self.queues = {}
+ self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
+ local BACKDROP_DIALOG_32_32 = BACKDROP_DIALOG_32_32 or {
+ bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
+ edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
+ tile = true,
+ tileSize = 32,
+ edgeSize = 32,
+ insets = { left = 11, right = 12, top = 12, bottom = 11 },
+ }
+ if BackdropTemplateMixin then Mixin(self, BackdropTemplateMixin) end
+ self:SetBackdrop(BACKDROP_DIALOG_32_32)
+
+
+
+
+
+
+
+
+
+
+
+
+
+ self:Hide() -- Ensure the texture starts hidden
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SafeQueue_Classic.lua b/SafeQueue_Classic.lua
index 3620efc..8c52b2c 100644
--- a/SafeQueue_Classic.lua
+++ b/SafeQueue_Classic.lua
@@ -1,156 +1,238 @@
-if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then return end
-
-local SafeQueue = SafeQueue
-
-local CreateFrame = CreateFrame
-local ENTER_BATTLE = ENTER_BATTLE
-local GetBattlefieldStatus = GetBattlefieldStatus
-local GetMapInfo = C_Map.GetMapInfo
-local GetMaxBattlefieldID = GetMaxBattlefieldID
-local InCombatLockdown = InCombatLockdown
-local PVPReadyDialog = PVPReadyDialog
-local PlaySound = PlaySound
-local REQUIRES_RELOAD = REQUIRES_RELOAD
-local SOUNDKIT = SOUNDKIT
-local StaticPopupSpecial_Hide = StaticPopupSpecial_Hide
-local StaticPopup_Hide = StaticPopup_Hide
-local format = format
-local hooksecurefunc = hooksecurefunc
-local issecurevariable = issecurevariable
-
-local ALTERAC_VALLEY = GetMapInfo(1459).name
-local WARSONG_GULCH = GetMapInfo(1460).name
-local ARATHI_BASIN = GetMapInfo(1461).name
-
-local BATTLEGROUND_COLORS = {
- default = "ffd100",
- [ALTERAC_VALLEY] = "007fff",
- [WARSONG_GULCH] = "00ff00",
- [ARATHI_BASIN] = "ffd100",
-}
-
-if PVPReadyDialog then
- PVPReadyDialog:SetHeight(120)
- -- add a minimize button
- local hideButton = CreateFrame("Button", nil, PVPReadyDialog, "UIPanelCloseButton")
- hideButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-HideButton-Up")
- hideButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-HideButton-Down")
- hideButton:SetPoint("TOPRIGHT", PVPReadyDialog, "TOPRIGHT", -3, -3)
- hideButton:SetScript("OnHide", function() PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) end)
-else
- -- Classic Era
- hooksecurefunc("StaticPopup_Show", function(name, _,_, i)
- if name ~= "CONFIRM_BATTLEFIELD_ENTRY" then return end
- SafeQueue.battlefieldId = i
- SafeQueue:ShowPopup()
- end)
-end
-
-SafeQueue:RegisterEvent("ADDON_ACTION_FORBIDDEN")
-
-function SafeQueue:ADDON_ACTION_FORBIDDEN(_, func)
- if (not self:IsVisible()) then return end
- if func == "AcceptBattlefieldPort()" then self.popupTainted = true end
- if func == "func()" then self.minimapTainted = true end
- if (not self.popupTainted) or (not self.minimapTainted) then return end
- StaticPopup_Hide("ADDON_ACTION_FORBIDDEN")
- self:SetMacroText()
-end
-
-function SafeQueue:HideBlizzardPopup()
- if PVPReadyDialog then
- StaticPopupSpecial_Hide(PVPReadyDialog)
- else
- StaticPopup_Hide("CONFIRM_BATTLEFIELD_ENTRY")
- end
-end
-
-SafeQueue:SetScript("OnShow", function(self)
- if (not self.battlefieldId) then return end
- if InCombatLockdown() then
- self.showPending = true
- self:RegisterEvent("PLAYER_REGEN_ENABLED")
- return
- end
-
- local status, battleground = GetBattlefieldStatus(self.battlefieldId)
-
- if status ~= "confirm" then return end
-
- self:HideBlizzardPopup()
-
- self.showPending = nil
- self.hidePending = nil
-
- self:SetExpiresText()
- self.SubText:SetText(format("|cff%s%s|r", self.color, battleground))
- local color = self.color and self.color.rgb
- if color then self.SubText:SetTextColor(color.r, color.g, color.b) end
-
- self:SetMacroText()
-end)
-
-SafeQueue:SetScript("OnHide", function(self)
- self.battleground = nil
- self.battlefieldId = nil
- self.EnterButton:SetAttribute("macrotext", "")
- self.EnterButton:SetText(ENTER_BATTLE)
-end)
-
-function SafeQueue:ShowPopup()
- local battlefieldId = self.battlefieldId
- if (not battlefieldId) then return end
- local status, battleground = GetBattlefieldStatus(battlefieldId)
- if status ~= "confirm" then return end
- self.battleground = battleground
- self.color = BATTLEGROUND_COLORS[battleground] or BATTLEGROUND_COLORS.default
- self:SetExpiresText()
- if InCombatLockdown() then
- self.showPending = true
- self:RegisterEvent("PLAYER_REGEN_ENABLED")
- return
- end
- self:Show()
-end
-
-function SafeQueue:HidePopup()
- self:HideBlizzardPopup()
- if InCombatLockdown() then
- self.hidePending = true
- self:RegisterEvent("PLAYER_REGEN_ENABLED")
- return
- end
- self:Hide()
-end
-
-function SafeQueue:PLAYER_REGEN_ENABLED()
- self:UnregisterEvent("PLAYER_REGEN_ENABLED")
- if self.hidePending then self:Hide() end
- if self.showPending then self:Show() end
-end
-
-local function GetDropDownListEnterButton(battlefieldId)
- local index = -1
- for i = 1, GetMaxBattlefieldID() do
- local status = GetBattlefieldStatus(i)
- if status ~= "none" then index = index + 3 end
- if i == battlefieldId then return "DropDownList1Button" .. index end
- end
-end
-
-function SafeQueue:SetMacroText()
- if InCombatLockdown() then return end
- if (not self.battlefieldId) then return end
- if (not issecurevariable("CURRENT_BATTLEFIELD_QUEUES")) then self.popupTainted = true end
- if self.popupTainted and self.minimapTainted then
- self.EnterButton:SetText(REQUIRES_RELOAD)
- self.EnterButton:SetAttribute("macrotext", "/reload")
- else
- local macrotext = "/click PVPReadyDialogEnterBattleButton\n"
- local button = GetDropDownListEnterButton(self.battlefieldId)
- if button then
- macrotext = macrotext .. "/click MiniMapBattlefieldFrame RightButton\n/click " .. button
- end
- self.EnterButton:SetAttribute("macrotext", macrotext)
- end
-end
+if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then return end
+
+local SafeQueue = SafeQueue
+
+local CreateFrame = CreateFrame
+local ENTER_BATTLE = ENTER_BATTLE
+local GetBattlefieldStatus = GetBattlefieldStatus
+local GetMapInfo = C_Map.GetMapInfo
+local GetMaxBattlefieldID = GetMaxBattlefieldID
+local InCombatLockdown = InCombatLockdown
+local PVPReadyDialog = PVPReadyDialog
+local PlaySound = PlaySound
+local REQUIRES_RELOAD = REQUIRES_RELOAD
+local SOUNDKIT = SOUNDKIT
+local StaticPopupSpecial_Hide = StaticPopupSpecial_Hide
+local StaticPopup_Hide = StaticPopup_Hide
+local format = format
+local hooksecurefunc = hooksecurefunc
+local issecurevariable = issecurevariable
+
+local alteracValleyInfo = GetMapInfo(1459)
+local warsongGulchInfo = GetMapInfo(1460)
+local arathiBasinInfo = GetMapInfo(1461)
+
+local ALTERAC_VALLEY = alteracValleyInfo and alteracValleyInfo.name or "Alterac Valley"
+local WARSONG_GULCH = warsongGulchInfo and warsongGulchInfo.name or "Warsong Gulch"
+local ARATHI_BASIN = arathiBasinInfo and arathiBasinInfo.name or "Arathi Basin"
+
+local BATTLEGROUND_COLORS = {
+ default = "ffd100",
+ [ALTERAC_VALLEY] = "007fff",
+ [WARSONG_GULCH] = "00ff00",
+ [ARATHI_BASIN] = "ffd100",
+}
+-- Textures for the battlegrounds
+local battlegroundTextures = {
+ ["Warsong Gulch"] = "Interface\\AddOns\\SafeQueue\\Media\\Textures\\wsglogo.png",
+ ["Alterac Valley"] = "Interface\\AddOns\\SafeQueue\\Media\\Textures\\avlogo.png",
+ ["Arathi Basin"] = "Interface\\AddOns\\SafeQueue\\Media\\Textures\\ablogo.png",
+}
+
+function SafeQueue:SetBackground(battleground)
+ if not self.BattlegroundTexture then
+ print("BattlegroundTexture is nil!")
+ return
+ end
+
+ local texturePath = battlegroundTextures[battleground]
+ if texturePath then
+ self.BattlegroundTexture:SetTexture(texturePath)
+ self.BattlegroundTexture:SetTexCoord(0, 1, 0, 1)
+ self.BattlegroundTexture:SetSize(300, 115) -- Match popup template dimensions
+ self.BattlegroundTexture:SetDrawLayer("BACKGROUND") -- Ensure texture is rendered below the popup
+ self.BattlegroundTexture:SetAlpha(0.7) -- Set alpha
+ self.BattlegroundTexture:Show()
+ else
+ print("No texture found for:", battleground)
+ self.BattlegroundTexture:Hide()
+ end
+end
+
+
+if PVPReadyDialog then
+ PVPReadyDialog:SetHeight(120)
+ -- add a minimize button
+ local hideButton = CreateFrame("Button", nil, PVPReadyDialog, "UIPanelCloseButton")
+ hideButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-HideButton-Up")
+ hideButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-HideButton-Down")
+ hideButton:SetPoint("TOPRIGHT", PVPReadyDialog, "TOPRIGHT", -3, -3)
+ hideButton:SetScript("OnHide", function() PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON) end)
+else
+ -- Classic Era
+ hooksecurefunc("StaticPopup_Show", function(name, _,_, i)
+ if name ~= "CONFIRM_BATTLEFIELD_ENTRY" then return end
+ SafeQueue.battlefieldId = i
+ SafeQueue:ShowPopup()
+ end)
+end
+
+SafeQueue:RegisterEvent("ADDON_ACTION_FORBIDDEN")
+
+function SafeQueue:ADDON_ACTION_FORBIDDEN(_, func)
+ if (not self:IsVisible()) then return end
+ if func == "AcceptBattlefieldPort()" then self.popupTainted = true end
+ if func == "func()" then self.minimapTainted = true end
+ if (not self.popupTainted) or (not self.minimapTainted) then return end
+ StaticPopup_Hide("ADDON_ACTION_FORBIDDEN")
+ self:SetMacroText()
+end
+
+function SafeQueue:HideBlizzardPopup()
+ if PVPReadyDialog then
+ StaticPopupSpecial_Hide(PVPReadyDialog)
+ else
+ StaticPopup_Hide("CONFIRM_BATTLEFIELD_ENTRY")
+ end
+end
+
+SafeQueue:SetScript("OnShow", function(self)
+ if (not self.battlefieldId) then return end
+ if InCombatLockdown() then
+ self.showPending = true
+ self:RegisterEvent("PLAYER_REGEN_ENABLED")
+ return
+ end
+
+ local status, battleground = GetBattlefieldStatus(self.battlefieldId)
+
+ if status ~= "confirm" then return end
+
+ self:HideBlizzardPopup()
+
+ self.showPending = nil
+ self.hidePending = nil
+
+ self:SetBackground(battleground) -- Ensure the background is set when the popup is shown
+ self:SetExpiresText()
+ self.SubText:SetText(format("|cff%s%s|r", self.color, battleground))
+ local color = self.color and self.color.rgb
+ if color then self.SubText:SetTextColor(color.r, color.g, color.b) end
+
+ self:SetMacroText()
+end)
+
+SafeQueue:SetScript("OnHide", function(self)
+ self.battleground = nil
+ self.battlefieldId = nil
+ self.EnterButton:SetAttribute("macrotext", "")
+ self.EnterButton:SetText(ENTER_BATTLE)
+end)
+
+function SafeQueue:ShowPopup()
+ local battlefieldId = self.battlefieldId
+ if (not battlefieldId) then return end
+ local status, battleground = GetBattlefieldStatus(battlefieldId)
+ if status ~= "confirm" then return end
+
+ -- Reset the minimized state when showing the popup
+ self.isMinimized = false
+
+ self.battleground = battleground
+ self.color = BATTLEGROUND_COLORS[battleground] or BATTLEGROUND_COLORS.default
+ self:SetExpiresText()
+ if InCombatLockdown() then
+ self.showPending = true
+ self:RegisterEvent("PLAYER_REGEN_ENABLED")
+ return
+ end
+ self:Show()
+end
+
+function SafeQueue:HidePopup()
+ self:HideBlizzardPopup()
+ if InCombatLockdown() then
+ self.hidePending = true
+ self:RegisterEvent("PLAYER_REGEN_ENABLED")
+ return
+ end
+ self:Hide()
+end
+
+function SafeQueue:PLAYER_REGEN_ENABLED()
+ self:UnregisterEvent("PLAYER_REGEN_ENABLED")
+ if self.hidePending then self:Hide() end
+ if self.showPending then self:Show() end
+end
+
+local function GetDropDownListEnterButton(battlefieldId)
+ local index = -1
+ for i = 1, GetMaxBattlefieldID() do
+ local status = GetBattlefieldStatus(i)
+ if status ~= "none" then index = index + 3 end
+ if i == battlefieldId then return "DropDownList1Button" .. index end
+ end
+end
+
+function SafeQueue:SetMacroText()
+ if InCombatLockdown() then return end
+ if (not self.battlefieldId) then return end
+ if (not issecurevariable("CURRENT_BATTLEFIELD_QUEUES")) then self.popupTainted = true end
+ if self.popupTainted and self.minimapTainted then
+ self.EnterButton:SetText(REQUIRES_RELOAD)
+ self.EnterButton:SetAttribute("macrotext", "/reload")
+ else
+ local macrotext = "/click PVPReadyDialogEnterBattleButton\n"
+ local button = GetDropDownListEnterButton(self.battlefieldId)
+ if button then
+ macrotext = macrotext .. "/click MiniMapBattlefieldFrame RightButton\n/click " .. button
+ end
+ self.EnterButton:SetAttribute("macrotext", macrotext)
+ end
+end
+
+-- Ensure the frame is movable
+SafeQueue:SetMovable(true)
+SafeQueue:EnableMouse(true)
+SafeQueue:RegisterForDrag("LeftButton")
+SafeQueue:SetScript("OnDragStart", function(self)
+ if InCombatLockdown() then return end -- Prevent dragging during combat
+ self:StartMoving()
+end)
+SafeQueue:SetScript("OnDragStop", function(self)
+ self:StopMovingOrSizing()
+ self:SavePosition() -- Save position when dragging stops
+end)
+
+-- Function to save the window's position
+function SafeQueue:SavePosition()
+ if not SafeQueueDB then SafeQueueDB = {} end
+ local point, _, relativePoint, x, y = self:GetPoint()
+ SafeQueueDB.position = { point = point, relativePoint = relativePoint, x = x, y = y }
+end
+
+-- Function to restore the window's position
+function SafeQueue:RestorePosition()
+ if SafeQueueDB and SafeQueueDB.position then
+ local pos = SafeQueueDB.position
+ self:ClearAllPoints()
+ self:SetPoint(pos.point, UIParent, pos.relativePoint, pos.x, pos.y)
+ else
+ -- Default position if no saved position exists
+ self:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
+ end
+end
+
+-- Restore position when the addon loads
+SafeQueue:RestorePosition()
+
+local LDB = LibStub("LibDataBroker-1.1", true)
+local LDBIcon = LibStub("LibDBIcon-1.0", true)
+
+local hideButton = CreateFrame("Button", nil, SafeQueue, "UIPanelCloseButton")
+hideButton:SetPoint("TOPRIGHT", SafeQueue, "TOPRIGHT", -3, -3)
+hideButton:SetScript("OnClick", function()
+ SafeQueue.isMinimized = true -- Set a flag to track the minimized state
+ SafeQueue:Hide() -- Hide the popup
+end)
+