From 519fa03edb2f1448559875e71289c002ba49fffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=9A=E7=BE=8E?= <2370337237@QQ.COM> Date: Mon, 30 Jun 2025 19:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E5=93=81=E6=94=B6=E8=97=8F=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=A1=86=E6=9E=B6=E8=84=B1=E6=8E=89=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=A3=85=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ItemCollection/SM_ItemCollectionUI.lua | 67 ++++++++++++++------------ SM_CollectionSystem.lua | 6 --- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/ItemCollection/SM_ItemCollectionUI.lua b/ItemCollection/SM_ItemCollectionUI.lua index c5cdf79..82d6857 100644 --- a/ItemCollection/SM_ItemCollectionUI.lua +++ b/ItemCollection/SM_ItemCollectionUI.lua @@ -679,29 +679,29 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel) end end - if model.TransmogStateTexture then model.TransmogStateTexture:Hide() end - table.insert(modelFrames, model) - model:Show() - model:EnableMouse(true) - model:SetScript("OnEnter", function(self) + if model.TransmogStateTexture then model.TransmogStateTexture:Hide() end --隐藏模型状态纹理 + table.insert(modelFrames, model) --将模型添加到模型帧数组中 + model:Show() --显示模型 + model:EnableMouse(true) --启用鼠标 + model:SetScript("OnEnter", function(self) --鼠标进入事件 -- 处理NEW图标 if self.newTexture and self.newTexture:IsShown() then - self.newTexture:Hide() + self.newTexture:Hide() --隐藏NEW图标 -- 从NewItems表中移除 - if SM_Collections and SM_Collections.NewItems and SM_Collections.NewItems.item then - SM_Collections.NewItems.item[tonumber(itemID)] = nil + if SM_Collections and SM_Collections.NewItems and SM_Collections.NewItems.item then --如果NewItems表存在且NewItems.item存在 + SM_Collections.NewItems.item[tonumber(itemID)] = nil --从NewItems表中移除 end end - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:SetHyperlink("item:" .. itemID) + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") --设置物品提示框位置 + GameTooltip:SetHyperlink("item:" .. itemID) --设置物品链接 GameTooltip:Show() end) model:SetScript("OnLeave", function() GameTooltip:Hide() end) local currentItemID = itemID local currentModel = model - model:SetScript("OnMouseDown", function(self) - SM_ItemCollectionUI:SelectModel(currentModel) + model:SetScript("OnMouseDown", function(self) --鼠标按下事件 + SM_ItemCollectionUI:SelectModel(currentModel) --选中模型 if SM_Collections.MainFrame and SM_Collections.MainFrame.RightSidePanel then local itemName = GetItemInfo(currentItemID) if SM_Collections.MainFrame.RightSidePanel.MountNama then @@ -715,11 +715,11 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel) end end) end - if #modelFrames > 0 and slot.items[startIdx] then - local firstModel = modelFrames[1] - self:SelectModel(firstModel) - local itemID = slot.items[startIdx] - local itemName = GetItemInfo(itemID) + if #modelFrames > 0 and slot.items[startIdx] then --如果模型帧数大于0且物品ID大于0 + local firstModel = modelFrames[1] --获取第一个模型 + self:SelectModel(firstModel) --选中第一个模型 + local itemID = slot.items[startIdx] --获取物品ID + local itemName = GetItemInfo(itemID) --获取物品名称 @@ -802,7 +802,7 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel) table.insert(modelFrames, model) model:Show() model:EnableMouse(true) - model:SetScript("OnEnter", function(self) + model:SetScript("OnEnter", function(self) --鼠标进入事件 -- 处理NEW图标 if self.newTexture and self.newTexture:IsShown() then self.newTexture:Hide() @@ -819,7 +819,7 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel) model:SetScript("OnLeave", function(self) GameTooltip:Hide() end) local currentItemID = itemID local currentModel = model - model:SetScript("OnMouseDown", function(self) + model:SetScript("OnMouseDown", function(self) --鼠标按下事件 SM_ItemCollectionUI:SelectModel(currentModel) if SM_Collections.MainFrame and SM_Collections.MainFrame.RightSidePanel then local itemName = GetItemInfo(currentItemID) @@ -854,17 +854,19 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel) SM_ItemCollectionUI:UpdateAttributes(currentItemID, slot.invType) 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() if slot.invType == "INVTYPE_WEAPONOFFHAND" then model.originalType = "off" - self:SetModelType(model, "off") + self:SetModelType(model, "off") --设置模型类型 副手 else model.originalType = "main" - self:SetModelType(model, "main") + self:SetModelType(model, "main") --设置模型类型 主手 end - model:Undress() - local success, error = pcall(function() model:TryOn(itemID) end) + model:Undress() --脱下装备 + local success, error = pcall(function() + model:TryOn(itemID) --穿上装备 + end) local weaponCameraID if slot.invType == "INVTYPE_WEAPONOFFHAND" then weaponCameraID = SM_CollectionData:GetWeaponCameraID("INVTYPE_WEAPONOFFHAND") @@ -872,12 +874,14 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel) weaponCameraID = SM_CollectionData:GetWeaponCameraID("INVTYPE_WEAPONMAINHAND") end self:ApplyCamera(model, weaponCameraID) - elseif slot.invType == "INVTYPE_RANGED" then + elseif slot.invType == "INVTYPE_RANGED" then --远程武器 model:ClearModel() model:SetUnit("player") model.animID = ANIMATION_RANGED_PREVIEW - model:Undress() - 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) self:ApplyCamera(model, cameraID) model:EnableMouse(true) @@ -928,9 +932,12 @@ function SM_ItemCollectionUI:ShowItemPreview(slot, panel) end GameTooltip:Hide() end) - else - self:SetModelType(model, "player") - local success, error = pcall(function() model:TryOn(itemID) end) + else --其他装备 + self:SetModelType(model, "player") --设置模型类型 + model:Undress() --脱下装备 + local success, error = pcall(function() + model:TryOn(itemID) --穿上装备 + end) local cameraID = SM_CollectionData:GetCharacterCameraID(slot.invType) self:ApplyCamera(model, cameraID) end diff --git a/SM_CollectionSystem.lua b/SM_CollectionSystem.lua index 31ebcff..1278f1d 100644 --- a/SM_CollectionSystem.lua +++ b/SM_CollectionSystem.lua @@ -5,15 +5,9 @@ 本地数据提供者 - 封装现有硬编码数据 服务端数据提供者 - 预留服务端通信接口 数据管理器 - 统一管理数据获取逻辑 - -当您准备好与 AzerothCore 服务端通信时,只需要: - SM_Collections.Config.UseServerData 默认 true 读取服务端数据 如需切换回本地数据,将 UseServerData 设为 false 在 ServerDataProvider:SendServerRequest 中实现实际的服务端通信逻辑 - -所有UI代码无需修改,插件可以正常测试UI功能,同时为未来的服务端集成做好了准备 - --]] -- 这里将拆分为多个文件,主入口只保留加载和初始化逻辑