From cd3c84b1a0f9baaf11ce2b3c145fbdba01a9bcae Mon Sep 17 00:00:00 2001 From: Christopher Rosell Date: Wed, 13 Oct 2010 01:33:26 +0200 Subject: [PATCH] Update to support 4.0.1 and removed tooltip since all mounts now scale to riding skill anyway. --- CompanionCount.lua | 146 ++++++---------------------------------------------- CompanionCount.toc | 4 +- 2 files changed, 17 insertions(+), 133 deletions(-) diff --git a/CompanionCount.lua b/CompanionCount.lua index dfea4b6..d2223a7 100644 --- a/CompanionCount.lua +++ b/CompanionCount.lua @@ -1,138 +1,22 @@ --- Scanning functions -local GetMountInfo, GetMountTypeSpeed -do - local L = { - fast = 'This is a very fast %w+', - fastest = 'This is an extremely fast %w+', - flying = 'Outland %w+ Northrend', - turtle = '[Tt]urtle', - aq = 'Emits a high frequency sound, forcing a silithid tank', - } - local speeds = { - flying_fastest = 310, flying_fast = 280, flying = 150, - ground_fast = 100, ground = 60, ground_slow = 0 - } - - local cache = {} - local scantt = CreateFrame('GameTooltip', 'CompanionCountTooltip', UIParent, 'GameTooltipTemplate') - - function GetMountType(spellid) - local rval - if not cache[spellid] then - local link = GetSpellLink(spellid) - - scantt:SetOwner(UIParent, 'ANCHOR_NONE') - scantt:SetHyperlink(link) - - if CompanionCountTooltipTextLeft3 then - local text = CompanionCountTooltipTextLeft3:GetText() - - scantt:Hide() - - if text:match(L.flying) then - if text:match(L.fastest) then - rval = 'flying_fastest' - elseif text:match(L.fast) then - rval = 'flying_fast' - else - rval = 'flying' - end - else - if text:match(L.fast) then - rval = 'ground_fast' - elseif text:match(L.turtle) then - rval = 'ground_slow' - elseif text:match(L.aq) then - rval = 'ground' - else - rval = 'ground' - end - end - end - cache[spellid] = rval - else - rval = cache[spellid] - end - - return rval - end - - function GetMountTypeSpeed(typ) - return speeds[typ] or 0 - end -end - - --- Text update -do - local TOTAL_FORMAT = ' ('..NUMBER_OF_RESULTS_TEMPLATE:match('%( (.-) %)')..')' - - hooksecurefunc("PetPaperDollFrame_SetCompanionPage", function(num) - local text = CompanionPageNumber:GetText() - local count = GetNumCompanions(PetPaperDollFrameCompanionFrame.mode) +local IsCataclysmWorld = select("#", GetMapContinents()) > 4 - CompanionPageNumber:SetFormattedText(text..TOTAL_FORMAT, count) - end) - - local point1, parent, point2, x, y = CompanionPrevPageButton:GetPoint(1) - CompanionPrevPageButton:ClearAllPoints() - CompanionPrevPageButton:SetPoint(point1, parent, point2, x-20, y) - - point1, parent, point2, x, y = CompanionNextPageButton:GetPoint(1) - CompanionNextPageButton:ClearAllPoints() - CompanionNextPageButton:SetPoint(point1, parent, point2, x+33, y) -end +local MAX_COMPANIONS = { + CRITTER = IsCataclysmWorld and 190 or 160, + MOUNT = IsCataclysmWorld and 290 or 263 +} - --- Tooltip do - local mounts = {} - local function DoMountTooltip(self, tt) - local show = function(msg, typ) - if mounts[typ] then - tt:AddDoubleLine(msg:format(GetMountTypeSpeed(typ)), mounts[typ], 1, 1, 1) - end - end + local progress = CreateFrame("StatusBar", "CompanionCountProgress", SpellBookCompanionsFrame, "ProfessionStatusBarTemplate") + progress:SetPoint("CENTER", 0, -220) - table.wipe(mounts) - for i=1, GetNumCompanions'MOUNT' do - local id, name, spellid = GetCompanionInfo('MOUNT', i) - local typ = GetMountType(spellid) + hooksecurefunc("SpellBookFrame_UpdatePages", function() + local mode = SpellBookCompanionsFrame.mode - mounts[typ] = (mounts[typ] or 0) + 1 + if mode then + local cur, max = GetNumCompanions(mode), MAX_COMPANIONS[mode] + progress:SetMinMaxValues(1, max) + progress:SetValue(cur) + progress.rankText:SetFormattedText("%d/%d", cur, max) end - - tt:SetOwner(self, 'ANCHOR_NONE') - tt:SetPoint('BOTTOMLEFT', self, 'TOPRIGHT') - tt:ClearLines() - tt:AddLine'Detailed Info' - - show('Flying (%d%%)', 'flying_fastest') - show('Flying (%d%%)', 'flying_fast') - show('Flying (%d%%)', 'flying') - show('Ground (%d%%)', 'ground_fast') - show('Ground (%d%%)', 'ground') - show('Ground (%d%%)', 'ground_slow') - - tt:Show() - end - - local function OnEnter(self) - - if PetPaperDollFrameCompanionFrame.mode == 'MOUNT' then - DoMountTooltip(self, GameTooltip) - end - end - - local function OnLeave(self) - GameTooltip:Hide() - end - - local ttparent = CreateFrame('Frame', nil, CompanionPageNumber:GetParent()) - ttparent:SetWidth(CompanionPageNumber:GetWidth()) - ttparent:SetHeight(CompanionPageNumber:GetHeight()) - ttparent:SetAllPoints(CompanionPageNumber) - ttparent:EnableMouse(true) - ttparent:SetScript('OnEnter', OnEnter) - ttparent:SetScript('OnLeave', OnLeave) + end) end diff --git a/CompanionCount.toc b/CompanionCount.toc index 765aba0..83dc6a6 100644 --- a/CompanionCount.toc +++ b/CompanionCount.toc @@ -1,7 +1,7 @@ -## Interface: 30300 +## Interface: 40000 ## Title: Companion Count ## Notes: Display number of companions on pet/mount tab -## Version: 1.1 +## Version: 1.2 ## Author: chrippa ## LoadManagers: AddonLoader -- 1.7.9.5