Mercurial > wow > breuesk
changeset 81:62805e6b46c5
Fleshing out the UI for those without the addon. Announcements in the raid, bidding via whisper.
author | John@Yosemite-PC |
---|---|
date | Fri, 13 Apr 2012 22:09:17 -0400 |
parents | 40c882db34f8 |
children | db7e4ee34dce |
files | Gui.lua Looting.lua State.lua |
diffstat | 3 files changed, 96 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/Gui.lua Fri Apr 13 00:02:56 2012 -0400 +++ b/Gui.lua Fri Apr 13 22:09:17 2012 -0400 @@ -108,6 +108,14 @@ LListEventDispatch = SelectorListEventDispatcher:new() RListEventDispatch = SelectorListEventDispatcher:new() +function ConvertLe2Line(le) + 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()]) + return line +end + local SListPopulator = { filtered = false, @@ -123,10 +131,7 @@ 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.textPlain = line.text - line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()]) + local line = ConvertLe2Line(le) line.disabled = disabled table.insert(self.data,line) end @@ -540,7 +545,7 @@ self.openButton:SetCallback("OnClick", function(widget) InitiateCloseBidding() end) self.assignButton:SetText("Finish & Assign") self.assignButton:SetDisabled(not (getn(staterolls) > 0 or getn(statebids) > 0)) - self.assignButton:SetCallback("OnClick", function(widget) ExpensiveLoot(LListEventDispatch:LatestValue(),SListPopulator.lref) end) + self.assignButton:SetCallback("OnClick", function(widget) ExpensiveLoot(LListEventDispatch:LatestValue(),SListPopulator.lref) end) -- todo: problem here - use stateitem instead self.suicideButton:SetText(" ") self.suicideButton:SetDisabled(true)
--- a/Looting.lua Fri Apr 13 00:02:56 2012 -0400 +++ b/Looting.lua Fri Apr 13 22:09:17 2012 -0400 @@ -54,6 +54,13 @@ -- todo: check that I am ML and that I'm an admin! InitiateBeginLoot(items,stateactivelist) + + local chan -- todo: idiom + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + _G.SendChatMessage("The following items are available -",chan) + for i,v in pairs(items) do + _G.SendChatMessage(v.link,chan) + end end function FreeLoot(item,person) @@ -73,7 +80,12 @@ function ExpensiveLoot(item,lref) if getn(statebids) > 0 then if FreeLoot(item,statebids[1]) then + local chan -- todo: idiom + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + _G.SendChatMessage(sformat("Awarding %s to %s!",item.link,statebids[1].textPlain),chan) + --_G.SendChatMessage(sformat("Awarding %s to %s!",item.link,statebids[1].textPlain),"GUILD") -- todo: enable lref:SuicidePerson(statebids[1].value) + InitiateCloseBidding() else printf("Could not suicide %s for item; they are ineligible or offline",statebids[1].textPlain) end @@ -81,7 +93,10 @@ end if getn(staterolls) > 0 then if FreeLoot(item,staterolls[1]) then - --lref:SuicidePerson(staterolls[1].value) + local chan -- todo: idiom + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + _G.SendChatMessage(sformat("Awarding %s to %s!",item.link,staterolls[1].textPlain),chan) + InitiateCloseBidding() else printf("Could not suicide %s for item; they are ineligible or offline",staterolls[1].textPlain) end @@ -98,6 +113,42 @@ end end +function WhisperReceived(...) + local _,message,sender = ... + local senderAction = function(func) + local le = PersonList:Select(sender) + if le then + local person = ConvertLe2Line(le) + if person then + func(person) + end + end + end + + if state == "bidding" and admin then -- todo: should only be ML + message = _G.strtrim(message) + message = _G.strlower(message) + if message == "bid" then + senderAction(InitiateBid) + elseif message == "retract" then + senderAction(InitiateRetract) + elseif message == "roll" then + senderAction(InitiateRollRequest) + end + end +end + +local statelistener = +{ + ["StateEvent"] = function(self) + if state == "bidding" then + event:RegisterEvent("CHAT_MSG_WHISPER", WhisperReceived) + else + --event:UnregisterEvent("CHAT_MSG_WHISPER") -- todo + end + end, +} + function InitializeLooting() event:RegisterEvent("OPEN_MASTER_LOOT_LIST",OpenMasterLootList) event:RegisterEvent("UPDATE_MASTER_LOOT_LIST",UpdateMasterLootList) @@ -107,5 +158,8 @@ -- todo: what are these event:RegisterEvent("LOOT_SLOT_CLEARED",function() print("LSCleared") end) event:RegisterEvent("LOOT_SLOT_CHANGED",function() print("LSChanged") end) + + RegisterListenerStateChange(statelistener) + statelistener:StateEvent() end
--- a/State.lua Fri Apr 13 00:02:56 2012 -0400 +++ b/State.lua Fri Apr 13 22:09:17 2012 -0400 @@ -134,6 +134,12 @@ state = "bidding" stateitem = item AlertStateChangeListeners() + if admin then -- todo: only ML + local chan + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + _G.SendChatMessage("Bidding is now open for "..item.link.."!",chan) + _G.SendChatMessage("Whisper me \"bid\" to bid or \"roll\" to offset roll; \"retract\" will remove your bid",chan) + end end end @@ -190,7 +196,6 @@ if state == "bidding" then if roll then - print("RB: ",person.value,roll) table.insert(staterolls,person) staterollvalues[roll] = person staterolls = SortByRoll(staterollvalues,staterolls) @@ -200,6 +205,23 @@ statebids = SortByList(lref,statebids) end AlertRollListeners() + if admin then -- todo: make ML + local leader + if getn(statebids) > 0 then + leader = statebids[1].textPlain + elseif getn(staterolls) > 0 then + leader = staterolls[1].textPlain + end + + local chan -- todo: this idiom is wearing on me already + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + + if roll then + _G.SendChatMessage(sformat("Received roll of %d from %s; current leader is %s", roll, person.textPlain, leader),chan) + else + _G.SendChatMessage(sformat("Received bid from %s; current leader is %s", person.textPlain, leader),chan) -- todo: tell what spot they're bidding from + end + end end -- else ignore ... @@ -250,7 +272,7 @@ function InitiateRetract(person) if state == "bidding" then - Comm:SendStateChange("RR",person,roll) + Comm:SendStateChange("RR",person) end end --}}} @@ -260,7 +282,13 @@ if state == "bidding" then state = "looting" AlertStateChangeListeners() - -- todo: remove the item from the window, record history + -- todo: record history + if admin then + local chan -- todo: pattern + local chan -- todo: this idiom is wearing on me already + if _G.GetNumRaidMembers() > 0 then chan = "RAID" else chan = "PARTY" end + _G.SendChatMessage("Bidding is closed",chan) + end end end