comparison Gui.lua @ 56:94ae80d58903

Settling in on a layout I like
author John@Yosemite-PC
date Sun, 25 Mar 2012 13:09:31 -0400
parents 11f18e279229
children 615346b6ee99
comparison
equal deleted inserted replaced
55:59829ae918eb 56:94ae80d58903
8 local tostring=tostring 8 local tostring=tostring
9 local type=type 9 local type=type
10 local getn=getn 10 local getn=getn
11 setfenv(1,bsk) 11 setfenv(1,bsk)
12 12
13 local ChangeTab = function(container, event, group) 13 local copy = function(t)
14 container:ReleaseChildren() 14 local c = {}
15 if group == "tab2" then 15 if not t then return c end
16 local desc = AceGUI:Create("Label") 16 for i,v in pairs(t) do c[i] = v end
17 desc:SetText("This is Tab 1") 17 return c
18 desc:SetFullWidth(true) 18 end
19 container:AddChild(desc) 19 local colorize = function(str,color)
20 20 if str==nil or str=="" then return "" end
21 local button = AceGUI:Create("Button") 21 if type(color) == "table" then
22 button:SetText("Tab 1 Button") 22 color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
23 button:SetWidth(200) 23 end
24 container:AddChild(button) 24 if color == nil then return str end
25 elseif group == "tab1" then 25 return "|cff"..tostring(color or "ffffff")..str.."|r"
26 --local leftGroup = AceGUI:Create("InlineGroup") 26 end
27 --leftGroup:SetFullHeight() 27
28 --leftGroup:SetWidth(200) 28 local CreateListSelector = function(OnValueChanged)
29 29 PersonList:RefreshRaidList()
30 local rightGroup = AceGUI:Create("InlineGroup") 30 local pulldown = AceGUI:Create("Dropdown")
31 rightGroup:SetTitle("title") 31 local pull = {}
32 --rightGroup:SetWidth(600) 32 local ltemp = 0
33 --rightGroup:SetHeight(200) 33 local lids = LootLists:GetAllIds()
34 rightGroup.width = 'fill' 34 for _,v in pairs(lids) do
35 --rightGroup:SetFullWidth() 35 local l = LootLists:Select(v)
36 --rightGroup.alignoffset = 25 36 pull[l:GetId()] = l:GetName()
37 rightGroup:SetLayout("Flow") 37 --local entry = {value=i,text=v.name}
38 38 if l:GetLength() > 0 then
39 --local desc = AceGUI:Create("Label") 39 pulldown:SetItemDisabled(i,true)
40 --desc:SetText("This is Tab 1") 40 if ltemp == 0 then
41 --desc:SetFullWidth(true) 41 ltemp = l:GetId()
42 --container:AddChild(desc)
43 local icon = AceGUI:Create("Icon")
44 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]])
45 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size
46 icon:SetWidth(sz,sz)
47 icon:SetHeight(sz,sz)
48 icon:SetImageSize(sz,sz)
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 )
50 icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
51 rightGroup:AddChild(icon)
52
53 for i=1,12 do
54 icon = AceGUI:Create("Icon")
55 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]])
56 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size
57 icon:SetWidth(sz,sz)
58 icon:SetHeight(sz,sz)
59 icon:SetImageSize(sz,sz)
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 )
61 icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
62 rightGroup:AddChild(icon)
63 end
64
65 local item2 = {string="item2!", color = {r=1,g=0,b=0.5} }
66 local itemList = {"Item1", "item2", "Item3", "Item4"}
67 for i=5,29 do
68 table.insert(itemList,"Item"..i)
69 end
70
71 local colorize = function(str,color)
72 if str==nil or str=="" then return "" end
73 if type(color) == "table" then
74 color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
75 end
76 if color == nil then return str end
77 return "|cff"..tostring(color or "ffffff")..str.."|r"
78 end
79
80 PersonList:RefreshRaidList() -- todo: this should be elsewhere
81
82 scroller = AceGUI:Create("ScrollFrame")
83 scroller:SetLayout("List")
84 scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why
85 scroller:SetFullHeight(true)
86 scroller:SetFullWidth(true)
87
88 local label = AceGUI:Create("InteractiveLabel")
89 label:SetText("fucking hell\n")
90 scroller:AddChild(label)
91 scroller:AddChild(rightGroup)
92
93 treecontrol = AceGUI:Create("TreeGroup")
94 treecontrol:EnableButtonTooltips(false)
95 treecontrol:SetFullWidth(true)
96 treecontrol:SetFullHeight(true)
97 treecontrol:SetAutoAdjustHeight(false)
98
99 treecontrol:AddChild(scroller)
100
101 local pulldown = AceGUI:Create("Dropdown")
102 local pull = {}
103 local ltemp = 0
104 local lids = LootLists:GetAllIds()
105 for _,v in pairs(lids) do
106 local l = LootLists:Select(v)
107 pull[l:GetId()] = l:GetName()
108 --local entry = {value=i,text=v.name}
109 if l:GetLength() > 0 then
110 pulldown:SetItemDisabled(i,true)
111 if ltemp == 0 then
112 ltemp = l:GetId()
113 end
114 end 42 end
115 end 43 end
116 pulldown:SetWidth(175) 44 end
117 pulldown:SetList(pull) 45 pulldown:SetWidth(175)
118 --for i,v in pairs(lists) do 46 pulldown:SetList(pull)
119 -- if getn(v) == 0 then 47 pulldown:SetCallback("OnValueChanged", OnValueChanged)
120 -- pulldown:SetItemDisabled(i,true) 48 if ltemp > 0 then pulldown:SetValue(ltemp); OnValueChanged(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
121 -- end 49 return pulldown
122 --end 50 end
123 local ovc = function(_,_,value) 51
124 --treecontrol:ReleaseChildren() 52 local tree = {}
125 local tree = {} 53 local ovc = function(t1,value)
126 local l = LootLists:Select(value) 54 tree = {}
127 for le in l:OrderedListEntryIter() do 55 local l = LootLists:Select(value)
128 local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]} 56 for le in l:OrderedListEntryIter() do
129 line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()] 57 local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
130 if not PersonList:IsActive(le:GetId()) then 58 line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()]
131 line.disabled = true 59 line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()])
132 else 60 line.disabled = not PersonList:IsActive(le:GetId())
133 line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()]) 61 table.insert(tree,line)
134 end 62 end
135 table.insert(tree,line) 63 t1:SetList(tree)
136 end 64 end
137 treecontrol:SetTree(tree)
138 end
139 pulldown:SetCallback("OnValueChanged", ovc)
140 if ltemp > 0 then pulldown:SetValue(ltemp); ovc(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
141
142 container:AddChild(pulldown)
143 container:AddChild(treecontrol)
144
145 --pulldown:EnableButtonTooltips(false)
146 --pulldown:SetFullWidth(true)
147 --pulldown:SetFullHeight(true)
148 --pulldown:SetAutoAdjustHeight(false)
149
150 --pulldown:SetCallback("OnGroupSelected", function(widget,_,uniquevalue) print("OGS: uniquevalue: "..uniquevalue)
151 --end)
152 --pulldown:SetCallback("OnClick", function(widget,_,uniquevalue) print("Onclick: uniquevalue: " .. uniquevalue) end)
153 --pulldown:SetCallback("OnButtonEnter", function(widget,_,value) print("OnButtonEnter: value: " .. value) end)
154
155
156 end
157 end
158
159 --local myhook = function(tooltip, spellid)
160 --tooltip:AddLine("MSS was here", 1, 1, 1)
161 --tooltip:Show()
162 --end
163 --if GameTooltip:GetScript("OnTooltipSetSpell") then
164 --GameTooltip:HookScript("OnTooltipSetSpell", myhook)
165 --else
166 --GameTooltip:SetScript("OnTooltipSetSpell", myhook)
167 --end
168 65
169 function CreateGUI() 66 function CreateGUI()
170 67 local admin = bsk.admin
171 -- Create a container frame 68 local f = AceGUI:Create("Frame")
172 frame = AceGUI:Create("Frame") 69
173 frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) 70 f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
174 frame:SetTitle("BSK") 71 f:SetTitle("BSK")
175 frame:SetLayout("Flow") 72 f:SetLayout("Flow")
176 frame:SetHeight(700) 73 f:SetHeight(680)
177 frame:SetWidth(700) 74 f:SetWidth(580)
178 75
179 --local opts = 76 local left = AceGUI:Create("InlineGroup")
180 --{ 77 left:SetLayout("List")
181 78 left:SetWidth(175)
182 --} 79 left:SetFullHeight(true)
183 80 left.alignoffset=0.25 -- hack, as per http://forums.wowace.com/showthread.php?t=17114
184 81
185 82 local right = AceGUI:Create("InlineGroup")
186 83 right:SetLayout("Flow")
187 84 right:SetWidth(700-175-160)
188 85 right:SetFullHeight(true)
189 --local tab = AceGUI:Create("TabGroup") 86 right.alignoffset=0.25
190 --tab:SetLayout("Flow") 87
191 --tab:SetTabs( 88 local t1 = AceGUI:Create("SelectorList")
192 -- { 89 t1:SetNumLines(25)
193 -- { 90 t1:SetFullWidth(true)
194 -- text="Tab 1", 91 t1:SetInteractive(admin)
195 -- value="tab1" 92
196 -- }, 93 local listChange = function(_,_,value)
197 94 ovc(t1,value)
198 -- { 95 end
199 -- text="Tab 2", 96 local p1 = CreateListSelector(listChange)
200 -- value="tab2" 97 p1:SetFullWidth(true)
201 -- }, 98
202 -- { 99 left:AddChild(p1)
203 -- text="Tab 3", 100 left:AddChild(t1)
204 -- value="tab3" 101
205 -- }, 102 local t2 = AceGUI:Create("SelectorList")
206 -- { 103 t2:SetNumLines(7)
207 -- text="Tab 4", 104 t2:SetFullWidth(true)
208 -- value="tab4" 105 t2:EnableButtonTooltips(true)
209 -- } 106 t2:SetList({
210 -- } 107 {
211 --) 108 value=1,
212 --tab.width = "fill" 109 text = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
213 --tab.height = "fill" 110 link = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
214 111 },
215 --tab:SetCallback("OnGroupSelected",ChangeTab) 112 {
216 --tab:SelectTab("tab1") 113 value=2,
217 --frame:AddChild(tab) 114 text = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r",
218 ChangeTab(frame,0,"tab1") 115 link = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r"
219 116 },
220 -- Create a button 117 {
221 --local btn = AceGUI:Create("Button") 118 value=3,
222 --btn:SetWidth(170) 119 text = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r",
223 --btn:SetText("Button !") 120 link = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r"
224 --btn:SetCallback("OnClick", function() Print("Click!") end) 121 },
225 -- Add the button to the container 122 {
226 --frame:AddChild(btn) 123 value=4,
227 end 124 text = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r",
228 125 link = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r"
229 126 },
127 {
128 value=5,
129 text = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r",
130 link = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r"
131 },
132 })
133
134 local alb1 = AceGUI:Create("Button")
135 alb1:SetWidth(100)
136 alb1:SetText("Open Bids")
137 local alb2 = AceGUI:Create("Button")
138 alb2:SetWidth(100)
139 alb2:SetText("Assign")
140 local alb3 = AceGUI:Create("Button")
141 alb3:SetWidth(100)
142 alb3:SetText("Suicide")
143
144 local spacer = AceGUI:Create("Label")
145 spacer:SetText(" ")
146 spacer:SetFullWidth(true)
147 local spacer2 = AceGUI:Create("Label")
148 spacer2:SetText(" ")
149 spacer2:SetFullWidth(true)
150
151 local biddingZone = AceGUI:Create("SimpleGroup")
152 biddingZone:SetLayout("Flow")
153 biddingZone:SetFullWidth(true)
154
155 local label = AceGUI:Create("Label")
156 label:SetText("Bidding now open for ...")
157 local biddingOn = AceGUI:Create("InteractiveLabel")
158 biddingOn:SetText( "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r")
159 biddingOn:SetFullWidth(true)
160 biddingOn:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink("|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r"); _G.GameTooltip:Show() end )
161 biddingOn:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
162 local b1 = AceGUI:Create("SelectorList")
163 b1:SetNumLines(6)
164 b1:SetInteractive(admin)
165 local dummydata = {copy(tree[1]),copy( tree[2] ),copy( tree[3] )}
166 for i,v in pairs(dummydata) do v.disabled = false end
167 dummydata[2].text = dummydata[2].text .. " (roll 73)"
168 b1:SetList(dummydata)
169 local bidTitle = AceGUI:Create("Label")
170 bidTitle:SetText("Current bids")
171 bidTitle:SetFullWidth(true)
172
173
174 local bidRetractButton = AceGUI:Create("Button")
175 bidRetractButton:SetText("Place Bid")
176 bidRetractButton:SetWidth(100)
177 local rollButton = AceGUI:Create("Button")
178 rollButton:SetText("Offset Roll")
179 rollButton:SetWidth(100)
180
181 b1.alignoffset = 0.25 -- or else g1 won't align well
182 local g1 = AceGUI:Create("SimpleGroup")
183 g1.alignoffset = 0.25
184 g1:SetWidth(120)
185 g1:SetLayout("List")
186 local adminForce = AceGUI:Create("Button")
187 adminForce:SetText("Force bid")
188 adminForce:SetWidth(100)
189 local adminRetract = AceGUI:Create("Button")
190 adminRetract:SetText("Retract bid")
191 adminRetract:SetWidth(100)
192 g1:AddChildren(adminForce,adminRetract)
193
194
195
196 local suicideSelected = AceGUI:Create("Button")
197 suicideSelected:SetFullWidth(true)
198 suicideSelected:SetText("Suicide")
199 local undo = AceGUI:Create("Button")
200 undo:SetText("Undo")
201 undo:SetFullWidth(true)
202 local filter = AceGUI:Create("CheckBox")
203 filter:SetLabel("Only show active")
204 filter:SetFullWidth(true)
205
206 left:AddChildren(filter)
207 if admin then left:AddChildren(suicideSelected,undo) end
208 biddingZone:AddChildren(spacer,label,biddingOn,bidRetractButton,rollButton,spacer2,bidTitle,b1)
209 if admin then biddingZone:AddChildren(g1) end
210 right:AddChildren(t2)
211 if admin then right:AddChildren(alb1,alb2,alb3) end
212 right:AddChildren(biddingZone)
213 f:AddChildren(left,right)
214 end