Skip to content

Commit

Permalink
New tekPanelAuction
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkub committed Aug 31, 2012
1 parent 5c584d8 commit 0a35f72
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 63 deletions.
2 changes: 1 addition & 1 deletion Panda.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ local L = setmetatable(locale == "deDE" and {
-- Addon Namespace --
-------------------------------

local panel = LibStub("tekPanel-Auction").new("PandaPanel", "Panda", true)
local panel = ns.tekPanelAuction("PandaPanel", "Panda", true)
Panda = {panel = panel, locale = L}
local butts, lastbutt = {}

Expand Down
192 changes: 130 additions & 62 deletions tekPanelAuction.lua
Original file line number Diff line number Diff line change
@@ -1,81 +1,77 @@

--[[
tekPanelAuction v11
local lib, oldminor = LibStub:NewLibrary("tekPanel-Auction", 9)
if not lib then return end
oldminor = oldminor or 0
Creates a frame using the Auction House textures. Also generates a panel
inside this frame. Additional panels can be created. Panels can be
completely blank, like the Bids tab or split with a side frame like the
Browse tab. When using the split panel, sub-panels can be registered that
will create a menu item on the left that opens the subpanel in the space on
the right. Switching between main panels is not automatically provided,
you must create tabs or some other interface to do this.
Make sure you use ShowUIPanel(...) to show your frame, this ensure it is
positioned by the game's engine, and closes with the ESC key.
local function createtex(parent, layer, w, h, ...)
local tex = parent:CreateTexture(nil, layer)
tex:SetWidth(w) tex:SetHeight(h)
tex:SetPoint(...)
return tex
end
name - A string defining the name to assign the frame in the global.
namespace, use nil for no name. Passed to CreateFrame.
titletext - A string containing the text to display in the frame's titlebar.
Nil can be passed if no title is desired, but one is recommended
splitstyle - A boolean to trigger using split style in the default panel.
Examples
ns.tekPanelAuction("rawr", "Imma bear", true)
-- Creates a frame nameed rawr, with title "Imma bear", and a split panel.
function lib.new(name, titletext, splitstyle)
local frame = CreateFrame("Frame", name, UIParent)
frame:CreateTitleRegion()
frame:SetToplevel(true)
frame:SetFrameLevel(100) -- Force frame to a high level so it shows on top the first time it's displayed
frame:SetWidth(832) frame:SetHeight(447)
frame:SetPoint("TOPLEFT", 0, -104)
frame:EnableMouse() -- To avoid click-thru
ns.tekPanelAuction()
-- Create an anonymous frame, with no title and a blank panel.
frame:Hide()
Returns the frame and the automatically generated panel.
frame:SetAttribute("UIPanelLayout-defined", true)
frame:SetAttribute("UIPanelLayout-enabled", true)
frame:SetAttribute("UIPanelLayout-area", "doublewide")
frame:SetAttribute("UIPanelLayout-whileDead", true)
table.insert(UISpecialFrames, name)
local title = frame:GetTitleRegion()
title:SetWidth(757) title:SetHeight(20)
title:SetPoint("TOPLEFT", 75, -15)
Additional panels can be generated with the NewPanel method on the frame.
The panel is inserted into the frame's panel list, but you must provide
means of toggling its visibility.
local portrait = createtex(frame, "OVERLAY", 57, 57, "TOPLEFT", 9, -7)
SetPortraitTexture(portrait, "player")
frame:SetScript("OnEvent", function(self, event, unit) if unit == "player" then SetPortraitTexture(portrait, "player") end end)
frame:RegisterEvent("UNIT_PORTRAIT_UPDATE")
splitstyle - A boolean to trigger using split style.
local title = frame:CreateFontString(nil, "OVERLAY")
title:SetFontObject(GameFontNormal)
title:SetPoint("TOP", 0, -18)
title:SetText(titletext)
Example
local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", 3, -8)
close:SetScript("OnClick", function() HideUIPanel(frame) end)
local f = ns.tekPanelAuction(nil, "")
local panel = f:NewPanel(true)
frame.topleft = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", 0, 0)
frame.top = createtex(frame, "ARTWORK", 320, 256, "TOPLEFT", 256, 0)
frame.topright = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", frame.top, "TOPRIGHT")
frame.bottomleft = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", 0, -256)
frame.bottom = createtex(frame, "ARTWORK", 320, 256, "TOPLEFT", 256, -256)
frame.bottomright = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", frame.bottom, "TOPRIGHT")
Returns the newly generated panel.
frame.panels = {}
frame.NewPanel = lib.newpanel
local panel = frame:NewPanel(splitstyle)
if splitstyle then
function frame:RegisterFrame(...)
panel:RegisterFrame(...)
end
end
When using the split style, you can register new subpanels by calling the
panel's RegisterFrame method. You do not need to parent or anchor the frame
passed in, it will be automatically positioned in the right side of the
panel when it is displayed.
local voyeur = CreateFrame("Frame", nil, frame)
voyeur:SetScript("OnShow", function()
local vis
for i,panel in pairs(frame.panels) do vis = vis or panel:IsShown() end
if not vis then frame.panels[1]:Show() end
end)
name - A string containing the name to display in the list on the left.
frame - The frame to display for the subpanel.
return frame, panel
Example
local subpanel = CreateFrame("Frame", nil, UIParent)
local f = ns.tekPanelAuction(nil, "")
local panel = f:NewPanel(true)
panel:RegisterFrame("Help", subpanel)
Returns nothing.
]]

local myname, ns = ...


local function createtex(parent, layer, w, h, ...)
local tex = parent:CreateTexture(nil, layer)
tex:SetWidth(w) tex:SetHeight(h)
tex:SetPoint(...)
return tex
end

function lib.newpanel(base, splitstyle)
local function newpanel(base, splitstyle)
local frame = CreateFrame("Frame", nil, base)
frame:SetAllPoints()
frame:Hide()
Expand Down Expand Up @@ -193,15 +189,87 @@ function lib.newpanel(base, splitstyle)
end)
else
frame:SetScript("OnShow", function(self)
-- AuctionFrameTopLeft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-TopLeft");
-- AuctionFrameTop:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Auction-Top");
-- AuctionFrameTopRight:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Auction-TopRight");
-- AuctionFrameBotLeft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-BotLeft");
-- AuctionFrameBot:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Auction-Bot");
-- AuctionFrameBotRight:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-BotRight");

self.base.topleft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-TopLeft")
self.base.top:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-Top")
self.base.topright:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-TopRight")
self.base.top:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Auction-Top")
self.base.topright:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Auction-TopRight")
self.base.bottomleft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-BotLeft")
self.base.bottom:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-Bot")
self.base.bottom:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Auction-Bot")
self.base.bottomright:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-BotRight")
end)
end

return frame
end


function ns.tekPanelAuction(name, titletext, splitstyle)
local frame = CreateFrame("Frame", name, UIParent)
-- frame:CreateTitleRegion()
frame:SetToplevel(true)
frame:SetFrameLevel(100) -- Force frame to a high level so it shows on top the first time it's displayed
frame:SetWidth(832) frame:SetHeight(447)
frame:SetPoint("TOPLEFT", 0, -104)
frame:EnableMouse() -- To avoid click-thru
-- frame:SetMovable(false)

frame:Hide()

frame:SetAttribute("UIPanelLayout-defined", true)
frame:SetAttribute("UIPanelLayout-enabled", true)
frame:SetAttribute("UIPanelLayout-area", "doublewide")
frame:SetAttribute("UIPanelLayout-whileDead", true)
table.insert(UISpecialFrames, name)

-- local title = frame:GetTitleRegion()
-- title:SetWidth(757) title:SetHeight(20)
-- title:SetPoint("TOPLEFT", 75, -15)

local portrait = createtex(frame, "OVERLAY", 57, 57, "TOPLEFT", 9, -7)
SetPortraitTexture(portrait, "player")
frame:SetScript("OnEvent", function(self, event, unit) if unit == "player" then SetPortraitTexture(portrait, "player") end end)
frame:RegisterEvent("UNIT_PORTRAIT_UPDATE")

local title = frame:CreateFontString(nil, "OVERLAY")
title:SetFontObject(GameFontNormal)
title:SetPoint("TOP", 0, -18)
title:SetText(titletext)

local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", 3, -8)
close:SetScript("OnClick", function() HideUIPanel(frame) end)

frame.topleft = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", 0, 0)
frame.top = createtex(frame, "ARTWORK", 320, 256, "TOPLEFT", 256, 0)
frame.topright = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", frame.top, "TOPRIGHT")
frame.bottomleft = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", 0, -256)
frame.bottom = createtex(frame, "ARTWORK", 320, 256, "TOPLEFT", 256, -256)
frame.bottomright = createtex(frame, "ARTWORK", 256, 256, "TOPLEFT", frame.bottom, "TOPRIGHT")

frame.panels = {}
frame.NewPanel = newpanel

local panel = frame:NewPanel(splitstyle)
if splitstyle then
function frame:RegisterFrame(...)
panel:RegisterFrame(...)
end
end

local voyeur = CreateFrame("Frame", nil, frame)
voyeur:SetScript("OnShow", function()
local vis
for i,panel in pairs(frame.panels) do vis = vis or panel:IsShown() end
if not vis then frame.panels[1]:Show() end
end)

return frame, panel
end


0 comments on commit 0a35f72

Please sign in to comment.