Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------
- -- BetterTooltips.lua
- --------------------------------------------------------------------------
- --[[Author: Maldarius of Arathor
- Usage: Auto-loads on login
- /btt -- root slash command
- /btt combat -- toggle hide/show of tooltip info while in combat
- /btt help -- display in-game help in chat box
- Change Log:
- v2.3.1 Current Official Release
- - Fixed a bug that prevented the Character Tooltip from updating properly
- - Beginning prep for the coming expansion: Legion
- v2.3
- - Updated for Warlord of Draenor patch 6.2.3
- - Added automatic Valor Point tracking to the WoD currency section
- v2.2.2
- - Verified no API or UI changes were made in WoD 6.2.2 that would affect BetterTooltips
- - Enjoy flying in Draenor!
- v2.2.1
- - Corrected a spacing & layout issue on the Spellbook Tooltip
- v2.2
- - Updated the Character Tooltip with a WoD-specific currency
- section that automatically populates with your Warlords of
- Draenor currency (Apexis Crystals, Oil, Garrison Resources,
- etc.)
- - Moved the three "tracked" currencies in their own section in the
- Character Tooltip
- - Updated Spellbook Tooltip to include a breakout of
- native profession skill + bonuses
- - Added conditional coloring to the Spellbook Tooltip
- - Updated the included Ace library packages
- - Changed some of the coding to be a bit more effecient
- - Still chasing the best solution for that pesky guild roster
- updating bug (you sometimes have to mouseover twice to get an
- updated roster if someone has very recently logged in)
- NOTE: If you have expertise in this area and can help me out
- with a fix, reach out to me via CurseForge
- http://www.curseforge.com/projects/44177/
- v2.1
- - Changed the slash command help text
- - Changed coloring & formatting of all the chat box text messages
- - Changed the folder name inside the addon package
- - Added Change Log to the main lua file (this file)
- v2.0.2
- - Implemented another quick code fix because it was late when I
- packaged the first TWO times...
- v2.0.1
- - Implemented a quick code fix because it was late when I packaged
- the first time... and mistakes happen
- v2.0
- - Second major release version
- - Added a slash command framework - [/btt]
- - Added a slash command to hide the tooltip info during combat,
- if desired. Use [/btt combat] to toggle the feature
- - Updated function hooks to reflect any changes since 5.4 that
- may affect tooltip rendering and information
- - Added conditional formatting and spacing to tooltips
- - Updated the Social Tooltip to better reflect the state of
- Battle.net and WoW friends
- - Updated the Guild Tooltip to update more frequently
- - Added a "Remote Guildies" section to the Guild Tooltip to track
- Mobile Armory App users
- v1.7b
- - Internal beta (withheld)
- - Function prototyping and code testing
- v1.6
- - Updated the onLoad chat notice function
- - Updated change log for consistency
- - Removed DragonHide feature
- v1.5
- - Revived project on Curse - Look for version 2.0 coming July 2015!
- - Updated TOC for patch 6.2
- v1.4
- - Updated TOC for patch 5.1 (two previous versions skipped due to
- development problems)
- v1.3b
- - Internal beta (withheld)
- - Function prototyping and code testing
- v1.2b
- - Internal beta (withheld)
- - Function prototyping and code testing
- v1.1
- - Patched the Guild Tooltip code that was causing an error to be
- thrown when a character was not in a guild and/or had not chosen
- a faction (i.e., Pandarens)
- v1.0
- - First official release
- - Added a MainMenuBar prep function that hides those pesky dragons
- v0.4b
- - Minor bug fixes
- v0.3b
- - Corrected error in .toc versioning
- v0.2b
- - Removed Mac OS-X folders and .DS_Store files
- v0.1b
- - Inital Public Beta Release
- ]]--
- BetterTooltips = LibStub("AceAddon-3.0"):NewAddon("BetterTooltips", "AceHook-3.0");
- -- GLOBAL VARIABLES
- bttConfigCombat = false;
- -- LOCAL FUNCTIONS AND HOOKS
- local function eventHandler(self, event, ...)
- if ( event == "PLAYER_ENTERING_WORLD" ) then
- self:UnregisterEvent("PLAYER_ENTERING_WORLD")
- DEFAULT_CHAT_FRAME:AddMessage(string.format("|cff00ffffBetterTooltips v2.3 for WoD:|r Successfully loaded"))
- end
- end
- local frame = CreateFrame("Frame")
- frame:RegisterEvent("PLAYER_ENTERING_WORLD")
- frame:SetScript("OnEvent", eventHandler)
- local function levelcolor(level)
- if level then
- local color = GetQuestDifficultyColor(level)
- return string.format("%02x%02x%02x", color.r*255, color.g*255, color.b*255)
- end
- end
- local colors = {}
- for class,color in pairs(RAID_CLASS_COLORS)
- do colors[class] = string.format("%02x%02x%02x", color.r*255, color.g*255, color.b*255);
- end
- function BetterTooltips:OnInitialize()
- -- do nothing
- end
- function BetterTooltips:OnEnable()
- self:SecureHookScript(QuickJoinToastButton, "OnEnter", "OnMouseOverFriends");
- self:SecureHookScript(CharacterMicroButton, "OnEnter", "OnMouseOverCharacter");
- self:SecureHookScript(SpellbookMicroButton, "OnEnter", "OnMouseOverSpellbook");
- self:SecureHookScript(GuildMicroButton, "OnEnter", "OnMouseOverGuild");
- --self:SecureHookScript(MainMenuBarBackpackButton, "OnEnter", "OnMouseOverBackpack");
- end
- function BetterTooltips:OnDisable()
- self:UnHookAll();
- end
- -- SOCIAL TOOLTIP
- function BetterTooltips:OnMouseOverFriends()
- if ((UnitAffectingCombat("player")) and (bttConfigCombat)) then
- -- Do Nothing
- else
- local numBNet, numBNetOnline = BNGetNumFriends();
- local numFriends, numFriendsOnline = GetNumFriends();
- local fcolor = "ffffff";
- GameTooltip:AddLine(" ");
- -- Battle.net Friends
- if numBNetOnline > 0 then
- fcolor = "00ff00";
- if numBNetOnline == 1 then
- GameTooltip:AddLine("|cff"..fcolor.."1 Battle.net Friend Online|r");
- else
- GameTooltip:AddLine("|cff"..fcolor..string.format("%d Battle.net Friends Online", numBNetOnline).."|r");
- end
- else
- GameTooltip:AddLine("|cff"..fcolor.."No Battle.net Friends Online|r");
- end
- for i = 1, numBNet, 1 do
- local presenceID, realName, toonName, toonID, client, isOnline = BNGetFriendInfo(i);
- if isOnline then
- local zone = client;
- if client == "WoW" then
- local _, _, _, zoneName = BNGetToonInfo(presenceID);
- zone = zoneName;
- end
- --GameTooltip:AddLine("|cff00fbf6"..toonName.." ("..zone..") ["..realName.."]|r");
- GameTooltip:AddLine("|cff00fbf6"..toonName.." ["..realName.."]|r");
- end
- end
- -- Spacer Line
- if (numFriendsOnline > 0) or (numBNetOnline > 0) then
- GameTooltip:AddLine(" ");
- end
- -- Regular Friends
- if numFriendsOnline > 0 then
- fcolor = "00ff00";
- if numFriendsOnline == 1 then
- GameTooltip:AddLine("|cff"..fcolor.."1 WoW Friend Online|r");
- else
- GameTooltip:AddLine("|cff"..fcolor..string.format("%d WoW Friends Online", numFriendsOnline).."|r");
- end
- else
- fcolor = "ffffff";
- GameTooltip:AddLine("|cff"..fcolor.."No WoW Friends Online|r");
- end
- for i = 1, numFriends, 1 do
- local name, level, class, area, connected, status, note = GetFriendInfo(i);
- if connected then
- GameTooltip:AddDoubleLine(("|cff"..levelcolor(level)..string.format("%2d", level).."|r".." "..string.format("|cff%s%s", colors[class:gsub(" ", ""):upper()] or "ffffff", name).."|r"),(area));
- end
- end
- GameTooltip:Show();
- end
- end
- local function trackCurrency()
- local toTrack = { "Apexis Crystal",
- "Garrison Resources",
- "Oil",
- "Valor",
- "Artifact Fragment",
- "Dingy Iron Coin",
- "Seal of Tempered Fate",
- "Seal of Inevitable Fate",
- "Curious Coin",
- "Coins of Air",
- "Legionfall War Supplies",
- "Order Resources",
- "Sightless Eye",
- "Timewarped Badge",
- "Lesser Charm of Good Fortune"
- }
- return toTrack
- end
- local function trackableCurrency(checkCurrency)
- for _,currency in ipairs(trackCurrency()) do
- if checkCurrency == currency then
- return true
- end
- end
- return false
- end
- -- CHARACTER INFO TOOLTIP
- function BetterTooltips:OnMouseOverCharacter()
- if ((UnitAffectingCombat("player")) and (bttConfigCombat)) then
- -- Do Nothing
- else
- --Durability
- local itemSlots = {
- "HeadSlot",
- "ShoulderSlot",
- "ChestSlot",
- "WristSlot",
- "HandsSlot",
- "WaistSlot",
- "LegsSlot",
- "FeetSlot",
- "MainHandSlot",
- "SecondaryHandSlot",
- }
- if not GetNumSubgroupMembers then
- tinsert(itemSlots, "RangedSlot")
- end
- local durability, maximum = 0, 0
- for i=1, #itemSlots do
- local slotId = GetInventorySlotInfo(itemSlots[i])
- local d, m = GetInventoryItemDurability(slotId)
- durability = durability + (d or 0)
- maximum = maximum + (m or 0)
- end
- local duraLast = durability / maximum * 100;
- local duraColor = "ffffff";
- if duraLast > 74 then duraColor = "00ff00"
- elseif duraLast > 59 then duraColor = "9acd32"
- elseif duraLast > 39 then duraColor = "ffff00"
- elseif duraLast > 19 then duraColor = "ffa500"
- elseif duraLast > 9 then duraColor = "ff4500"
- else duraColor = "ff0000"
- end
- GameTooltip:AddDoubleLine(("Durability: "),(("|T%s:0|t"):format("Interface\\Icons\\Trade_BlackSmithing").." |cff"..duraColor..("%.0f%%"):format(duraLast).."|r"));
- GameTooltip:AddLine(" ");
- --Money
- local money = GetCoinTextureString(GetMoney("player"))
- GameTooltip:AddDoubleLine(("Money: "),("|cffffffff"..money.."|r"))
- --Currency
- local numCurTypes = GetCurrencyListSize()
- local warlordsCount = 0;
- for i = 1, numCurTypes, 1 do
- local name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetCurrencyListInfo(i);
- if count == nil then
- GameTooltip:AddLine(" ");
- GameTooltip:AddLine(name);
- elseif count > 0 then
- --if trackableCurrency(name) then
- GameTooltip:AddDoubleLine("|cffffffff"..name.."|r","|cffffffff"..("%d%s|T%s:0|t"):format(count," ",icon).."|r");
- --end
- end
- end
- --[[
- local watchCount = 0;
- for i = 1, numCurTypes, 1 do
- local name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetCurrencyListInfo(i);
- if (isWatched and name ~= "Apexis Crystal" and name ~= "Garrison Resources" and name ~= "Oil" and name ~= "Valor" and name ~= "Artifact Fragment" and name ~= "Dingy Iron Coin" and name ~= "Seal of Tempered Fate" and name ~= "Seal of Inevitable Fate") then
- if watchCount == 0 then
- GameTooltip:AddLine(" ");
- GameTooltip:AddLine("Tracked Currency:");
- end
- GameTooltip:AddDoubleLine("|cffffffff"..name.."|r","|cffffffff"..("%d%s|T%s:0|t"):format(count," ",icon).."|r");
- watchCount = watchCount + 1
- end
- end
- --]]
- GameTooltip:Show();
- end
- end
- -- SPELLBOOK & ABILITIES TOOLTIP
- local function AddSkillToTooltip(skillid, fallback)
- if (not skillid) then
- return GameTooltip:AddDoubleLine(fallback, "See Trainer!");
- else
- local name, icon, skillLevel, maxSkillLevel, numSpells, spellOffset, skillLine, skillModifier = GetProfessionInfo(skillid);
- if (skillLevel < maxSkillLevel) then
- if (skillModifier ~= 0) then
- skillLevel = "|cff00ff00"..("%d"):format(skillLevel + skillModifier).."|r (|cffeeeeee"..("%d"):format(skillLevel).."+|r|cff00ff00"..("%d"):format(skillModifier).."|r)";
- else
- skillLevel = "|cffeeeeee"..("%d"):format(skillLevel).."|r";
- end
- else
- skillLevel = ("%d"):format(skillLevel);
- end
- GameTooltip:AddDoubleLine(("|cffffffff"..("|T%s:0|t%s"):format(icon, " "..name).."|r"),(skillLevel..("/%d"):format(maxSkillLevel)));
- end
- end
- function BetterTooltips:OnMouseOverSpellbook()
- if (UnitAffectingCombat("player") and bttConfigCombat) then
- -- Do Nothing
- else
- local prof1, prof2, arch, fish, cook, firstAid = GetProfessions();
- GameTooltip:AddLine(" ");
- GameTooltip:AddLine("Professions");
- AddSkillToTooltip(prof1, PROFESSIONS_FIRST_PROFESSION);
- AddSkillToTooltip(prof2, PROFESSIONS_SECOND_PROFESSION);
- AddSkillToTooltip(arch, PROFESSIONS_ARCHAEOLOGY);
- AddSkillToTooltip(fish, PROFESSIONS_FISHING);
- AddSkillToTooltip(cook, PROFESSIONS_COOKING);
- AddSkillToTooltip(firstAid, PROFESSIONS_FIRST_AID);
- GameTooltip:Show();
- end
- end
- -- GUILD TOOLTIP
- function BetterTooltips:OnMouseOverGuild()
- if (UnitAffectingCombat("player") and bttConfigCombat) then
- -- Do Nothing
- else
- if IsInGuild() then
- GuildRoster();
- local guildName, guildRankName, guildRankIndex = GetGuildInfo("player");
- local numGuildMembers, numOnline = GetNumGuildMembers();
- local sMsg = "";
- local spacer = true;
- if (numOnline) == 1 then
- sMsg = "1 Guildie Online";
- else
- sMsg = string.format("%0d Guildies Online", numOnline);
- end
- GameTooltip:AddLine("|cffffffff"..guildName.." - |r".."|cff00ff00"..sMsg.."|r");
- for i = 1, numOnline, 1 do
- local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPoints, achievementRank, isMobile = GetGuildRosterInfo(i);
- if online then
- if (level < 100) then
- GameTooltip:AddDoubleLine(("|cff"..levelcolor(level).." "..string.format("%2d", level).."|r".." "..string.format("|cff%s%s", colors[classFileName] or "ffffff", name).."|r"),(zone));
- else
- GameTooltip:AddDoubleLine(("|cff"..levelcolor(level)..string.format("%2d", level).."|r".." "..string.format("|cff%s%s", colors[classFileName] or "ffffff", name).."|r"),(zone));
- end
- end
- end
- for i = 1, numGuildMembers, 1 do
- local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPoints, achievementRank, isMobile = GetGuildRosterInfo(i);
- if isMobile then
- if (spacer) then
- GameTooltip:AddLine(" ");
- GameTooltip:AddLine("Remote Guildies (Mobile Armory App)");
- spacer = false;
- end
- if (level < 100) then
- GameTooltip:AddLine(("|cff"..levelcolor(level).." "..string.format("%2d", level).."|r".." "..string.format("|cff%s%s", colors[classFileName] or "ffffff", name).."|r"));
- else
- GameTooltip:AddLine(("|cff"..levelcolor(level)..string.format("%2d", level).."|r".." "..string.format("|cff%s%s", colors[classFileName] or "ffffff", name).."|r"));
- end
- end
- end
- else
- GameTooltip:AddLine("You are not currently in a guild.");
- GameTooltip:AddLine(" ");
- GameTooltip:AddLine("Once you join a guild, information about your guild mates who are logged on will appear in this tooltip.");
- end
- GameTooltip:Show();
- end
- end
- --[[ BACKPACK INFO TOOLTIP (REAGENT COUNTER BASED ON PROFESSIONS)
- function BetterTooltips:OnMouseOverBackpack()
- if ((UnitAffectingCombat("player")) and (bttConfigCombat)) then
- -- Do Nothing
- else
- --Currency
- GameTooltip:AddLine(" ");
- GameTooltip:AddLine("Currency:");
- local numCurTypes = GetCurrencyListSize()
- for i = 1, numCurTypes, 1 do
- local name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetCurrencyListInfo(i);
- if (isHeader and not isUnused and name ~= "Dungeon and Raid") then
- if (i > 1) then
- GameTooltip:AddLine(" ");
- end
- GameTooltip:AddLine(name);
- elseif (not isHeader and not isUnused and count > 0) then
- GameTooltip:AddDoubleLine("|cffffffff"..name.."|r","|cffffffff"..("%d%s|T%s:0|t"):format(count," ",icon).."|r");
- end
- end
- GameTooltip:Show();
- end
- end]]
- --[[ WORLD/FRAME UNIT TOOLTIP (AVERAGE ITEM LEVEL)
- function BetterTooltips:OnMouseOverBackpack()
- if ((UnitAffectingCombat("player")) and (bttConfigCombat)) then
- -- Do Nothing
- else
- --Currency
- GameTooltip:AddLine(" ");
- GameTooltip:AddLine("Currency:");
- local numCurTypes = GetCurrencyListSize()
- for i = 1, numCurTypes, 1 do
- local name, isHeader, isExpanded, isUnused, isWatched, count, icon = GetCurrencyListInfo(i);
- if (isHeader and not isUnused and name ~= "Dungeon and Raid") then
- if (i > 1) then
- GameTooltip:AddLine(" ");
- end
- GameTooltip:AddLine(name);
- elseif (not isHeader and not isUnused and count > 0) then
- GameTooltip:AddDoubleLine("|cffffffff"..name.."|r","|cffffffff"..("%d%s|T%s:0|t"):format(count," ",icon).."|r");
- end
- end
- GameTooltip:Show();
- end
- end]]
- -- SLASH COMMANDS
- SLASH_BTTCONFIG1 = "/btt";
- function SlashCmdList.BTTCONFIG(arg)
- -- Combat Visibility Toggle
- if (arg == "combat") then
- -- Toggle and echo current setting
- bttConfigCombat = (bttConfigCombat == false);
- if (bttConfigCombat) then
- DEFAULT_CHAT_FRAME:AddMessage("|cffddaa11BetterTooltips will be hidden during combat|r");
- else
- DEFAULT_CHAT_FRAME:AddMessage("|cffddaa11BetterTooltips will show both in and out of combat|r");
- end
- else
- -- Print help
- DEFAULT_CHAT_FRAME:AddMessage("|cffddaa11BetterTooltips v2.0.3 -- |cffffffffCommand Help:|r");
- DEFAULT_CHAT_FRAME:AddMessage("|cffeeee00/btt combat|r".."|cff4de6cc -- Toggle hide/show BetterTooltips during combat|r");
- DEFAULT_CHAT_FRAME:AddMessage("|cffeeee00/btt help|r".."|cff4de6cc -- Display this help menu|r");
- DEFAULT_CHAT_FRAME:AddMessage("|cffddaa11More to come... send in feature/command requests!|r");
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement