修改优化等

This commit is contained in:
rucky
2026-03-18 02:01:36 +08:00
parent 2a55dd6dad
commit 923a1f9ce2
15 changed files with 1578 additions and 371 deletions

View File

@@ -3109,73 +3109,136 @@ function CP:BuildSkillsPage()
page.skillRows = {}
end
function CP:UpdateSkills()
local page = pages[3]
if not page or not page.built then return end
local child = page.scrollArea.child
if page.skillRows then
for _, row in ipairs(page.skillRows) do if row.frame then row.frame:Hide() end end
end
page.skillRows = {}
do
local TRADE_HEADERS = { ["Trade Skills"] = true, ["专业技能"] = true, ["Professions"] = true,
["商业技能"] = true, ["专业"] = true }
local pendingAbandonIndex
local numSkills = GetNumSkillLines and GetNumSkillLines() or 0
local y = -6
local rowH, barH, headerH = 28, 7, 24
for i = 1, numSkills do
local sn, isH, isE, sr, nt, sm, smr
if GetSkillLineInfo then sn, isH, isE, sr, nt, sm, smr = GetSkillLineInfo(i) end
if not sn then break end
if isH then
local hf = CreateFrame("Button", nil, child)
hf:SetWidth(SCROLL_W - 16)
hf:SetHeight(headerH)
hf:SetPoint("TOPLEFT", child, "TOPLEFT", 8, y)
local arrow = MakeFS(hf, 10, "LEFT", T.dimText)
arrow:SetPoint("LEFT", hf, "LEFT", 0, 0)
arrow:SetText(isE and "-" or "+")
local ht = MakeFS(hf, 11, "LEFT", T.sectionTitle)
ht:SetPoint("LEFT", arrow, "RIGHT", 3, 0)
ht:SetText(sn)
hf.skillIndex = i
hf:SetScript("OnClick", function()
if isE then CollapseSkillHeader(this.skillIndex) else ExpandSkillHeader(this.skillIndex) end
StaticPopupDialogs = StaticPopupDialogs or {}
StaticPopupDialogs["NANAMI_ABANDON_SKILL"] = {
text = "确定要遗弃 %s 吗?\n该操作不可撤销!",
button1 = "确定",
button2 = "取消",
OnAccept = function()
if pendingAbandonIndex and AbandonSkill then
AbandonSkill(pendingAbandonIndex)
pendingAbandonIndex = nil
CP:UpdateSkills()
end)
table.insert(page.skillRows, { frame = hf })
y = y - headerH
else
local sf = CreateFrame("Frame", nil, child)
sf:SetWidth(SCROLL_W - 24)
sf:SetHeight(rowH)
sf:SetPoint("TOPLEFT", child, "TOPLEFT", 18, y)
local nfs = MakeFS(sf, 9, "LEFT", T.valueText)
nfs:SetPoint("TOPLEFT", sf, "TOPLEFT", 0, -2)
nfs:SetText(sn or "")
local rt = tostring(sr or 0)
if smr and smr > 0 then rt = rt .. "/" .. tostring(smr) end
local rfs = MakeFS(sf, 8, "RIGHT", T.dimText)
rfs:SetPoint("TOPRIGHT", sf, "TOPRIGHT", 0, -2)
rfs:SetText(rt)
if smr and smr > 0 then
local bf = CreateFrame("Frame", nil, sf)
bf:SetHeight(barH)
bf:SetPoint("BOTTOMLEFT", sf, "BOTTOMLEFT", 0, 2)
bf:SetPoint("BOTTOMRIGHT", sf, "BOTTOMRIGHT", 0, 2)
SetPixelBackdrop(bf, T.barBg, { 0.15, 0.15, 0.18, 0.5 })
local bar = bf:CreateTexture(nil, "ARTWORK")
bar:SetTexture(SFrames:GetTexture())
bar:SetVertexColor(0.4, 0.65, 0.85, 0.85)
bar:SetPoint("TOPLEFT", bf, "TOPLEFT", 1, -1)
bar:SetPoint("BOTTOMLEFT", bf, "BOTTOMLEFT", 1, 1)
bar:SetWidth(math.max((SCROLL_W - 26) * Clamp((sr or 0) / smr, 0, 1), 1))
end
table.insert(page.skillRows, { frame = sf })
y = y - rowH
end,
OnCancel = function() pendingAbandonIndex = nil end,
timeout = 0, whileDead = true, hideOnEscape = true,
}
function CP:UpdateSkills()
local page = pages[3]
if not page or not page.built then return end
local child = page.scrollArea.child
if page.skillRows then
for _, row in ipairs(page.skillRows) do if row.frame then row.frame:Hide() end end
end
page.skillRows = {}
local numSkills = GetNumSkillLines and GetNumSkillLines() or 0
local y = -6
local rowH, barH, headerH = 28, 7, 24
local currentHeader = ""
local delBtnSize = 14
for i = 1, numSkills do
local sn, isH, isE, sr, nt, sm, smr, isAbandonable
if GetSkillLineInfo then sn, isH, isE, sr, nt, sm, smr, isAbandonable = GetSkillLineInfo(i) end
if not sn then break end
if isH then
currentHeader = sn or ""
local hf = CreateFrame("Button", nil, child)
hf:SetWidth(SCROLL_W - 16)
hf:SetHeight(headerH)
hf:SetPoint("TOPLEFT", child, "TOPLEFT", 8, y)
local arrow = MakeFS(hf, 10, "LEFT", T.dimText)
arrow:SetPoint("LEFT", hf, "LEFT", 0, 0)
arrow:SetText(isE and "-" or "+")
local ht = MakeFS(hf, 11, "LEFT", T.sectionTitle)
ht:SetPoint("LEFT", arrow, "RIGHT", 3, 0)
ht:SetText(sn)
hf.skillIndex = i
hf:SetScript("OnClick", function()
if isE then CollapseSkillHeader(this.skillIndex) else ExpandSkillHeader(this.skillIndex) end
CP:UpdateSkills()
end)
table.insert(page.skillRows, { frame = hf })
y = y - headerH
else
local canAbandon = TRADE_HEADERS[currentHeader]
local rightPad = canAbandon and (delBtnSize + 6) or 0
local sf = CreateFrame("Frame", nil, child)
sf:SetWidth(SCROLL_W - 24)
sf:SetHeight(rowH)
sf:SetPoint("TOPLEFT", child, "TOPLEFT", 18, y)
local nfs = MakeFS(sf, 9, "LEFT", T.valueText)
nfs:SetPoint("TOPLEFT", sf, "TOPLEFT", 0, -2)
nfs:SetText(sn or "")
local rt = tostring(sr or 0)
if smr and smr > 0 then rt = rt .. "/" .. tostring(smr) end
local rfs = MakeFS(sf, 8, "RIGHT", T.dimText)
rfs:SetPoint("TOPRIGHT", sf, "TOPRIGHT", -rightPad, -2)
rfs:SetText(rt)
if smr and smr > 0 then
local bf = CreateFrame("Frame", nil, sf)
bf:SetHeight(barH)
bf:SetPoint("BOTTOMLEFT", sf, "BOTTOMLEFT", 0, 2)
bf:SetPoint("BOTTOMRIGHT", sf, "BOTTOMRIGHT", -rightPad, 2)
SetPixelBackdrop(bf, T.barBg, { 0.15, 0.15, 0.18, 0.5 })
local bar = bf:CreateTexture(nil, "ARTWORK")
bar:SetTexture(SFrames:GetTexture())
bar:SetVertexColor(0.4, 0.65, 0.85, 0.85)
bar:SetPoint("TOPLEFT", bf, "TOPLEFT", 1, -1)
bar:SetPoint("BOTTOMLEFT", bf, "BOTTOMLEFT", 1, 1)
bar:SetWidth(math.max((SCROLL_W - 26 - rightPad) * Clamp((sr or 0) / smr, 0, 1), 1))
end
if canAbandon then
local db = CreateFrame("Button", nil, sf)
db:SetWidth(delBtnSize)
db:SetHeight(delBtnSize)
db:SetPoint("RIGHT", sf, "RIGHT", 0, 0)
db:SetFrameLevel(sf:GetFrameLevel() + 2)
SetPixelBackdrop(db, { 0.25, 0.08, 0.08, 0.7 }, { 0.5, 0.15, 0.15, 0.6 })
local ico = SFrames:CreateIcon(db, "close", 8)
ico:SetDrawLayer("OVERLAY")
ico:SetPoint("CENTER", db, "CENTER", 0, 0)
ico:SetVertexColor(0.9, 0.4, 0.4)
db.skillIndex = i
db.skillName = sn
db:SetScript("OnClick", function()
pendingAbandonIndex = this.skillIndex
if StaticPopup_Show then
StaticPopup_Show("NANAMI_ABANDON_SKILL", this.skillName)
end
end)
db:SetScript("OnEnter", function()
this:SetBackdropColor(0.45, 0.1, 0.1, 0.9)
this:SetBackdropBorderColor(0.8, 0.2, 0.2, 0.9)
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:AddLine("遗弃 " .. (this.skillName or ""), 1, 0.4, 0.4)
GameTooltip:AddLine("点击遗弃该技能", 0.7, 0.7, 0.7)
GameTooltip:Show()
end)
db:SetScript("OnLeave", function()
this:SetBackdropColor(0.25, 0.08, 0.08, 0.7)
this:SetBackdropBorderColor(0.5, 0.15, 0.15, 0.6)
GameTooltip:Hide()
end)
end
table.insert(page.skillRows, { frame = sf })
y = y - rowH
end
end
page.scrollArea:SetContentHeight(math.abs(y) + 16)
end
page.scrollArea:SetContentHeight(math.abs(y) + 16)
end
--------------------------------------------------------------------------------