Mercurial > wow > breuesk
changeset 69:b7352f007028
Working on bids/rolls in the GUI
Added debug mode to populate things with dummy data.
author | John@Yosemite-PC |
---|---|
date | Thu, 29 Mar 2012 20:17:59 -0400 |
parents | a177b863ed6c |
children | 236117ab8a49 |
files | Core.lua Gui.lua |
diffstat | 2 files changed, 123 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/Core.lua Wed Mar 28 23:29:36 2012 -0400 +++ b/Core.lua Thu Mar 29 20:17:59 2012 -0400 @@ -40,6 +40,8 @@ function OnInitialize() + debug = true + db = _G.LibStub("AceDB-3.0"):New("BskDB", defaults, "Default") options.args.profile = _G.LibStub("AceDBOptions-3.0"):GetOptionsTable(db)
--- a/Gui.lua Wed Mar 28 23:29:36 2012 -0400 +++ b/Gui.lua Thu Mar 29 20:17:59 2012 -0400 @@ -12,6 +12,8 @@ local getn=getn setfenv(1,bsk) +-- todo: switching lists should close a presently-open bid + local copy = function(t) local c = {} if not t then return c end @@ -151,7 +153,116 @@ end, ["DataEvent"] = function(self) self:Redraw() - end + end, + ["GetMe"] = function(self) + local me = _G.UnitName("player") + for i,v in pairs(self.data) do + if v.textPlain == me then + return v + end + end + end, +} + +local LListPopulator = +{ + -- todo: set event receivers from the comm and for loot + data = {}, + widget = nil, + ["Release"] = function(self) self.data = {}; self.widget = nil end, + ["Redraw"]= function(self) + self.widget:SetList(self.data) + LListEventDispatch:Event("Redraw") + end, + ["SetWidget"] = function(self,w) + if type(w) ~= "table" or type(w.SetList) ~= "function" then + _G.error("Bad SetWidget") + end + self.widget = w + if debug then + self.data = { + { + 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" + }, + } + end + self:Redraw() + end, +} + +local RListPopulator = +{ + data = {}, + widget = nil, + ["Release"] = function(self) self.data = {}; self.widget = nil end, + ["Redraw"] = function(self) + self.widget:SetList(self.data) + RListEventDispatch:Event("Redraw") + end, + ["SetWidget"] = function(self,w) + if type(w) ~= "table" or type(w.SetList) ~= "function" then + _G.error("Bad SetWidget") + end + self.widget = w + if debug then + 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 + self.data = dummydata + end + self:Redraw() + end, + ["Force"] = function(self,who) + for i,v in pairs(self.data) do + if who.value == v.value then + print(who.value .. " is already on the list") + return -- no double adds please + end + end + local new = self.Convert(who,72) + table.insert(self.data,new) + -- todo: keep this list sorted + self:Redraw() + end, + ["Retract"] = function(self,who) + for i,v in pairs(self.data) do + if who.value == v.value then + table.remove(self.data,i) + end + end + self:Redraw() + end, + ["Convert"] = function(who,roll) -- convert an LE object into one suitable to put in a SelectorList + local new = copy(who) + new.disabled = false -- todo: should be unnessary - they can't get on the list like this + if roll then + new.text = new.text .. " (roll 73)" + end + return new + end, } DataEventDispatch = @@ -185,10 +296,10 @@ --table.insert(_G.UISpecialFrames, "BSK_ESCAPEBUTTON") if f then return end -- no second gui please - local admin = bsk.admin or true + local admin = 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(); RListEventDispatch: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(); LListPopulator:Release(); RListPopulator:Release() end) f:SetTitle("BSK") f:SetLayout("Flow") f:SetHeight(680) @@ -210,8 +321,8 @@ t1:SetNumLines(25) t1:SetFullWidth(true) t1:SetInteractive(admin) + SListEventDispatch:SetTarget(t1) SListPopulator:SetWidget(t1) - SListEventDispatch:SetTarget(t1) local p1 = CreateListSelector(SListPopulator) p1:SetFullWidth(true) @@ -223,34 +334,8 @@ 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" - }, - }) LListEventDispatch:SetTarget(t2) + LListPopulator:SetWidget(t2) local biddingZone = AceGUI:Create("SimpleGroup") biddingZone:SetLayout("Flow") @@ -304,19 +389,16 @@ local bidRetractButton = AceGUI:Create("Button") bidRetractButton:SetText("Place Bid") bidRetractButton:SetWidth(100) + bidRetractButton:SetCallback("OnClick", function(widget) RListPopulator:Force(SListPopulator:GetMe()) end) local rollButton = AceGUI:Create("Button") 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) + RListEventDispatch:SetTarget(b1) + RListPopulator:SetWidget(b1) 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 @@ -334,6 +416,7 @@ adminForce:SetDisabled(true) end adminForce:SetWidth(160) + adminForce:SetCallback("OnClick",function(widget) RListPopulator:Force(SListEventDispatch:LatestValue()) end) adminForce.userdata = { widget = adminForce, @@ -359,6 +442,7 @@ ["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 } + adminRetract:SetCallback("OnClick",function(widget) RListPopulator:Retract(RListEventDispatch:LatestValue()) end) RListEventDispatch:RegisterListener(adminRetract.userdata) adminRetract:SetDisabled(true)