Mercurial > wow > breuesk
diff Gui.lua @ 42:72055fc7e115
A lot of work to reign in namespacing (inspiration: WIM)
author | John@Doomsday |
---|---|
date | Thu, 15 Mar 2012 08:47:41 -0400 |
parents | 90622848932b |
children | 4109683c3172 |
line wrap: on
line diff
--- a/Gui.lua Wed Mar 14 22:06:19 2012 -0400 +++ b/Gui.lua Thu Mar 15 08:47:41 2012 -0400 @@ -1,4 +1,14 @@ 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() @@ -36,8 +46,8 @@ icon:SetWidth(sz,sz) icon:SetHeight(sz,sz) icon:SetImageSize(sz,sz) - icon:SetCallback("OnEnter", function(widget) GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); GameTooltip:Show() end ) - icon:SetCallback("OnLeave", function(widget) GameTooltip:Hide() end ) + 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 @@ -47,8 +57,8 @@ icon:SetWidth(sz,sz) icon:SetHeight(sz,sz) icon:SetImageSize(sz,sz) - icon:SetCallback("OnEnter", function(widget) GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); GameTooltip:Show() end ) - icon:SetCallback("OnLeave", function(widget) GameTooltip:Hide() end ) + 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 @@ -68,7 +78,7 @@ end local pull = {} local ltemp = 0 - for i,v in pairs(bsk.lists) do + 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 @@ -76,57 +86,57 @@ end end - bsk:PopulateRaidList() -- todo: this should be elsewhere + PopulateRaidList() -- todo: this should be elsewhere - bsk.scroller = AceGUI:Create("ScrollFrame") - bsk.scroller:SetLayout("List") - bsk.scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why - bsk.scroller:SetFullHeight(true) - bsk.scroller:SetFullWidth(true) + 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") - bsk.scroller:AddChild(label) - bsk.scroller:AddChild(rightGroup) + scroller:AddChild(label) + scroller:AddChild(rightGroup) - bsk.treecontrol = AceGUI:Create("TreeGroup") - bsk.treecontrol:EnableButtonTooltips(false) - bsk.treecontrol:SetFullWidth(true) - bsk.treecontrol:SetFullHeight(true) - bsk.treecontrol:SetAutoAdjustHeight(false) + treecontrol = AceGUI:Create("TreeGroup") + treecontrol:EnableButtonTooltips(false) + treecontrol:SetFullWidth(true) + treecontrol:SetFullHeight(true) + treecontrol:SetAutoAdjustHeight(false) - bsk.treecontrol:AddChild(bsk.scroller) + treecontrol:AddChild(scroller) local pulldown = AceGUI:Create("Dropdown") pulldown:SetWidth(175) pulldown:SetList(pull) - for i,v in pairs(bsk.lists) do + for i,v in pairs(lists) do if getn(v) == 0 then pulldown:SetItemDisabled(i,true) end end local ovc = function(_,_,value) - --bsk.treecontrol:ReleaseChildren() + --treecontrol:ReleaseChildren() local tree = {} - for x,y in ipairs(bsk.lists[value]) do - local p = bsk.persons[y.id] + 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=CLASS_ICON_TCOORDS[p.class] - if not bsk.raidIdP[y.id] and not bsk.reserveIdP[y.id] then + 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,RAID_CLASS_COLORS[p.class]) + line.text=colorize(line.text,_G.RAID_CLASS_COLORS[p.class]) end table.insert(tree,line) end - bsk.treecontrol:SetTree(tree) + 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(bsk.treecontrol) + container:AddChild(treecontrol) --pulldown:EnableButtonTooltips(false) --pulldown:SetFullWidth(true) @@ -152,15 +162,15 @@ --GameTooltip:SetScript("OnTooltipSetSpell", myhook) --end -function bsk:CreateGUI() +function CreateGUI() -- Create a container frame - self.frame = AceGUI:Create("Frame") - self.frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) - self.frame:SetTitle("BSK") - self.frame:SetLayout("Flow") - self.frame:SetHeight(700) - self.frame:SetWidth(700) + 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 = --{ @@ -200,16 +210,16 @@ --tab:SetCallback("OnGroupSelected",ChangeTab) --tab:SelectTab("tab1") - --self.frame:AddChild(tab) - ChangeTab(self.frame,0,"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) + --btn:SetCallback("OnClick", function() bsk:print("Click!") end) -- Add the button to the container - --self.frame:AddChild(btn) + --frame:AddChild(btn) end