Compare with Previous | Blame | View Log
--========================================================== -- Variables --========================================================== GuildRole_Class_Icon_Tcoords = {["MONK"] = {0, 0.25, 0, 0.25},["WARRIOR"] = {0, 0.25, 0, 0.25}, ["MAGE"] = {0.25, 0.50, 0, 0.25}, ["ROGUE"] = {0.50, 0.75, 0, 0.25}, ["DRUID"] = {0.75, 1, 0, 0.25}, ["HUNTER"] = {0, 0.25, 0.25, 0.5}, ["SHAMAN"] = {0.25, 0.50, 0.25, 0.5}, ["PRIEST"] = {0.50, 0.75, 0.25, 0.5}, ["WARLOCK"] = {0.75, 1, 0.25, 0.5}, ["PALADIN"] = {0, 0.25, 0.5, 0.75}, ["DEATH KNIGHT"] = {0.25, 0.5, 0.5, 0.75} }; GuildRole_Class_Colors = {["MONK"] = "C79C6E", ["WARRIOR"] = "C79C6E", ["MAGE"] = "69CCF0", ["ROGUE"] = "FFF569", ["DRUID"] = "FF7D0A", ["HUNTER"] = "ABD473", ["SHAMAN"] = "0070DE", ["PRIEST"] = "FFFFFF", ["WARLOCK"] = "9482C9", ["PALADIN"] = "F58CBA", ["DEATH KNIGHT"] = "C41F3B" }; -- { Lead, Heal, Tank, Damage } GuildRole_PortraitRoles_Coords = {{0, 0.32, 0, 0.32}, {0.33, 0.65, 0, 0.32}, {0, 0.32, 0.33, 0.65}, {0.33, 0.65, 0.33, 0.65}}; GuildRole_Roles_Coords = {{0, 0.26, 0, 0.26}, {0.26, 0.51, 0, 0.26}, {0, 0.26, 0.26, 0.51}, {0.26, 0.51, 0.26, 0.51}}; -- Heal, Tank, Damage Class_Roles = {["MONK"] = "1011", ["WARRIOR"] = "1011", ["MAGE"] = "1001", ["ROGUE"] = "1001", ["DRUID"] = "1111", ["HUNTER"] = "1001", ["SHAMAN"] = "1101", ["PRIEST"] = "1101", ["WARLOCK"] = "1001", ["PALADIN"] = "1111", ["DEATH KNIGHT"] = "1011" }; LT3TimeSinceLastUpdate = 0 LT3LastTime = 0 LT3Delay = 10 --========================================================== -- Functions --========================================================== function GetGuildMemberList(showOffline) if LT3debugmsg then print("GetGuildMemberList")end if LT3debugmsg then print(IsInGuild())end local dataArray = {}; if IsInGuild() then local guildName, guildRankName, guildRankIndex = GetGuildInfo("player"); if LT3debugmsg then print("GetGuildMemberList Guild Name " .. guildName)end if guildName == "Less Than Three" then elseif guildName == "Ten Ton Hammer" then else return nil end local totalMembers, onlineMembers = GetNumGuildMembers(); if LT3debugmsg then print("GetGuildMemberList online " .. onlineMembers)end local numGuildMembers = (showOffline and totalMembers or onlineMembers); local sliderMax = numGuildMembers onlText:SetText(sliderMax) -- if sliderMax <13 then sliderMax = 1 end -- GGsetSlider(sliderMax) for i = 1, numGuildMembers do local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPoints, achievementRank, isMobile= GetGuildRosterInfo(i); name = removeServerFromName(name) local equip = getiLvl() -- Info from Saved Variables if class then if not LT3Roster[name] then local pData = {}; pData.ScannedAt = date("%m/%d/%y %H:%M:%S") pData.Level = level; pData.Name = name; pData.Online = online; pData.Roles = Class_Roles[class:upper()] pData.Class = class pData.ScannedAt = 0; pData.iLvL = 0; pData.Raids = 0; pData.Dngs = 0; pData.PrvngGnds = 0; LT3Roster[name] = pData; end end local playerData = LT3Roster[name]; playerData.Online = online table.insert(dataArray, playerData); end if lt3GuildSlider then lt3GuildSlider:SetValue(1) end end if LT3debugmsg then print(#dataArray .. " GuildMembers returned")end if #dataArray == 0 then return nil -- 0 is good as nil else return dataArray; end end function GuildRosterButton_OnClick(self, button, down) local gM = GetGuildMemberList(GuildRosterShowOfflineButton:GetChecked()) local v = lt3Guildslider:GetValue() local x = strsub(self:GetName(),4) v = v + tonumber(x) print("Index " .. index) local name = gM[v -1].Name if button == "RightButton" then -- FriendsFrame_ShowDropdown(name, 0); end end function RefreshMemeberList() if LT3debugmsg then print("RefreshMemeberList")end if #rowLevel > 10 then loadList() else end end function setRole(roles) roleButton:Refresh() end function LT3OnEnable() showTitleBar() showButtonBar() end function raidInstance( name, reset) -- Raid counter limited to per 3600 seconds if LT3Options["RaidName"] == name then if GetTime() - LT3Options["RaidTime"] > 3600 then if LT3Options["GuildRaid"] == true then IncEvent("RAIDINC") end else end end LT3Options["RaidName"] = name LT3Options["RaidTime"] = GetTime() end function getiLvl() local eown , equip = GetAverageItemLevel(); return floor(equip) end function removeServerFromName(name) local N if name == nil then return -1 end N = strfind(name,"-") if N == nil then return name else return strsub(name,1,strfind(name,"-") -1 ) end end function getUnitName(unit) if LT3debugmsg then print("getUnitName" .. unit)end local name, realm = UnitName(unit) if name then return removeServerFromName(name) else return "NoName" end end --=============================================== -- Achievement functions --=============================================== function GetStatisticId(StatisticTitle) -- look for an achievement local catlist = GetCategoryList() for x = 1, #catlist do for i = 1, 1 do local IDNumber, Name, Points, Completed, Month, Day, Year, Description, Flags, Image, RewardText, IsGuild, WasEarnedByMe, EarnedBy = GetAchievementInfo(catlist[x],i) if not Name then return -1 end if LT3debugmsg then print("achievement " .. Name) end if string.match(Name,StatisticTitle) then return Name end end end return -1 end function getProvingGround() if LT3debugmsg then print("getProvingGround") end local achiveString = GetStatisticId("Proving Yourself") if achiveString == -1 then return 0 else if string.match(achiveString,"Bronze") then return 1 elseif string.match(achiveString,"Silver") then return 2 elseif string.match(achiveString,"Gold") then return 3 elseif string.match(achiveString,"10") then return 4 elseif string.match(achiveString,"20") then return 5 elseif string.match(achiveString,"30") then return 6 else return 0 end end end --========================================================== -- OnEvent handlers --========================================================== OnEvent = {}; function OnEvent:ADDON_LOADED(arg1) -- addon is loaded if arg1 == "LT3GuildRoster" then if LT3debugmsg then print(" OnEvent:ADDON_LOADED") end if not LT3Options or LT3Options == nil then LT3Options = {} LT3Options["Version"] = "1.10" LT3Options["FirstLoad"] = true LT3Options["point"] = "Center" LT3Options["rel2"] = "Center" LT3Options["x"] = 0 LT3Options["y"] = 0 LT3Options["GuildGroup"] = false LT3Options["GuildRaid"] = false LT3Options["Engage"] = 0 end if not LT3Roster or LT3Roster == nil then LT3Roster = {} LT3Roster = {} end LT3OnEnable() local loaded, finished = IsAddOnLoaded("LT3GuildRoster") LT3GuildRoster:SetPoint( LT3Options["point"], nil, LT3Options["rel2"], LT3Options["x"], LT3Options["y"]); LT3Options["Version"] = "1.10" revText:SetText(LT3Options["Version"]) -- if finished then -- GetGuildMemberList(GuildRosterShowOfflineButton:GetChecked()); -- ShowGroupMemberList(); local gl = loadList() lt3Guildslider:SetScript("OnValueChanged", function (self, value) loadList() end) lt3Guildslider:SetValue(1) AutoRefresh:SetChecked(true) if gl then SendMessage("SET",getUnitName("player")) end if LT3debugmsg then print("END :ADDON_LOADED") end end -- end end --========================================================================== -- Events for Raid and Group counters --=========================================================================== function OnEvent:INSTANCE_ENCOUNTER_ENGAGE_UNIT() -- I am fighting a Boss if LT3Options["Engage"] == 0 and LT3Options["GuildRaid"] == true then IncEvent("RAIDINC") end if LT3Options["Engage"] == 0 and LT3Options["GuildGroup"] == true then IncEvent("DNGINC") end LT3Options["Engage"] = LT3Options["Engage"] + 1 -- limit one boss per zone in end function OnEvent:PLAYER_ENTERING_WORLD() -- Maybe I am in an instance LT3Options["DngTime"] = GetTime() -- get time so I can limit events per LT3Options["RaidTime"] = GetTime() -- get time so I can limit events per LT3Options["Engage"] = 0 -- zero boss battler toggle local mapFileName, textureHeight, textureWidth, isIndoor, indoorMapFileName = GetMapInfo(); LT3Options["LastWorld"] = mapFileName -- get zone name end function OnEvent:RAID_INSTANCE_WELCOME( name, reset) -- Im in a Raid Instance raidInstance( name, reset) end function OnEvent:GROUP_ROSTER_UPDATE() -- Am I in a guild group if LT3debugmsg then print("OnEvent:GROUP_ROSTER_UPDATE")end local numGroupMembers = GetNumGroupMembers( ) local isInRaid = IsInRaid() local inGroup = IsInGroup() local raidCntr = 0 local guildRaidThreashold = 5 local guildGroupThreashold = 3 local groupCntr = 0 if numGroupMembers > 0 then if isInRaid then for i = 1, numGroupMembers do local name = getUnitName("raid"..i); if LT3Roster[name] then raidCntr = raidCntr + 1 if raidCntr > guildRaidThreashold then LT3Options["GuildRaid"] = true else LT3Options["GuildRaid"] = false end end end else for i = 1, numGroupMembers do local name = getUnitName("party"..i); if LT3Roster[name] then groupCntr = groupCntr + 1 if groupCntr > guildGroupThreashold then LT3Options["GuildGroup"] = true else LT3Options["GuildGroup"] = false end end end end end end function OnEvent:GUILD_ROSTER_UPDATE(arg1)-- catch guild login and logout if AutoRefresh:GetChecked() then if LT3debugmsg then print(floor(GetTime() - floor(LT3LastTime)) .. "last Roster event" )end if floor(GetTime()) - floor(LT3LastTime) > 9 then if arg1 == 1 then if LT3debugmsg then print("OnEvent:GUILD_ROSTER_UPDATE" .. arg1 )end RefreshMemeberList() else if LT3debugmsg then print("OnEvent:GUILD_ROSTER_UPDATE" )end RefreshMemeberList() end end LT3LastTime = GetTime() end end function OnEvent:CHAT_MSG_ADDON( GRprefix, GRMessage, GRType, GRWho) -- message receiver function if LT3debugmsg then print(" OnEvent:CHAT_MSG_ADDON")end if not GRMessage then return end if GRMessage == "" then return end local q1 = strfind(GRMessage,"#",1) if not q1 or q1 < 3 then return end tWho = strsub(GRMessage,q1 + 1,strfind(GRMessage,"#",q1 +1) -1 ) if GRprefix == "LT3" then ACT = strsub(GRMessage,1,strfind(GRMessage,"#") -1 ) if ACT == "SET" then UpdatePData(GRMessage, removeServerFromName(strtrim(GRWho))) elseif ACT == "RESET" then ResetPData(GRMessage) elseif ACT == "DNGINC" then IncEvent(ACT, tWho) elseif ACT == "RAIDINC" then IncEvent(ACT, tWho) elseif ACT == "REQUEST" then SendMessage("SET") end end end function OnEvent:PLAYER_EQUIPMENT_CHANGED(slotid, wasadded ) -- I changed gear so Broadcast if LT3debugmsg then print("OnEvent:PLAYER_EQUIPMENT_CHANGED")end local name = getUnitName("player") if wasadded then if LT3Roster[name].iLvL == getiLvl() then else LT3Roster[name].iLvL = getiLvl() SendMessage("SET") end end end --===================================================== --Received message --====================================================== function IncEvent(ACT, tWho) -- increment counters local name = getUnitName("player") if tWho == name then if ACT == "DNGINC" then LT3Roster[name].Dngs = LT3Roster[name].Dngs + 1 elseif ACT == "RAIDINC" then LT3Roster[name].Raids = LT3Roster[name].Raids + 1 end else if ACT == "DNGINC" then LT3Roster[name].Dngs = LT3Roster[name].Dngs + 1 elseif ACT == "RAIDINC" then LT3Roster[name].Raids = LT3Roster[name].Raids + 1 end end showChanges(LT3Roster[name]) end function ResetPData(GRMessage) -- Zero my counters local a, b, name, pData a = 1 b = strfind(GRMessage,"#",a) trash = strsub(GRMessage, a, b - 1) a = b +1 b = strfind(GRMessage,"#",a) name = strsub(GRMessage, a, b - 1) if strsub(GRMessage,8,12) == "Reset" then LT3Roster[getUnitName("player")].Dngs = 0 LT3Roster[getUnitName("player")].Raids = 0 showChanges(getUnitName("player")) end end function UpdatePData(GRMessage, GRWho) -- update LT3Roster db if LT3debugmsg then print(" UpdatePData " .. GRMessage .. " : " .. GRWho)end local a,b,trash -- Info from Saved Variables if not LT3Roster[GRWho] then return end a = 1 b = strfind(GRMessage,"#",a) trash = strsub(GRMessage, a, b - 1) a = b +1 b = strfind(GRMessage,"#",a) LT3Roster[GRWho].Roles = strsub(GRMessage, a, b - 1) a = b +1 b = strfind(GRMessage,"#",a) LT3Roster[GRWho].iLvL = strsub(GRMessage, a, b - 1) a = b +1 b = strfind(GRMessage,"#",a) LT3Roster[GRWho].Raids = strsub(GRMessage, a, b - 1) a = b + 1 b = strfind(GRMessage,"#",a) LT3Roster[GRWho].Dngs = strsub(GRMessage, a, b - 1) a = b + 1 b = strfind(GRMessage,"#",a) LT3Roster[GRWho].PrvngGnds = strsub(GRMessage, a, b - 1) a = b +1 LT3Roster[GRWho].ScannedAt = date("%m/%d/%y %H:%M:%S") RefreshMemeberList() end --==================================================== --Send Message functions --==================================================== function showChanges(name) -- send changes if LT3debugmsg then print("showChanges")end if #rowLevel > 10 then RefreshMemeberList() SendMessage("SET", name) else end end function MkMessage(mType,MWho) -- Create the message based on type and who to send it to local GRMessage local pData = LT3Roster[getUnitName("player")] if LT3debugmsg then print("MkMessage")end if pData == nil then return -1 end if mType == "SET" then GRMessage = "SET#" GRMessage = GRMessage .. pData.Roles .."#" GRMessage = GRMessage .. getiLvl() .."#" GRMessage = GRMessage .. pData.Raids .."#" GRMessage = GRMessage .. pData.Dngs .."#" GRMessage = GRMessage .. getProvingGround() .."#" return GRMessage elseif mType =="RESET" then if MWho == nil then GRMessage = "RESET##ResetEventCounters#" else GRMessage = "RESET#".. MWho .. "#ResetEventCounters#" end return GRMessage elseif mType == "DNGINC" then if MWho == nil then GRMessage = "DNGINC##INCREMENTDNGEventCounters#" else GRMessage = "DNGINC#".. MWho .. "#IncrementDNGEventCounters#" end return GRMessage elseif mType == "RAIDINC" then if MWho == nil then GRMessage = "RAIDINC##INCREMENTDNGEventCounters#" else GRMessage = "RAIDINC#".. MWho .. "#IncrementRaidEventCounters#" end return GRMessage elseif mType == "REQUEST" then if MWho == nil then GRMessage = "REQUEST##BROADCASTREQUEST#" else GRMessage = "REQUEST#".. MWho .. "#BROADCASTREQUEST#" end return GRMessage else return -1 end end function SendMessage(mType, MWho) -- Call to send a message if LT3debugmsg then print("SendMessage " .. mType)end if LT3debugmsg and MWho then print("Who " .. MWho)end GRMessage = MkMessage(mType, MWho) if GRMessage == -1 then if LT3debugmsg then print("showChanges")end return end SendAddonMessage("LT3",GRMessage, "GUILD") end --========================================================== -- Main frame init --========================================================== function toggleDBug() if LT3debugmsg then LT3debugmsg = false else LT3debugmsg = true end end function pinger() if LT3TimeSinceLastUpdate == 0 then LT3TimeSinceLastUpdate = floor(GetTime()) end if floor(GetTime()) - floor(LT3TimeSinceLastUpdate) == LT3Delay then if LT3debugmsg then print(floor(GetTime() - floor(LT3TimeSinceLastUpdate)) .. "Load Delay" )end if not loadList() then LT3Delay = LT3Delay + 10 else LT3Delay = 8 GGResetSlider() SendMessage("SET",getUnitName("player")) end end end function GR_SlashHandler(msg) local tWho local w = strfind(msg, " ") if w then tWho = strsub(msg, w + 1) end if strmatch(msg,"send" , 1) then SendMessage("SET") elseif strmatch(msg,"reset" ,1) then if w then SendMessage("RESET", tWho) else SendMessage("RESET") end elseif strmatch(msg,"dnginc" , 1) then if w then SendMessage("DNGINC", tWho) else SendMessage("DNGINC") end elseif strmatch(msg,"raidinc" , 1) then SendMessage("RAIDINC") elseif strmatch(msg,"show" , 1) then LT3GuildRoster:Show() elseif strmatch(msg,"refresh" , 1) then RefreshMemeberList() elseif strmatch(msg,"hide" , 1 )then LT3GuildRoster:Hide() elseif strmatch(msg,"req" , 1 )then SendMessage("REQUEST") elseif strmatch(msg,"dbg" , 1 )then toggleDBug() elseif strmatch(msg,"rld" , 1 )then ReloadUI() else print("LT3GuildRoster Slash commands are: \r show -- Show LT3 \r hide -- Hide LT3 \r send -- Broadcast your information ") end end if not LT3GuildRoster then if RegisterAddonMessagePrefix("LT3") then print("YEA") end LT3GuildRoster = CreateFrame("Frame", nil, UIParent); LT3GuildRoster:SetFrameStrata("DIALOG"); LT3GuildRoster:SetWidth(390); LT3GuildRoster:SetHeight(432); --"Interface/Tooltips/UI-Tooltip-Background""Interface/Tooltips/UI-Tooltip-Border"Interface/CHARACTERFRAME/UI-Party-Border -- LT3GuildRoster:SetBackdrop({bgFile = "Interface/FrameGeneral/UI-Background-Marble", edgeFile = "Interface/DialogFrame/UI-DialogBox-Border", tile = true, tileSize = 16, edgeSize = 16, -- insets = { left = 4, right = 4, top = 4, bottom = 4 }}); LT3GuildRoster:SetBackdrop({bgFile = "Interface/Stationery/Stationery_OG1", edgeFile = "Interface/Tooltips/UI-Party-Border", tile = false, tileSize = 1, edgeSize = 8, insets = { left = 1, right = 1, top = 1, bottom = 1 }}) LT3GuildRoster:SetBackdropColor(.1,.1,.1,.7) LT3GuildRoster:SetBackdropBorderColor(.1,.1,.1,.7) LT3GuildRoster:EnableMouse(true) LT3GuildRoster:EnableMouseWheel(true) LT3GuildRoster:SetMovable(true) LT3GuildRoster:SetClampedToScreen(true) LT3GuildRoster:RegisterForDrag("RightButton") LT3GuildRoster:SetScript("OnDragStart", function(self)if IsAltKeyDown() then self:StartMoving()end end) LT3GuildRoster:SetScript("OnDragStop",function(self) self:StopMovingOrSizing() local a, b, c, x, y = self:GetPoint() LT3Options["x"] = math.floor(x) LT3Options["y"] = math.floor(y) LT3Options["point"] = a LT3Options["rel1"] = b LT3Options["rel2"] = c end) LT3GuildRoster:SetScript("OnHide", LT3GuildRoster.StopMovingOrSizing) LT3GuildRoster:SetScript("OnUpdate", function() pinger()end) LT3GuildRoster:Hide() local closeButton = CreateFrame("Button", nil, LT3GuildRoster); closeButton:SetWidth(32); closeButton:SetHeight(32); closeButton:SetPoint("TOPRIGHT", 0, 0); closeButton:SetScript("OnClick",function (self) LT3GuildRoster:Hide() end) closeButton:SetNormalTexture( "Interface\\BUTTONS\\UI-Panel-HideButton-Up") closeButton:SetPushedTexture( "Interface\\BUTTONS\\UI-Panel-HideButton-Up") GroupMemberList = GGCreateFrame(LT3GuildRoster, nil, "TOPLEFT", 10, -53, LT3GuildRoster:GetWidth(), LT3GuildRoster:GetHeight() - 112, LT3GuildRoster); GroupMemberList:Show(); lt3Guildslider = GGMakeSlider(GroupMemberList) ShowGroupMemberList(); LT3GuildRoster:RegisterEvent("ADDON_LOADED"); LT3GuildRoster:RegisterEvent("CHAT_MSG_ADDON"); LT3GuildRoster:RegisterEvent("PLAYER_ENTERING_WORLD"); LT3GuildRoster:RegisterEvent("GUILD_ROSTER_UPDATE") LT3GuildRoster:RegisterEvent("GROUP_ROSTER_UPDATE"); LT3GuildRoster:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT") LT3GuildRoster:RegisterEvent("PLAYER_EQUIPMENT_CHANGED") LT3GuildRoster:SetScript("OnEvent", function(self, event, ...) OnEvent[event](self, ...) end); SlashCmdList['LT3GuildRoster_SLASHCMD'] = function(msg) DEFAULT_CHAT_FRAME:AddMessage(msg or 'nil') GR_SlashHandler(msg) end SLASH_LT3GuildRoster_SLASHCMD1 = '/lt3' end