John@38: local AceGUI = LibStub("AceGUI-3.0") John@42: local bsk=bsk John@42: local _G=_G John@42: local table=table John@42: local pairs=pairs John@65: local setmetatable=setmetatable John@42: local ipairs=ipairs John@42: local string=string John@67: local sformat=string.format John@42: local tostring=tostring John@42: local type=type John@42: local getn=getn John@42: setfenv(1,bsk) John@1: John@69: -- todo: switching lists should close a presently-open bid John@69: John@56: local copy = function(t) John@56: local c = {} John@56: if not t then return c end John@56: for i,v in pairs(t) do c[i] = v end John@56: return c John@56: end John@56: local colorize = function(str,color) John@56: if str==nil or str=="" then return "" end John@56: if type(color) == "table" then John@56: color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b) John@56: end John@56: if color == nil then return str end John@56: return "|cff"..tostring(color or "ffffff")..str.."|r" John@56: end John@1: John@63: local CreateListSelector = function(SListPopulator) John@56: PersonList:RefreshRaidList() John@56: local pulldown = AceGUI:Create("Dropdown") John@56: local pull = {} John@56: local lids = LootLists:GetAllIds() John@56: for _,v in pairs(lids) do John@56: local l = LootLists:Select(v) John@56: pull[l:GetId()] = l:GetName() John@56: --local entry = {value=i,text=v.name} John@56: if l:GetLength() > 0 then John@56: pulldown:SetItemDisabled(i,true) John@51: end John@1: end John@56: pulldown:SetWidth(175) John@56: pulldown:SetList(pull) John@71: SListPopulator:SetSwidget(pulldown) John@72: pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:PulldownEvent(value) end) John@73: if stateactivelist > 0 then SListPopulator:PulldownEvent(stateactivelist) end -- default value John@56: return pulldown John@1: end John@1: John@72: local f, right -- important gui elements John@59: local escapeButton = John@59: { John@59: shown = false, John@59: ["IsShown"] = function(self) return self.shown end, John@60: ["Hide"] = function(self) if f then AceGUI:Release(f); self.shown=false end end John@59: } John@38: John@65: SelectorListEventDispatcher = John@63: { John@65: listeners = nil, John@63: target = nil, John@67: line = nil, John@63: ["SetTarget"] = function(self,other) John@63: self.target = other John@65: self.target:SetCallback("OnSelectionCleared",function(...) self:OnSelectionCleared(...) end) John@65: self.target:SetCallback("OnSelection",function(...) self:OnSelection(...) end) John@63: end, John@63: ["RegisterListener"] = function(self,other) table.insert(self.listeners,other) end, John@63: ["OnSelectionCleared"] = function(self,_) John@67: self.line = nil John@63: self:Event("OnSelectionCleared") John@63: end, John@65: ["OnSelection"] = function(self,_,_,line) John@67: self.line = line John@63: self:Event("OnSelection",line) John@63: end, John@63: ["Event"] = function(self,event,arg) John@63: if not self.target then error("Event called with no listener...") end John@63: if not self.listeners then return end John@63: for i,v in pairs(self.listeners) do John@67: --bsk.print("listener") John@63: if type(v) == "table" then John@63: if v[event] then John@63: v[event](v,arg) John@63: end John@63: elseif type(v) == "function" then John@63: v(event,arg) John@63: elseif type(v) ~= "nil" then -- allow nils to pass quietly John@63: _G.error("Bad listener - "..type(v)) John@63: end John@63: end John@63: end, John@67: ["Release"] = function(self) self.listeners = {}; self.target=nil; self.line=nil end, John@67: ["LatestValue"] = function(self) return self.line end John@63: } John@65: function SelectorListEventDispatcher:new() John@65: local t = {} John@65: setmetatable(t,SelectorListEventDispatcher) John@65: self.__index = self John@65: t.listeners = {} John@65: return t John@63: end John@65: John@65: SListEventDispatch = SelectorListEventDispatcher:new() John@65: LListEventDispatch = SelectorListEventDispatcher:new() John@67: RListEventDispatch = SelectorListEventDispatcher:new() John@65: John@81: function ConvertLe2Line(le) John@81: local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]} John@81: line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()] John@81: line.textPlain = line.text John@81: line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()]) John@81: return line John@81: end John@81: John@63: local SListPopulator = John@63: { John@63: filtered = false, John@63: widget = nil, John@71: swidget = nil, John@63: data = nil, John@63: lref = nil, John@63: John@71: ["Release"] = function(self) self.filtered, self.widget, self.swidget, self.data, self.lref = false, nil, nil, nil, nil end, John@63: ["Redraw"] = function(self) John@63: if self.lref == nil or self.widget == nil then return end -- don't do work if not fully initialized John@63: self.data = {} John@63: for le in self.lref:OrderedListEntryIter() do John@63: local disabled = not PersonList:IsActive(le:GetId()) John@63: if not self.filtered or not disabled then John@81: local line = ConvertLe2Line(le) John@63: line.disabled = disabled John@63: table.insert(self.data,line) John@63: end John@63: end John@63: self.widget:SetList(self.data) John@65: SListEventDispatch:Event("Redraw") John@63: end, John@71: ["SetSwidget"] = function(self,w) John@71: if type(w) ~= "table" or type(w.SetList) ~= "function" then John@71: _G.error("Bad SetWidget") John@71: end John@71: self.swidget = w John@71: end, John@63: ["SetWidget"] = function(self,w) John@65: if type(w) ~= "table" or type(w.SetList) ~= "function" then John@63: _G.error("Bad SetWidget") John@63: end John@63: self.widget = w John@63: end, John@63: ["SetFiltered"] = function(self,value) John@63: self.filtered = value John@63: self:Redraw() John@63: end, John@72: ["SelectList"] = function(self,value,nocomm) John@71: self.swidget:SetValue(value) John@72: local l = LootLists:Select(value) John@72: if l ~= self.lref then John@72: self.lref = l John@72: self:Redraw() John@72: end John@72: if nocomm then InitiateActiveList(value) end John@72: end, John@72: John@72: John@72: ["PulldownEvent"] = function(self,value) John@72: self:SelectList(value) John@72: if admin and state == "looting" then John@72: InitiateActivateList(value) John@72: end John@68: end, John@68: ["DataEvent"] = function(self) John@68: self:Redraw() John@69: end, John@72: ["StateEvent"] = function(self) John@75: -- todo: events still happen even if the gui is closed. protect the api. John@75: John@73: print("State event in SL: ", state, admin) John@72: if state == "bidding" or (state == "looting" and not admin) then John@72: self.swidget:SetDisabled(true) John@72: self:SelectList(stateactivelist) John@72: else John@72: self.swidget:SetDisabled(false) John@72: end John@72: -- if bidding then disable pulldown John@72: -- if looting and not admin then disable pulldown John@72: -- if looting and admin then enable pulldown John@72: -- otherwise enable pulldown John@72: end, John@72: ["ActiveListEvent"] = function(self) John@72: self:SelectList(stateactivelist) John@72: end, John@72: John@72: John@72: John@69: ["GetMe"] = function(self) John@69: local me = _G.UnitName("player") John@69: for i,v in pairs(self.data) do John@69: if v.textPlain == me then John@69: return v John@69: end John@69: end John@69: end, John@69: } John@69: John@69: local LListPopulator = John@69: { John@69: data = {}, John@69: widget = nil, John@69: ["Release"] = function(self) self.data = {}; self.widget = nil end, John@73: ["ItemListEvent"] = function(self) self:Redraw() end, John@69: ["Redraw"]= function(self) John@73: self.data = {} John@73: for i,v in pairs(stateitemlist) do John@78: local entry = {value=i, text=v.link, link=v.link, mlid=v.mlid} John@73: table.insert(self.data,entry) John@73: end John@73: if self.widget then John@73: self.widget:SetList(self.data) John@73: LListEventDispatch:Event("Redraw") John@73: end John@69: end, John@69: ["SetWidget"] = function(self,w) John@69: if type(w) ~= "table" or type(w.SetList) ~= "function" then John@69: _G.error("Bad SetWidget") John@69: end John@69: self.widget = w John@76: --if debug then John@76: -- self.data = { John@76: -- { John@76: -- value=1, John@76: -- text = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r", John@76: -- link = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r", John@76: -- }, John@76: -- { John@76: -- value=2, John@76: -- text = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r", John@76: -- link = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r" John@76: -- }, John@76: -- { John@76: -- value=3, John@76: -- text = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r", John@76: -- link = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r" John@76: -- }, John@76: -- { John@76: -- value=4, John@76: -- text = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r", John@76: -- link = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r" John@76: -- }, John@76: -- { John@76: -- value=5, John@76: -- text = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r", John@76: -- link = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r" John@76: -- }, John@76: -- } John@76: --end John@69: self:Redraw() John@69: end, John@69: } John@69: John@69: local RListPopulator = John@69: { John@69: widget = nil, John@71: ["RollEvent"] = function(self) self:Redraw() end, John@71: ["Release"] = function(self) self.widget = nil end, John@69: ["Redraw"] = function(self) John@79: local list = {} John@79: for i,v in pairs(statebids) do John@79: table.insert(list,v) John@79: end John@79: for i,v in pairs(staterolls) do John@79: local roll John@79: for r,s in pairs(staterollvalues) do John@79: if s.value == v.value then John@79: roll = r John@79: break John@79: end John@79: end John@79: print("Inserting a roll ", v.value, roll) John@79: John@79: local c = copy(v) John@79: c.disabled = false John@79: c.text = c.text .. " (roll "..roll..")" John@79: table.insert(list,c) John@79: end John@79: self.widget:SetList(list) John@69: RListEventDispatch:Event("Redraw") John@69: end, John@69: ["SetWidget"] = function(self,w) John@69: if type(w) ~= "table" or type(w.SetList) ~= "function" then John@69: _G.error("Bad SetWidget") John@69: end John@69: self.widget = w John@71: --if debug then John@71: -- local dummydata = {} John@71: -- local tree = SListPopulator.data John@71: -- for i,v in pairs(tree) do dummydata[i] = copy(v); dummydata[i].disabled = false end John@71: -- if dummydata[2] then dummydata[2].text = dummydata[2].text .. " (roll 73)" end John@71: -- self.data = dummydata John@71: --end John@69: self:Redraw() John@69: end, John@79: ["Force"] = function(self,who) -- todo: remove this and the horse it rode in on John@69: local new = self.Convert(who,72) John@71: InitiateBid(new) John@71: --self:Redraw() John@69: end, John@79: ["Retract"] = function(self,who) -- todo: remove this and the horse it rode in on John@71: -- todo John@71: --for i,v in pairs(self.data) do John@71: -- if who.value == v.value then John@71: -- table.remove(self.data,i) John@71: -- end John@71: --end John@71: InitiateRetract(copy(who)) John@71: --self:Redraw() John@69: end, John@69: ["Convert"] = function(who,roll) -- convert an LE object into one suitable to put in a SelectorList John@69: local new = copy(who) John@69: new.disabled = false -- todo: should be unnessary - they can't get on the list like this John@69: if roll then John@69: new.text = new.text .. " (roll 73)" John@69: end John@69: return new John@69: end, John@63: } John@63: John@75: local BZPopulator = John@75: { John@75: group = nil, John@75: ["SetGroup"] = function(self,g) John@75: if type(g) ~= "table" or type(g.AddChild) ~= "function" then John@75: _G.error("Bad SetGroup for BZPopulator") John@75: end John@75: self.group = g John@75: end, John@75: John@75: John@75: ["Release"] = function(self) self.group = nil; RListEventDispatch:Release(); RListPopulator:Release() end, John@75: John@75: ["StateEvent"] = function(self) John@75: if state == "bidding" then John@75: John@75: local spacer = AceGUI:Create("Label") John@75: spacer:SetText(" ") John@75: spacer:SetFullWidth(true) John@76: local spacer2 = AceGUI:Create("Label") -- don't try to combine this with "spacer" - you can't add a child more than once John@75: spacer2:SetText(" ") John@75: spacer2:SetFullWidth(true) John@75: John@75: local label = AceGUI:Create("Label") John@75: label:SetText("Bidding now open for ...") John@75: local biddingOn = AceGUI:Create("InteractiveLabel") John@75: biddingOn.userdata = { stateitem.link } John@75: biddingOn:SetText(biddingOn.userdata[1]) John@75: biddingOn:SetFullWidth(true) John@75: biddingOn:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink(widget.userdata[1]); _G.GameTooltip:Show() end ) John@75: biddingOn:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end ) John@75: local b1 = AceGUI:Create("SelectorList") John@75: b1:SetNumLines(6) John@75: b1:SetInteractive(admin) John@75: local bidTitle = AceGUI:Create("Label") John@75: bidTitle:SetText("Current bids") John@75: bidTitle:SetFullWidth(true) John@75: John@75: local bidRetractButton = AceGUI:Create("Button") John@75: bidRetractButton:SetText("Place Bid") John@75: bidRetractButton:SetWidth(100) John@76: bidRetractButton:SetCallback("OnClick", function(widget) InitiateBid(SListPopulator:GetMe()) end) John@76: John@75: local rollButton = AceGUI:Create("Button") John@75: rollButton:SetText("Offset Roll") John@75: rollButton:SetWidth(100) John@79: rollButton:SetCallback("OnClick", function(widget) InitiateRollRequest(SListPopulator:GetMe()) end) -- todo: wrong behavior. GetMe will nil if the person isn't on the currently selected loot list. this could easily happen. return a new thingy instead John@79: local retractButton = AceGUI:Create("Button") John@79: retractButton:SetText("Retract") John@79: retractButton:SetWidth(100) John@79: retractButton:SetCallback("OnClick", function(widget) InitiateRetract(SListPopulator:GetMe()) end) John@75: John@75: RListEventDispatch:SetTarget(b1) John@75: RListPopulator:SetWidget(b1) John@75: John@75: local g1 John@75: if admin then John@75: b1.alignoffset = 0.25 -- or else g1 won't align well John@75: g1 = AceGUI:Create("SimpleGroup") John@75: g1.alignoffset = 0.25 John@75: g1:SetWidth(120) John@75: g1:SetLayout("List") John@75: John@75: -- todo: convoluted and repetitive - surely there's a John@75: -- better way than this ... John@75: adminForce = AceGUI:Create("Button") John@75: if SListEventDispatch:LatestValue() then John@75: adminForce:SetText(sformat("Force bid (%s)",SListEventDispatch:LatestValue().textPlain)) John@75: adminForce:SetDisabled(false) John@75: else John@75: adminForce:SetText("Force bid") John@75: adminForce:SetDisabled(true) John@75: end John@75: adminForce:SetWidth(160) John@78: adminForce:SetCallback("OnClick",function(widget) InitiateBid(SListEventDispatch:LatestValue()) end) John@75: adminForce.userdata = John@75: { John@75: widget = adminForce, John@75: ["Redraw"] = function(self,_) self.widget:SetDisabled(true); self.widget:SetText("Force bid") end, John@75: ["OnSelection"] = function(self,_) self.widget:SetDisabled(false); self.widget:SetText(sformat("Force bid (%s)",SListEventDispatch:LatestValue().textPlain)) end, John@75: ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true); self.widget:SetText("Force bid") end John@75: } John@75: SListEventDispatch:RegisterListener(adminForce.userdata) John@75: John@75: adminRetract = AceGUI:Create("Button") John@75: if RListEventDispatch:LatestValue() then John@75: adminRetract:SetText(sformat("Retract bid (%s)",RListEventDispatch:LatestValue().textPlain)) John@75: adminRetract:SetDisabled(false) John@75: else John@75: adminRetract:SetText("Retract bid") John@75: adminRetract:SetDisabled(true) John@75: end John@75: adminRetract:SetWidth(160) John@75: adminRetract.userdata = John@75: { John@75: widget = adminRetract, John@75: ["Redraw"] = function(self,_) self.widget:SetDisabled(true); self.widget:SetText("Retract bid") end, John@75: ["OnSelection"] = function(self,_) self.widget:SetDisabled(false); self.widget:SetText(sformat("Retract bid (%s)",RListEventDispatch:LatestValue().textPlain)) end, John@75: ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true); self.widget:SetText("Retract bid") end John@75: } John@75: adminRetract:SetCallback("OnClick",function(widget) RListPopulator:Retract(RListEventDispatch:LatestValue()) end) John@75: RListEventDispatch:RegisterListener(adminRetract.userdata) John@75: adminRetract:SetDisabled(true) John@75: John@75: g1:AddChildren(adminForce,adminRetract) John@75: end John@75: John@79: self.group:AddChildren(spacer,label,biddingOn,bidRetractButton,rollButton,retractButton,spacer2,bidTitle,b1) John@75: if admin then self.group:AddChildren(g1) end John@75: John@75: else John@75: John@75: John@75: self.group:ReleaseChildren() John@75: RListEventDispatch:Release() John@75: RListPopulator:Release() John@75: end John@75: John@75: end, John@75: John@75: John@75: } John@75: John@68: DataEventDispatch = John@68: { John@68: -- todo: batch events John@68: listeners = {}, John@68: ["DataEvent"] = function(self,_) --todo: pass along the received event John@68: for i,v in pairs(self.listeners) do John@68: if v and v["DataEvent"] then John@68: v:DataEvent() John@68: end John@68: end John@68: end, John@68: ["RegisterListener"] = function(self,listener) John@68: if not listener or not listener["DataEvent"] then John@68: _G.error("Bad listener") John@68: end John@68: table.insert(self.listeners,listener) John@68: end John@68: } John@68: John@76: AdminLootButtons = John@76: { John@76: openButton = nil, John@76: assignButton = nil, John@76: suicideButton = nil, John@76: -- todo - open roll button John@76: John@76: eventsFromLL = John@76: { John@76: ["Redraw"] = function(self) AdminLootButtons:Redraw() end, John@76: ["OnSelection"] = function(self) AdminLootButtons:Redraw() end, John@76: ["OnSelectionCleared"] = function(self) AdminLootButtons:Redraw() end, John@76: }, John@76: eventsFromSL = John@76: { John@76: ["Redraw"] = function(self) AdminLootButtons:Redraw() end, John@76: ["OnSelection"] = function(self) AdminLootButtons:Redraw() end, John@76: ["OnSelectionCleared"] = function(self) AdminLootButtons:Redraw() end, John@76: }, John@76: ["StateEvent"] = function(self) self:Redraw() end, John@76: ["RollEvent"] = function(self) self:Redraw() end, John@76: John@76: ["SetButtons"] = function(self,open,assign,suicide) John@76: self.openButton = open John@76: self.assignButton = assign John@76: self.suicideButton = suicide John@76: SListEventDispatch:RegisterListener(self.eventsFromSL) John@76: LListEventDispatch:RegisterListener(self.eventsFromLL) John@76: self:Redraw() John@76: end, John@76: ["Release"] = function(self) John@76: self.openButton = nil John@76: self.assignButton = nil John@76: self.suicideButton = nil John@76: end, John@76: John@76: ["Redraw"] = function(self) John@76: if state == "neutral" then -- gray all buttons John@76: self.openButton:SetText("Open Bids") John@76: self.openButton:SetDisabled(true) John@76: self.assignButton:SetText("Assign") John@76: self.assignButton:SetDisabled(true) John@76: self.suicideButton:SetText("Suicide") John@76: self.suicideButton:SetDisabled(true) John@76: elseif state == "looting" then John@76: if LListEventDispatch.line then John@76: self.openButton:SetDisabled(false) John@76: self.openButton:SetText("Open Bids") John@76: self.openButton:SetCallback("OnClick", function(widget) InitiateOpenBid(LListEventDispatch:LatestValue()) end) John@76: else John@76: self.openButton:SetText("Open Bids") John@76: self.openButton:SetDisabled(true) John@76: end John@76: if LListEventDispatch.line and SListEventDispatch.line then John@76: self.assignButton:SetText("Assign") John@76: self.assignButton:SetDisabled(false) John@76: self.assignButton:SetCallback("OnClick", function(widget) FreeLoot(LListEventDispatch:LatestValue(),SListEventDispatch:LatestValue()) end) John@76: self.suicideButton:SetText("Suicide") John@76: self.suicideButton:SetDisabled(false) John@78: self.suicideButton:SetCallback("OnClick", function(widget) DirectSuicideLoot(LListEventDispatch:LatestValue(),SListEventDispatch:LatestValue(),SListPopulator.lref) end) John@76: else John@76: self.assignButton:SetText("Assign") John@76: self.assignButton:SetDisabled(true) John@76: self.suicideButton:SetText("Suicide") John@76: self.suicideButton:SetDisabled(true) John@76: end John@76: -- if item selected, light up Open button John@76: -- if item selected and name selected, light up assign/suicide John@76: -- buttons John@76: elseif state == "bidding" then John@76: self.openButton:SetDisabled(false) John@76: self.openButton:SetText("Cancel Bidding") John@76: self.openButton:SetCallback("OnClick", function(widget) InitiateCloseBidding() end) John@76: self.assignButton:SetText("Finish & Assign") John@76: self.assignButton:SetDisabled(not (getn(staterolls) > 0 or getn(statebids) > 0)) John@81: self.assignButton:SetCallback("OnClick", function(widget) ExpensiveLoot(LListEventDispatch:LatestValue(),SListPopulator.lref) end) -- todo: problem here - use stateitem instead John@76: self.suicideButton:SetText(" ") John@76: self.suicideButton:SetDisabled(true) John@76: John@76: -- change open button to cancel John@76: -- change assign button to award John@76: -- disable ... and rename? the third button John@76: John@76: end John@76: end, John@76: } John@76: John@68: function OnInitializeSetStaticData() John@68: SetChangeListener(DataEventDispatch) John@68: DataEventDispatch:RegisterListener(SListPopulator) John@72: RegisterListenerActiveListChanged(SListPopulator) John@72: RegisterListenerStateChange(SListPopulator) John@71: RegisterListenerRolls(RListPopulator) John@73: RegisterItemListListener(LListPopulator) John@75: RegisterListenerStateChange(BZPopulator) John@76: if admin then John@76: RegisterListenerStateChange(AdminLootButtons) John@76: RegisterListenerRolls(AdminLootButtons) John@76: end John@68: end John@68: John@42: function CreateGUI() John@59: -- special registration procedure to be closable with the escape button John@59: --escapeButton.shown = true John@59: --_G["BSK_ESCAPEBUTTON"] = escapeButton John@59: --table.insert(_G.UISpecialFrames, "BSK_ESCAPEBUTTON") John@59: John@60: if f then return end -- no second gui please John@59: f = AceGUI:Create("Frame") John@1: John@76: f:SetCallback("OnClose",function(widget) escapeButton.shown = false; AceGUI:Release(widget); f=nil; right=nil; SListEventDispatch:Release(); LListEventDispatch:Release(); SListPopulator:Release(); RListEventDispatch:Release(); LListPopulator:Release(); RListPopulator:Release(); BZPopulator:Release(); AdminLootButtons:Release() end) John@56: f:SetTitle("BSK") John@56: f:SetLayout("Flow") John@56: f:SetHeight(680) John@56: f:SetWidth(580) John@1: John@56: local left = AceGUI:Create("InlineGroup") John@56: left:SetLayout("List") John@56: left:SetWidth(175) John@56: left:SetFullHeight(true) John@56: left.alignoffset=0.25 -- hack, as per http://forums.wowace.com/showthread.php?t=17114 John@1: John@65: right = AceGUI:Create("InlineGroup") John@56: right:SetLayout("Flow") John@56: right:SetWidth(700-175-160) John@56: right:SetFullHeight(true) John@56: right.alignoffset=0.25 John@38: John@56: local t1 = AceGUI:Create("SelectorList") John@56: t1:SetNumLines(25) John@56: t1:SetFullWidth(true) John@56: t1:SetInteractive(admin) John@69: SListEventDispatch:SetTarget(t1) John@63: SListPopulator:SetWidget(t1) John@38: John@63: local p1 = CreateListSelector(SListPopulator) John@56: p1:SetFullWidth(true) John@38: John@56: left:AddChild(p1) John@56: left:AddChild(t1) John@38: John@56: local t2 = AceGUI:Create("SelectorList") John@56: t2:SetNumLines(7) John@56: t2:SetFullWidth(true) John@56: t2:EnableButtonTooltips(true) John@65: LListEventDispatch:SetTarget(t2) John@69: LListPopulator:SetWidget(t2) John@65: John@75: biddingZone = AceGUI:Create("SimpleGroup") John@65: biddingZone:SetLayout("Flow") John@65: biddingZone:SetFullWidth(true) John@75: BZPopulator:SetGroup(biddingZone) John@38: John@60: local alb1, alb2, alb3 John@60: if admin then John@60: alb1 = AceGUI:Create("Button") John@76: alb1:SetWidth(120) John@76: --alb1:SetText("Open Bids") John@76: --alb1.userdata = John@76: --{ John@76: -- state = false, John@76: -- widget = alb1, John@76: -- ["Redraw"] = function(self,_) self.widget:SetDisabled(true); self.item = nil end, John@76: -- ["OnSelection"] = function(self,value) self.widget:SetDisabled(false); self.item = value end, John@76: -- ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true); self.item = nil end John@76: --} John@76: --alb1:SetDisabled(true) John@76: --LListEventDispatch:RegisterListener(alb1.userdata) John@76: --alb1:SetCallback("OnClick", John@76: -- function(widget) John@76: -- if widget.userdata.state then -- we were bidding when the button was pressed John@76: -- widget:SetText("Open Bids") John@76: -- InitiateCloseBidding() -- todo: plug in loot award, etc John@76: -- else John@76: -- widget:SetText("Close bids") John@76: -- InitiateOpenBid(LListEventDispatch:LatestValue()) John@76: -- end John@76: -- widget.userdata.state = not widget.userdata.state John@76: -- end John@76: --) John@60: John@60: alb2 = AceGUI:Create("Button") John@76: alb2:SetWidth(120) John@76: --alb2:SetText("Assign") John@76: --alb2.userdata = John@76: --{ John@76: -- widget = alb2, John@76: -- ["OnUpdate"] = function(self) self.widget:SetDisabled(not (self.slist.checked and self.llist.checked)) end, John@76: --} John@76: --alb2.userdata.slist = John@76: --{ John@76: -- parent = alb2.userdata, John@76: -- checked = false, John@76: -- ["Redraw"] = function(self) self.checked = false; self.parent:OnUpdate() end, John@76: -- ["OnSelection"] = function(self) self.checked = true; self.parent:OnUpdate() end, John@76: -- ["OnSelectionCleared"] = function(self) self.checked = false; self.parent:OnUpdate() end, John@76: --} John@76: --alb2.userdata.llist = John@76: --{ John@76: -- parent = alb2.userdata, John@76: -- checked = false, John@76: -- ["Redraw"] = function(self) self.checked = false; self.parent:OnUpdate() end, John@76: -- ["OnSelection"] = function(self) self.checked = true; self.parent:OnUpdate() end, John@76: -- ["OnSelectionCleared"] = function(self) self.checked = false; self.parent:OnUpdate() end, John@76: --} John@76: --SListEventDispatch:RegisterListener(alb2.userdata.slist) John@76: --LListEventDispatch:RegisterListener(alb2.userdata.llist) John@60: John@60: alb3 = AceGUI:Create("Button") John@76: alb3:SetWidth(120) John@76: --alb3:SetText("Suicide") John@76: --alb3.userdata = -- TODO: holy hell, come up with a pattern or something for this .... John@76: --{ John@76: -- widget = alb3, John@76: -- ["OnUpdate"] = function(self) self.widget:SetDisabled(not (self.slist.checked and self.llist.checked)) end, John@76: --} John@76: --alb3.userdata.slist = John@76: --{ John@76: -- parent = alb3.userdata, John@76: -- checked = false, John@76: -- ["Redraw"] = function(self) self.checked = false; self.parent:OnUpdate() end, John@76: -- ["OnSelection"] = function(self) self.checked = true; self.parent:OnUpdate() end, John@76: -- ["OnSelectionCleared"] = function(self) self.checked = false; self.parent:OnUpdate() end, John@76: --} John@76: --alb3.userdata.llist = John@76: --{ John@76: -- parent = alb3.userdata, John@76: -- checked = false, John@76: -- ["Redraw"] = function(self) self.checked = false; self.parent:OnUpdate() end, John@76: -- ["OnSelection"] = function(self) self.checked = true; self.parent:OnUpdate() end, John@76: -- ["OnSelectionCleared"] = function(self) self.checked = false; self.parent:OnUpdate() end, John@76: --} John@76: --SListEventDispatch:RegisterListener(alb3.userdata.slist) John@76: --LListEventDispatch:RegisterListener(alb3.userdata.llist) John@76: AdminLootButtons:SetButtons(alb1,alb2,alb3) John@60: end John@38: John@65: local suicideSelected, undo John@60: if admin then John@60: John@60: suicideSelected = AceGUI:Create("Button") John@60: suicideSelected:SetFullWidth(true) John@60: suicideSelected:SetText("Suicide") John@68: suicideSelected:SetCallback("OnClick", John@68: function(_) John@68: local p = SListEventDispatch:LatestValue() John@68: local lref = SListPopulator.lref John@68: lref:SuicidePerson(p.value) John@68: end John@68: ) John@68: John@63: -- use userdata + SListEventDispatch to toggle state John@63: suicideSelected.userdata = John@63: { John@63: widget = suicideSelected, John@65: ["Redraw"] = function(self,_) self.widget:SetDisabled(true) end, John@63: ["OnSelection"] = function(self,_) self.widget:SetDisabled(false) end, John@63: ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true) end John@63: } John@63: SListEventDispatch:RegisterListener(suicideSelected.userdata) John@60: John@60: undo = AceGUI:Create("Button") John@63: undo:SetText("Undo / out of order") John@60: undo:SetFullWidth(true) John@63: undo:SetDisabled(true) John@60: end John@60: John@56: local filter = AceGUI:Create("CheckBox") John@56: filter:SetLabel("Only show active") John@56: filter:SetFullWidth(true) John@63: filter:SetValue(false) John@63: SListPopulator:SetFiltered(false) John@63: filter:SetCallback("OnValueChanged",function(widget,_,value) SListPopulator:SetFiltered(value) end) John@56: John@56: left:AddChildren(filter) John@56: if admin then left:AddChildren(suicideSelected,undo) end John@56: right:AddChildren(t2) John@56: if admin then right:AddChildren(alb1,alb2,alb3) end John@56: right:AddChildren(biddingZone) John@56: f:AddChildren(left,right) John@58: John@58: John@1: end