skin: add dualpane tradeskill and craft window

This commit is contained in:
shagu
2019-03-31 14:59:21 +02:00
parent 1d071108a5
commit 4781f0910a
+193 -146
View File
@@ -2,169 +2,216 @@ pfUI:RegisterSkin("Profession", function ()
local border = tonumber(pfUI_config.appearance.border.default)
local bpad = border > 1 and border - 1 or 1
HookAddonOrVariable("Blizzard_TradeSkillUI", function()
StripTextures(TradeSkillFrame)
CreateBackdrop(TradeSkillFrame, nil, nil, .75)
TradeSkillFrame.backdrop:SetPoint("TOPLEFT", 10, -10)
TradeSkillFrame.backdrop:SetPoint("BOTTOMRIGHT", -32, 72)
TradeSkillFrame:SetHitRectInsets(10,32,10,72)
EnableMovable(TradeSkillFrame)
local frames = {
["TradeSkill"] = { "Blizzard_TradeSkillUI", "TRADE_SKILLS_DISPLAYED", "TradeSkillSkill", "MAX_TRADE_SKILL_REAGENTS" },
["Craft"] = { "Blizzard_CraftUI", "CRAFTS_DISPLAYED", "Craft", "MAX_CRAFT_REAGENTS" },
}
SkinCloseButton(TradeSkillFrameCloseButton, TradeSkillFrame.backdrop, -6, -6)
for name, ext in pairs(frames) do
local name = name
local ext = ext
local addon = ext[1]
local displayed = ext[2]
local template = ext[3]
local maxreagents = ext[4]
local frame = name .. "Frame"
TradeSkillFrame:DisableDrawLayer("BACKGROUND")
HookAddonOrVariable(addon, function()
_G[displayed] = 23
_G.UIPanelWindows[frame] = {area = "doublewide", pushable = 0, whileDead = 1}
TradeSkillFrameTitleText:ClearAllPoints()
TradeSkillFrameTitleText:SetPoint("TOP", TradeSkillFrame.backdrop, "TOP", 0, -10)
local SetSelection = frame.."_SetSelection"
local icon = _G[template.."Icon"]
local seltitle = _G[template.."Name"]
local reagentlabel = _G[name.."ReagentLabel"]
local collapseall = _G[name.."CollapseAllButton"]
local detailscroll = _G[name.."DetailScrollFrame"]
local detailscrollchild = _G[name.."DetailScrollChildFrame"]
local detailscrollbar = _G[name.."DetailScrollFrameScrollBar"]
local rankbar = _G[name.."RankFrame"]
local decrease = _G[name.."DecrementButton"]
local increase = _G[name.."IncrementButton"]
local inputbox = _G[name.."InputBox"]
local cancel = _G[name.."CancelButton"]
local create = _G[name.."CreateButton"]
local createall = _G[name.."CreateAllButton"]
local subclassdropdown = _G[name.."SubClassDropDown"]
local invslotdropdown = _G[name.."InvSlotDropDown"]
local scrollbar = _G[name.."ListScrollFrameScrollBar"]
local scrollframe = _G[name.."ListScrollFrame"]
local close = _G[frame.."CloseButton"]
local title = _G[frame.."TitleText"]
local frame = _G[frame]
StripTextures(TradeSkillRankFrameBorder)
CreateBackdrop(TradeSkillRankFrame, nil, true)
TradeSkillRankFrame:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar")
TradeSkillRankFrame:ClearAllPoints()
TradeSkillRankFrame:SetPoint("TOP", TradeSkillFrame.backdrop, "TOP", 0, -32)
StripTextures(TradeSkillInvSlotDropDown)
SkinDropDown(TradeSkillInvSlotDropDown)
StripTextures(TradeSkillSubClassDropDown)
SkinDropDown(TradeSkillSubClassDropDown)
TradeSkillSubClassDropDown:ClearAllPoints()
TradeSkillSubClassDropDown:SetPoint("RIGHT", TradeSkillInvSlotDropDown, "LEFT", 27, 0)
StripTextures(TradeSkillDetailScrollFrame)
StripTextures(TradeSkillDetailScrollChildFrame)
SkinScrollbar(TradeSkillDetailScrollFrameScrollBar)
StripTextures(TradeSkillListScrollFrame)
SkinScrollbar(TradeSkillListScrollFrameScrollBar)
SkinArrowButton(TradeSkillDecrementButton, "left", 18)
SkinArrowButton(TradeSkillIncrementButton, "right", 18)
TradeSkillInputBox:DisableDrawLayer("BACKGROUND")
CreateBackdrop(TradeSkillInputBox, nil, true)
TradeSkillInputBox:SetWidth(36)
SkinButton(TradeSkillCreateAllButton)
SkinButton(TradeSkillCancelButton)
SkinButton(TradeSkillCreateButton)
TradeSkillCreateButton:ClearAllPoints()
TradeSkillCreateButton:SetPoint("RIGHT", TradeSkillCancelButton, "LEFT", -2*bpad, 0)
StripTextures(TradeSkillExpandButtonFrame)
StripTextures(TradeSkillCollapseAllButton)
SkinCollapseButton(TradeSkillCollapseAllButton, true)
for i = 1, TRADE_SKILLS_DISPLAYED do
SkinCollapseButton(_G["TradeSkillSkill"..i])
end
for i = 1, MAX_TRADE_SKILL_REAGENTS do
local button = _G["TradeSkillReagent"..i]
StripTextures(button)
SkinButton(button, nil, nil, nil, nil, true)
local itemButton = CreateFrame("Button", button:GetName().."ItemButton", button)
itemButton:SetWidth(37)
itemButton:SetHeight(37)
itemButton:SetPoint("LEFT", 2, 0)
itemButton.icon = itemButton:CreateTexture("ARTWORK")
SkinButton(itemButton, nil, nil, nil, itemButton.icon, true)
itemButton.text = itemButton:CreateFontString("Status", "LOW", "GameFontNormal")
itemButton.text:SetFontObject(GameFontWhite)
itemButton.text:SetPoint("BOTTOMRIGHT", -4, 1)
itemButton.text:SetFont(pfUI.font_default, C.global.font_size, "OUTLINE")
end
StripTextures(TradeSkillSkillIcon)
SkinButton(TradeSkillSkillIcon, nil, nil, nil, nil, true)
hooksecurefunc("TradeSkillFrame_SetSelection", function()
HandleIcon(TradeSkillSkillIcon, TradeSkillSkillIcon:GetNormalTexture())
for i = 1, MAX_TRADE_SKILL_REAGENTS do
local button = _G["TradeSkillReagent"..i]
if button:IsShown() then
local count = _G[button:GetName().."Count"]:GetText()
local texture = _G[button:GetName().."IconTexture"]:GetTexture()
local itemButton = _G[button:GetName().."ItemButton"]
itemButton.icon:SetTexture(texture)
itemButton.text:SetText(count)
end
-- build remaining tradeskills
for i = 9, _G[displayed] do
local button = CreateFrame("Button", template..i, frame, template.."ButtonTemplate")
button:SetPoint("TOPLEFT", _G[template..i - 1], "BOTTOMLEFT")
end
end, 1)
end)
HookAddonOrVariable("Blizzard_CraftUI", function()
StripTextures(CraftFrame)
CreateBackdrop(CraftFrame, nil, nil, .75)
CraftFrame.backdrop:SetPoint("TOPLEFT", 10, -10)
CraftFrame.backdrop:SetPoint("BOTTOMRIGHT", -32, 72)
CraftFrame:SetHitRectInsets(10,32,10,72)
EnableMovable(CraftFrame)
StripTextures(frame)
CreateBackdrop(frame, nil, nil, .75)
SkinCloseButton(CraftFrameCloseButton, CraftFrame.backdrop, -6, -6)
frame:SetWidth(676)
frame:SetHeight(440)
frame:DisableDrawLayer("BACKGROUND")
EnableMovable(frame)
CraftFrame:DisableDrawLayer("BACKGROUND")
title:ClearAllPoints()
title:SetPoint("TOP", 0, -10)
title:SetTextColor(1,1,1,1)
SkinCloseButton(close, frame, -6, -6)
CraftFrameTitleText:ClearAllPoints()
CraftFrameTitleText:SetPoint("TOP", CraftFrame.backdrop, "TOP", 0, -10)
do -- left pane
StripTextures(scrollframe)
SkinScrollbar(scrollbar)
StripTextures(CraftRankFrameBorder)
CreateBackdrop(CraftRankFrame, nil, true)
CraftRankFrame:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar")
CraftRankFrame:ClearAllPoints()
CraftRankFrame:SetPoint("TOP", CraftFrame.backdrop, "TOP", 0, -32)
scrollframe:ClearAllPoints()
scrollframe:SetPoint("TOPLEFT", 10, -65)
scrollframe:SetWidth(300)
scrollframe:SetHeight(365)
StripTextures(CraftDetailScrollFrame)
StripTextures(CraftDetailScrollChildFrame)
SkinScrollbar(CraftDetailScrollFrameScrollBar)
local backdrop = CreateFrame("Frame", nil, frame)
CreateBackdrop(backdrop, nil, nil, .75)
backdrop.backdrop:SetPoint("TOPLEFT", scrollframe, "TOPLEFT", -5, 5)
backdrop.backdrop:SetPoint("BOTTOMRIGHT", scrollframe, "BOTTOMRIGHT", 26, -5)
StripTextures(CraftListScrollFrame)
SkinScrollbar(CraftListScrollFrameScrollBar)
SkinButton(CraftCancelButton)
SkinButton(CraftCreateButton)
CraftCreateButton:ClearAllPoints()
CraftCreateButton:SetPoint("RIGHT", CraftCancelButton, "LEFT", -2*bpad, 0)
_G[template..1]:ClearAllPoints()
_G[template..1]:SetPoint("TOPLEFT", scrollframe, "TOPLEFT", 0, 0)
for i = 1, MAX_CRAFT_REAGENTS do
local button = _G["CraftReagent"..i]
StripTextures(button)
SkinButton(button, nil, nil, nil, nil, true)
StripTextures(collapseall)
SkinCollapseButton(collapseall, true)
collapseall:ClearAllPoints()
collapseall:SetPoint("BOTTOMLEFT", scrollframe, "TOPLEFT", -5, 5)
for i = 1, _G[displayed] do SkinCollapseButton(_G[template..i]) end
local itemButton = CreateFrame("Button", button:GetName().."ItemButton", button)
itemButton:SetWidth(37)
itemButton:SetHeight(37)
itemButton:SetPoint("LEFT", 2, 0)
itemButton.icon = itemButton:CreateTexture("ARTWORK")
SkinButton(itemButton, nil, nil, nil, itemButton.icon, true)
itemButton.text = itemButton:CreateFontString("Status", "LOW", "GameFontNormal")
itemButton.text:SetFontObject(GameFontWhite)
itemButton.text:SetPoint("BOTTOMRIGHT", -4, 1)
itemButton.text:SetFont(pfUI.font_default, C.global.font_size, "OUTLINE")
end
if invslotdropdown then
StripTextures(invslotdropdown)
SkinDropDown(invslotdropdown)
invslotdropdown:SetHeight(10)
invslotdropdown:ClearAllPoints()
invslotdropdown:SetPoint("BOTTOMRIGHT", backdrop.backdrop, "TOPRIGHT", 15, 0)
StripTextures(CraftIcon)
SkinButton(CraftIcon, nil, nil, nil, nil, true)
hooksecurefunc("CraftFrame_SetSelection", function(id)
HandleIcon(CraftIcon, CraftIcon:GetNormalTexture())
for i = 1, MAX_CRAFT_REAGENTS do
local button = _G["CraftReagent"..i]
if button:IsShown() then
local count = _G[button:GetName().."Count"]:GetText()
local texture = _G[button:GetName().."IconTexture"]:GetTexture()
local itemButton = _G[button:GetName().."ItemButton"]
itemButton.icon:SetTexture(texture)
itemButton.text:SetText(count)
StripTextures(subclassdropdown)
SkinDropDown(subclassdropdown)
subclassdropdown:ClearAllPoints()
subclassdropdown:SetPoint("RIGHT", invslotdropdown, "LEFT", 27, 0)
end
end
-- fix Blizzard bug
if GetCraftNumReagents(id) < 3 and CraftDetailScrollFrameScrollBar:IsShown() then
CraftDetailScrollFrameScrollBar:Hide()
do -- right pane
StripTextures(detailscroll)
StripTextures(detailscrollchild)
SkinScrollbar(detailscrollbar)
local backdrop = CreateFrame("Frame", nil, frame)
CreateBackdrop(backdrop, nil, nil, .75)
backdrop.backdrop:SetPoint("TOPLEFT", detailscroll, "TOPLEFT", -5, 5)
backdrop.backdrop:SetPoint("BOTTOMRIGHT", detailscroll, "BOTTOMRIGHT", 26, -5)
StripTextures(_G[name.."RankFrameBorder"])
CreateBackdrop(rankbar, nil, true)
rankbar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar")
rankbar:ClearAllPoints()
rankbar:SetPoint("TOPLEFT", backdrop.backdrop, "TOPLEFT", 0, 25)
rankbar:SetPoint("BOTTOMRIGHT", backdrop.backdrop, "TOPRIGHT", 0, 6)
if decrease and increase then
SkinArrowButton(decrease, "left", 18)
SkinArrowButton(increase, "right", 18)
end
if inputbox then
inputbox:DisableDrawLayer("BACKGROUND")
CreateBackdrop(inputbox, nil, true)
inputbox:SetWidth(36)
end
SkinButton(cancel)
cancel:ClearAllPoints()
cancel:SetPoint("TOPRIGHT", backdrop.backdrop, "BOTTOMRIGHT", 0, -5)
SkinButton(create)
create:ClearAllPoints()
create:SetPoint("RIGHT", cancel, "LEFT", -2*bpad, 0)
SkinButton(createall)
StripTextures(_G[name.."ExpandButtonFrame"])
detailscroll:ClearAllPoints()
detailscroll:SetPoint("TOPLEFT", 346, -65)
detailscroll:SetWidth(299)
detailscroll:SetHeight(338)
-- skin buttons
for i = 1, _G[maxreagents] do
local name = name.."Reagent" .. i
local item = _G[name]
local icon = _G[name.."IconTexture"]
local count = _G[name.."Count"]
local title = _G[name.."Name"]
local size = item:GetHeight() - 10
StripTextures(item)
CreateBackdrop(item, nil, nil, .75)
SetAllPointsOffset(item.backdrop, item, 4)
SetHighlight(item)
icon:SetWidth(size)
icon:SetHeight(size)
icon:ClearAllPoints()
icon:SetPoint("LEFT", 5, 0)
icon:SetTexCoord(.08, .92, .08, .92)
icon:SetParent(item.backdrop)
icon:SetDrawLayer("OVERLAY")
count:SetParent(item.backdrop)
count:SetDrawLayer("OVERLAY")
count:ClearAllPoints()
count:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", 0, 0)
title:SetParent(item.backdrop)
title:SetDrawLayer("OVERLAY")
end
StripTextures(icon)
icon:ClearAllPoints()
icon:SetPoint("TOPLEFT", 5, -5)
SkinButton(icon, nil, nil, nil, nil, true)
seltitle:SetJustifyV("TOP")
seltitle:SetTextColor(.8,.8,.8,1)
reagentlabel:ClearAllPoints()
reagentlabel:SetTextColor(1,1,1,1)
reagentlabel:SetPoint("TOPLEFT", seltitle, "BOTTOMLEFT", -45, -15)
local scanner = libtipscan:GetScanner(name)
hooksecurefunc(SetSelection, function(id)
if id and id ~= 0 then
detailscroll:Show()
HandleIcon(icon, icon:GetNormalTexture())
if name == "TradeSkill" then
local itemlink = GetTradeSkillItemLink(id)
if not itemlink then return end
local _, _, link = string.find(itemlink, "(item:%d+:%d+:%d+:%d+)")
if link then
scanner:SetHyperlink(link)
seltitle:SetHeight(0)
seltitle:SetText(scanner:FontString())
if seltitle:GetHeight() < 30 then
seltitle:SetHeight(35)
end
else
detailscroll:Hide()
end
end
end
end, true)
end
end, 1)
end)
end)
end
end)