--Want to add Show Hide function for each window. ( barQWindow, barAWindow, barMWindow, barCWindow )
--With the Show Hide I want to add this in an addon options window.
--Want to add a lock frame for each window.
--With lock frame I want to add this in an addon options window.
--Create a button using lua that pulls up a window for ZBar Options.
--Saved Variable Table
ZBarConfig = {
barQWindowVisible = true,
barQWindowEnabled = true,
}
-- creates a generic button in the middle of the screen --
ZBarButton = CreateFrame("Button","ZBarButton",UIParent,"UIPanelButtonTemplate")
ZBarButton:SetPoint("CENTER",0,0)
ZBarButton:SetWidth(30)
ZBarButton:SetHeight(30)
ZBarButton:SetText("ZB")
ZBarButton:SetMovable(true)
ZBarButton:RegisterForDrag("LeftButton")
ZBarButton:SetScript("OnDragStart",ZBarButton.StartMoving)
ZBarButton:SetScript("OnDragStop",ZBarButton.StopMovingOrSizing)
ZBarOptionFrame = CreateFrame("Frame")
ZBarOptionFrame:ClearAllPoints()
ZBarOptionFrame:SetBackdrop(StaticPopup1:GetBackdrop())
ZBarOptionFrame:SetHeight(300)
ZBarOptionFrame:SetWidth(300)
ZBarOptionFrame:Hide(true)
ZBarOptionFrame.text = ZBarOptionFrame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
ZBarOptionFrame.text:SetPoint("CENTER", 0, 125)
ZBarOptionFrame.text:SetText("ZBar Options Verison 1.0")
ZBarOptionFrame:SetPoint("CENTER", 0, 0)
ZBarButton:RegisterForClicks("AnyUp")
ZBarButton:SetScript("OnClick", function(self, button, ...)
if (button == "RightButton") then
if ZBarOptionFrame:IsShown() then
ZBarOptionFrame:Hide()
else
ZBarOptionFrame:Show()
end
end
end)
-- My window Names are barQWindow (name frame 1), barCWindow (name frame 2), barMWindow (name frame 3), barAWindow (name frame 4)
--Frame 1 (barQWindow)
barQWindowCheckButton = CreateFrame("CheckButton", "barQWindowCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
barQWindowCheckButton:SetPoint("TOPLEFT", 25, -65);
barQWindowCheckButton_GlobalNameText:SetText("Frame 1 Hide");
barQWindowCheckButton.tooltip = "This is will hide the frame.";
barQWindowCheckButton:SetScript("OnClick", function(self, button)
ZBarConfig.barQWindowVisible = not self:GetChecked()
barQWindow:SetShown(ZBarConfig.barQWindowVisible)
end)
--Frame 2(barCWindow)
barCWindowCheckButton = CreateFrame("CheckButton", "barCWindowCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
barCWindowCheckButton:SetPoint("TOPLEFT", 25, -85);
barCWindowCheckButton_GlobalNameText:SetText("Frame 2 Hide");
barCWindowCheckButton.tooltip = "This is will hide the frame.";
barCWindowCheckButton:SetScript("OnClick",
function()
if barCWindow:IsShown() then
barCWindow:Hide()
else
barCWindow:Show()
end
end
);
--Frame 3 (barMWindow)
barMWindowCheckButton = CreateFrame("CheckButton", "barMWindowCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
barMWindowCheckButton:SetPoint("TOPLEFT", 25, -105);
barMWindowCheckButton_GlobalNameText:SetText("Frame 3 Hide");
barMWindowCheckButton.tooltip = "This is will hide the frame.";
barMWindowCheckButton:SetScript("OnClick",
function()
if barMWindow:IsShown() then
barMWindow:Hide()
else
barMWindow:Show()
end
end
);
--Frame 4 (barAWindow)
barAWindowCheckButton = CreateFrame("CheckButton", "barAWindowCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
barAWindowCheckButton:SetPoint("TOPLEFT", 25, -125);
barAWindowCheckButton_GlobalNameText:SetText("Frame 4 Hide");
barAWindowCheckButton.tooltip = "This is will hide the frame.";
barAWindowCheckButton:SetScript("OnClick",
function()
if barAWindow:IsShown() then
barAWindow:Hide()
else
barAWindow:Show()
end
end
);
--This will be to lock the frame into place
--Frame 1 (barQWindow)
barQWindowLockCheckButton = CreateFrame("CheckButton", "barQWindowLockCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
barQWindowLockCheckButton:SetPoint("TOPLEFT", 150, -65);
barQWindowLockCheckButton_GlobalNameText:SetText("Frame 1 Lock");
barQWindowLockCheckButton.tooltip = "This is will lock the frame in place.";
barQWindowLockCheckButton:SetScript("OnClick",
function()
if barQWindow:IsMovable() then
barQWindow:SetMovable(false)
else
barQWindow:SetMovable(true)
end
end
);
--Frame 2 (barCWindow)
barCWindowLockCheckButton = CreateFrame("CheckButton", "barCWindowLockCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
barCWindowLockCheckButton:SetPoint("TOPLEFT", 150, -85);
barCWindowLockCheckButton_GlobalNameText:SetText("Frame 2 Lock");
barCWindowLockCheckButton.tooltip = "This is will lock the frame in place.";
barCWindowLockCheckButton:SetScript("OnClick",
function()
if barCWindow:IsMovable() then
barCWindow:SetMovable(false)
else
barCWindow:SetMovable(true)
end
end
);
--Frame 3 (barMWindow)
barMWindowLockCheckButton = CreateFrame("CheckButton", "barMWindowLockCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
barMWindowLockCheckButton:SetPoint("TOPLEFT", 150, -105);
barMWindowLockCheckButton_GlobalNameText:SetText("Frame 3 Lock");
barMWindowLockCheckButton.tooltip = "This is will lock the frame in place.";
barMWindowLockCheckButton:SetScript("OnClick",
function()
if barMWindow:IsMovable() then
barMWindow:SetMovable(false)
else
barMWindow:SetMovable(true)
end
end
);
--Frame 4 (barMWindow)
barAWindowLockCheckButton = CreateFrame("CheckButton", "barAWindowLockCheckButton_GlobalName", ZBarOptionFrame, "ChatConfigCheckButtonTemplate");
barAWindowLockCheckButton:SetPoint("TOPLEFT", 150, -125);
barAWindowLockCheckButton_GlobalNameText:SetText("Frame 4 Lock");
barAWindowLockCheckButton.tooltip = "This is will lock the frame in place.";
barAWindowLockCheckButton:SetScript("OnClick",
function()
if barAWindow:IsMovable() then
barAWindow:SetMovable(false)
else
barAWindow:SetMovable(true)
end
end
);
--Function to refresh the options panel
function ZBarOptionFrame:refresh()
barQWindowCheckButton:SetChecked(not ZBarConfig.barQWindowVisible)
end
--Addon_Loaded
local MyFrame=CreateFrame("Frame");
MyFrame:RegisterEvent("ADDON_LOADED");
MyFrame:SetScript("OnEvent",function(self,event,...)
if event=="ADDON_LOADED" and (...)==Name then
barQWindow:SetShown(ZBarConfig.barQWindowVisible)
self:UnregisterEvent("ADDON_LOADED");
end
end);