Quantcast Tooltip Item Level AddOn - WoWInterface
Thread Tools Display Modes
01-15-15, 08:09 AM   #1
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 759
Tooltip Item Level AddOn

There are many AddOns that show the Equipped Item Level in the tooltip but non of them seam to be up to date. Untill now I was using FreebTip that had this integrated but it dosen't work corretly and also buggs if you try to inspect someone So I'd like to switch to TipTac but its missing this.
I just need to see the overall itemlevel NOT the item level of each item seperated.

http://www.wowinterface.com/download...ScoreLite.html
http://www.wowinterface.com/download...ItemLevel.html
http://www.wowinterface.com/download...ItemLevel.html
http://www.wowinterface.com/download...elTooltip.html
http://www.curse.com/addons/wow/eil
http://www.curse.com/addons/wow/simple-ilevel --> latest beta bugged/not updated since

http://www.wowinterface.com/download...vgItemLvl.html --> this one is up to date but shows pvp gear with lower item level? Bad idea when pvp items are better the some heroic gear
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
01-15-15, 11:41 AM   #2
EKE
A Fallenroot Satyr
 
EKE's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2011
Posts: 22
this is an update from villiv's EquippedItemLevel, edit by nj55top

but cant use with freebtip because they get lua code conflict.

Code:
--[[ Equipped Item Level v121025 villiv ]]--

-- decimal places of the equipped average item level. to assign '2' will show it like '123.45'
local DECIMAL_PLACES = 2

-- additional strings. if you don't like it just assign 'nil'. but do not delete these variables themselves.
local UPDATED = CANNOT_COOPERATE_LABEL -- '*'
local WAITING = CONTINUED -- '...'
local PENDING = CONTINUED .. CONTINUED -- '......'

-- output prefix. has to have unique strings to update the tooltip correctly
local PREFIX = STAT_FORMAT:format(STAT_AVERAGE_ITEM_LEVEL) .. '|Heqppditmlvl|h |h' .. HIGHLIGHT_FONT_COLOR_CODE


local f = CreateFrame('Frame')
f:SetScript('OnEvent', function(self, event, ...) return self[event](self, event, ...) end)
f:Hide()

local playerGUID, inCombat, updateTimer
local currentUnit, currentGUID
local isDelayed, isForced, isNotified, isReady

local function GetTipUnit ()
	local _, unit = GameTooltip:GetUnit()
	if ( not unit ) then
		local mouseFocus = GetMouseFocus()
		unit = mouseFocus and (mouseFocus.unit or mouseFocus:GetAttribute('unit'))
	end

	return unit and UnitIsPlayer(unit) and unit
end

local SetTipText
do
	local function search (line, numLines)
		if ( line > numLines ) then return end

		local fontString = _G['GameTooltipTextLeft' .. line]
		local stringText = fontString and fontString:GetText()
		if ( stringText and stringText:match(PREFIX) ) then	return fontString end

		return search(line + 1, numLines)
	end

	function SetTipText (text)
		if ( not text ) then return end

		local fontString = search(1, GameTooltip:NumLines())
		if ( fontString ) then
			fontString:SetText(PREFIX .. text)
		else
			GameTooltip:AddLine(PREFIX .. text)
		end

		return GameTooltip:Show()
	end
end

local CanSafeInspect -- 6 times per 10 secs
do
	local limit, period = 6, 11
	local count, startTime = 0, 0

	hooksecurefunc('NotifyInspect', function ()
		local currentTime = GetTime()
		if ( currentTime - startTime > period ) then
			count, startTime = 1, currentTime
			return
		end

		count = count + 1
	end)

	function CanSafeInspect (unit)
		if ( not CanInspect(unit) or InspectFrame and InspectFrame:IsShown() or Examiner and Examiner:IsShown() ) then return end

		local pending = count > limit and period - (GetTime() - startTime)
		return true, pending and pending > 0 and pending
	end
end

local UnitItemLevel
do
	local formatString = '%.' .. DECIMAL_PLACES .. 'f'

	local function scan (unit, slot, total, count, twoHanded, incomplete)
		if ( slot > INVSLOT_LAST_EQUIPPED ) then
			return formatString:format(total / (twoHanded and count - 2 or count-1)), incomplete
		end

		if ( slot == INVSLOT_BODY or slot == INVSLOT_TABARD ) then
			return scan(unit, slot + 1, total, count, twoHanded, incomplete)
		end

		local hasItem = GetInventoryItemTexture(unit, slot) and true
		local _, level, equipLoc

		local link = hasItem and GetInventoryItemLink(unit, slot)
		if ( link ) then
			repeat
				_, _, _, level, _, _, _, _, equipLoc = GetItemInfo(link)
			until level and equipLoc

			total = total + level
		end

		-- two-handed weapon and Titan's Grip
		if ( slot == INVSLOT_MAINHAND ) then
			twoHanded = equipLoc == 'INVTYPE_2HWEAPON' and 1 or not hasItem and 0
		elseif ( slot == INVSLOT_OFFHAND ) then
			twoHanded = twoHanded == 1 and not hasItem or twoHanded == 0 and equipLoc == 'INVTYPE_2HWEAPON'
		end

		local failed = hasItem and not link
		return scan(unit, slot + 1, total, failed and count or count + 1, twoHanded, incomplete or failed)
	end

	function UnitItemLevel (unit)
		if ( unit == 'player' or UnitIsUnit(unit, 'player') ) then
			local _, level = GetAverageItemLevel()
			return formatString:format(level)
		end

		return scan(unit, INVSLOT_FIRST_EQUIPPED, 0, 0)
	end
end

local UpdateItemLevel
do
	local cache = {}
	local cachedLevel

	local function update (unit, guid)
		local level, incomplete = UnitItemLevel(unit)

		if ( incomplete ) then
			updateTimer = TOOLTIP_UPDATE_TIME
			f:Show()
			level = cachedLevel or level
			return SetTipText(WAITING and level .. WAITING or level)
		end

		if ( isReady ) then
			cache[guid] = level
			return SetTipText(UPDATED and level .. UPDATED or level)
		end

		level = cachedLevel or level
		return SetTipText(WAITING and level .. WAITING or level)
	end

	function UpdateItemLevel ()
		cachedLevel = cache[currentGUID]

		if ( inCombat ) then return SetTipText(cachedLevel) end

		if ( isReady ) then return update(currentUnit, currentGUID) end

		if ( not isForced and cachedLevel ) then return SetTipText(cachedLevel) end

		if ( currentGUID == playerGUID ) then
			local level = UnitItemLevel('player')
			cache[playerGUID] = level
			return SetTipText(level)
		end

		local canInspect, pending = CanSafeInspect(currentUnit)
		if ( not canInspect ) then return SetTipText(cachedLevel) end

		if ( pending ) then
			updateTimer = pending
			f:Show()
			return SetTipText(cachedLevel and cachedLevel .. PENDING or PENDING)
		end

		if ( not isDelayed ) then
			isDelayed = true
			updateTimer = TOOLTIP_UPDATE_TIME
			f:Show()
			return SetTipText(cachedLevel and (WAITING and cachedLevel .. WAITING or cachedLevel) or PENDING)
		end

		if ( not isNotified ) then
			isNotified = true
			NotifyInspect(currentUnit)
		end

		return update(currentUnit, currentGUID)
	end
end

local function OnTooltipSetUnit ()
	currentUnit, currentGUID, isDelayed, isForced, isNotified, isReady = GetTipUnit(), nil, nil, nil, nil, nil
	if ( not currentUnit ) then return end

	currentGUID, isForced = UnitGUID(currentUnit), UnitIsUnit(currentUnit, 'target')

	return UpdateItemLevel()
end
GameTooltip:HookScript('OnTooltipSetUnit', OnTooltipSetUnit)

f:SetScript('OnUpdate', function (self, elapsed)
	updateTimer = updateTimer - elapsed
	if ( updateTimer > 0 ) then return end
	self:Hide()

	if ( not currentGUID ) then return end

	local tipUnit = GetTipUnit()
	if ( not tipUnit or UnitGUID(tipUnit) ~= currentGUID ) then return end

	return UpdateItemLevel()
end)

function f:INSPECT_READY (_, guid)
	if ( not currentGUID or guid ~= currentGUID ) then return end

	local tipUnit = GetTipUnit()
	if ( not tipUnit or UnitGUID(tipUnit) ~= currentGUID ) then return end

	isReady = true

	return UpdateItemLevel()
end
f:RegisterEvent('INSPECT_READY')

function f:UNIT_INVENTORY_CHANGED (_, unit)
	if ( not currentGUID or UnitGUID(unit) ~= currentGUID ) then return end

	local tipUnit = GetTipUnit()
	if ( not tipUnit or UnitGUID(tipUnit) ~= currentGUID ) then return end

	isForced, isNotified, isReady = true, nil, nil

	return UpdateItemLevel()
end
f:RegisterEvent('UNIT_INVENTORY_CHANGED')

function f:PLAYER_TARGET_CHANGED ()
	return self:UNIT_INVENTORY_CHANGED (nil, 'target')
end
f:RegisterEvent('PLAYER_TARGET_CHANGED')

function f:PLAYER_REGEN_DISABLED ()
	inCombat = true
end
f:RegisterEvent('PLAYER_REGEN_DISABLED')

function f:PLAYER_REGEN_ENABLED ()
	inCombat = nil
end
f:RegisterEvent('PLAYER_REGEN_ENABLED')

function f:PLAYER_LOGIN ()
	self:UnregisterEvent('PLAYER_LOGIN')
	self.PLAYER_LOGIN = nil

	playerGUID = UnitGUID('player')
end

if ( IsLoggedIn() ) then
	f:PLAYER_LOGIN()
	inCombat = InCombatLockdown()
	return OnTooltipSetUnit()
end

return f:RegisterEvent('PLAYER_LOGIN')

Last edited by EKE : 01-15-15 at 04:15 PM. Reason: Don't link to off-site downloads.
  Reply With Quote
01-15-15, 05:50 PM   #3
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 759
Thank you very much! It works fine with TipTac.

BTW you can attach zip and lua files to your forum posts
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
01-15-15, 09:12 PM   #4
EKE
A Fallenroot Satyr
 
EKE's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2011
Posts: 22
Originally Posted by Tonyleila View Post
Thank you very much! It works fine with TipTac.

BTW you can attach zip and lua files to your forum posts
well err im not the auther or editer, also use forum first time....

actually i hope can find other lite addon to replace freebtip_ilvl and freeb_spec

Last edited by EKE : 01-15-15 at 10:38 PM.
  Reply With Quote
01-16-15, 07:13 AM   #5
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 759
Originally Posted by EKE View Post
well err im not the auther or editer, also use forum first time....

actually i hope can find other lite addon to replace freebtip_ilvl and freeb_spec
What are you missing in TipTac? Its also very lite and TipTacTalents and TipTacItemRef can be removed. The Author seams to be very active.
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
01-16-15, 02:30 PM   #6
EKE
A Fallenroot Satyr
 
EKE's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2011
Posts: 22
Originally Posted by Tonyleila View Post
What are you missing in TipTac? Its also very lite and TipTacTalents and TipTacItemRef can be removed. The Author seams to be very active.
i use tiptac few years ago , but for my habit, i like no SavedVariables, no gui addon, just my preferences.
  Reply With Quote
01-16-15, 02:33 PM   #7
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 759
Originally Posted by EKE View Post
i use tiptac few years ago , but for my habit, i like no SavedVariables, no gui addon, just my preferences.
FreebTip has SavedVariables and TipTac options can be changed in core.lua and then you can just remove the TipTacOptions folder.
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
01-16-15, 03:07 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,394
Originally Posted by EKE View Post
i use tiptac few years ago , but for my habit, i like no SavedVariables, no gui addon, just my preferences.
Just curious, but are you running a machine with only 2GB of RAM?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-16-15, 04:03 PM   #9
EKE
A Fallenroot Satyr
 
EKE's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2011
Posts: 22
Originally Posted by Tonyleila View Post
FreebTip has SavedVariables and TipTac options can be changed in core.lua and then you can just remove the TipTacOptions folder.
just only tooltip anchor can be ignore and i dont need much config XD
  Reply With Quote
01-16-15, 04:15 PM   #10
EKE
A Fallenroot Satyr
 
EKE's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2011
Posts: 22
Originally Posted by Seerah View Post
Just curious, but are you running a machine with only 2GB of RAM?
hahahaha not

my computer running with 16GB ram, so i said just my strange preferences O.o
  Reply With Quote
01-16-15, 07:01 PM   #11
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 759
So I'm not 100% happy with the code yet.
I'd like disable this part of the tooltip for e.g. group members that are not in range, when you hoover them it trys to update and trys and that looks odd
But it also shoud be possible to view the itemlevel of group/raid members that are not in range because you can inspect there gear when they are in your group even if there are not in range.
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________

Last edited by Tonyleila : 01-16-15 at 07:26 PM.
  Reply With Quote
12-01-15, 02:43 PM   #12
pas06
A Wyrmkin Dreamwalker
Join Date: Apr 2009
Posts: 54
the code above shows an too low item level for hunters for me. Don't you have that problem?
  Reply With Quote
12-01-15, 03:19 PM   #13
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 759
Originally Posted by pas06 View Post
the code above shows an too low item level for hunters for me. Don't you have that problem?
Yes
and if I remember right its also has another wrong display for something. Woud be great if someone coud fix it
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________

Last edited by Tonyleila : 12-02-15 at 07:42 AM.
  Reply With Quote
12-02-15, 12:48 PM   #14
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 759
Uhm... where is the post that some guy here posted yesterday with new addon code?? I woud like to test it please
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
12-02-15, 01:09 PM   #15
pas06
A Wyrmkin Dreamwalker
Join Date: Apr 2009
Posts: 54
i posted it but i deleted it because i was not sure if it is against any license because i copy and pasted stuff and mofified it
  Reply With Quote
12-02-15, 03:24 PM   #16
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 759
Originally Posted by pas06 View Post
i posted it but i deleted it because i was not sure if it is against any license because i copy and pasted stuff and mofified it
Its not. But if you don't want to share it again here woud be cool if you coud send me the code via PM
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Tooltip Item Level AddOn

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off