Mercurial > wow > breuesk
view Gui.lua @ 48:b3679847e292
Kind of useful. I've accidentally gotten a table as the key before.
author | John@Yosemite-PC |
---|---|
date | Wed, 21 Mar 2012 22:51:34 -0400 |
parents | 4109683c3172 |
children | 11f18e279229 |
line wrap: on
line source
local AceGUI = LibStub("AceGUI-3.0") local bsk=bsk local _G=_G local table=table local pairs=pairs local ipairs=ipairs local string=string local tostring=tostring local type=type local getn=getn setfenv(1,bsk) local ChangeTab = function(container, event, group) container:ReleaseChildren() if group == "tab2" then local desc = AceGUI:Create("Label") desc:SetText("This is Tab 1") desc:SetFullWidth(true) container:AddChild(desc) local button = AceGUI:Create("Button") button:SetText("Tab 1 Button") button:SetWidth(200) container:AddChild(button) elseif group == "tab1" then --local leftGroup = AceGUI:Create("InlineGroup") --leftGroup:SetFullHeight() --leftGroup:SetWidth(200) local rightGroup = AceGUI:Create("InlineGroup") rightGroup:SetTitle("title") --rightGroup:SetWidth(600) --rightGroup:SetHeight(200) rightGroup.width = 'fill' --rightGroup:SetFullWidth() --rightGroup.alignoffset = 25 rightGroup:SetLayout("Flow") --local desc = AceGUI:Create("Label") --desc:SetText("This is Tab 1") --desc:SetFullWidth(true) --container:AddChild(desc) local icon = AceGUI:Create("Icon") icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]]) local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size icon:SetWidth(sz,sz) icon:SetHeight(sz,sz) icon:SetImageSize(sz,sz) icon:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); _G.GameTooltip:Show() end ) icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end ) rightGroup:AddChild(icon) for i=1,12 do icon = AceGUI:Create("Icon") icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]]) local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size icon:SetWidth(sz,sz) icon:SetHeight(sz,sz) icon:SetImageSize(sz,sz) icon:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); _G.GameTooltip:Show() end ) icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end ) rightGroup:AddChild(icon) end local item2 = {string="item2!", color = {r=1,g=0,b=0.5} } local itemList = {"Item1", "item2", "Item3", "Item4"} for i=5,29 do table.insert(itemList,"Item"..i) end local colorize = function(str,color) if str==nil or str=="" then return "" end if type(color) == "table" then color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b) end if color == nil then return str end return "|cff"..tostring(color or "ffffff")..str.."|r" end local pull = {} local ltemp = 0 for i,v in pairs(lists) do pull[i] = v.name --local entry = {value=i,text=v.name} if ltemp == 0 and getn(v) > 0 then ltemp = i end end PopulateRaidList() -- todo: this should be elsewhere scroller = AceGUI:Create("ScrollFrame") scroller:SetLayout("List") scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why scroller:SetFullHeight(true) scroller:SetFullWidth(true) local label = AceGUI:Create("InteractiveLabel") label:SetText("fucking hell\n") scroller:AddChild(label) scroller:AddChild(rightGroup) treecontrol = AceGUI:Create("TreeGroup") treecontrol:EnableButtonTooltips(false) treecontrol:SetFullWidth(true) treecontrol:SetFullHeight(true) treecontrol:SetAutoAdjustHeight(false) treecontrol:AddChild(scroller) local pulldown = AceGUI:Create("Dropdown") pulldown:SetWidth(175) pulldown:SetList(pull) for i,v in pairs(lists) do if getn(v) == 0 then pulldown:SetItemDisabled(i,true) end end local ovc = function(_,_,value) --treecontrol:ReleaseChildren() local tree = {} for x,y in ipairs(lists[value]) do local p = persons[y.id] local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]} line.iconCoords=_G.CLASS_ICON_TCOORDS[p.class] if not raidIdP[y.id] and not reserveIdP[y.id] then line.disabled = true else line.text=colorize(line.text,_G.RAID_CLASS_COLORS[p.class]) end table.insert(tree,line) end treecontrol:SetTree(tree) end pulldown:SetCallback("OnValueChanged", ovc) if ltemp > 0 then pulldown:SetValue(ltemp); ovc(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged container:AddChild(pulldown) container:AddChild(treecontrol) --pulldown:EnableButtonTooltips(false) --pulldown:SetFullWidth(true) --pulldown:SetFullHeight(true) --pulldown:SetAutoAdjustHeight(false) --pulldown:SetCallback("OnGroupSelected", function(widget,_,uniquevalue) print("OGS: uniquevalue: "..uniquevalue) --end) --pulldown:SetCallback("OnClick", function(widget,_,uniquevalue) print("Onclick: uniquevalue: " .. uniquevalue) end) --pulldown:SetCallback("OnButtonEnter", function(widget,_,value) print("OnButtonEnter: value: " .. value) end) end end --local myhook = function(tooltip, spellid) --tooltip:AddLine("MSS was here", 1, 1, 1) --tooltip:Show() --end --if GameTooltip:GetScript("OnTooltipSetSpell") then --GameTooltip:HookScript("OnTooltipSetSpell", myhook) --else --GameTooltip:SetScript("OnTooltipSetSpell", myhook) --end function CreateGUI() -- Create a container frame frame = AceGUI:Create("Frame") frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) frame:SetTitle("BSK") frame:SetLayout("Flow") frame:SetHeight(700) frame:SetWidth(700) --local opts = --{ --} --local tab = AceGUI:Create("TabGroup") --tab:SetLayout("Flow") --tab:SetTabs( -- { -- { -- text="Tab 1", -- value="tab1" -- }, -- { -- text="Tab 2", -- value="tab2" -- }, -- { -- text="Tab 3", -- value="tab3" -- }, -- { -- text="Tab 4", -- value="tab4" -- } -- } --) --tab.width = "fill" --tab.height = "fill" --tab:SetCallback("OnGroupSelected",ChangeTab) --tab:SelectTab("tab1") --frame:AddChild(tab) ChangeTab(frame,0,"tab1") -- Create a button --local btn = AceGUI:Create("Button") --btn:SetWidth(170) --btn:SetText("Button !") --btn:SetCallback("OnClick", function() Print("Click!") end) -- Add the button to the container --frame:AddChild(btn) end