John@38
|
1 local AceGUI = LibStub("AceGUI-3.0")
|
John@42
|
2 local bsk=bsk
|
John@42
|
3 local _G=_G
|
John@42
|
4 local table=table
|
John@42
|
5 local pairs=pairs
|
John@42
|
6 local ipairs=ipairs
|
John@42
|
7 local string=string
|
John@42
|
8 local tostring=tostring
|
John@42
|
9 local type=type
|
John@42
|
10 local getn=getn
|
John@42
|
11 setfenv(1,bsk)
|
John@1
|
12
|
John@56
|
13 local copy = function(t)
|
John@56
|
14 local c = {}
|
John@56
|
15 if not t then return c end
|
John@56
|
16 for i,v in pairs(t) do c[i] = v end
|
John@56
|
17 return c
|
John@56
|
18 end
|
John@56
|
19 local colorize = function(str,color)
|
John@56
|
20 if str==nil or str=="" then return "" end
|
John@56
|
21 if type(color) == "table" then
|
John@56
|
22 color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
|
John@56
|
23 end
|
John@56
|
24 if color == nil then return str end
|
John@56
|
25 return "|cff"..tostring(color or "ffffff")..str.."|r"
|
John@56
|
26 end
|
John@1
|
27
|
John@63
|
28 local CreateListSelector = function(SListPopulator)
|
John@56
|
29 PersonList:RefreshRaidList()
|
John@56
|
30 local pulldown = AceGUI:Create("Dropdown")
|
John@56
|
31 local pull = {}
|
John@56
|
32 local ltemp = 0
|
John@56
|
33 local lids = LootLists:GetAllIds()
|
John@56
|
34 for _,v in pairs(lids) do
|
John@56
|
35 local l = LootLists:Select(v)
|
John@56
|
36 pull[l:GetId()] = l:GetName()
|
John@56
|
37 --local entry = {value=i,text=v.name}
|
John@56
|
38 if l:GetLength() > 0 then
|
John@56
|
39 pulldown:SetItemDisabled(i,true)
|
John@56
|
40 if ltemp == 0 then
|
John@56
|
41 ltemp = l:GetId()
|
John@51
|
42 end
|
John@51
|
43 end
|
John@1
|
44 end
|
John@56
|
45 pulldown:SetWidth(175)
|
John@56
|
46 pulldown:SetList(pull)
|
John@63
|
47 pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:SetList(value) end)
|
John@63
|
48 if ltemp > 0 then pulldown:SetValue(ltemp); SListPopulator:SetList(ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
|
John@56
|
49 return pulldown
|
John@1
|
50 end
|
John@1
|
51
|
John@59
|
52 local f
|
John@59
|
53 local escapeButton =
|
John@59
|
54 {
|
John@59
|
55 shown = false,
|
John@59
|
56 ["IsShown"] = function(self) return self.shown end,
|
John@60
|
57 ["Hide"] = function(self) if f then AceGUI:Release(f); self.shown=false end end
|
John@59
|
58 }
|
John@38
|
59
|
John@63
|
60 local function FilterEventDispatcher()
|
John@63
|
61 end
|
John@63
|
62
|
John@63
|
63 SListEventDispatch =
|
John@63
|
64 {
|
John@63
|
65 listeners= {},
|
John@63
|
66 target = nil,
|
John@63
|
67 ["SetTarget"] = function(self,other)
|
John@63
|
68 self.target = other
|
John@63
|
69 self.target:SetCallback("OnSelectionCleared",SListListenerRebindOSC)
|
John@63
|
70 self.target:SetCallback("OnSelection",SListListenerRebindOS)
|
John@63
|
71 end,
|
John@63
|
72 ["RegisterListener"] = function(self,other) table.insert(self.listeners,other) end,
|
John@63
|
73 ["OnSelectionCleared"] = function(self,_)
|
John@63
|
74 self:Event("OnSelectionCleared")
|
John@63
|
75 end,
|
John@63
|
76 ["OnSelection"] = function(self,_,line)
|
John@63
|
77 self:Event("OnSelection",line)
|
John@63
|
78 end,
|
John@63
|
79 ["Event"] = function(self,event,arg)
|
John@63
|
80 if not self.target then error("Event called with no listener...") end
|
John@63
|
81 if not self.listeners then return end
|
John@63
|
82 for i,v in pairs(self.listeners) do
|
John@63
|
83 if type(v) == "table" then
|
John@63
|
84 if v[event] then
|
John@63
|
85 v[event](v,arg)
|
John@63
|
86 end
|
John@63
|
87 elseif type(v) == "function" then
|
John@63
|
88 v(event,arg)
|
John@63
|
89 elseif type(v) ~= "nil" then -- allow nils to pass quietly
|
John@63
|
90 _G.error("Bad listener - "..type(v))
|
John@63
|
91 end
|
John@63
|
92 end
|
John@63
|
93 end,
|
John@63
|
94 ["Release"] = function(self) self.listeners = {}; target=nil end
|
John@63
|
95 }
|
John@63
|
96 function SListListenerRebindOSC(...)
|
John@63
|
97 SListEventDispatch:OnSelectionCleared(...)
|
John@63
|
98 end
|
John@63
|
99 function SListListenerRebindOS(...)
|
John@63
|
100 SListEventDispatch:OnSelection(...)
|
John@63
|
101 end
|
John@63
|
102 local SListPopulator =
|
John@63
|
103 {
|
John@63
|
104 filtered = false,
|
John@63
|
105 widget = nil,
|
John@63
|
106 data = nil,
|
John@63
|
107 lref = nil,
|
John@63
|
108
|
John@63
|
109 ["Release"] = function(self) self.filtered, self.widget, self.data, self.lref = false, nil, nil, nil end,
|
John@63
|
110 ["Redraw"] = function(self)
|
John@63
|
111 if self.lref == nil or self.widget == nil then return end -- don't do work if not fully initialized
|
John@63
|
112 self.data = {}
|
John@63
|
113 for le in self.lref:OrderedListEntryIter() do
|
John@63
|
114 local disabled = not PersonList:IsActive(le:GetId())
|
John@63
|
115 if not self.filtered or not disabled then
|
John@63
|
116 local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
|
John@63
|
117 line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()]
|
John@63
|
118 line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()])
|
John@63
|
119 line.disabled = disabled
|
John@63
|
120 table.insert(self.data,line)
|
John@63
|
121 end
|
John@63
|
122 end
|
John@63
|
123 self.widget:SetList(self.data)
|
John@63
|
124 end,
|
John@63
|
125 ["SetWidget"] = function(self,w)
|
John@63
|
126 if type(w) ~= "table" or w["SetList"] == nil then
|
John@63
|
127 _G.error("Bad SetWidget")
|
John@63
|
128 end
|
John@63
|
129 self.widget = w
|
John@63
|
130 end,
|
John@63
|
131 ["SetFiltered"] = function(self,value)
|
John@63
|
132 self.filtered = value
|
John@63
|
133 self:Redraw()
|
John@63
|
134 end,
|
John@63
|
135 ["SetList"] = function(self,value)
|
John@63
|
136 self.lref = LootLists:Select(value)
|
John@63
|
137 self:Redraw()
|
John@63
|
138 end
|
John@63
|
139 }
|
John@63
|
140
|
John@42
|
141 function CreateGUI()
|
John@59
|
142 -- special registration procedure to be closable with the escape button
|
John@59
|
143 --escapeButton.shown = true
|
John@59
|
144 --_G["BSK_ESCAPEBUTTON"] = escapeButton
|
John@59
|
145 --table.insert(_G.UISpecialFrames, "BSK_ESCAPEBUTTON")
|
John@59
|
146
|
John@60
|
147 if f then return end -- no second gui please
|
John@60
|
148 local admin = bsk.admin or true
|
John@59
|
149 f = AceGUI:Create("Frame")
|
John@1
|
150
|
John@63
|
151 f:SetCallback("OnClose",function(widget) escapeButton.shown = false; AceGUI:Release(widget); f=nil; SListEventDispatch:Release(); SListPopulator:Release() end)
|
John@56
|
152 f:SetTitle("BSK")
|
John@56
|
153 f:SetLayout("Flow")
|
John@56
|
154 f:SetHeight(680)
|
John@56
|
155 f:SetWidth(580)
|
John@1
|
156
|
John@56
|
157 local left = AceGUI:Create("InlineGroup")
|
John@56
|
158 left:SetLayout("List")
|
John@56
|
159 left:SetWidth(175)
|
John@56
|
160 left:SetFullHeight(true)
|
John@56
|
161 left.alignoffset=0.25 -- hack, as per http://forums.wowace.com/showthread.php?t=17114
|
John@1
|
162
|
John@56
|
163 local right = AceGUI:Create("InlineGroup")
|
John@56
|
164 right:SetLayout("Flow")
|
John@56
|
165 right:SetWidth(700-175-160)
|
John@56
|
166 right:SetFullHeight(true)
|
John@56
|
167 right.alignoffset=0.25
|
John@38
|
168
|
John@56
|
169 local t1 = AceGUI:Create("SelectorList")
|
John@56
|
170 t1:SetNumLines(25)
|
John@56
|
171 t1:SetFullWidth(true)
|
John@56
|
172 t1:SetInteractive(admin)
|
John@63
|
173 SListPopulator:SetWidget(t1)
|
John@63
|
174 SListEventDispatch:SetTarget(t1)
|
John@38
|
175
|
John@63
|
176 local p1 = CreateListSelector(SListPopulator)
|
John@56
|
177 p1:SetFullWidth(true)
|
John@38
|
178
|
John@56
|
179 left:AddChild(p1)
|
John@56
|
180 left:AddChild(t1)
|
John@38
|
181
|
John@56
|
182 local t2 = AceGUI:Create("SelectorList")
|
John@56
|
183 t2:SetNumLines(7)
|
John@56
|
184 t2:SetFullWidth(true)
|
John@56
|
185 t2:EnableButtonTooltips(true)
|
John@56
|
186 t2:SetList({
|
John@56
|
187 {
|
John@56
|
188 value=1,
|
John@56
|
189 text = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
|
John@56
|
190 link = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
|
John@56
|
191 },
|
John@56
|
192 {
|
John@56
|
193 value=2,
|
John@56
|
194 text = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r",
|
John@56
|
195 link = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r"
|
John@56
|
196 },
|
John@56
|
197 {
|
John@56
|
198 value=3,
|
John@56
|
199 text = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r",
|
John@56
|
200 link = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r"
|
John@56
|
201 },
|
John@56
|
202 {
|
John@56
|
203 value=4,
|
John@56
|
204 text = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r",
|
John@56
|
205 link = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r"
|
John@56
|
206 },
|
John@56
|
207 {
|
John@56
|
208 value=5,
|
John@56
|
209 text = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r",
|
John@56
|
210 link = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r"
|
John@56
|
211 },
|
John@56
|
212 })
|
John@38
|
213
|
John@60
|
214 local alb1, alb2, alb3
|
John@60
|
215 if admin then
|
John@60
|
216 alb1 = AceGUI:Create("Button")
|
John@60
|
217 alb1:SetWidth(100)
|
John@60
|
218 alb1:SetText("Open Bids")
|
John@60
|
219
|
John@60
|
220 alb2 = AceGUI:Create("Button")
|
John@60
|
221 alb2:SetWidth(100)
|
John@60
|
222 alb2:SetText("Assign")
|
John@60
|
223
|
John@60
|
224 alb3 = AceGUI:Create("Button")
|
John@60
|
225 alb3:SetWidth(100)
|
John@60
|
226 alb3:SetText("Suicide")
|
John@60
|
227 end
|
John@38
|
228
|
John@56
|
229 local spacer = AceGUI:Create("Label")
|
John@56
|
230 spacer:SetText(" ")
|
John@56
|
231 spacer:SetFullWidth(true)
|
John@56
|
232 local spacer2 = AceGUI:Create("Label")
|
John@56
|
233 spacer2:SetText(" ")
|
John@56
|
234 spacer2:SetFullWidth(true)
|
John@38
|
235
|
John@56
|
236 local biddingZone = AceGUI:Create("SimpleGroup")
|
John@56
|
237 biddingZone:SetLayout("Flow")
|
John@56
|
238 biddingZone:SetFullWidth(true)
|
John@1
|
239
|
John@56
|
240 local label = AceGUI:Create("Label")
|
John@56
|
241 label:SetText("Bidding now open for ...")
|
John@56
|
242 local biddingOn = AceGUI:Create("InteractiveLabel")
|
John@58
|
243 biddingOn.userdata = { "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r" }
|
John@58
|
244 biddingOn:SetText(biddingOn.userdata[1])
|
John@56
|
245 biddingOn:SetFullWidth(true)
|
John@58
|
246 biddingOn:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink(widget.userdata[1]); _G.GameTooltip:Show() end )
|
John@56
|
247 biddingOn:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
|
John@56
|
248 local b1 = AceGUI:Create("SelectorList")
|
John@56
|
249 b1:SetNumLines(6)
|
John@56
|
250 b1:SetInteractive(admin)
|
John@63
|
251 local dummydata= {}
|
John@63
|
252 local tree =SListPopulator.data
|
John@63
|
253 for i,v in pairs(tree) do dummydata[i] = copy(v); dummydata[i].disabled = false end
|
John@63
|
254 if dummydata[2] then dummydata[2].text = dummydata[2].text .. " (roll 73)" end
|
John@56
|
255 b1:SetList(dummydata)
|
John@56
|
256 local bidTitle = AceGUI:Create("Label")
|
John@56
|
257 bidTitle:SetText("Current bids")
|
John@56
|
258 bidTitle:SetFullWidth(true)
|
John@56
|
259
|
John@56
|
260 local bidRetractButton = AceGUI:Create("Button")
|
John@56
|
261 bidRetractButton:SetText("Place Bid")
|
John@56
|
262 bidRetractButton:SetWidth(100)
|
John@56
|
263 local rollButton = AceGUI:Create("Button")
|
John@56
|
264 rollButton:SetText("Offset Roll")
|
John@56
|
265 rollButton:SetWidth(100)
|
John@56
|
266
|
John@60
|
267 local g1, suicideSelected, undo
|
John@60
|
268 if admin then
|
John@60
|
269 b1.alignoffset = 0.25 -- or else g1 won't align well
|
John@60
|
270 g1 = AceGUI:Create("SimpleGroup")
|
John@60
|
271 g1.alignoffset = 0.25
|
John@60
|
272 g1:SetWidth(120)
|
John@60
|
273 g1:SetLayout("List")
|
John@56
|
274
|
John@60
|
275 adminForce = AceGUI:Create("Button")
|
John@60
|
276 adminForce:SetText("Force bid")
|
John@60
|
277 adminForce:SetWidth(100)
|
John@56
|
278
|
John@60
|
279 adminRetract = AceGUI:Create("Button")
|
John@60
|
280 adminRetract:SetText("Retract bid")
|
John@60
|
281 adminRetract:SetWidth(100)
|
John@56
|
282
|
John@60
|
283 g1:AddChildren(adminForce,adminRetract)
|
John@60
|
284
|
John@60
|
285 suicideSelected = AceGUI:Create("Button")
|
John@60
|
286 suicideSelected:SetFullWidth(true)
|
John@60
|
287 suicideSelected:SetText("Suicide")
|
John@63
|
288 suicideSelected:SetDisabled(true) -- default is no selection has been made
|
John@63
|
289 -- use userdata + SListEventDispatch to toggle state
|
John@63
|
290 suicideSelected.userdata =
|
John@63
|
291 {
|
John@63
|
292 widget = suicideSelected,
|
John@63
|
293 ["OnSelection"] = function(self,_) self.widget:SetDisabled(false) end,
|
John@63
|
294 ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true) end
|
John@63
|
295 }
|
John@63
|
296 SListEventDispatch:RegisterListener(suicideSelected.userdata)
|
John@60
|
297
|
John@60
|
298 undo = AceGUI:Create("Button")
|
John@63
|
299 undo:SetText("Undo / out of order")
|
John@60
|
300 undo:SetFullWidth(true)
|
John@63
|
301 undo:SetDisabled(true)
|
John@60
|
302 end
|
John@60
|
303
|
John@60
|
304
|
John@56
|
305 local filter = AceGUI:Create("CheckBox")
|
John@56
|
306 filter:SetLabel("Only show active")
|
John@56
|
307 filter:SetFullWidth(true)
|
John@63
|
308 filter:SetValue(false)
|
John@63
|
309 SListPopulator:SetFiltered(false)
|
John@63
|
310 filter:SetCallback("OnValueChanged",function(widget,_,value) SListPopulator:SetFiltered(value) end)
|
John@56
|
311
|
John@56
|
312 left:AddChildren(filter)
|
John@56
|
313 if admin then left:AddChildren(suicideSelected,undo) end
|
John@56
|
314 biddingZone:AddChildren(spacer,label,biddingOn,bidRetractButton,rollButton,spacer2,bidTitle,b1)
|
John@56
|
315 if admin then biddingZone:AddChildren(g1) end
|
John@56
|
316 right:AddChildren(t2)
|
John@56
|
317 if admin then right:AddChildren(alb1,alb2,alb3) end
|
John@56
|
318 right:AddChildren(biddingZone)
|
John@56
|
319 f:AddChildren(left,right)
|
John@58
|
320
|
John@58
|
321
|
John@1
|
322 end
|