物品收藏模型框架脱掉所有装备

This commit is contained in:
尚美 2025-06-30 19:30:16 +08:00
parent 01676c66fb
commit 519fa03edb
2 changed files with 37 additions and 36 deletions

View File

@ -679,29 +679,29 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel)
end end
end end
if model.TransmogStateTexture then model.TransmogStateTexture:Hide() end if model.TransmogStateTexture then model.TransmogStateTexture:Hide() end --隐藏模型状态纹理
table.insert(modelFrames, model) table.insert(modelFrames, model) --将模型添加到模型帧数组中
model:Show() model:Show() --显示模型
model:EnableMouse(true) model:EnableMouse(true) --启用鼠标
model:SetScript("OnEnter", function(self) model:SetScript("OnEnter", function(self) --鼠标进入事件
-- 处理NEW图标 -- 处理NEW图标
if self.newTexture and self.newTexture:IsShown() then if self.newTexture and self.newTexture:IsShown() then
self.newTexture:Hide() self.newTexture:Hide() --隐藏NEW图标
-- 从NewItems表中移除 -- 从NewItems表中移除
if SM_Collections and SM_Collections.NewItems and SM_Collections.NewItems.item then if SM_Collections and SM_Collections.NewItems and SM_Collections.NewItems.item then --如果NewItems表存在且NewItems.item存在
SM_Collections.NewItems.item[tonumber(itemID)] = nil SM_Collections.NewItems.item[tonumber(itemID)] = nil --从NewItems表中移除
end end
end end
GameTooltip:SetOwner(self, "ANCHOR_RIGHT") GameTooltip:SetOwner(self, "ANCHOR_RIGHT") --设置物品提示框位置
GameTooltip:SetHyperlink("item:" .. itemID) GameTooltip:SetHyperlink("item:" .. itemID) --设置物品链接
GameTooltip:Show() GameTooltip:Show()
end) end)
model:SetScript("OnLeave", function() GameTooltip:Hide() end) model:SetScript("OnLeave", function() GameTooltip:Hide() end)
local currentItemID = itemID local currentItemID = itemID
local currentModel = model local currentModel = model
model:SetScript("OnMouseDown", function(self) model:SetScript("OnMouseDown", function(self) --鼠标按下事件
SM_ItemCollectionUI:SelectModel(currentModel) SM_ItemCollectionUI:SelectModel(currentModel) --选中模型
if SM_Collections.MainFrame and SM_Collections.MainFrame.RightSidePanel then if SM_Collections.MainFrame and SM_Collections.MainFrame.RightSidePanel then
local itemName = GetItemInfo(currentItemID) local itemName = GetItemInfo(currentItemID)
if SM_Collections.MainFrame.RightSidePanel.MountNama then if SM_Collections.MainFrame.RightSidePanel.MountNama then
@ -715,11 +715,11 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel)
end end
end) end)
end end
if #modelFrames > 0 and slot.items[startIdx] then if #modelFrames > 0 and slot.items[startIdx] then --如果模型帧数大于0且物品ID大于0
local firstModel = modelFrames[1] local firstModel = modelFrames[1] --获取第一个模型
self:SelectModel(firstModel) self:SelectModel(firstModel) --选中第一个模型
local itemID = slot.items[startIdx] local itemID = slot.items[startIdx] --获取物品ID
local itemName = GetItemInfo(itemID) local itemName = GetItemInfo(itemID) --获取物品名称
@ -802,7 +802,7 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel)
table.insert(modelFrames, model) table.insert(modelFrames, model)
model:Show() model:Show()
model:EnableMouse(true) model:EnableMouse(true)
model:SetScript("OnEnter", function(self) model:SetScript("OnEnter", function(self) --鼠标进入事件
-- 处理NEW图标 -- 处理NEW图标
if self.newTexture and self.newTexture:IsShown() then if self.newTexture and self.newTexture:IsShown() then
self.newTexture:Hide() self.newTexture:Hide()
@ -819,7 +819,7 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel)
model:SetScript("OnLeave", function(self) GameTooltip:Hide() end) model:SetScript("OnLeave", function(self) GameTooltip:Hide() end)
local currentItemID = itemID local currentItemID = itemID
local currentModel = model local currentModel = model
model:SetScript("OnMouseDown", function(self) model:SetScript("OnMouseDown", function(self) --鼠标按下事件
SM_ItemCollectionUI:SelectModel(currentModel) SM_ItemCollectionUI:SelectModel(currentModel)
if SM_Collections.MainFrame and SM_Collections.MainFrame.RightSidePanel then if SM_Collections.MainFrame and SM_Collections.MainFrame.RightSidePanel then
local itemName = GetItemInfo(currentItemID) local itemName = GetItemInfo(currentItemID)
@ -854,17 +854,19 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel)
SM_ItemCollectionUI:UpdateAttributes(currentItemID, slot.invType) SM_ItemCollectionUI:UpdateAttributes(currentItemID, slot.invType)
end end
end) end)
if slot.invType == "INVTYPE_WEAPONMAINHAND" or slot.invType == "INVTYPE_WEAPONOFFHAND" then if slot.invType == "INVTYPE_WEAPONMAINHAND" or slot.invType == "INVTYPE_WEAPONOFFHAND" then --主副手武器
model:ClearModel() model:ClearModel()
if slot.invType == "INVTYPE_WEAPONOFFHAND" then if slot.invType == "INVTYPE_WEAPONOFFHAND" then
model.originalType = "off" model.originalType = "off"
self:SetModelType(model, "off") self:SetModelType(model, "off") --设置模型类型 副手
else else
model.originalType = "main" model.originalType = "main"
self:SetModelType(model, "main") self:SetModelType(model, "main") --设置模型类型 主手
end end
model:Undress() model:Undress() --脱下装备
local success, error = pcall(function() model:TryOn(itemID) end) local success, error = pcall(function()
model:TryOn(itemID) --穿上装备
end)
local weaponCameraID local weaponCameraID
if slot.invType == "INVTYPE_WEAPONOFFHAND" then if slot.invType == "INVTYPE_WEAPONOFFHAND" then
weaponCameraID = SM_CollectionData:GetWeaponCameraID("INVTYPE_WEAPONOFFHAND") weaponCameraID = SM_CollectionData:GetWeaponCameraID("INVTYPE_WEAPONOFFHAND")
@ -872,12 +874,14 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel)
weaponCameraID = SM_CollectionData:GetWeaponCameraID("INVTYPE_WEAPONMAINHAND") weaponCameraID = SM_CollectionData:GetWeaponCameraID("INVTYPE_WEAPONMAINHAND")
end end
self:ApplyCamera(model, weaponCameraID) self:ApplyCamera(model, weaponCameraID)
elseif slot.invType == "INVTYPE_RANGED" then elseif slot.invType == "INVTYPE_RANGED" then --远程武器
model:ClearModel() model:ClearModel()
model:SetUnit("player") model:SetUnit("player")
model.animID = ANIMATION_RANGED_PREVIEW model.animID = ANIMATION_RANGED_PREVIEW
model:Undress() model:Undress() --脱下装备
local success, error = pcall(function() model:TryOn(itemID) end) local success, error = pcall(function()
model:TryOn(itemID) --穿上装备
end)
local cameraID = SM_CollectionData:GetCharacterCameraID(slot.invType) local cameraID = SM_CollectionData:GetCharacterCameraID(slot.invType)
self:ApplyCamera(model, cameraID) self:ApplyCamera(model, cameraID)
model:EnableMouse(true) model:EnableMouse(true)
@ -928,9 +932,12 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel)
end end
GameTooltip:Hide() GameTooltip:Hide()
end) end)
else else --其他装备
self:SetModelType(model, "player") self:SetModelType(model, "player") --设置模型类型
local success, error = pcall(function() model:TryOn(itemID) end) model:Undress() --脱下装备
local success, error = pcall(function()
model:TryOn(itemID) --穿上装备
end)
local cameraID = SM_CollectionData:GetCharacterCameraID(slot.invType) local cameraID = SM_CollectionData:GetCharacterCameraID(slot.invType)
self:ApplyCamera(model, cameraID) self:ApplyCamera(model, cameraID)
end end

View File

@ -5,15 +5,9 @@
- -
- -
- -
AzerothCore
SM_Collections.Config.UseServerData true SM_Collections.Config.UseServerData true
UseServerData false UseServerData false
ServerDataProvider:SendServerRequest ServerDataProvider:SendServerRequest
UI代码无需修改,UI功能
--]] --]]
-- 这里将拆分为多个文件,主入口只保留加载和初始化逻辑 -- 这里将拆分为多个文件,主入口只保留加载和初始化逻辑