diff --git a/FLeX_BG_Selector.lua b/FLeX_BG_Selector.lua new file mode 100644 index 0000000..4f12576 --- /dev/null +++ b/FLeX_BG_Selector.lua @@ -0,0 +1,46 @@ +local function SetSelectedBattlefieldByNumber(bgNumber) + for i=1, GetNumBattlefields(), 1 do + if tostring(GetBattlefieldInstanceInfo(i)) == bgNumber then + SetSelectedBattlefield(i); + BattlefieldFrame_Update(); + return true; + end + end + return false; +end + +StaticPopupDialogs["BG_SELECTOR_NOT_FOUND"] = { + text = "BG with that number was not found.", + button1 = "Okay", + timeout = 0, + whileDead = true, + hideOnEscape = true, + referredIndex = 3 + } + +local frame = CreateFrame("Frame", "BGSelectorFrame", BattlefieldFrame); + +local editBox = CreateFrame("EditBox", "BGSelectorEditBox", frame, "InputBoxTemplate"); +editBox:SetSize(80, 22); +editBox:SetPoint("CENTER", BattlefieldFrame, "TOPLEFT", 305, -401); +editBox:SetAutoFocus(false); +editBox:SetNumeric(true); +editBox:SetScript("OnEnterPressed", function(self) + self:ClearFocus(); + local text = self:GetText(); + + if SetSelectedBattlefieldByNumber(text) then + BattlefieldFrameJoinButton:SetText(BATTLEFIELD_JOIN.."("..text..")"); + elseif text == "" then + BattlefieldFrame_Update(); + BattlefieldFrameJoinButton:SetText(BATTLEFIELD_JOIN); + else + StaticPopup_Show("BG_SELECTOR_NOT_FOUND"); + BattlefieldFrameJoinButton:SetText(BATTLEFIELD_JOIN); + end +end) + +editBox:SetScript("OnShow", function(self) + self:SetText(""); + BattlefieldFrameJoinButton:SetText(BATTLEFIELD_JOIN); +end) \ No newline at end of file diff --git a/FLeX_BG_Selector.toc b/FLeX_BG_Selector.toc new file mode 100644 index 0000000..21b93b1 --- /dev/null +++ b/FLeX_BG_Selector.toc @@ -0,0 +1,10 @@ +## Interface: 11302 + +## Title: FLeX BG Selector + +## Notes: Allows you to select a battleground by BG number. + +## Version: 1.0 +## Author: FLeX + +FLeX_BG_Selector.lua \ No newline at end of file