Mercurial > wow > squawk
changeset 2:75a76882c343
more work on the controller
author | wobin |
---|---|
date | Thu, 16 Apr 2009 22:05:24 +1000 |
parents | 188273d0efad |
children | 1cc6e4710e2e |
files | Squawk.lua |
diffstat | 1 files changed, 34 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/Squawk.lua Thu Apr 16 17:29:58 2009 +1000 +++ b/Squawk.lua Thu Apr 16 22:05:24 2009 +1000 @@ -78,46 +78,47 @@ return table.sort(Squawks, function(a,b) return a.Time < b.Time end) end +function Squawk:GetOwn(Squawks) + local mine = {} + for _, squawk in ipairs(Squawks) do + if squawk.Owner == UnitName("player") then + table.insert(mine, squawk) + end + end + return self:Sort(mine) +end + function Settings:IsPrivate() return Settings.Private end function Settings:AddFollower(Name) - table.insert(Settings.Follower, Name) + Settings.Follower[Name] = 1 end function Settings:AddFollowing(Name) - table.insert(Settings.Following, Name) + Settings.Following[Name] = 1 end function Settings:AddBlock(Name) - table.insert(Settings.Blocked, Name) + Settings.Blocked[Name] = 1 end function Settings:RemoveFollower(Name) - for i,v in ipairs(Settings.Follower) do - if v == Name then - table.remove(Settings.Follower, i) - return - end + if Settings.Follower[Name] then + Settings.Follower[Name] = nil end end function Settings:RemoveFollowing(Name) - for i,v in ipairs(Settings.Following) do - if v == Name then - table.remove(Settings.Following, i) - return - end + if Settings.Following[Name] then + Settings.Following[Name] = nil end end function Settings:RemoveBlock(Name) - for i,v in ipairs(Settings.Blocked) do - if v == Name then - table.remove(Settings.Blocked, i) - return - end + if Settings.Blocked[Name] then + Settings.Blocked[Name] = nil end end @@ -135,7 +136,7 @@ end function Controller:IWantToFollowThem(Name) - + self:SendMessageToTarget(Name, "#Request|"..UnitName("player")) end function Controller:IAmNowFollowingThem(Name) @@ -148,6 +149,18 @@ View:UpdateSquawkList() end +function Controller:SendNewSquawk(Message) + if not Model:IsPrivate() then + self:SendMessageToGuild("#Squawk|"..UnitName("player").."|"..Message) + end + + self:AddANewSquawk(UnitName("player"), Message) + + for name, _ in pairs(Model.Following) do + self:SendMessageToTarget(name, "#Squawk|"..UnitName("player").."|"..Message) + end +end + function Controller:ImPending(Name) View:NotifyOfPending(Name) end @@ -163,7 +176,8 @@ local Parse = { ["#Pending"] = Controller.ImPending, ["#Follow"] = Controller.IAmNowFollowingThem, - ["#Squawk"] = Controller.AddANewSquawk + ["#Squawk"] = Controller.AddANewSquawk, + ["#Request"] = Controller.TheyWantToFollowMe, } function Controller:ReceiveMessage(Prefix, Message, Distribution, Sender)