Thread Tools Display Modes
02-01-15, 07:03 PM   #1
siweia
A Flamescale Wyrmkin
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 126
Not a clue on the addon GUI

I try to create a GUI for my addons, which I just change settings in a simple config.lua for now.
A simple GUI panel has been created, and it can sucessful change the WTF files by toggle the options.
But I found it quite difficult to link my addons to read from the saved variables once I change the settings.

Most of the GUIs are created by Acelib, but it's too hard for me as a newbee(especially a med school student).
Is there any link or tutorial that can help me to start with?

Last edited by siweia : 02-01-15 at 07:06 PM.
  Reply With Quote
02-01-15, 09:27 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I've moved your thread to the correct area of the forums.

And don't assume that because of this:
(especially a med school student)
that you don't have the know-how/experience to learn and get this. I'm a music teacher.

By "Acelib" do you mean AceConfig? What is "too hard"? What exactly are you having trouble with? What do you mean exactly by this: "But I found it quite difficult to link my addons to read from the saved variables once I change the settings"?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-02-15, 08:05 PM   #3
siweia
A Flamescale Wyrmkin
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 126
Originally Posted by Seerah View Post
I've moved your thread to the correct area of the forums.

And don't assume that because of this:

that you don't have the know-how/experience to learn and get this. I'm a music teacher.
...
Sorry for my poor English.
"Too hard" means the GUI created by AceConfig seems too complicated for me to understand.
That's why I try to do one on my own.

For now if I change the option in GUI, it only effects after reload ui.
It won't automaticly update the function, and I don't have a clue to do so either.

Last edited by siweia : 02-02-15 at 11:43 PM.
  Reply With Quote
02-02-15, 08:18 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by siweia View Post
For now if I change the option in GUI, it only effects after reload ui.
It would automaticly update the function, and I don't have a clue to do so either.
Post your code. We can't help you with code we can't see!
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
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
02-03-15, 09:39 AM   #6
siweia
A Flamescale Wyrmkin
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 126
For Example, I create an actionbar codes in "Actionbar.lua",
and I normally do write an individual lua to put all those configures in there,
eg Buttonsize, button position.

The problem now I am having is, I don't know how to convert the config.lua into a GUI panel.

At the moment, I take those actionbar codes effect after "PLAYER_ENTERING_WORLD", is that on the right track?
  Reply With Quote
02-03-15, 05:11 PM   #7
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by Seerah View Post
I'm a music teacher.
One of my favorite subjects in school. Four years Marching and Symphonic band playing trumpet.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
02-03-15, 11:18 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by rocnroll View Post
One of my favorite subjects in school. Four years Marching and Symphonic band playing trumpet.
3 years in band playing flute here (no, I never went to band camp!) but switched to choir my last 2 years of high school due to scheduling conflicts... was the only girl not in the soprano section. Both were among the only classes I wasn't totally bored with. Unfortunately small schools in rural areas are not well-equipped to provide a useful or enjoyable education for smart kids.

Originally Posted by siweia View Post
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.
Well, your code is quite convoluted and overcomplicated, so I'm not surprised you're getting confused, and I'm not going to dig through it to address any specifics, but generally speaking, if your saved variables are a table that looks like this:

Code:
MyAddonDB = {
    width = 64,
    height = 24,
    bgColor = { r = 0, g = 1, b = 0 }
}
... and your addon does something like this on login:

Code:
MyAddonFrame:SetSize( MyAddonDB.width, MyAddonDB.height )
MyAddonFrame:SetBackdropColor( MyAddonDB.bgColor.r, MyAddonDB.bgColor.g, MyAddonDB.bgColor.b )
... then when your width option was changed you'd just set the new value in the table:

Code:
MyAddonDB.width = NEW_OPTION_VALUE
... and then apply it to your frame:

Code:
MyAddonFrame:SetWidth( NEW_OPTION_VALUE )
It kind of looks like you're trying to write a generalized options framework, rather than just hardcoding the specific options you want. If that's the case (eg. if you need dynamic options because the user can add or remove instances of some kind of object, like action bars, that each have their own set of options) I'd suggest just using AceConfig instead. That way you can just:

1. Create an options table and add/remove/change sections as needed.
2. Register it with AceConfig-Registry.
3a. Open an options window with AceConfig-Dialog, which automatically generates and lays out all the actual option widgets and container frames using AceGUI behind the scenes.
3b. AceConfig-Dialog can also add your options window to the Interface Options frame.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
02-04-15, 06:56 PM   #9
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
It kind of looks like you're trying to write a generalized options framework, rather than just hardcoding the specific options you want. If that's the case (eg. if you need dynamic options because the user can add or remove instances of some kind of object, like action bars, that each have their own set of options) I'd suggest just using AceConfig instead. That way you can just:
Thanks, you got me, I would have a try with AceConfig.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Not a clue on the addon GUI

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off