Mercurial > wow > breuesk
view Gui.lua @ 58:615346b6ee99
Starting to use userdata
author | John@Yosemite-PC |
---|---|
date | Sun, 25 Mar 2012 17:43:09 -0400 |
parents | 94ae80d58903 |
children | c7330bc4a9ea |
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(OnValueChanged) 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", OnValueChanged) if ltemp > 0 then pulldown:SetValue(ltemp); OnValueChanged(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged return pulldown end local tree = {} local ovc = function(t1,value) tree = {} local l = LootLists:Select(value) for le in l:OrderedListEntryIter() do 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 = not PersonList:IsActive(le:GetId()) table.insert(tree,line) end t1:SetList(tree) end function CreateGUI() local admin = bsk.admin local f = AceGUI:Create("Frame") f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) 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) local listChange = function(_,_,value) ovc(t1,value) end local p1 = CreateListSelector(listChange) 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 = AceGUI:Create("Button") alb1:SetWidth(100) alb1:SetText("Open Bids") local alb2 = AceGUI:Create("Button") alb2:SetWidth(100) alb2:SetText("Assign") local alb3 = AceGUI:Create("Button") alb3:SetWidth(100) alb3:SetText("Suicide") 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 = {copy(tree[1]),copy( tree[2] ),copy( tree[3] )} for i,v in pairs(dummydata) do v.disabled = false end dummydata[2].text = dummydata[2].text .. " (roll 73)" 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) b1.alignoffset = 0.25 -- or else g1 won't align well local g1 = AceGUI:Create("SimpleGroup") g1.alignoffset = 0.25 g1:SetWidth(120) g1:SetLayout("List") local adminForce = AceGUI:Create("Button") adminForce:SetText("Force bid") adminForce:SetWidth(100) local adminRetract = AceGUI:Create("Button") adminRetract:SetText("Retract bid") adminRetract:SetWidth(100) g1:AddChildren(adminForce,adminRetract) local suicideSelected = AceGUI:Create("Button") suicideSelected:SetFullWidth(true) suicideSelected:SetText("Suicide") local undo = AceGUI:Create("Button") undo:SetText("Undo") undo:SetFullWidth(true) local filter = AceGUI:Create("CheckBox") filter:SetLabel("Only show active") filter:SetFullWidth(true) 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