From 3c6121a40a0e81abdf06b0286a2d3aad7127321c Mon Sep 17 00:00:00 2001 From: yaroot Date: Mon, 13 Sep 2010 14:23:07 +0800 Subject: [PATCH] cata beta support --- yClassColors.lua | 123 ++++++++++++++++++++++++++++++++++++++---------------- yClassColors.toc | 4 +- 2 files changed, 90 insertions(+), 37 deletions(-) diff --git a/yClassColors.lua b/yClassColors.lua index d4ca7a1..f5c2316 100644 --- a/yClassColors.lua +++ b/yClassColors.lua @@ -30,6 +30,7 @@ local enable_wholist = true local enable_bgscoreboard = true -------------------------------------------------------------------------- +local is_cata = select(4, GetBuildInfo()) >= 40000 local GUILD_INDEX_MAX = 12 local SMOOTH = { @@ -129,51 +130,101 @@ if(enable_friendslist) then local WHITE = {r = 1, g = 1, b = 1} local FRIENDS_LEVEL_TEMPLATE = FRIENDS_LEVEL_TEMPLATE:gsub('%%d', '%%s') FRIENDS_LEVEL_TEMPLATE = FRIENDS_LEVEL_TEMPLATE:gsub('%$d', '%$s') -- '%2$s %1$d-го уровня' - hooksecurefunc(FriendsFrameFriendsScrollFrame, 'buttonFunc', function(button, index, fristButton) - local height - local nameText - local infoText - local nameColor - local playerArea = GetRealZoneText() + if(is_cata) then + hooksecurefunc('FriendsFrame_UpdateFriends', function() + local scrollFrame = FriendsFrameFriendsScrollFrame + local offset = HybridScrollFrame_GetOffset(scrollFrame) + local buttons = scrollFrame.buttons + + local playerArea = GetRealZoneText() + + for i = 1, #buttons do + local nameText, nameColor, infoText + button = buttons[i] + index = offset + i + if(button:IsShown()) then + if ( button.buttonType == FRIENDS_BUTTON_TYPE_WOW ) then + local name, level, class, area, connected, status, note = GetFriendInfo(button.id) + if(connected) then + nameText = classColorHex[class] .. name.."|r, "..format(FRIENDS_LEVEL_TEMPLATE, diffColor[level] .. level .. '|r', class) + if(areaName == playerArea) then + infoText = format('|cff00ff00%s|r', area) + end + end + elseif (button.buttonType == FRIENDS_BUTTON_TYPE_BNET) then + local presenceID, givenName, surname, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText = BNGetFriendInfo(button.id) + if(isOnline and client==BNET_CLIENT_WOW) then + local hasFocus, toonName, client, realmName, faction, race, class, guild, zoneName, level, gameText, broadcastText, broadcastTime = BNGetToonInfo(toonID) + if(givenName and surname and toonName) then + if(enable_friendslist_wowcrossrealmfriend or CanCooperateWithToon(toonID)) then + nameText = format(BATTLENET_NAME_FORMAT, givenName, surname) ..' '.. FRIENDS_WOW_NAME_COLOR_CODE .. '(' .. classColorHex[class] .. toonName .. FRIENDS_WOW_NAME_COLOR_CODE .. ')' + if(zoneName == playerArea) then + infoText = format('|cff00ff00%s|r', zoneName) + end + end + end + end + end + end - if(button.buttonType == FRIENDS_BUTTON_TYPE_WOW) then - local name, level, class, area, connected, status, note = GetFriendInfo(button.id) - if(connected) then - nameText = classColorHex[class] .. name .. "|r, " .. format(FRIENDS_LEVEL_TEMPLATE, diffColor[level] .. level .. '|r', class) - if(enable_friendslist_wowfriendswhitetext) then - nameColor = WHITE - end - if(area == playerArea) then - infoText = format('|cff00ff00%s|r', area) + if(nameText) then + button.name:SetText(nameText) + end + if(nameColor) then + button.name:SetTextColor(nameColor.r, nameColor.g, nameColor.b) + end + if(infoText) then + button.info:SetText(infoText) end end - elseif(button.buttonType == FRIENDS_BUTTON_TYPE_BNET) then - local presenceID, givenName, surname, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText = BNGetFriendInfo(button.id) - if(isOnline and client==BNET_CLIENT_WOW) then - local hasFocus, toonName, client, realmName, faction, race, class, guild, zoneName, level, gameText, broadcastText, broadcastTime = BNGetToonInfo(toonID) - if(givenName and surname and toonName) then - if(enable_friendslist_wowcrossrealmfriend or CanCooperateWithToon(toonID)) then - nameText = format(BATTLENET_NAME_FORMAT, givenName, surname) ..' '.. FRIENDS_WOW_NAME_COLOR_CODE .. '(' .. classColorHex[class] .. toonName .. FRIENDS_WOW_NAME_COLOR_CODE .. ')' - if(zoneName == playerArea) then - infoText = format('|cff00ff00%s|r', zoneName) + end) + else + hooksecurefunc(FriendsFrameFriendsScrollFrame, 'buttonFunc', function(button, index, fristButton) + local height + local nameText + local infoText + local nameColor + local playerArea = GetRealZoneText() + + if(button.buttonType == FRIENDS_BUTTON_TYPE_WOW) then + local name, level, class, area, connected, status, note = GetFriendInfo(button.id) + if(connected) then + nameText = classColorHex[class] .. name .. "|r, " .. format(FRIENDS_LEVEL_TEMPLATE, diffColor[level] .. level .. '|r', class) + if(enable_friendslist_wowfriendswhitetext) then + nameColor = WHITE + end + if(area == playerArea) then + infoText = format('|cff00ff00%s|r', area) + end + end + elseif(button.buttonType == FRIENDS_BUTTON_TYPE_BNET) then + local presenceID, givenName, surname, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText = BNGetFriendInfo(button.id) + if(isOnline and client==BNET_CLIENT_WOW) then + local hasFocus, toonName, client, realmName, faction, race, class, guild, zoneName, level, gameText, broadcastText, broadcastTime = BNGetToonInfo(toonID) + if(givenName and surname and toonName) then + if(enable_friendslist_wowcrossrealmfriend or CanCooperateWithToon(toonID)) then + nameText = format(BATTLENET_NAME_FORMAT, givenName, surname) ..' '.. FRIENDS_WOW_NAME_COLOR_CODE .. '(' .. classColorHex[class] .. toonName .. FRIENDS_WOW_NAME_COLOR_CODE .. ')' + if(zoneName == playerArea) then + infoText = format('|cff00ff00%s|r', zoneName) + end end end end end - end - if(nameText) then - button.name:SetText(nameText) - end - if(nameColor) then - button.name:SetTextColor(nameColor.r, nameColor.g, nameColor.b) - end - if(infoText) then - button.info:SetText(infoText) - end - end) + if(nameText) then + button.name:SetText(nameText) + end + if(nameColor) then + button.name:SetTextColor(nameColor.r, nameColor.g, nameColor.b) + end + if(infoText) then + button.info:SetText(infoText) + end + end) + end end -if(enable_guildlist) then +if(enable_guildlist and not is_cata) then hooksecurefunc('GuildStatus_Update', function() local playerArea = GetRealZoneText() diff --git a/yClassColors.toc b/yClassColors.toc index cae98b4..d5e2cb7 100644 --- a/yClassColors.toc +++ b/yClassColors.toc @@ -1,9 +1,11 @@ ## Interface: 30300 +## X-Compatible-With: 40000 ## Title: |cffff8800y|rClassColors ## Note: Colorize name by class! ## Author: yleaf -## Version: 2.0.4 +## Version: 2.1 ## OptionalDeps: !ClassColors yClassColors.lua + -- 1.7.9.5