local p,K="\073\099\111\110",21 local a=LibStub and LibStub("\065\099\101\071\085\073-\051\046\048",true)if not a or(a:GetWidgetVersion(p)or 0)>=K then return end local w,R,H=select,pairs,print local C,c=CreateFrame,UIParent local function f(p)p.obj:Fire("\079\110\069\110\116\101\114")end local function U(p)p.obj:Fire("\079\110\076\101\097\118\101")end local function W(p,K)p.obj:Fire("\079\110\067\108\105\099\107",K)a:ClearFocus()end local G={OnAcquire=function(p)p:SetHeight(110)p:SetWidth(110)p:SetLabel()p:SetImage(nil)p:SetImageSize(64,64)p:SetDisabled(false)end,SetLabel=function(p,K)if K and K~=""then p.label:Show()p.label:SetText(K)p:SetHeight(p.image:GetHeight()+25)else p.label:Hide()p:SetHeight(p.image:GetHeight()+10)end end,SetImage=function(p,K,...)local a=p.image a:SetTexture(K)if a:GetTexture()then local p=w("\035",...)if p==4 or p==8 then a:SetTexCoord(...)else a:SetTexCoord(0,1,0,1)end end end,SetImageSize=function(p,K,a)p.image:SetWidth(K)p.image:SetHeight(a)if p.label:IsShown()then p:SetHeight(a+25)else p:SetHeight(a+10)end end,SetDisabled=function(p,K)p.disabled=K if K then p.frame:Disable()p.label:SetTextColor(.5,.5,.5)p.image:SetVertexColor(.5,.5,.5,.5)else p.frame:Enable()p.label:SetTextColor(1,1,1)p.image:SetVertexColor(1,1,1,1)end end}local function M()local K=C("\066\117\116\116\111\110",nil,c)K:Hide()K:EnableMouse(true)K:SetScript("\079\110\069\110\116\101\114",f)K:SetScript("\079\110\076\101\097\118\101",U)K:SetScript("\079\110\067\108\105\099\107",W)local w=K:CreateFontString(nil,"\066\065\067\075\071\082\079\085\078\068","\071\097\109\101\070\111\110\116\072\105\103\104\108\105\103\104\116")w:SetPoint("\066\079\084\084\079\077\076\069\070\084")w:SetPoint("\066\079\084\084\079\077\082\073\071\072\084")w:SetJustifyH("\067\069\078\084\069\082")w:SetJustifyV("\084\079\080")w:SetHeight(18)local M=K:CreateTexture(nil,"\066\065\067\075\071\082\079\085\078\068")M:SetWidth(64)M:SetHeight(64)M:SetPoint("\084\079\080",0,-5)local b=K:CreateTexture(nil,"\072\073\071\072\076\073\071\072\084")b:SetAllPoints(M)b:SetTexture(136580)b:SetTexCoord(0,1,.23,.77)b:SetBlendMode("\065\068\068")local k={label=w;image=M;frame=K;type=p}for p,K in R(G)do k[p]=K end k.SetText=function(p,...)H("\065\099\101\071\085\073-\051\046\048-\073\099\111\110\058 \083\101\116\084\101\120\116 \105\115 \100\101\112\114\101\099\097\116\101\100\033 \085\115\101 \083\101\116\076\097\098\101\108 \105\110\115\116\101\097\100\033")p:SetLabel(...)end return a:RegisterAsWidget(k)end a:RegisterWidgetType(p,M,K)
--[[-----------------------------------------------------------------------------
Icon Widget
-------------------------------------------------------------------------------]]
local Type, Version = "Icon", 21
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end

-- Lua APIs
local select, pairs, print = select, pairs, print

-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent

--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter(frame)
	frame.obj:Fire("OnEnter")
end

local function Control_OnLeave(frame)
	frame.obj:Fire("OnLeave")
end

local function Button_OnClick(frame, button)
	frame.obj:Fire("OnClick", button)
	AceGUI:ClearFocus()
end

--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
	["OnAcquire"] = function(self)
		self:SetHeight(110)
		self:SetWidth(110)
		self:SetLabel()
		self:SetImage(nil)
		self:SetImageSize(64, 64)
		self:SetDisabled(false)
	end,

	-- ["OnRelease"] = nil,

	["SetLabel"] = function(self, text)
		if text and text ~= "" then
			self.label:Show()
			self.label:SetText(text)
			self:SetHeight(self.image:GetHeight() + 25)
		else
			self.label:Hide()
			self:SetHeight(self.image:GetHeight() + 10)
		end
	end,

	["SetImage"] = function(self, path, ...)
		local image = self.image
		image:SetTexture(path)

		if image:GetTexture() then
			local n = select("#", ...)
			if n == 4 or n == 8 then
				image:SetTexCoord(...)
			else
				image:SetTexCoord(0, 1, 0, 1)
			end
		end
	end,

	["SetImageSize"] = function(self, width, height)
		self.image:SetWidth(width)
		self.image:SetHeight(height)
		--self.frame:SetWidth(width + 30)
		if self.label:IsShown() then
			self:SetHeight(height + 25)
		else
			self:SetHeight(height + 10)
		end
	end,

	["SetDisabled"] = function(self, disabled)
		self.disabled = disabled
		if disabled then
			self.frame:Disable()
			self.label:SetTextColor(0.5, 0.5, 0.5)
			self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
		else
			self.frame:Enable()
			self.label:SetTextColor(1, 1, 1)
			self.image:SetVertexColor(1, 1, 1, 1)
		end
	end
}

--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
	local frame = CreateFrame("Button", nil, UIParent)
	frame:Hide()

	frame:EnableMouse(true)
	frame:SetScript("OnEnter", Control_OnEnter)
	frame:SetScript("OnLeave", Control_OnLeave)
	frame:SetScript("OnClick", Button_OnClick)

	local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight")
	label:SetPoint("BOTTOMLEFT")
	label:SetPoint("BOTTOMRIGHT")
	label:SetJustifyH("CENTER")
	label:SetJustifyV("TOP")
	label:SetHeight(18)

	local image = frame:CreateTexture(nil, "BACKGROUND")
	image:SetWidth(64)
	image:SetHeight(64)
	image:SetPoint("TOP", 0, -5)

	local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
	highlight:SetAllPoints(image)
	highlight:SetTexture(136580) -- Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight
	highlight:SetTexCoord(0, 1, 0.23, 0.77)
	highlight:SetBlendMode("ADD")

	local widget = {
		label = label,
		image = image,
		frame = frame,
		type  = Type
	}
	for method, func in pairs(methods) do
		widget[method] = func
	end

	widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end

	return AceGUI:RegisterAsWidget(widget)
end

AceGUI:RegisterWidgetType(Type, Constructor, Version)
