Mercurial > wow > breuesk
view Gui.lua @ 63:00cb497201d0
Left side of the GUI works ...
author | John@Yosemite-PC |
---|---|
date | Mon, 26 Mar 2012 20:31:45 -0400 |
parents | dcf7c835d0a7 |
children | d3f64d7246b3 |
line wrap: on
line source
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 copy = function(t) local c = {} if not t then return c end for i,v in pairs(t) do c[i] = v end return c end local colorize = function(str,color) if str==nil or str=="" then return "" end if type(color) == "table" then color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b) end if color == nil then return str end return "|cff"..tostring(color or "ffffff")..str.."|r" end local CreateListSelector = function(SListPopulator) PersonList:RefreshRaidList() local pulldown = AceGUI:Create("Dropdown") local pull = {} local ltemp = 0 local lids = LootLists:GetAllIds() for _,v in pairs(lids) do local l = LootLists:Select(v) pull[l:GetId()] = l:GetName() --local entry = {value=i,text=v.name} if l:GetLength() > 0 then pulldown:SetItemDisabled(i,true) if ltemp == 0 then ltemp = l:GetId() end end end pulldown:SetWidth(175) pulldown:SetList(pull) pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:SetList(value) end) if ltemp > 0 then pulldown:SetValue(ltemp); SListPopulator:SetList(ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged return pulldown end local f local escapeButton = { shown = false, ["IsShown"] = function(self) return self.shown end, ["Hide"] = function(self) if f then AceGUI:Release(f); self.shown=false end end } local function FilterEventDispatcher() end SListEventDispatch = { listeners= {}, target = nil, ["SetTarget"] = function(self,other) self.target = other self.target:SetCallback("OnSelectionCleared",SListListenerRebindOSC) self.target:SetCallback("OnSelection",SListListenerRebindOS) end, ["RegisterListener"] = function(self,other) table.insert(self.listeners,other) end, ["OnSelectionCleared"] = function(self,_) self:Event("OnSelectionCleared") end, ["OnSelection"] = function(self,_,line) self:Event("OnSelection",line) end, ["Event"] = function(self,event,arg) if not self.target then error("Event called with no listener...") end if not self.listeners then return end for i,v in pairs(self.listeners) do if type(v) == "table" then if v[event] then v[event](v,arg) end elseif type(v) == "function" then v(event,arg) elseif type(v) ~= "nil" then -- allow nils to pass quietly _G.error("Bad listener - "..type(v)) end end end, ["Release"] = function(self) self.listeners = {}; target=nil end } function SListListenerRebindOSC(...) SListEventDispatch:OnSelectionCleared(...) end function SListListenerRebindOS(...) SListEventDispatch:OnSelection(...) end local SListPopulator = { filtered = false, widget = nil, data = nil, lref = nil, ["Release"] = function(self) self.filtered, self.widget, self.data, self.lref = false, nil, nil, nil end, ["Redraw"] = function(self) if self.lref == nil or self.widget == nil then return end -- don't do work if not fully initialized self.data = {} for le in self.lref:OrderedListEntryIter() do local disabled = not PersonList:IsActive(le:GetId()) if not self.filtered or not disabled then local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]} line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()] line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()]) line.disabled = disabled table.insert(self.data,line) end end self.widget:SetList(self.data) end, ["SetWidget"] = function(self,w) if type(w) ~= "table" or w["SetList"] == nil then _G.error("Bad SetWidget") end self.widget = w end, ["SetFiltered"] = function(self,value) self.filtered = value self:Redraw() end, ["SetList"] = function(self,value) self.lref = LootLists:Select(value) self:Redraw() end } function CreateGUI() -- special registration procedure to be closable with the escape button --escapeButton.shown = true --_G["BSK_ESCAPEBUTTON"] = escapeButton --table.insert(_G.UISpecialFrames, "BSK_ESCAPEBUTTON") if f then return end -- no second gui please local admin = bsk.admin or true f = AceGUI:Create("Frame") f:SetCallback("OnClose",function(widget) escapeButton.shown = false; AceGUI:Release(widget); f=nil; SListEventDispatch:Release(); SListPopulator:Release() end) f:SetTitle("BSK") f:SetLayout("Flow") f:SetHeight(680) f:SetWidth(580) local left = AceGUI:Create("InlineGroup") left:SetLayout("List") left:SetWidth(175) left:SetFullHeight(true) left.alignoffset=0.25 -- hack, as per http://forums.wowace.com/showthread.php?t=17114 local right = AceGUI:Create("InlineGroup") right:SetLayout("Flow") right:SetWidth(700-175-160) right:SetFullHeight(true) right.alignoffset=0.25 local t1 = AceGUI:Create("SelectorList") t1:SetNumLines(25) t1:SetFullWidth(true) t1:SetInteractive(admin) SListPopulator:SetWidget(t1) SListEventDispatch:SetTarget(t1) local p1 = CreateListSelector(SListPopulator) p1:SetFullWidth(true) left:AddChild(p1) left:AddChild(t1) local t2 = AceGUI:Create("SelectorList") t2:SetNumLines(7) t2:SetFullWidth(true) t2:EnableButtonTooltips(true) t2:SetList({ { value=1, text = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r", link = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r", }, { value=2, text = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r", link = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r" }, { value=3, text = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r", link = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r" }, { value=4, text = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r", link = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r" }, { value=5, text = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r", link = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r" }, }) local alb1, alb2, alb3 if admin then alb1 = AceGUI:Create("Button") alb1:SetWidth(100) alb1:SetText("Open Bids") alb2 = AceGUI:Create("Button") alb2:SetWidth(100) alb2:SetText("Assign") alb3 = AceGUI:Create("Button") alb3:SetWidth(100) alb3:SetText("Suicide") end local spacer = AceGUI:Create("Label") spacer:SetText(" ") spacer:SetFullWidth(true) local spacer2 = AceGUI:Create("Label") spacer2:SetText(" ") spacer2:SetFullWidth(true) local biddingZone = AceGUI:Create("SimpleGroup") biddingZone:SetLayout("Flow") biddingZone:SetFullWidth(true) local label = AceGUI:Create("Label") label:SetText("Bidding now open for ...") local biddingOn = AceGUI:Create("InteractiveLabel") biddingOn.userdata = { "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r" } biddingOn:SetText(biddingOn.userdata[1]) biddingOn:SetFullWidth(true) biddingOn:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink(widget.userdata[1]); _G.GameTooltip:Show() end ) biddingOn:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end ) local b1 = AceGUI:Create("SelectorList") b1:SetNumLines(6) b1:SetInteractive(admin) local dummydata= {} local tree =SListPopulator.data for i,v in pairs(tree) do dummydata[i] = copy(v); dummydata[i].disabled = false end if dummydata[2] then dummydata[2].text = dummydata[2].text .. " (roll 73)" end b1:SetList(dummydata) local bidTitle = AceGUI:Create("Label") bidTitle:SetText("Current bids") bidTitle:SetFullWidth(true) local bidRetractButton = AceGUI:Create("Button") bidRetractButton:SetText("Place Bid") bidRetractButton:SetWidth(100) local rollButton = AceGUI:Create("Button") rollButton:SetText("Offset Roll") rollButton:SetWidth(100) local g1, suicideSelected, undo if admin then b1.alignoffset = 0.25 -- or else g1 won't align well g1 = AceGUI:Create("SimpleGroup") g1.alignoffset = 0.25 g1:SetWidth(120) g1:SetLayout("List") adminForce = AceGUI:Create("Button") adminForce:SetText("Force bid") adminForce:SetWidth(100) adminRetract = AceGUI:Create("Button") adminRetract:SetText("Retract bid") adminRetract:SetWidth(100) g1:AddChildren(adminForce,adminRetract) suicideSelected = AceGUI:Create("Button") suicideSelected:SetFullWidth(true) suicideSelected:SetText("Suicide") suicideSelected:SetDisabled(true) -- default is no selection has been made -- use userdata + SListEventDispatch to toggle state suicideSelected.userdata = { widget = suicideSelected, ["OnSelection"] = function(self,_) self.widget:SetDisabled(false) end, ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true) end } SListEventDispatch:RegisterListener(suicideSelected.userdata) undo = AceGUI:Create("Button") undo:SetText("Undo / out of order") undo:SetFullWidth(true) undo:SetDisabled(true) end local filter = AceGUI:Create("CheckBox") filter:SetLabel("Only show active") filter:SetFullWidth(true) filter:SetValue(false) SListPopulator:SetFiltered(false) filter:SetCallback("OnValueChanged",function(widget,_,value) SListPopulator:SetFiltered(value) end) left:AddChildren(filter) if admin then left:AddChildren(suicideSelected,undo) end biddingZone:AddChildren(spacer,label,biddingOn,bidRetractButton,rollButton,spacer2,bidTitle,b1) if admin then biddingZone:AddChildren(g1) end right:AddChildren(t2) if admin then right:AddChildren(alb1,alb2,alb3) end right:AddChildren(biddingZone) f:AddChildren(left,right) end