View Single Post
02-02-15, 11:47 PM   #5
siweia
A Flamescale Wyrmkin
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 126
Originally Posted by Phanx View Post
Post your code. We can't help you with code we can't see!
Code:
local B, C, L, DB = unpack(select(2, ...))

local r, g, b = DB.cc.r, DB.cc.g, DB.cc.b
local optionlist = {
	"ActionBar",
	"Auras",
	"UnitFrames",
	"Chat",
	"Maps",
	"Nameplate",
	"Addon Skin",
	"Gametooltip",
	"Others",
}
local f = CreateFrame("Frame", "NDuiGUI", UIParent)
f:Hide()
local tab, box, x, y = {}, {}

local function CreateTab(i, name)
	local tab = CreateFrame("Button", "NDuiGUI_Tab"..i, NDuiGUI)
	tab:SetPoint("TOPLEFT", 30, -(28*i + 40))
	tab:SetSize(130, 26)
	B.CreateBD(tab, .3, 1.2)
	B.CreateTT(tab, 14, name, "LEFT", 15, 0)
	local hl = tab:CreateTexture(nil, "HIGHLIGHT")
	hl:SetPoint("TOPLEFT", 1, -1)
	hl:SetPoint("BOTTOMRIGHT", -1, 1)
	hl:SetTexture(r, g, b, .3)
	return tab
end

function CreateOption(f, i, index, name, x, y)
	f = CreateFrame("CheckButton", "NDuiGUI_Page"..i.."_Option"..index, _G["NDuiGUI_Page"..i], "InterfaceOptionsCheckButtonTemplate")
	f:SetSize(26, 26)
	f:SetPoint("TOPLEFT", x, y)
	B.CreateCB(f)
	f.text = f:CreateFontString(nil, "OVERLAY")
	f.text:SetFont(unpack(DB.Font))
	f.text:SetPoint("LEFT", 30, 0)
	f.text:SetText(name)
	return f
end

function CreateDropdown(f, i, index, name, x, y)
	f = CreateFrame("Button", "NDuiGUI_Page"..i.."_Option"..index, _G["NDuiGUI_Page"..i])
	f:SetSize(18, 18)
	f:SetPoint("TOPLEFT", x, y)
	B.CreateBD(f, .5, 2)
	B.CreateTT(f, 18, "+")
	f.text = f:CreateFontString(nil, "OVERLAY")
	f.text:SetFont(unpack(DB.Font))
	f.text:SetPoint("LEFT", 25, 0)
	f.text:SetText(name)
	return f
end

function SetOption(i)
	if i == 1 then
		if not NDuiDB["Actionbar"] then NDuiDB["Actionbar"] = {} end
		if not NDuiDB["Actionbar"]["layout"] then NDuiDB["Actionbar"]["layout"] = C.bars.layout end
		local opt1 = CreateDropdown(opt1, i, 1, "UseLayout"..NDuiDB["Actionbar"]["layout"], 24, -20)
		local menuFrame = CreateFrame("Frame", "HEHEHE", _G["NDuiGUI_Page"..i.."_Option1"], "UIDropDownMenuTemplate")
		local menuList = {
			{notCheckable = true, text = "UseLayout1", value = "1"},
			{notCheckable = true, text = "UseLayout2", value = "2"},
			{notCheckable = true, text = "UseLayout3", value = "3"},
		}
		opt1:SetScript("OnMouseUp", function(self)
			for i = 1, 3 do
				local function testobj()
					NDuiDB["Actionbar"]["layout"] = menuList[i].value
				end
				if i == NDuiDB["Actionbar"]["layout"] then
					menuList[i].checked = true
				end
				menuList[i].func = function() testobj() end
			end
			EasyMenu(menuList, menuFrame, opt1, 0, 0, "MENU", 2)
		end)

		local opt2 = CreateOption(opt2, i, 1, "ShowMacro", 20, -50)
		opt2:SetChecked(NDuiDB["Actionbar"]["macro"])
		opt2:SetScript("OnClick", function(self)
			if self:GetChecked() then
				NDuiDB["Actionbar"]["macro"] = true
			else
				NDuiDB["Actionbar"]["macro"] = false
			end
		end)
	end
end

function SelectTab(i)
	for num = 1, #optionlist do
		if num == i then
			_G["NDuiGUI_Tab"..num]:SetBackdropColor(r, g, b, .3)
			_G["NDuiGUI_Page"..num]:Show()
		else
			_G["NDuiGUI_Tab"..num]:SetBackdropColor(0, 0, 0, .3)
			_G["NDuiGUI_Page"..num]:Hide()
		end
	end
end

local function OpenGUI()
	if InCombatLockdown() then print(ERR_NOT_IN_COMBAT) return end
	if f.created then f:Show() return end

	-- Main Frame
	f:SetSize(800, 600)
	f:SetPoint("CENTER")
	f:SetFrameStrata("HIGH")
	B.CreateMF(f)
	B.CreateBD(f)
	B.CreateTex(f)
	B.CreateTT(f, 18, "NDui GUI", "TOP", 0, -10, true)

	local lu = CreateFrame("Frame", nil, f)
	lu:SetPoint("BOTTOMLEFT", f, "LEFT", 180, 1)
	B.CreateGF(lu, .5, 250, "Vertical", .7, .7, .7, .7, 0)
	lu:SetFrameStrata("HIGH")
	local ld = CreateFrame("Frame", nil, f)
	ld:SetPoint("TOPLEFT", f, "LEFT", 180, -1)
	B.CreateGF(ld, .5, 250, "Vertical", .7, .7, .7, 0, .7)
	ld:SetFrameStrata("HIGH")

	local close = CreateFrame("Button", nil, f)
	close:SetPoint("BOTTOMRIGHT", -15, 15)
	close:SetSize(80, 20)
	B.CreateBD(close, 0.3, 2)
	B.CreateBC(close)
	B.CreateTT(close, 14, CANCEL)
	close:SetScript("OnClick", function(self)
		f:Hide()
	end)
	local ok = CreateFrame("Button", nil, f)
	ok:SetPoint("RIGHT", close, "LEFT", -10, 0)
	ok:SetSize(80, 20)
	B.CreateBD(ok, 0.3, 2)
	B.CreateBC(ok)
	B.CreateTT(ok, 14, OKAY)
	ok:SetScript("OnClick", function(self)
		f:Hide()
		StaticPopup_Show("RELOAD_NDUI")
	end)

	for i = 1, #optionlist do
		local f = CreateFrame("Frame", "NDuiGUI_Page"..i, NDuiGUI)
		f:SetPoint("TOPLEFT", 200, -60)
		f:SetSize(570, 500)
		B.CreateBD(f, .3, .1)
		f:Hide()
		SetOption(i)
		tab[i] = CreateTab(i, optionlist[i])
		tab[i]:SetScript("OnClick", function(self)
			PlaySound("igMainMenuOptionCheckBoxOn")
			SelectTab(i)
		end)
	end

	f:Show()
	SelectTab(1)
	f.created = true
end

local gui = CreateFrame("Button", "GameMenuFrameNDui", GameMenuFrame, "GameMenuButtonTemplate")
gui:SetText("NDui GUI")
gui:SetPoint("TOP", GameMenuButtonContinue, "BOTTOM", 0, -1)
GameMenuFrame:HookScript("OnShow", function(self)
	self:SetHeight(self:GetHeight() + gui:GetHeight())
end)

gui:SetScript("OnClick", function()
	OpenGUI()
	HideUIPanel(GameMenuFrame)
	PlaySound("igMainMenuOption")
end)
I just start to add few options, but I don't know how to update it to swith on/off addon function.
It is only a panel which stands alone.
  Reply With Quote