Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

127 lines (98 sloc) 4.161 kB
local HideTooltip, ShowTooltip, GS, G = Panda.HideTooltip, Panda.ShowTooltip, Panda.GS, Panda.G
local auc = LibStub("tekAucQuery")
local UNK = "Interface\\Icons\\INV_Misc_QuestionMark"
local server = GetRealmName().." "..UnitFactionGroup("player")
local function OnEvent(self)
if not self.id then return end
local count = GetItemCount(self.id)
self.count:SetText(count > 0 and count or "")
if self.text then self.text:SetText(GS(auc[self.id])) end
if ForSaleByOwnerDB then
local count, name = 0, GetItemInfo(self.id)
for char,vals in pairs(ForSaleByOwnerDB[server]) do count = count + (vals[name] or 0) end
self.ahcount:SetText(count ~= 0 and count or "")
end
end
local function OnHide(self) self:UnregisterEvent("BAG_UPDATE") end
local function OnShow(self)
self:RegisterEvent("BAG_UPDATE")
OnEvent(self)
end
function Panda.CraftMacro(name, id)
return "/run if IsShiftKeyDown() then ChatEdit_InsertLink('"..select(2, GetItemInfo(id)).."') end\n"..
"/stopmacro [mod:shift]\n"..
"/run CloseTradeSkill()\n/cast "..name.."\n"..
"/run for i=1,GetNumTradeSkills() do local l = GetTradeSkillItemLink(i) if l and l:match('item:"..id..":') then TradeSkillFrame_SetSelection(i); DoTradeSkill(i, IsAltKeyDown() and select(3, GetTradeSkillInfo(i)) or 1) end end\n"..
"/run if not IsAltKeyDown() then CloseTradeSkill() end"
end
function Panda.ButtonFactory(parent, id, secure, notext, ...)
local f = CreateFrame(secure and "CheckButton" or "Frame", id == 6948 and "MassMill" or nil, parent, secure and "SecureActionButtonTemplate")
local name, link, _, _, _, _, _, _, _, texture = GetItemInfo(id)
f.link, f.id, f.name = link, id, name or ""
f:SetHeight(32)
f:SetWidth(32)
if not secure then f:EnableMouse() end
if select("#", ...) > 0 then f:SetPoint(...) end
f:SetScript("OnEnter", ShowTooltip)
f:SetScript("OnLeave", HideTooltip)
f:SetScript("OnShow", OnShow)
f:SetScript("OnHide", OnHide)
f:SetScript("OnEvent", OnEvent)
local icon = f:CreateTexture(nil, "ARTWORK")
icon:SetAllPoints(f)
icon:SetTexture(texture or UNK)
f.icon = icon
if not notext then
f.text = f:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
f.text:SetPoint("TOP", icon, "BOTTOM")
end
local count = f:CreateFontString(nil, "ARTWORK", "NumberFontNormalSmall")
count:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", -2, 2)
f.count = count
f.ahcount = f:CreateFontString(nil, "ARTWORK", "NumberFontNormalSmall")
f.ahcount:SetPoint("TOPRIGHT", icon, "TOPRIGHT", -2, -2)
-- Thanks to oglow for this method
local border = f:CreateTexture(nil, "OVERLAY")
border:SetTexture("Interface\\Buttons\\UI-ActionButton-Border")
border:SetBlendMode("ADD")
border:SetAlpha(.5)
border:Hide()
border:SetPoint('CENTER', f, 'CENTER', 0, 1)
border:SetWidth(f:GetWidth() * 2 - 5)
border:SetHeight(f:GetHeight() * 2 - 5)
f.border = border
if secure and name then
if type(secure) == "function" then
secure(f)
else
f:SetAttribute("type", "macro")
f:SetAttribute("macrotext", Panda.CraftMacro(secure, id))
end
end
if f:IsVisible() then OnShow(f) end
return f
end
function Panda.RefreshButtonFactory(parent, tradeskill, ...)
local b = CreateFrame("Button", nil, parent, "SecureActionButtonTemplate")
b:SetPoint(...)
b:SetWidth(80) b:SetHeight(22)
-- Fonts --
b:SetDisabledFontObject(GameFontDisable)
b:SetHighlightFontObject(GameFontHighlight)
b:SetNormalFontObject(GameFontNormal)
-- Textures --
b:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up")
b:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down")
b:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight")
b:SetDisabledTexture("Interface\\Buttons\\UI-Panel-Button-Disabled")
b:GetNormalTexture():SetTexCoord(0, 0.625, 0, 0.6875)
b:GetPushedTexture():SetTexCoord(0, 0.625, 0, 0.6875)
b:GetHighlightTexture():SetTexCoord(0, 0.625, 0, 0.6875)
b:GetDisabledTexture():SetTexCoord(0, 0.625, 0, 0.6875)
b:GetHighlightTexture():SetBlendMode("ADD")
b:SetText("Refresh")
b:SetAttribute("type", "macro")
b:SetAttribute("macrotext", "/run CloseTradeSkill()\n/cast "..tradeskill.."\n/run CloseTradeSkill()")
return b
end
Jump to Line
Something went wrong with that request. Please try again.