--Setup variables saving/loading
----------------------------------------------------------------------------------
HideMicroMenuDBPC = { }
function HideMicroMenuDBPC:PLAYER_LOGIN()
-- This table defines the addon's default settings:
local defaults = {
BagButtonVisable = true,
MicroMenuVisable = true,
}
-- This function copies values from one table into another:
local function copyDefaults(src, dst)
-- If no source (defaults) is specified, return an empty table:
if type(src) ~= "table" then return {} end
-- If no target (saved variable) is specified, create a new table:
if not type(dst) then dst = {} end
-- Loop through the source (defaults):
for k, v in pairs(src) do
-- If the value is a sub-table:
if type(v) == "table" then
-- Recursively call the function:
dst[k] = copyDefaults(v, dst[k])
-- Or if the default value type doesn't match the existing value type:
elseif type(v) ~= type(dst[k]) then
-- Overwrite the existing value with the default one:
dst[k] = v
end
end
-- Return the destination table:
return dst
end
-- Copy the values from the defaults table into the saved variables table
-- if it exists, and assign the result to the saved variable:
HideMicroMenuDBPC = copyDefaults(defaults, HideMicroMenuDBPC)
end
--Setup Options Panel
----------------------------------------------------------------------------------
local Frame = CreateFrame("Frame")
Frame:RegisterEvent("PLAYER_LOGIN")
HideMicroMenu = {};
HideMicroMenu.panel = CreateFrame( "Frame", "HideMicroMenuPanel", UIParent );
HideMicroMenu.panel.name = "Hide Micro Menu";
InterfaceOptions_AddCategory(HideMicroMenu.panel);
-- Create BagButton Frame
local BagButtonFrame = CreateFrame("Frame", nil, nil, "BackdropTemplate")
BagButtonFrame:SetSize(50, 50)
BagButtonFrame:SetBackdrop(BACKDROP_TUTORIAL_16_16)
BagButtonFrame:ClearBackdrop()
BagButtonFrame:SetPoint("CENTER", MainMenuBarBackpackButton, "CENTER", 0, -0)
--BagButton Button in Options
BagButton = CreateFrame("Button", "BagButton", HideMicroMenuPanel, "UIPanelButtonTemplate");
BagButton:SetSize(200 ,40)
BagButton:SetText("Toggle Bag Button Visability")
BagButton:SetPoint("TOPLEFT", 35, -65);
BagButton:SetScript("OnClick",
function()
if BagButtonVisable == true then
BagButtonFrame:Hide()
BagButtonVisable = false
print ("BagButton ", BagButtonVisable)
else
BagButtonFrame:Show()
BagButtonVisable = true
print ("BagButton ", BagButtonVisable)
end
end
);
--MicroMenu Button in Options
MicroMenu = CreateFrame("Button", "MicroMenu", HideMicroMenuPanel, "UIPanelButtonTemplate");
MicroMenu:SetSize(200 ,40)
MicroMenu:SetText("Toggle Micro Menu Visability")
MicroMenu:SetPoint("TOPLEFT", 35, -165);
MicroMenu:SetScript("OnClick",
function()
if MicroMenuVisable == true then
MicroButtonAndBagsBar:Hide()
MicroMenuVisable = false
print ("MicroMenu ", MicroMenuVisable)
else
MicroButtonAndBagsBar:Show()
MicroMenuVisable = true
print ("MicroMenu ", MicroMenuVisable)
end
end
);
--Setup Bag Button
----------------------------------------------------------------------------------
MainMenuBarBackpackButton:SetParent(BagButtonFrame)
MainMenuBarBackpackButton:SetScale (0.65)
BagBarExpandToggle:ClearAllPoints()
BagBarExpandToggle:SetParent(BagButtonFrame)
if (BagButtonVisable == false) then
BagButtonFrame:Hide()
else
BagButtonFrame:Show()
end
--Setup Micro Menu
----------------------------------------------------------------------------------
if (MicroMenuVisable == false) then
MicroButtonAndBagsBar:Hide()
else
MicroButtonAndBagsBar:Show()
end
--Setup Queue Status
----------------------------------------------------------------------------------
local QueueButtonFrame = CreateFrame("Frame", nil, nil, "BackdropTemplate")
QueueButtonFrame:SetPoint("CENTER", QueueStatusButton, "CENTER", 0, -0)
QueueButtonFrame:SetSize(50, 50)
QueueButtonFrame:SetBackdrop(BACKDROP_TUTORIAL_16_16)
QueueButtonFrame:ClearBackdrop()
QueueButtonFrameCenter = QueueButtonFrame:GetCenter()
print (QueueButtonFrameCenter)
QueueStatusButton:SetParent(QueueButtonFrame)
QueueStatusButton:SetScale (0.65)
--Make Queue Status Frame Draggable
QueueStatusButton:SetMovable(true)
QueueStatusButton:EnableMouse(true)
QueueStatusButton:RegisterForDrag("LeftButton")
QueueStatusButton:SetScript("OnDragStart", function(self, button)
self:StartMoving()
end)
QueueStatusButton:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
end)
QueueStatusButton:SetUserPlaced(true)