diff --git a/core.lua b/core.lua index 6407efd..c9572ce 100644 --- a/core.lua +++ b/core.lua @@ -1,5 +1,7 @@ -local parent, ns = ... +local _, ns = ... +local ycc = {} +ns.ycc = ycc local GUILD_INDEX_MAX = 12 local SMOOTH = { @@ -7,7 +9,7 @@ local SMOOTH = { 1, 1, 0, 0, 1, 0, } -ns.myName = UnitName'player' +ycc.myName = UnitName'player' local BC = {} for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do @@ -53,7 +55,7 @@ end --GuildControlGetNumRanks() --GuildControlGetRankName(index) -ns.guildRankColor = setmetatable({}, { +ycc.guildRankColor = setmetatable({}, { __index = function(t, i) if i then local c = Hex(ColorGradient(i/GUILD_INDEX_MAX, unpack(SMOOTH))) @@ -66,18 +68,18 @@ ns.guildRankColor = setmetatable({}, { end end }) -ns.guildRankColor[0] = WHITE_HEX +ycc.guildRankColor[0] = WHITE_HEX -ns.diffColor = setmetatable({}, { +ycc.diffColor = setmetatable({}, { __index = function(t,i) local c = i and GetQuestDifficultyColor(i) t[i] = c and Hex(c) or t[0] return t[i] end }) -ns.diffColor[0] = WHITE_HEX +ycc.diffColor[0] = WHITE_HEX -ns.classColor = setmetatable({}, { +ycc.classColor = setmetatable({}, { __index = function(t,i) local c = i and RAID_CLASS_COLORS[BC[i] or i] if(c) then @@ -91,7 +93,7 @@ ns.classColor = setmetatable({}, { do local WHITE = {1,1,1} - ns.classColorRaw = setmetatable({}, { + ycc.classColorRaw = setmetatable({}, { __index = function(t, i) local c = i and RAID_CLASS_COLORS[BC[i] or i] if not c then return WHITE end diff --git a/friends.lua b/friends.lua index f84d821..6ff71b6 100644 --- a/friends.lua +++ b/friends.lua @@ -1,5 +1,6 @@ -local parent, ns = ... +local _, ns = ... +local ycc = ns.ycc local WHITE = {r = 1, g = 1, b = 1} local FRIENDS_LEVEL_TEMPLATE = FRIENDS_LEVEL_TEMPLATE:gsub('%%d', '%%s') @@ -19,7 +20,7 @@ local function friendsFrame() if ( button.buttonType == FRIENDS_BUTTON_TYPE_WOW ) then local name, level, class, area, connected, status, note = GetFriendInfo(button.id) if(connected) then - nameText = ns.classColor[class] .. name.."|r, "..format(FRIENDS_LEVEL_TEMPLATE, ns.diffColor[level] .. level .. '|r', class) + nameText = ycc.classColor[class] .. name.."|r, "..format(FRIENDS_LEVEL_TEMPLATE, ycc.diffColor[level] .. level .. '|r', class) if(areaName == playerArea) then infoText = format('|cff00ff00%s|r', area) end @@ -27,11 +28,11 @@ local function friendsFrame() 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) + local hasFocus, toonName, client, realmName, realmID, faction, race, class, guild, zoneName, level, gameText, broadcastText, broadcastTime = BNGetToonInfo(toonID) if(givenName and surname and toonName and class) then -- color them all --if CanCooperateWithToon(toonID) then - nameText = format(BATTLENET_NAME_FORMAT, givenName, surname) ..' '.. FRIENDS_WOW_NAME_COLOR_CODE .. '(' .. ns.classColor[class] .. ns.classColor[class] .. toonName .. FRIENDS_WOW_NAME_COLOR_CODE .. ')' + nameText = format(BATTLENET_NAME_FORMAT, givenName, surname) ..' '.. FRIENDS_WOW_NAME_COLOR_CODE .. '(' .. ycc.classColor[class] .. ycc.classColor[class] .. toonName .. FRIENDS_WOW_NAME_COLOR_CODE .. ')' if(zoneName == playerArea) then infoText = format('|cff00ff00%s|r', zoneName) end diff --git a/guild.lua b/guild.lua index 975186d..8767cec 100644 --- a/guild.lua +++ b/guild.lua @@ -1,10 +1,12 @@ -local parent, ns = ... +local _, ns = ... +local ycc = ns.ycc -local _VIEW = 'playerStatus' -- default +local _VIEW_DEFAULT = 'playerStatus' +local _VIEW = _VIEW_DEFAULT local function viewChanged(view) - _VIEW = view + _VIEW = view or _VIEW_DEFAULT end local function update() @@ -14,27 +16,33 @@ local function update() local buttons = GuildRosterContainer.buttons for i, button in ipairs(buttons) do - local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPnts, achievementRank, isMobile = GetGuildRosterInfo(button.guildIndex) - if(name and button:IsShown() and button.online and button.guildIndex) then - --print(button.guildIndex, name, time()) + -- why the fuck no continue? + if(button:IsShown() and button.online and button.guildIndex) then + local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPnts, achievementRank, isMobile = GetGuildRosterInfo(button.guildIndex) + local displayedName = ycc.classColor[classFileName] .. name + if(isMobile) then + name = ChatFrame_GetMobileEmbeddedTexture(73/255, 177/255, 73/255) .. name + end + if(_VIEW == 'playerStatus') then - button.string1:SetText(ns.diffColor[level] .. level) - if(not isMobile) then - button.string2:SetText(ns.classColor[classFileName] .. name) - end + button.string1:SetText(ycc.diffColor[level] .. level) + button.string2:SetText(displayedName) if(zone == playerArea) then button.string3:SetText('|cff00ff00' .. zone) end elseif(_VIEW == 'guildStatus') then - button.string1:SetText(ns.classColor[classFileName] .. name) + button.string1:SetText(displayedName) if(rankIndex and rank) then - button.string2:SetText(ns.guildRankColor[rankIndex] .. rank) + button.string2:SetText(ycc.guildRankColor[rankIndex] .. rank) end elseif(_VIEW == 'achievement') then - button.string1:SetText(ns.diffColor[level] .. level) + button.string1:SetText(ycc.diffColor[level] .. level) if(classFileName and name) then - button.string2:SetText(ns.classColor[classFileName] .. name) + button.string2:SetText(displayedName) end + elseif(_VIEW == 'weeklyxp' or _VIEW == 'totalxp') then + button.string1:SetText(ycc.diffColor[level] .. level) + button.string2:SetText(displayedName) end end end @@ -44,9 +52,9 @@ local function tradeupdate() local myZone = GetRealZoneText() for i, button in ipairs(GuildRosterContainer.buttons) do if(button:IsShown() and button.online and button.guildIndex) then - local skillID, isCollapsed, iconTexture, headerName, numOnline, numPlayers, playerName, class, online, zone, skill, classFileName = GetGuildTradeSkillInfo(button.guildIndex) + local skillID, isCollapsed, iconTexture, headerName, numOnline, numVisible, numPlayers, playerName, class, online, zone, skill, classFileName, isMobile = GetGuildTradeSkillInfo(button.guildIndex) if(not headerName) then - button.string1:SetText(ns.classColor[classFileName] .. playerName) + button.string1:SetText(ycc.classColor[classFileName] .. playerName) if(zone == myZone) then button.string2:SetText('|cff00ff00' .. zone) end diff --git a/lfr.lua b/lfr.lua index c9476e8..201b759 100644 --- a/lfr.lua +++ b/lfr.lua @@ -1,14 +1,14 @@ -local parent, ns = ... -local myName = UnitName'player' +local _, ns = ... +local ycc = ns.ycc hooksecurefunc('LFRBrowseFrameListButton_SetData', function(button, index) local name, level, areaName, className, comment, partyMembers, status, class, encountersTotal, encountersComplete, isLeader, isTank, isHealer, isDamage = SearchLFGGetResults(index) - if(index and class and name and level and (name~=myName)) then - button.name:SetText(ns.classColor[class] .. name) - button.class:SetText(ns.classColor[class] .. className) - button.level:SetText(ns.diffColor[level] .. level) + if(index and class and name and level and (name~=ycc.myName)) then + button.name:SetText(ycc.classColor[class] .. name) + button.class:SetText(ycc.classColor[class] .. className) + button.level:SetText(ycc.diffColor[level] .. level) end end) diff --git a/who.lua b/who.lua index 610f966..39afc55 100644 --- a/who.lua +++ b/who.lua @@ -1,4 +1,5 @@ -local parent, ns = ... +local _, ns = ... +local ycc = ns.ycc hooksecurefunc('WhoList_Update', function() local whoOffset = FauxScrollFrame_GetOffset(WhoListScrollFrame) @@ -27,9 +28,9 @@ hooksecurefunc('WhoList_Update', function() end local columnTable = { zone, guild, race } - local c = ns.classColorRaw[classFileName] + local c = ycc.classColorRaw[classFileName] nameText:SetTextColor(c.r, c.g, c.b) - levelText:SetText(ns.diffColor[level] .. level) + levelText:SetText(ycc.diffColor[level] .. level) variableText:SetText(columnTable[UIDropDownMenu_GetSelectedID(WhoFrameDropDown)]) end end diff --git a/yClassColors.toc b/yClassColors.toc index c78faab..d96faeb 100644 --- a/yClassColors.toc +++ b/yClassColors.toc @@ -1,17 +1,16 @@ -## Interface: 40000 - -## Title: |cffff8800y|rClassColors -## Note: Colorize name by class! -## Author: yleaf -## Version: 2.1.4 -## OptionalDeps: !ClassColors - -core.lua - - -battlefield.lua -friends.lua -guild.lua -lfr.lua -who.lua - +## Interface: 40200 + +## Title: |cffff8800y|rClassColors +## Note: Colorize name by class! +## Author: yleaf +## Version: 2.2.0 +## OptionalDeps: !ClassColors + +core.lua + +battlefield.lua +friends.lua +guild.lua +lfr.lua +who.lua +