Thread Tools Display Modes
11-30-10, 02:26 PM   #1
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Need some help with my inspect glow script.

Hello.

I've got an oGlow-ish script in my UI which colours item borders according to quality. I'm trying to get it to work on the inspect frame and it works fine, however, when switching targets while the inspect frame is open, it won't update. It does update though if you close the inspect frame, switch target, and then reopen it.

Here's the relevant stuff:

Code:
local function UpdateGlow(button, id)
	local quality, texture, _
	if(id) then
		quality, _, _, _, _, _, _, texture = select(3, GetItemInfo(id))
	end

	local glow = button.glow
	if(not glow) then
		glow = CreateFrame("Frame", nil, button)
		glow:SetBackdrop({ 
			bgFile = "", 
			edgeFile = FreeUI.backdrop, 
			edgeSize = 1, 
			insets = {left = 0, right = 0, top = 0, bottom = 0},
		})
		glow:SetPoint("TOPLEFT", button, "TOPLEFT", -1, 1)
		glow:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 1, -1)
		button.glow = glow
	end

	if(texture) then
		local r, g, b = GetItemQualityColor(quality)
		if(r==1) then r, g, b = 0, 0, 0 end
		glow:SetBackdropBorderColor(r, g, b)
		glow:Show()
	else
		glow:Hide()
	end
end
Code:
local updateinspect = function(self)
	local unit = InspectFrame.unit
	if InspectFrame:IsShown() then
		for key, slotName in ipairs(slots) do
			local slotID = key % 20
			local slotFrame = _G["Inspect"..slotName.."Slot"]
			local slotLink = GetInventoryItemLink(unit, slotID)
			UpdateGlow(slotFrame, slotLink)
		end
	end	
end
local g = CreateFrame("Frame")
g:RegisterEvent("ADDON_LOADED")
g:SetScript("OnEvent", function(self, event, addon)
	if addon == "Blizzard_InspectUI" then
		InspectFrame:HookScript("OnShow", updateinspect)
		g:RegisterEvent("PLAYER_TARGET_CHANGED", updateinspect)
		--[[g:RegisterEvent("INSPECT_READY", updateinspect)
		g:RegisterEvent("UNIT_INVENTORY_CHANGED", function(self, event, unit)
			if(InspectFrame.unit == unit) then
				updateinspect()
			end
		end)]]
	g:UnregisterEvent("ADDON_LOADED")
	end
end)
I tried a couple of different things. The commented out part doesn't really seem to change anything noticeable.

Does anyone have any suggestions? They'd be appreciated.
  Reply With Quote
11-30-10, 03:01 PM   #2
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Unless you've defined your own :RegisterEvent, this bit is wrong:

Code:
g:RegisterEvent("PLAYER_TARGET_CHANGED", updateinspect)
:RegisterEvent only accepts the name of the event as an argument.

http://wowprogramming.com/docs/widge.../RegisterEvent
__________________
Oh, the simulated horror!
  Reply With Quote
11-30-10, 03:26 PM   #3
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Oh, fail. I think I've been looking into other people's code too much.

I'll try again, I'll update when I can.

Right, that seemed to have done the trick, thank you. I've got this now:

Code:
local g = CreateFrame("Frame")
g:RegisterEvent("ADDON_LOADED")
g:SetScript("OnEvent", function(self, event, addon)
	if addon == "Blizzard_InspectUI" then
		InspectFrame:HookScript("OnShow", updateinspect)
		g:RegisterEvent("PLAYER_TARGET_CHANGED")
		g:UnregisterEvent("ADDON_LOADED")
		g:SetScript("OnEvent", function(self, event, ...)
			if event == "PLAYER_TARGET_CHANGED" then
				updateinspect()
			end
		end)
	end
end)

Last edited by Haleth : 11-30-10 at 03:33 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need some help with my inspect glow script.


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