Mercurial > wow > breuesk
comparison 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 |
comparison
equal
deleted
inserted
replaced
41:dc9bfacca238 | 42:72055fc7e115 |
---|---|
1 local AceGUI = LibStub("AceGUI-3.0") | 1 local AceGUI = LibStub("AceGUI-3.0") |
2 local bsk=bsk | |
3 local _G=_G | |
4 local table=table | |
5 local pairs=pairs | |
6 local ipairs=ipairs | |
7 local string=string | |
8 local tostring=tostring | |
9 local type=type | |
10 local getn=getn | |
11 setfenv(1,bsk) | |
2 | 12 |
3 local ChangeTab = function(container, event, group) | 13 local ChangeTab = function(container, event, group) |
4 container:ReleaseChildren() | 14 container:ReleaseChildren() |
5 if group == "tab2" then | 15 if group == "tab2" then |
6 local desc = AceGUI:Create("Label") | 16 local desc = AceGUI:Create("Label") |
34 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]]) | 44 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]]) |
35 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size | 45 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size |
36 icon:SetWidth(sz,sz) | 46 icon:SetWidth(sz,sz) |
37 icon:SetHeight(sz,sz) | 47 icon:SetHeight(sz,sz) |
38 icon:SetImageSize(sz,sz) | 48 icon:SetImageSize(sz,sz) |
39 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 ) | 49 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 ) |
40 icon:SetCallback("OnLeave", function(widget) GameTooltip:Hide() end ) | 50 icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end ) |
41 rightGroup:AddChild(icon) | 51 rightGroup:AddChild(icon) |
42 | 52 |
43 for i=1,12 do | 53 for i=1,12 do |
44 icon = AceGUI:Create("Icon") | 54 icon = AceGUI:Create("Icon") |
45 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]]) | 55 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]]) |
46 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size | 56 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size |
47 icon:SetWidth(sz,sz) | 57 icon:SetWidth(sz,sz) |
48 icon:SetHeight(sz,sz) | 58 icon:SetHeight(sz,sz) |
49 icon:SetImageSize(sz,sz) | 59 icon:SetImageSize(sz,sz) |
50 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 ) | 60 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 ) |
51 icon:SetCallback("OnLeave", function(widget) GameTooltip:Hide() end ) | 61 icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end ) |
52 rightGroup:AddChild(icon) | 62 rightGroup:AddChild(icon) |
53 end | 63 end |
54 | 64 |
55 local item2 = {string="item2!", color = {r=1,g=0,b=0.5} } | 65 local item2 = {string="item2!", color = {r=1,g=0,b=0.5} } |
56 local itemList = {"Item1", "item2", "Item3", "Item4"} | 66 local itemList = {"Item1", "item2", "Item3", "Item4"} |
66 if color == nil then return str end | 76 if color == nil then return str end |
67 return "|cff"..tostring(color or "ffffff")..str.."|r" | 77 return "|cff"..tostring(color or "ffffff")..str.."|r" |
68 end | 78 end |
69 local pull = {} | 79 local pull = {} |
70 local ltemp = 0 | 80 local ltemp = 0 |
71 for i,v in pairs(bsk.lists) do | 81 for i,v in pairs(lists) do |
72 pull[i] = v.name | 82 pull[i] = v.name |
73 --local entry = {value=i,text=v.name} | 83 --local entry = {value=i,text=v.name} |
74 if ltemp == 0 and getn(v) > 0 then | 84 if ltemp == 0 and getn(v) > 0 then |
75 ltemp = i | 85 ltemp = i |
76 end | 86 end |
77 end | 87 end |
78 | 88 |
79 bsk:PopulateRaidList() -- todo: this should be elsewhere | 89 PopulateRaidList() -- todo: this should be elsewhere |
80 | 90 |
81 | 91 |
82 bsk.scroller = AceGUI:Create("ScrollFrame") | 92 scroller = AceGUI:Create("ScrollFrame") |
83 bsk.scroller:SetLayout("List") | 93 scroller:SetLayout("List") |
84 bsk.scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why | 94 scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why |
85 bsk.scroller:SetFullHeight(true) | 95 scroller:SetFullHeight(true) |
86 bsk.scroller:SetFullWidth(true) | 96 scroller:SetFullWidth(true) |
87 | 97 |
88 local label = AceGUI:Create("InteractiveLabel") | 98 local label = AceGUI:Create("InteractiveLabel") |
89 label:SetText("fucking hell\n") | 99 label:SetText("fucking hell\n") |
90 bsk.scroller:AddChild(label) | 100 scroller:AddChild(label) |
91 bsk.scroller:AddChild(rightGroup) | 101 scroller:AddChild(rightGroup) |
92 | 102 |
93 bsk.treecontrol = AceGUI:Create("TreeGroup") | 103 treecontrol = AceGUI:Create("TreeGroup") |
94 bsk.treecontrol:EnableButtonTooltips(false) | 104 treecontrol:EnableButtonTooltips(false) |
95 bsk.treecontrol:SetFullWidth(true) | 105 treecontrol:SetFullWidth(true) |
96 bsk.treecontrol:SetFullHeight(true) | 106 treecontrol:SetFullHeight(true) |
97 bsk.treecontrol:SetAutoAdjustHeight(false) | 107 treecontrol:SetAutoAdjustHeight(false) |
98 | 108 |
99 bsk.treecontrol:AddChild(bsk.scroller) | 109 treecontrol:AddChild(scroller) |
100 | 110 |
101 local pulldown = AceGUI:Create("Dropdown") | 111 local pulldown = AceGUI:Create("Dropdown") |
102 pulldown:SetWidth(175) | 112 pulldown:SetWidth(175) |
103 pulldown:SetList(pull) | 113 pulldown:SetList(pull) |
104 for i,v in pairs(bsk.lists) do | 114 for i,v in pairs(lists) do |
105 if getn(v) == 0 then | 115 if getn(v) == 0 then |
106 pulldown:SetItemDisabled(i,true) | 116 pulldown:SetItemDisabled(i,true) |
107 end | 117 end |
108 end | 118 end |
109 local ovc = function(_,_,value) | 119 local ovc = function(_,_,value) |
110 --bsk.treecontrol:ReleaseChildren() | 120 --treecontrol:ReleaseChildren() |
111 local tree = {} | 121 local tree = {} |
112 for x,y in ipairs(bsk.lists[value]) do | 122 for x,y in ipairs(lists[value]) do |
113 local p = bsk.persons[y.id] | 123 local p = persons[y.id] |
114 local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]} | 124 local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]} |
115 line.iconCoords=CLASS_ICON_TCOORDS[p.class] | 125 line.iconCoords=_G.CLASS_ICON_TCOORDS[p.class] |
116 if not bsk.raidIdP[y.id] and not bsk.reserveIdP[y.id] then | 126 if not raidIdP[y.id] and not reserveIdP[y.id] then |
117 line.disabled = true | 127 line.disabled = true |
118 else | 128 else |
119 line.text=colorize(line.text,RAID_CLASS_COLORS[p.class]) | 129 line.text=colorize(line.text,_G.RAID_CLASS_COLORS[p.class]) |
120 end | 130 end |
121 table.insert(tree,line) | 131 table.insert(tree,line) |
122 end | 132 end |
123 bsk.treecontrol:SetTree(tree) | 133 treecontrol:SetTree(tree) |
124 end | 134 end |
125 pulldown:SetCallback("OnValueChanged", ovc) | 135 pulldown:SetCallback("OnValueChanged", ovc) |
126 if ltemp > 0 then pulldown:SetValue(ltemp); ovc(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged | 136 if ltemp > 0 then pulldown:SetValue(ltemp); ovc(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged |
127 | 137 |
128 container:AddChild(pulldown) | 138 container:AddChild(pulldown) |
129 container:AddChild(bsk.treecontrol) | 139 container:AddChild(treecontrol) |
130 | 140 |
131 --pulldown:EnableButtonTooltips(false) | 141 --pulldown:EnableButtonTooltips(false) |
132 --pulldown:SetFullWidth(true) | 142 --pulldown:SetFullWidth(true) |
133 --pulldown:SetFullHeight(true) | 143 --pulldown:SetFullHeight(true) |
134 --pulldown:SetAutoAdjustHeight(false) | 144 --pulldown:SetAutoAdjustHeight(false) |
150 --GameTooltip:HookScript("OnTooltipSetSpell", myhook) | 160 --GameTooltip:HookScript("OnTooltipSetSpell", myhook) |
151 --else | 161 --else |
152 --GameTooltip:SetScript("OnTooltipSetSpell", myhook) | 162 --GameTooltip:SetScript("OnTooltipSetSpell", myhook) |
153 --end | 163 --end |
154 | 164 |
155 function bsk:CreateGUI() | 165 function CreateGUI() |
156 | 166 |
157 -- Create a container frame | 167 -- Create a container frame |
158 self.frame = AceGUI:Create("Frame") | 168 frame = AceGUI:Create("Frame") |
159 self.frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) | 169 frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) |
160 self.frame:SetTitle("BSK") | 170 frame:SetTitle("BSK") |
161 self.frame:SetLayout("Flow") | 171 frame:SetLayout("Flow") |
162 self.frame:SetHeight(700) | 172 frame:SetHeight(700) |
163 self.frame:SetWidth(700) | 173 frame:SetWidth(700) |
164 | 174 |
165 --local opts = | 175 --local opts = |
166 --{ | 176 --{ |
167 | 177 |
168 --} | 178 --} |
198 --tab.width = "fill" | 208 --tab.width = "fill" |
199 --tab.height = "fill" | 209 --tab.height = "fill" |
200 | 210 |
201 --tab:SetCallback("OnGroupSelected",ChangeTab) | 211 --tab:SetCallback("OnGroupSelected",ChangeTab) |
202 --tab:SelectTab("tab1") | 212 --tab:SelectTab("tab1") |
203 --self.frame:AddChild(tab) | 213 --frame:AddChild(tab) |
204 ChangeTab(self.frame,0,"tab1") | 214 ChangeTab(frame,0,"tab1") |
205 | 215 |
206 -- Create a button | 216 -- Create a button |
207 --local btn = AceGUI:Create("Button") | 217 --local btn = AceGUI:Create("Button") |
208 --btn:SetWidth(170) | 218 --btn:SetWidth(170) |
209 --btn:SetText("Button !") | 219 --btn:SetText("Button !") |
210 --btn:SetCallback("OnClick", function() print("Click!") end) | 220 --btn:SetCallback("OnClick", function() bsk:print("Click!") end) |
211 -- Add the button to the container | 221 -- Add the button to the container |
212 --self.frame:AddChild(btn) | 222 --frame:AddChild(btn) |
213 end | 223 end |
214 | 224 |
215 | 225 |