Thread Tools Display Modes
02-22-11, 03:28 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Config item templates

Currently looking for a list of config item templates.

FrameXML
http://wowprogramming.com/utils/xmlbrowser
https://github.com/tekkub/wow-ui-source/

UIPanelTemplates
http://wowprogramming.com/utils/xmlb...lTemplates.xml
https://github.com/tekkub/wow-ui-sou...lTemplates.xml

OptionsPanelTemplates
http://wowprogramming.com/utils/xmlb...lTemplates.xml
https://github.com/tekkub/wow-ui-sou...lTemplates.xml
Consists of templates for
Code:
<Button name="OptionsButtonTemplate" inherits="UIPanelButtonTemplate" virtual="true">
<CheckButton name="OptionsBaseCheckButtonTemplate" virtual="true">
<CheckButton name="OptionsCheckButtonTemplate" virtual="true" inherits="OptionsBaseCheckButtonTemplate">
<CheckButton name="OptionsSmallCheckButtonTemplate" virtual="true" inherits="OptionsBaseCheckButtonTemplate">
<Slider name="OptionsSliderTemplate" orientation="HORIZONTAL" virtual="true" enableMouse="true">
<Frame name="OptionsBoxTemplate" virtual="true">
OptionsFrameTemplates
http://wowprogramming.com/utils/xmlb...eTemplates.xml
https://github.com/tekkub/wow-ui-sou...eTemplates.xml
Consists of templates for
Code:
<Button name="OptionsFrameTabButtonTemplate" virtual="true"></Button>
<Frame name="OptionsFrameListTemplate" virtual="true"></Frame>
<Button name="OptionsListButtonTemplate" virtual="true"></Button>
<Frame name="OptionsFrameTemplate" toplevel="true" parent="UIParent" hidden="true" enableMouse="true" frameStrata="HIGH" virtual="true"></Frame>
UIDropDownMenuTemplates
http://wowprogramming.com/utils/xmlb...uTemplates.xml
https://github.com/tekkub/wow-ui-sou...uTemplates.xml

Config items
- editbox http://wowprogramming.com/docs/widgets/EditBox
- slider http://wowprogramming.com/docs/widgets/Slider
- scrollframe http://wowprogramming.com/docs/widgets/ScrollFrame
- checkbutton http://wowprogramming.com/docs/widgets/CheckButton
- button http://wowprogramming.com/docs/widgets/Button
- colorselect http://wowprogramming.com/docs/widgets/ColorSelect

Examples

OptionsSliderTemplate
Code:
local fname = "TestSlider"
local f = CreateFrame("Slider", fname, UIParent, "OptionsSliderTemplate")

f:ClearAllPoints()
f:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
f:SetMinMaxValues(0, 100)
f:SetValue(50)
_G[fname.."Low"]:SetText("0");
_G[fname.."High"]:SetText("100");
_G[fname.."Text"]:SetText(fname);
f:Show()
hank posted an example for the scrollframe using UIPanelScrollFrameTemplate
Code:
f.scroll = CreateFrame("ScrollFrame", "myScrollFrame", f, "UIPanelScrollFrameTemplate")
Example by Xchg http://us.battle.net/wow/en/forum/topic/1305771013
Code:
--parent frame
local frame = CreateFrame("Frame", "MyFrame", UIParent)
frame:SetSize(150, 200)
frame:SetPoint("CENTER")
local texture = frame:CreateTexture()
texture:SetAllPoints()
texture:SetTexture(1,1,1,1)
frame.background = texture

--scrollframe
scrollframe = CreateFrame("ScrollFrame", nil, frame)
scrollframe:SetPoint("TOPLEFT", 10, -10)
scrollframe:SetPoint("BOTTOMRIGHT", -10, 10)
local texture = scrollframe:CreateTexture()
texture:SetAllPoints()
texture:SetTexture(.5,.5,.5,1)
frame.scrollframe = scrollframe

--scrollbar
scrollbar = CreateFrame("Slider", nil, scrollframe, "UIPanelScrollBarTemplate")
scrollbar:SetPoint("TOPLEFT", frame, "TOPRIGHT", 4, -16)
scrollbar:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT", 4, 16)
scrollbar:SetMinMaxValues(1, 200)
scrollbar:SetValueStep(1)
scrollbar.scrollStep = 1
scrollbar:SetValue(0)
scrollbar:SetWidth(16)
scrollbar:SetScript("OnValueChanged",
	function (self, value)
		self:GetParent():SetVerticalScroll(value)
	end)
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
scrollbg:SetAllPoints(scrollbar)
scrollbg:SetTexture(0, 0, 0, 0.4)
frame.scrollbar = scrollbar

--content frame
local content = CreateFrame("Frame", nil, scrollframe)
content:SetSize(128, 128)
local texture = content:CreateTexture()
texture:SetAllPoints()
texture:SetTexture("Interface\\GLUES\\MainMenu\\Glues-BlizzardLogo")
content.texture = texture
scrollframe.content = content

scrollframe:SetScrollChild(content)
Question
Does anyone have other examples/links/infos to corresponding panel/config item templates? Basically anything that helps setting up a gui config panel.

UI editor: http://www.feverguild.com/uieditor/

Implementation
Where does Blizzard use parts of that config templates? For example in the interface options.
https://github.com/tekkub/wow-ui-sou...ionsPanels.xml

Example XML implementation of the slider template
Code:
			<Slider name="$parentSpellAlertOpacitySlider" inherits="OptionsSliderTemplate">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentShowSpellAlerts" relativePoint="BOTTOMLEFT">
						<Offset>
							<AbsDimension x="24" y="-8"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnLoad>
						self.type = CONTROLTYPE_SLIDER;
						self.cvar = "spellActivationOverlayOpacity";
						self.SetDisplayValue = self.SetValue;
						self.SetValue = function (self, value)
							self:SetDisplayValue(value);
							SpellActivationOverlayFrame:SetAlpha(value);
						end
						BlizzardOptionsPanel_RegisterControl(self, self:GetParent());
						self:RegisterEvent("VARIABLES_LOADED");
						
						BlizzardOptionsPanel_SetupDependentControl(_G[self:GetParent():GetName().."ShowSpellAlerts"], self);
					</OnLoad>
					<OnValueChanged>
						self.value = value;
						self:SetValue(value);
						SetCVar(self.cvar, value);
					</OnValueChanged>
					<OnEvent>
						local val = tonumber(GetCVar(self.cvar));
						self:SetValue(val);
					</OnEvent>
				</Scripts>
			</Slider>
SetValue gets saved in a variable called SetDisplayValue. That is because SetValue gets overloaded by a new function that calls the old SetValue function but aswell calls another function to change the spellActivationOverlay for example. So that basically shows how to use the slider and change sth in the background while moving the slider.

Bringing both together (slider example and functionality from Blizzard example we get)
lua Code:
  1. local fname = "TestSlider"
  2. local f = CreateFrame("Slider", fname, UIParent, "OptionsSliderTemplate")
  3.  
  4. f:ClearAllPoints()
  5. f:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  6. f:SetMinMaxValues(0, 100)
  7. f:SetValue(50)
  8. _G[fname.."Low"]:SetText("0");
  9. _G[fname.."High"]:SetText("100");
  10. _G[fname.."Text"]:SetText(fname);
  11. f:Show()
  12.  
  13. f.cvar = "TestSliderValue";
  14. f.SetDisplayValue = f.SetValue;
  15. f.SetValue = function (s, v)
  16.   s:SetDisplayValue(v);
  17.   --function call
  18.   print("Slider value changed to: "..v);
  19. end
  20. --register variables loaded for later
  21. f:RegisterEvent("VARIABLES_LOADED");
  22.  
  23. f:SetScript("OnValueChanged", function(self, value)
  24.   --change stuff on value changed
  25.   self.value = value;
  26.   self:SetValue(value);
  27.   SetCVar(self.cvar, value);
  28. end)
  29.  
  30. f:SetScript("OnEvent", function(self)
  31.   --gets called on variables loaded
  32.   local val = tonumber(GetCVar(self.cvar));
  33.   self:SetValue(val);
  34. end)

__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 02-22-11 at 06:27 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Config item templates


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