View Single Post
02-23-10, 03:25 PM   #18
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,929
Aha, I figured out why everything seemed extra codey to the way I usually work. The screenshot below I just wrote from the ground up with the following code. Where I use the UI Options templates it cuts down alot of the code which I personally don't need to alter. For those that like full control over their controls may be quite happy with your utility unfortunately it isn't for me in its current state. The same layout ( which you could see didn't work successfully ) took up at least 3 times the amount of coding which was unnecessary in my case. All I need to do is now set the anchors the way I usually do, although at present they look fine so far, and also set up the coding to reflect the changes and default values. And of course my SetMovable function needs to be set up along with the other related functions.

Code:
addonData["Interface"].AddCheckButton = function(name,text,parent)
	local f = CreateFrame("CheckButton", name, parent,"OptionsCheckButtonTemplate");
	_G[f:GetName().."Text"]:SetText(text);
	return f;
end

addonData["Interface"].AddPushButton = function(name,text,parent)
	local f = CreateFrame("Button",name,parent,"OptionsButtonTemplate");
	_G[f:GetName().."Text"]:SetText(text);
	return f;	
end

addonData["Interface"].AddSlider = function(name,text,parent,minValue,maxValue,stepValue, orientation)
        local f = CreateFrame("Slider",name,parent,"OptionsSliderTemplate");
		_G[f:GetName().."Text"]:SetText(text);
        _G[f:GetName().."Low"]:SetText(minValue);
        _G[f:GetName().."High"]:SetText(maxValue);
        f:SetMinMaxValues(minValue,maxValue);
        f:SetValueStep(stepValue);          
        f:SetOrientation(orientation);
        return f;      
end

addonData["Interface"].Create = function()

	local DefaultBackDrop = {
		bgFile = "Interface/Tooltips/UI-Tooltip-Background", 
		edgeFile = "Interface/Tooltips/UI-Tooltip-Border", 
		tile = true, 
		tileSize = 16, 
		edgeSize = 16, 
		insets = { left = 4, right = 4, top = 4, bottom = 4 }
	};

	local f = CreateFrame("Frame", "frameOptions", UIParent);
	f:SetBackdrop(DefaultBackDrop);
    f:SetBackdropColor(0, 0, 0, 1)
    f:SetHeight(320)
    f:SetWidth(400)
    f:SetPoint("CENTER",0,0)
    f:SetFrameStrata("HIGH")
    f:EnableMouse(true)
    f:SetClampedToScreen(true)
    f:SetMovable(true)
     
	f.Lock = addonData["Interface"].AddCheckButton("cbLock","Lock Frame",f);
    f.Lock:SetPoint("TOPLEFT",10,-230)
	    
	f.Multiple = addonData["Interface"].AddCheckButton("cbMultiple","Track Multiple Anchors",f);
    f.Multiple:SetPoint("TOPLEFT",10,-210)  

	f.BackGround = addonData["Interface"].AddCheckButton("cbBackGround","Show BackGround",f);
    f.BackGround:SetPoint("TOPLEFT",230,-250)

	f.AutoHide = addonData["Interface"].AddCheckButton("cbAutoHide","Auto Hide Frame",f);
    f.AutoHide:SetPoint("TOPLEFT",230,-210)
    
	f.AutoWiden = addonData["Interface"].AddCheckButton("cbAutoWiden","Auto Widen Frame",f);
    f.AutoWiden:SetPoint("TOPLEFT",230,-230)
	
	f.Reset = addonData["Interface"].AddPushButton("pbReset","Reset Config",f);
	f.Reset:SetWidth(150);
	f.Reset:SetHeight(30);
    f.Reset:SetPoint("TOPLEFT",10,-280)
	
	f.Dock = addonData["Interface"].AddPushButton("pbDock","Dock in InfoPanel",f);
	f.Dock:SetWidth(150);
	f.Dock:SetHeight(30);
    f.Dock:SetPoint("TOPLEFT",230,-280)
    
	f.Width = addonData["Interface"].AddSlider("sliWidth","Frame Width",f,1,100,1, "HORIZONTAL");
    f.Width:SetHeight(20);
    f.Width:SetWidth(360);
	f.Width:SetValue(50);
    f.Width:SetPoint("TOPLEFT",10,-20)
	
	f.Height = addonData["Interface"].AddSlider("sliHeight","Frame Height",f,1,100,1, "HORIZONTAL");
    f.Height:SetHeight(20);
    f.Height:SetWidth(360);
	f.Height:SetValue(50);
    f.Height:SetPoint("TOPLEFT",10,-60)

	f.Scroll = addonData["Interface"].AddSlider("sliScroll","Scroll Height",f,1,100,1, "HORIZONTAL");
    f.Scroll:SetHeight(20);
    f.Scroll:SetWidth(360);
	f.Scroll:SetValue(50);
    f.Scroll:SetPoint("TOPLEFT",10,-100)
	
	f.WatchableQuests = addonData["Interface"].AddSlider("sliWatchableQuests","Maximum Watchable Quests",f,1,100,1, "HORIZONTAL");
    f.WatchableQuests:SetHeight(20);
    f.WatchableQuests:SetWidth(360);
	f.WatchableQuests:SetValue(50);
    f.WatchableQuests:SetPoint("TOPLEFT",10,-140)
	
	f.WatchableCriteria = addonData["Interface"].AddSlider("sliWatchableCriteria","Maximum Watchable Achievement Criteria",f,1,100,1, "HORIZONTAL");
    f.WatchableCriteria:SetHeight(20);
    f.WatchableCriteria:SetWidth(360);
	f.WatchableCriteria:SetValue(50);
    f.WatchableCriteria:SetPoint("TOPLEFT",10,-180)
	
	f:Show();
end
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_022310_211748.jpg
Views:	1200
Size:	265.9 KB
ID:	3997  
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote