annotate 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
rev   line source
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@56 28 local CreateListSelector = function(OnValueChanged)
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@56 47 pulldown:SetCallback("OnValueChanged", OnValueChanged)
John@56 48 if ltemp > 0 then pulldown:SetValue(ltemp); OnValueChanged(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
John@56 49 return pulldown
John@1 50 end
John@1 51
John@56 52 local tree = {}
John@56 53 local ovc = function(t1,value)
John@56 54 tree = {}
John@56 55 local l = LootLists:Select(value)
John@56 56 for le in l:OrderedListEntryIter() do
John@56 57 local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
John@56 58 line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()]
John@56 59 line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()])
John@56 60 line.disabled = not PersonList:IsActive(le:GetId())
John@56 61 table.insert(tree,line)
John@56 62 end
John@56 63 t1:SetList(tree)
John@56 64 end
John@38 65
John@42 66 function CreateGUI()
John@56 67 local admin = bsk.admin
John@56 68 local f = AceGUI:Create("Frame")
John@1 69
John@56 70 f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
John@56 71 f:SetTitle("BSK")
John@56 72 f:SetLayout("Flow")
John@56 73 f:SetHeight(680)
John@56 74 f:SetWidth(580)
John@1 75
John@58 76
John@56 77 local left = AceGUI:Create("InlineGroup")
John@56 78 left:SetLayout("List")
John@56 79 left:SetWidth(175)
John@56 80 left:SetFullHeight(true)
John@56 81 left.alignoffset=0.25 -- hack, as per http://forums.wowace.com/showthread.php?t=17114
John@1 82
John@56 83 local right = AceGUI:Create("InlineGroup")
John@56 84 right:SetLayout("Flow")
John@56 85 right:SetWidth(700-175-160)
John@56 86 right:SetFullHeight(true)
John@56 87 right.alignoffset=0.25
John@38 88
John@56 89 local t1 = AceGUI:Create("SelectorList")
John@56 90 t1:SetNumLines(25)
John@56 91 t1:SetFullWidth(true)
John@56 92 t1:SetInteractive(admin)
John@38 93
John@56 94 local listChange = function(_,_,value)
John@56 95 ovc(t1,value)
John@56 96 end
John@56 97 local p1 = CreateListSelector(listChange)
John@56 98 p1:SetFullWidth(true)
John@38 99
John@56 100 left:AddChild(p1)
John@56 101 left:AddChild(t1)
John@38 102
John@56 103 local t2 = AceGUI:Create("SelectorList")
John@56 104 t2:SetNumLines(7)
John@56 105 t2:SetFullWidth(true)
John@56 106 t2:EnableButtonTooltips(true)
John@56 107 t2:SetList({
John@56 108 {
John@56 109 value=1,
John@56 110 text = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
John@56 111 link = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
John@56 112 },
John@56 113 {
John@56 114 value=2,
John@56 115 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 116 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 117 },
John@56 118 {
John@56 119 value=3,
John@56 120 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 121 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 122 },
John@56 123 {
John@56 124 value=4,
John@56 125 text = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r",
John@56 126 link = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r"
John@56 127 },
John@56 128 {
John@56 129 value=5,
John@56 130 text = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r",
John@56 131 link = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r"
John@56 132 },
John@56 133 })
John@38 134
John@56 135 local alb1 = AceGUI:Create("Button")
John@56 136 alb1:SetWidth(100)
John@56 137 alb1:SetText("Open Bids")
John@56 138 local alb2 = AceGUI:Create("Button")
John@56 139 alb2:SetWidth(100)
John@56 140 alb2:SetText("Assign")
John@56 141 local alb3 = AceGUI:Create("Button")
John@56 142 alb3:SetWidth(100)
John@56 143 alb3:SetText("Suicide")
John@38 144
John@56 145 local spacer = AceGUI:Create("Label")
John@56 146 spacer:SetText(" ")
John@56 147 spacer:SetFullWidth(true)
John@56 148 local spacer2 = AceGUI:Create("Label")
John@56 149 spacer2:SetText(" ")
John@56 150 spacer2:SetFullWidth(true)
John@38 151
John@56 152 local biddingZone = AceGUI:Create("SimpleGroup")
John@56 153 biddingZone:SetLayout("Flow")
John@56 154 biddingZone:SetFullWidth(true)
John@1 155
John@56 156 local label = AceGUI:Create("Label")
John@56 157 label:SetText("Bidding now open for ...")
John@56 158 local biddingOn = AceGUI:Create("InteractiveLabel")
John@58 159 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 160 biddingOn:SetText(biddingOn.userdata[1])
John@56 161 biddingOn:SetFullWidth(true)
John@58 162 biddingOn:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink(widget.userdata[1]); _G.GameTooltip:Show() end )
John@56 163 biddingOn:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
John@56 164 local b1 = AceGUI:Create("SelectorList")
John@56 165 b1:SetNumLines(6)
John@56 166 b1:SetInteractive(admin)
John@56 167 local dummydata = {copy(tree[1]),copy( tree[2] ),copy( tree[3] )}
John@56 168 for i,v in pairs(dummydata) do v.disabled = false end
John@56 169 dummydata[2].text = dummydata[2].text .. " (roll 73)"
John@56 170 b1:SetList(dummydata)
John@56 171 local bidTitle = AceGUI:Create("Label")
John@56 172 bidTitle:SetText("Current bids")
John@56 173 bidTitle:SetFullWidth(true)
John@56 174
John@56 175 local bidRetractButton = AceGUI:Create("Button")
John@56 176 bidRetractButton:SetText("Place Bid")
John@56 177 bidRetractButton:SetWidth(100)
John@56 178 local rollButton = AceGUI:Create("Button")
John@56 179 rollButton:SetText("Offset Roll")
John@56 180 rollButton:SetWidth(100)
John@56 181
John@56 182 b1.alignoffset = 0.25 -- or else g1 won't align well
John@56 183 local g1 = AceGUI:Create("SimpleGroup")
John@56 184 g1.alignoffset = 0.25
John@56 185 g1:SetWidth(120)
John@56 186 g1:SetLayout("List")
John@56 187 local adminForce = AceGUI:Create("Button")
John@56 188 adminForce:SetText("Force bid")
John@56 189 adminForce:SetWidth(100)
John@56 190 local adminRetract = AceGUI:Create("Button")
John@56 191 adminRetract:SetText("Retract bid")
John@56 192 adminRetract:SetWidth(100)
John@56 193 g1:AddChildren(adminForce,adminRetract)
John@56 194
John@56 195
John@56 196
John@56 197 local suicideSelected = AceGUI:Create("Button")
John@56 198 suicideSelected:SetFullWidth(true)
John@56 199 suicideSelected:SetText("Suicide")
John@56 200 local undo = AceGUI:Create("Button")
John@56 201 undo:SetText("Undo")
John@56 202 undo:SetFullWidth(true)
John@56 203 local filter = AceGUI:Create("CheckBox")
John@56 204 filter:SetLabel("Only show active")
John@56 205 filter:SetFullWidth(true)
John@56 206
John@56 207 left:AddChildren(filter)
John@56 208 if admin then left:AddChildren(suicideSelected,undo) end
John@56 209 biddingZone:AddChildren(spacer,label,biddingOn,bidRetractButton,rollButton,spacer2,bidTitle,b1)
John@56 210 if admin then biddingZone:AddChildren(g1) end
John@56 211 right:AddChildren(t2)
John@56 212 if admin then right:AddChildren(alb1,alb2,alb3) end
John@56 213 right:AddChildren(biddingZone)
John@56 214 f:AddChildren(left,right)
John@58 215
John@58 216
John@1 217 end