So I've been workin on a new addon for a little while that I haven't found a similar match to.
If you've ever logged into Starcraft II you have a nice broadcast list with client icons etc, and I'm simply trying to recreate the same idea but for wow.
My only issue is I'm a little unsure of how to set up a ticker style frame that can sort and so on. I've not really worked with xml much which I'm sure would be the best way of creating this addon.
Suggestions on how I should continue to build my addon would be appreciated, still somewhat of a novice when it comes to addons like this.
Here's my scripting so far:
lua Code:
local Addon = "BattleNetFeed"
local MessageList = {} -- Table of all friend messages and their timestamp listed by presenceID.
local function Meta(vaL)
local text = GetAddOnMetadata(Addon, vaL)
return text
end
BNFText = Meta("Title")..": "
local defaults = {
locked = true,
}
local copytable
copytable = function(original)
local duplicate = {}
for key, value in pairs(original) do
if type(value) == "table" then duplicate[key] = copytable(value)
else duplicate[key] = value end
end
return duplicate
end
local function CreateFeed(frame)
frame:SetWidth(220)
frame:SetHeight(160)
frame:SetPoint("TOPLEFT",FriendsFrame,"BOTTOMLEFT",0,-25)
frame.background = frame:CreateTexture(nil, "BACKGROUND")
frame.background:SetTexture(0,0,0,0.25)
frame.background:SetAllPoints(frame)
end
BattleNetFeed = CreateFrame("Frame","BattleNetFeed");
BattleNetFeed:RegisterEvent("ADDON_LOADED");
BattleNetFeed:RegisterEvent("BN_CUSTOM_MESSAGE_CHANGED");
BattleNetFeed:RegisterEvent("BN_CUSTOM_MESSAGE_LOADED");
BattleNetFeed:RegisterEvent("BN_FRIEND_INFO_CHANGED");
BattleNetFeed:RegisterEvent("BN_FRIEND_LIST_SIZE_CHANGED");
function BattleNetFeed:Update()
local numBNetTotal, numBNetOnline = BNGetNumFriends();
local numBNetOffline = numBNetTotal - numBNetOnline;
local numWoWTotal, numWoWOnline = GetNumFriends();
local numWoWOffline = numWoWTotal - numWoWOnline;
local friends = numBNetTotal + numWoWTotal
for i = 1, friends do
local presenceID, givenName, surname, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i);
if not MessageList[presenceID] then
MessageList[presenceID] = {};
MessageList[presenceID].message = messageText;
MessageList[presenceID].timestamp = messageTime;
end
if presenceID and MessageList[presenceID].message ~= messageText then -- If the message has changed, update.
MessageList[presenceID].message = messageText;
MessageList[presenceID].timestamp = messageTime;
if messageText ~= "" then -- Test updates to messages
if toonName then
print(givenName.." "..surname.." ("..toonName.."): "..messageText)
else
print(givenName.." "..surname.." :"..messageText)
end
end
end
end
end
BattleNetFeed:SetScript("OnEvent", function(self,event,...)
local arg1,arg2,arg3 = ...
if event == "ADDON_LOADED" then
if arg1 == Addon then
CreateFeed(self)
if not BNFDB then
BNFDB = copytable(defaults)
end
self:UnregisterEvent("ADDON_LOADED")
end
elseif event == "BN_FRIEND_INFO_CHANGED" or event == "BN_FRIEND_LIST_SIZE_CHANGED" then
self:Update()
end
end)
FriendsFrame:HookScript("OnShow", function() BattleNetFeed:Show(); BattleNetFeed:Update(); end)
FriendsFrame:HookScript("OnHide", function() BattleNetFeed:Hide(); end)