Mercurial > wow > breuesk
changeset 67:8387dc2ff658
Getting the rest of the UI elements to respond intuitively
author | John@Doomsday |
---|---|
date | Tue, 27 Mar 2012 10:19:48 -0400 |
parents | 331b5e176d79 |
children | a177b863ed6c |
files | Gui.lua |
diffstat | 1 files changed, 54 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/Gui.lua Tue Mar 27 10:18:55 2012 -0400 +++ b/Gui.lua Tue Mar 27 10:19:48 2012 -0400 @@ -6,6 +6,7 @@ local setmetatable=setmetatable local ipairs=ipairs local string=string +local sformat=string.format local tostring=tostring local type=type local getn=getn @@ -63,6 +64,7 @@ { listeners = nil, target = nil, + line = nil, ["SetTarget"] = function(self,other) self.target = other self.target:SetCallback("OnSelectionCleared",function(...) self:OnSelectionCleared(...) end) @@ -70,16 +72,18 @@ end, ["RegisterListener"] = function(self,other) table.insert(self.listeners,other) end, ["OnSelectionCleared"] = function(self,_) + self.line = nil self:Event("OnSelectionCleared") end, ["OnSelection"] = function(self,_,_,line) + self.line = 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 - bsk.print("listener") + --bsk.print("listener") if type(v) == "table" then if v[event] then v[event](v,arg) @@ -91,7 +95,8 @@ end end end, - ["Release"] = function(self) self.listeners = {}; self.target=nil end + ["Release"] = function(self) self.listeners = {}; self.target=nil; self.line=nil end, + ["LatestValue"] = function(self) return self.line end } function SelectorListEventDispatcher:new() local t = {} @@ -103,6 +108,7 @@ SListEventDispatch = SelectorListEventDispatcher:new() LListEventDispatch = SelectorListEventDispatcher:new() +RListEventDispatch = SelectorListEventDispatcher:new() local AdminLootEventCollector = { @@ -133,6 +139,7 @@ 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.textPlain = line.text line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()]) line.disabled = disabled table.insert(self.data,line) @@ -167,7 +174,7 @@ local admin = bsk.admin or true f = AceGUI:Create("Frame") - f:SetCallback("OnClose",function(widget) escapeButton.shown = false; AceGUI:Release(widget); f=nil; right=nil; SListEventDispatch:Release(); LListEventDispatch:Release(); SListPopulator:Release() end) + f:SetCallback("OnClose",function(widget) escapeButton.shown = false; AceGUI:Release(widget); f=nil; right=nil; SListEventDispatch:Release(); LListEventDispatch:Release(); SListPopulator:Release(); RListEventDispatch:Release() end) f:SetTitle("BSK") f:SetLayout("Flow") f:SetHeight(680) @@ -254,6 +261,7 @@ function(widget) if widget.userdata.state then -- we were bidding when the button was pressed biddingZone:ReleaseChildren() + RListEventDispatch:Release() else local spacer = AceGUI:Create("Label") spacer:SetText(" ") @@ -265,7 +273,7 @@ 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.userdata = { LListEventDispatch:LatestValue().link } 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 ) @@ -273,11 +281,6 @@ 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) @@ -289,29 +292,65 @@ rollButton:SetText("Offset Roll") rollButton:SetWidth(100) + 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 g1 if admin then + RListEventDispatch:SetTarget(b1) 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") + -- todo: convoluted and repetitive - surely there's a + -- better way than this ... adminForce = AceGUI:Create("Button") - adminForce:SetText("Force bid") - adminForce:SetWidth(100) + if SListEventDispatch:LatestValue() then + adminForce:SetText(sformat("Force bid (%s)",SListEventDispatch:LatestValue().textPlain)) + adminForce:SetDisabled(false) + else + adminForce:SetText("Force bid") + adminForce:SetDisabled(true) + end + adminForce:SetWidth(160) + adminForce.userdata = + { + widget = adminForce, + ["Redraw"] = function(self,_) self.widget:SetDisabled(true); self.widget:SetText("Force bid") end, + ["OnSelection"] = function(self,_) self.widget:SetDisabled(false); self.widget:SetText(sformat("Force bid (%s)",SListEventDispatch:LatestValue().textPlain)) end, + ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true); self.widget:SetText("Force bid") end + } + SListEventDispatch:RegisterListener(adminForce.userdata) adminRetract = AceGUI:Create("Button") - adminRetract:SetText("Retract bid") - adminRetract:SetWidth(100) + if RListEventDispatch:LatestValue() then + adminRetract:SetText(sformat("Retract bid (%s)",RListEventDispatch:LatestValue().textPlain)) + adminRetract:SetDisabled(false) + else + adminRetract:SetText("Retract bid") + adminRetract:SetDisabled(true) + end + adminRetract:SetWidth(160) + adminRetract.userdata = + { + widget = adminRetract, + ["Redraw"] = function(self,_) self.widget:SetDisabled(true); self.widget:SetText("Retract bid") end, + ["OnSelection"] = function(self,_) self.widget:SetDisabled(false); self.widget:SetText(sformat("Retract bid (%s)",RListEventDispatch:LatestValue().textPlain)) end, + ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true); self.widget:SetText("Retract bid") end + } + RListEventDispatch:RegisterListener(adminRetract.userdata) + adminRetract:SetDisabled(true) g1:AddChildren(adminForce,adminRetract) end biddingZone:AddChildren(spacer,label,biddingOn,bidRetractButton,rollButton,spacer2,bidTitle,b1) if admin then biddingZone:AddChildren(g1) end - - end widget.userdata.state = not widget.userdata.state end