添加武器附魔幻光按钮,未实现功能

This commit is contained in:
尚美 2025-07-03 22:28:28 +08:00
parent 6c26659a91
commit f46f79f70a
2 changed files with 160 additions and 19 deletions

View File

@ -160,10 +160,9 @@ function SM_ItemCollectionUI:InitSlotData()
{ name = "主手", invType = "INVTYPE_WEAPONMAINHAND", items = {}, icon = "Interface\\PaperDoll\\UI-PaperDoll-Slot-MainHand" },
{ name = "副手", invType = "INVTYPE_WEAPONOFFHAND", items = {}, icon = "Interface\\PaperDoll\\UI-PaperDoll-Slot-Relic" },
{ name = "远程", invType = "INVTYPE_RANGED", items = {}, icon = "Interface\\PaperDoll\\UI-PaperDoll-Slot-Ranged" },
{ name = "颈部", invType = "INVTYPE_NECK", items = {}, icon = "Interface\\PaperDoll\\UI-PaperDoll-Slot-Neck" },
{ name = "戒指", invType = "INVTYPE_FINGER", items = {}, icon = "Interface\\PaperDoll\\UI-PaperDoll-Slot-Finger" },
{ name = "饰品", invType = "INVTYPE_TRINKET", items = {}, icon = "Interface\\PaperDoll\\UI-PaperDoll-Slot-Trinket" },
{ name = "颈部", invType = "INVTYPE_NECK", items = {}, icon = "Interface\\AddOns\\SM_CollectionSystem\\Interface\\PaperDoll\\UI-PaperDoll-Slot-Neck" },
{ name = "戒指", invType = "INVTYPE_FINGER", items = {}, icon = "Interface\\AddOns\\SM_CollectionSystem\\Interface\\PaperDoll\\UI-PaperDoll-Slot-Finger" },
{ name = "饰品", invType = "INVTYPE_TRINKET", items = {}, icon = "Interface\\AddOns\\SM_CollectionSystem\\Interface\\PaperDoll\\UI-PaperDoll-Slot-Trinket" },
}
self.ALL_SLOTS = MODEL_SLOTS
-- 动态生成类型映射表,保证和槽位定义一致
@ -560,11 +559,10 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel)
-- 创建预览框架
local previewFrame = CreateFrame("Frame", "ItemCollectionPreviewFrame", panel)
previewFrame:SetSize(580, 400)
previewFrame:SetPoint("LEFT", SM_Collections.MainFrame, "LEFT", 30, -20)
previewFrame:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
})
previewFrame:SetSize(580, 410)
previewFrame:SetPoint("TOPLEFT", SM_Collections.MainFrame, "TOPLEFT", 30, -90)
previewFrame:SetBackdrop({bgFile = "Interface\\AddOns\\SM_CollectionSystem\\Textures\\liebiaoditu"})
previewFrame:SetBackdropColor(0, 0, 0, 1) -- 设置纯黑背景,参数为(r, g, b, a)
previewFrame:Show()
panel.previewFrame = previewFrame
self.previewFrame = previewFrame
@ -1209,7 +1207,7 @@ function SM_ItemCollectionUI:CreateButtons()
-- 对于没有对应纹理的槽位(颈部、戒指、饰品),创建独立按钮
if slotName == "neck" or slotName == "finger" or slotName == "trinket" then
-- 创建独立按钮,不使用模板
btn = CreateFrame("Button", nil, SM_ItemCollectionUI.currentPanel)
btn = CreateFrame("Button", "ItemCollectionSlot" .. i, SM_ItemCollectionUI.currentPanel)
btn:SetSize(30, 30)
-- 智能定位:相对于最后一个按钮
if lastButton then
@ -1245,15 +1243,16 @@ function SM_ItemCollectionUI:CreateButtons()
--SetPortraitToTexture(ArtworkTexture, "Interface\\AddOns\\SM_CollectionSystem\\Textures\\NeckButon_ARTWORK")
btn.ArtworkTexture = ArtworkTexture
-- local selectedTexture = btn:CreateTexture(nil, "OVERLAY", nil, 1)
-- selectedTexture:SetSize(45, 47)
-- selectedTexture:SetPoint("CENTER", 0, -2)
-- selectedTexture:SetTexture("Interface\\AddOns\\SM_CollectionSystem\\Interface\\Transmogrify\\Transmogrify")
-- selectedTexture:SetTexCoord(0.734375, 0.802734375, 0.171875, 0.244140625) -- 这是XML里的
-- selectedTexture:Hide()
-- btn.SelectedTexture = selectedTexture
local selectedTexture = btn:CreateTexture(nil, "OVERLAY", nil, 1)
selectedTexture:SetSize(45, 47)
selectedTexture:SetPoint("CENTER", 0, -2)
selectedTexture:SetTexture("Interface\\AddOns\\SM_CollectionSystem\\Interface\\Transmogrify\\Transmogrify")
selectedTexture:SetTexCoord(0.734375, 0.802734375, 0.171875, 0.244140625) -- 这是XML里的
selectedTexture:Hide()
btn.SelectedTexture = selectedTexture
else
btn = CreateFrame("Button", nil, SM_ItemCollectionUI.currentPanel, "SM_CollectionSystemWardrobeSlotButtonTemplate")
btn = CreateFrame("Button", "ItemCollectionSlot" .. i, SM_ItemCollectionUI.currentPanel,
"SM_CollectionSystemWardrobeSlotButtonTemplate")
btn:SetSize(40, 40)
btn:SetPoint("TOPLEFT", 80 + (i - 1) * 35, 35)
@ -1303,8 +1302,150 @@ function SM_ItemCollectionUI:CreateButtons()
atlasName = atlasName .. "back"
elseif slotName == "weaponmainhand" then
atlasName = atlasName .. "mainhand"
-- 添加附魔按钮
local enchantBtn = CreateFrame("Button", btn:GetName() .. "Enchant", btn)
enchantBtn:SetSize(25, 25)
enchantBtn:SetPoint("TOPRIGHT", btn, "TOPRIGHT", 2, 2)
-- 使用已有的附魔纹理
local enchantTexture = enchantBtn:CreateTexture(nil, "ARTWORK")
enchantTexture:SetAllPoints()
enchantTexture:SetTexture(
"Interface\\AddOns\\SM_CollectionSystem\\Interface\\Transmogrify\\Transmogrify")
-- 应用atlas纹理
SM_Collections:Mixin(enchantTexture, SetAtlasMixin)
enchantTexture:SetAtlas("transmog-nav-slot-enchant", true)
enchantBtn.texture = enchantTexture
-- 添加高光纹理
local highlightTexture = enchantBtn:CreateTexture(nil, "HIGHLIGHT")
highlightTexture:SetSize(17, 17)
highlightTexture:SetPoint("CENTER", 0, 2)
highlightTexture:SetTexture(
"Interface\\AddOns\\SM_CollectionSystem\\Interface\\ContainerFrame\\Bags")
highlightTexture:SetTexCoord(0.1640625, 0.3046875, 0.6875, 0.828125)
highlightTexture:SetBlendMode("ADD")
enchantBtn.highlightTexture = highlightTexture
-- 添加选中纹理,默认隐藏
local selectedTexture = enchantBtn:CreateTexture(nil, "OVERLAY")
selectedTexture:SetSize(22, 22)
selectedTexture:SetPoint("CENTER", 0, 2)
selectedTexture:SetTexture("Interface\\AddOns\\SM_CollectionSystem\\Textures\\Cir_Overlay")
selectedTexture:Hide()
enchantBtn.SelectedTexture = selectedTexture
-- 将附魔按钮添加到全局按钮列表中
table.insert(SM_ItemCollectionUI.buttons, enchantBtn)
-- 设置点击事件
enchantBtn:SetScript("OnClick", function(self)
-- 播放点击音效
PlaySound("igSpellBookSpellIconPickup")
print("点击了武器附魔按钮")
-- 清除所有附魔按钮的选中状态
for _, button in ipairs(SM_ItemCollectionUI.buttons) do
if button.SelectedTexture then
button.SelectedTexture:Hide()
end
end
-- 显示当前按钮的选中状态
self.SelectedTexture:Show()
-- 这里可以添加处理附魔选择的函数
-- SM_ItemCollectionUI:HandleEnchantButtonClick(self.slotData)
end)
-- 设置提示
enchantBtn:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("武器附魔")
GameTooltip:Show()
end)
enchantBtn:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)
-- 存储在主按钮上,以便后续访问
btn.enchantButton = enchantBtn
elseif slotName == "weaponoffhand" then
atlasName = atlasName .. "secondaryhand"
-- 添加附魔按钮
local enchantBtn = CreateFrame("Button", btn:GetName() .. "Enchant", btn)
enchantBtn:SetSize(25, 25)
enchantBtn:SetPoint("TOPRIGHT", btn, "TOPRIGHT", 2, 2)
-- 使用已有的附魔纹理
local enchantTexture = enchantBtn:CreateTexture(nil, "ARTWORK")
enchantTexture:SetAllPoints()
enchantTexture:SetTexture(
"Interface\\AddOns\\SM_CollectionSystem\\Interface\\Transmogrify\\Transmogrify")
-- 应用atlas纹理
SM_Collections:Mixin(enchantTexture, SetAtlasMixin)
enchantTexture:SetAtlas("transmog-nav-slot-enchant", true)
enchantBtn.texture = enchantTexture
-- 添加高光纹理
local highlightTexture = enchantBtn:CreateTexture(nil, "HIGHLIGHT")
highlightTexture:SetSize(17, 17)
highlightTexture:SetPoint("CENTER", 0, 2)
highlightTexture:SetTexture(
"Interface\\AddOns\\SM_CollectionSystem\\Interface\\ContainerFrame\\Bags")
highlightTexture:SetTexCoord(0.1640625, 0.3046875, 0.6875, 0.828125)
highlightTexture:SetBlendMode("ADD")
enchantBtn.highlightTexture = highlightTexture
-- 添加选中纹理,默认隐藏
local selectedTexture = enchantBtn:CreateTexture(nil, "OVERLAY")
selectedTexture:SetSize(22, 22)
selectedTexture:SetPoint("CENTER", 0, 2)
selectedTexture:SetTexture("Interface\\AddOns\\SM_CollectionSystem\\Textures\\Cir_Overlay")
selectedTexture:Hide()
enchantBtn.SelectedTexture = selectedTexture
-- 将附魔按钮添加到全局按钮列表中
table.insert(SM_ItemCollectionUI.buttons, enchantBtn)
-- 设置点击事件
enchantBtn:SetScript("OnClick", function(self)
-- 播放点击音效
PlaySound("igSpellBookSpellIconPickup")
print("点击了副手附魔按钮")
-- 清除所有附魔按钮的选中状态
for _, button in ipairs(SM_ItemCollectionUI.buttons) do
if button.SelectedTexture then
button.SelectedTexture:Hide()
end
end
-- 显示当前按钮的选中状态
self.SelectedTexture:Show()
-- 这里可以添加处理附魔选择的函数
-- SM_ItemCollectionUI:HandleEnchantButtonClick(self.slotData)
end)
-- 设置提示
enchantBtn:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("副手附魔")
GameTooltip:Show()
end)
enchantBtn:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)
-- 存储在主按钮上,以便后续访问
btn.enchantButton = enchantBtn
elseif slotName == "ranged" then
atlasName = atlasName .. "ranged"
elseif slotName == "tabard" then
@ -1347,7 +1488,7 @@ function SM_ItemCollectionUI:CreateButtons()
btn:SetScript("OnClick", function(self)
-- 播放点击音效
PlaySound("igSpellBookSpellIconPickup")
print("点击了按钮:", btn:GetName())
-- 清除所有按钮的选中状态
for _, button in ipairs(SM_ItemCollectionUI.buttons) do
if button.SelectedTexture then

Binary file not shown.