Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FLeXyo committed Dec 13, 2019
0 parents commit bee5104
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
46 changes: 46 additions & 0 deletions FLeX_BG_Selector.lua
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions FLeX_BG_Selector.toc
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bee5104

Please sign in to comment.