-- 角色面板 装备
PlayerEquip = {}

PlayerEquip._ui = nil

-- 13 斗笠位置比较特殊 属于和头盔位置同部位
-- 要斗笠和头盔分开 需要设置Panel_pos13为显示 
PlayerEquip.showModelCapAndHelmet = false -- 斗笠和头盔分开情况下  模型是否显示 斗笠头盔
PlayerEquip.posSetting = {}
PlayerEquip._hideNodePos = {}
PlayerEquip.RoleType = {
    Self = 1 -- 自己
}

-- 剑甲分离出格子 需要对应相应装备位置
PlayerEquip.realUIPos = {
    [GUIDefine.EquipPosUI.Equip_Type_Dress] = 1000, 
    [GUIDefine.EquipPosUI.Equip_Type_Weapon] = 1001,
}

PlayerEquip.fictionalUIPos = {
    [1000] = GUIDefine.EquipPosUI.Equip_Type_Dress,
    [1001] = GUIDefine.EquipPosUI.Equip_Type_Weapon, 
}

function PlayerEquip.main(data)
    PlayerEquip.posSetting = {
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, --1000, 1001 如有分离装备 需要添加
    }
    local parent = GUI:Attach_Parent()
    GUI:LoadExport(parent, "player/player_equip_node_win32")

    PlayerEquip._ui = GUI:ui_delegate(parent)
    if not PlayerEquip._ui then
        return false
    end
    PlayerEquip._parent = parent

    PlayerEquip._samePosDiff = {}

    -- 初始化装备槽
    PlayerEquip.InitEquipCells()
    -- 角色性别
    PlayerEquip.playerSex = SL:GetMetaValue("SEX")
    -- 发型
    PlayerEquip.playerHairID = SL:GetMetaValue("HAIR")
    -- 职业
    PlayerEquip.playerJob = SL:GetMetaValue("JOB")
    

    -- 首饰盒
    local ringBoxShow = SL:GetMetaValue("SERVER_OPTION", SW_KEY_SNDAITEMBOX) == 1 -- 首饰盒功能是否开启
    GUI:setVisible(PlayerEquip._ui.Best_ringBox, ringBoxShow)
    GUI:addOnClickEvent(PlayerEquip._ui.Best_ringBox,function()
        -- 请求玩家首饰盒状态
        SL:RequestOpenPlayerBestRings()

        GUI:delayTouchEnabled(PlayerEquip._ui.Best_ringBox, 0.3) -- 0.3秒后启用触摸事件
    end)
    
    --刷新首饰盒状态
    PlayerEquip.RefreshPlayerBestRingsOpenState()
    PlayerEquip.RefreshBestRingBox()
    ----------------------
    --刷新行会信息
    PlayerEquip.RefreshGuildInfo()
    ----------------------
    PlayerEquip.RegisterEvent()
end

-- 初始化隐藏位置
function PlayerEquip.InitHideNodePos()
    PlayerEquip._hideNodePos = {}
    local posList = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 55}
    for _, i in ipairs(posList) do
        if PlayerEquip._ui[string.format("Node_%s", i)] then
            local visible = GUI:getVisible(PlayerEquip._ui[string.format("Node_%s", i)])
            if not visible then
                PlayerEquip._hideNodePos[i] = true
            end
        end
    end

    SL:Dump(PlayerEquip._hideNodePos, "_hideNodePos", 1)
end


function PlayerEquip.InitSamePosDiff(isAfterF10Load)
    -- 获取斗笠装备槽(位置13)的显示状态
    PlayerEquip._pos13Visible = GUI:getVisible(PlayerEquip._ui.Panel_pos13)
    
    if PlayerEquip._pos13Visible then  -- 如果斗笠槽可见
        -- 将斗笠(13)和面巾(55)位置添加到装备位置设置中
        table.insert(PlayerEquip.posSetting, 13)
        table.insert(PlayerEquip.posSetting, 55)
        
        -- 设置特殊位置映射关系
        PlayerEquip._samePosDiff = {
            [4] = 4,   -- 头盔位置
            [13] = 13  -- 斗笠位置
        }
    end

    -- 根据斗笠槽的显示状态来决定是否显示面巾相关UI元素
    GUI:setVisible(PlayerEquip._ui.Panel_pos55, PlayerEquip._pos13Visible)
    GUI:setVisible(PlayerEquip._ui.Node_55, PlayerEquip._pos13Visible)

    -- 如果是F10加载后的初始化
    if isAfterF10Load then
        PlayerEquip.InitEquipEvent()    -- 初始化装备事件
        PlayerEquip.InitEquipUI()       -- 初始化装备UI
        PlayerEquip.UpdatePlayerView(nil, true)  -- 更新角色模型显示
    end
end

function PlayerEquip.InitEquipEvent()
    local posSetting = PlayerEquip.posSetting
    for _, pos in ipairs(posSetting) do
        local equipPanel = PlayerEquip._ui["Panel_pos" .. pos]
        PlayerEquip.InitPanelMoveEvent(equipPanel, pos)
    end
end

-- 注册装备移动时的事件
function PlayerEquip.InitPanelMoveEvent(equipPanel, pos)
    -- 根据装备位置获取装备数据
    local function GetEquipDataByPos(equipPos, equipList)
        local beginOnMoving = true
        -- 如果是特殊位置(如头盔/斗笠共用位置),特殊处理
        if PlayerEquip._samePosDiff[equipPos] then
            equipList = false
            beginOnMoving = false
        end

        local equipItems = nil
        local posData = nil
        -- 根据是否需要列表来获取装备数据
        if equipList then
            equipItems = SL:GetMetaValue("EQUIP_DATA_LIST", equipPos)
        else
            posData = SL:GetMetaValue("EQUIP_DATA", equipPos, beginOnMoving) 
        end

        -- 处理返回数据格式
        if not equipItems and posData then
            if not beginOnMoving then
                equipItems = {}
                table.insert(equipItems, posData)
            else
                equipItems = posData
            end
        end
        
        return equipItems
    end

    -- 检查同位置装备的当前选择
    -- 主要用于处理头盔/斗笠这样的共用位置
    local function checkSamePosCurSelect(equipPos)
        if not PlayerEquip._samePosDiff[equipPos] then
            local itemData = SL:GetMetaValue("EQUIP_DATA", equipPos, true)
            if itemData and itemData.Where then
                return itemData.Where
            end
        end
        return equipPos
    end

    -- 获取实际的装备位置(处理虚拟位置到实际位置的映射)
    local equipPos = PlayerEquip.fictionalUIPos and PlayerEquip.fictionalUIPos[pos] or pos
    
    -- 刷新装备移动状态的回调函数
    local function refreshMoveState(_, bool)
        local setPos = equipPos
        -- 处理可显示装备的位置
        if GUIFunction:CheckCanShowEquipItem(setPos) or PlayerEquip._samePosDiff[setPos] then
            local itemNode = PlayerEquip._ui["Node_" .. setPos]
            if PlayerEquip._hideNodePos[setPos] then
                GUI:setVisible(itemNode, false)
            else
                GUI:setVisible(itemNode, not bool)
            end
        else
            -- 处理特殊装备位置的显示/隐藏
            local noEquip = nil
            if bool then
                if setPos == GUIDefine.EquipPosUI.Equip_Type_Helmet then
                    setPos = checkSamePosCurSelect(GUIDefine.EquipPosUI.Equip_Type_Helmet)
                end
                -- 设置不同类型装备的显示标记
                noEquip = {}
                if setPos == GUIDefine.EquipPosUI.Equip_Type_Dress then
                    noEquip.NoCloth = true
                elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Weapon then
                    noEquip.NoWeapon = true
                elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Helmet then
                    noEquip.NoHead = true
                elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Cap then
                    noEquip.NoCap = true
                elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Shield then
                    noEquip.NoShield = true
                elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Veil then
                    noEquip.NoVeil = true
                end
            end
            PlayerEquip.UpdatePlayerView(noEquip)
        end

        -- 处理实际UI位置的显示/隐藏
        if PlayerEquip.realUIPos and PlayerEquip.realUIPos[setPos] then 
            if bool then 
                PlayerEquip.HideEquipItemsUI(setPos)
            else 
                PlayerEquip.ShowEquipItemsUI(setPos)
            end 
        end

        -- 记录移动中的装备数据
        if bool then
            PlayerEquip._moveItemData = SL:GetMetaValue("EQUIP_DATA", equipPos)
        else
            PlayerEquip._moveItemData = nil
        end
    end

    -- 移动结束回调,清理移动数据
    local function endMoveCallBack()
        PlayerEquip._moveItemData = nil
    end

    -- 双击卸下装备的回调函数
    local function doubleCallBack()
        if PlayerEquip._moveItemData then
            return
        end
        local isList = false
        if not PlayerEquip._samePosDiff[equipPos] then
            isList = equipPos == GUIDefine.EquipPosUI.Equip_Type_Helmet or equipPos == GUIDefine.EquipPosUI.Equip_Type_Super_Helmet
        end
        local itemData = SL:GetMetaValue("EQUIP_DATA", equipPos, isList)
        if itemData then
            SL:TakeOffPlayerEquip(itemData)
        end
    end

    -- 鼠标滚动
    local function scrollCallBack(data)
        SL:onLUAEvent(LUA_EVENT_ITEMTIPS_MOUSE_SCROLL, data)
    end

    -- 创建可移动组件
    local panelSize = GUI:getContentSize(equipPanel)
    local equipWidget = GUI:MoveWidget_Create(equipPanel, "move_equip_" .. pos, panelSize.width / 2 , panelSize.height / 2, panelSize.width, panelSize.height, SL:GetMetaValue("ITEMFROMUI_ENUM").PALYER_EQUIP, {
        equipPos = equipPos,
        equipList = not PlayerEquip._samePosDiff[equipPos] and true or false,
        beginMoveCB = refreshMoveState,
        cancelMoveCB = refreshMoveState,
        endMoveCB = endMoveCallBack,
        pcDoubleCB = doubleCallBack,
        mouseScrollCB = scrollCallBack,
    })

    -- 鼠标移入延迟计时器
    local enterDelayTimer = nil
    -- 清理计时器函数
    local function CleanupTimer()
        if enterDelayTimer then
            GUI:stopAllActions(equipPanel)
            enterDelayTimer = nil
        end
    end

    -- 鼠标移动显示装备信息的回调
    local function mouseMoveCallBack()
        local itemData = GetEquipDataByPos(equipPos, true)
        
        if not itemData or PlayerEquip._moveItemData then
            return
        end
        local panelPos = GUI:getWorldPosition(equipPanel)
        local data = {}
        data.itemData = itemData[#itemData]
        data.itemData2 = itemData[#itemData - 1]
        data.itemData3 = itemData[#itemData - 2]
        data.pos = panelPos
        data.lookPlayer = false
        data.from = SL:GetMetaValue("ITEMFROMUI_ENUM").PALYER_EQUIP
        SL:OpenItemTips(data)
        CleanupTimer()
    end

    -- 鼠标进入回调
    local function onEnterFunc()
        if enterDelayTimer then
            return
        end
        -- 延迟显示装备信息提示
        enterDelayTimer = SL:scheduleOnce(equipPanel, function()
            mouseMoveCallBack()
        end, 0.05)
    end

    -- 鼠标离开回调
    local function onLeaveFunc()
        SL:CloseItemTips()
        CleanupTimer()
    end

    -- 添加鼠标移动事件监听
    GUI:addMouseMoveEvent(equipPanel, {
        onEnterFunc = onEnterFunc,
        onLeaveFunc = onLeaveFunc,
        checkIsVisible = true
    })
end

-- 初始化装备UI显示
function PlayerEquip.InitEquipUI()
    -- 获取所有装备位置的数据
    local equipDataByPos = SL:GetMetaValue("EQUIP_POS_DATAS")  
    
    -- 遍历每个装备位置
    for pos, data in pairs(equipDataByPos) do
        -- 获取对应位置的装备面板
        local equipPanel = PlayerEquip._ui["Panel_pos" .. pos]
        
        -- 检查该位置是否可以显示装备(普通位置或特殊位置如头盔/斗笠)
        if equipPanel and (GUIFunction:CheckCanShowEquipItem(pos) or PlayerEquip._samePosDiff[pos]) then
            -- 根据MakeIndex获取装备数据
            local item = SL:GetMetaValue("EQUIP_DATA_BY_MAKEINDEX", data)
            if item then 
                -- 获取装备显示节点
                local itemNode = PlayerEquip._ui["Node_"..pos]
                -- 清除节点上的所有子节点
                GUI:removeAllChildren(itemNode)
                -- 创建单个并显示装备
                PlayerEquip.CreateEquipItem(itemNode, item, pos)
            end
        end
        -- 显示该位置的装备UI
        PlayerEquip.ShowEquipItemsUI(pos)
    end
end

-- --创建装备显示
function PlayerEquip.CreateEquipItem(parent, data, uiPos)
    -- 剑甲分离装备框不显示内观特效
    local function checkPos(uiPos)
        if PlayerEquip.fictionalUIPos and PlayerEquip.fictionalUIPos[uiPos] then 
            local pos = PlayerEquip.fictionalUIPos[uiPos]
            if pos == GUIDefine.EquipPosUI.Equip_Type_Dress or pos == GUIDefine.EquipPosUI.Equip_Type_Weapon then
                return false
            end
        end
        return true
    end

    local info = {}
    info.itemData = data
    info.index = data.Index
    info.noMouseTips = true  --鼠标移入不显示tips
    info.showModelEffect = checkPos(uiPos)
    info.from = SL:GetMetaValue("ITEMFROMUI_ENUM").PALYER_EQUIP  --物品来自玩家身上
    local item = GUI:ItemShow_Create(parent, "item_" .. uiPos, 0, 0, info) -- 创建物品框
    GUI:setAnchorPoint(item, 0.5, 0.5)
end

function PlayerEquip.InitEquipCells() 
    local uid = SL:GetMetaValue("USER_ID")
    -- 请求通知脚本查看uid的珍宝
    SL:RequestLookZhenBao(uid)
    -- 额外的装备位置
    local equipPosSet = SL:GetMetaValue("SERVER_OPTION", SW_KEY_EQUIP_EXTRA_POS) or 0 --是否开启6格
    local showExtra = equipPosSet == 1
    if showExtra then --开启6格后,把装备位置设置到PlayerEquip.posSetting中
        
        table.insert(PlayerEquip.posSetting, 14)
        table.insert(PlayerEquip.posSetting, 15)
    else
        GUI:setVisible(PlayerEquip._ui.Panel_pos14, false)
        GUI:setVisible(PlayerEquip._ui.Panel_pos15, false)
        GUI:setVisible(PlayerEquip._ui.Node_14, false)
        GUI:setVisible(PlayerEquip._ui.Node_15, false)
    end

    -- 剑甲分离配置
    if SL:GetMetaValue("GAME_DATA", "DivideWeaponAndClothes") == 1 then 
        GUI:setVisible(PlayerEquip._ui.Panel_pos1000, true)
        GUI:setVisible(PlayerEquip._ui.Panel_pos1001, true)
        GUI:setVisible(PlayerEquip._ui.Node_1000, true)
        GUI:setVisible(PlayerEquip._ui.Node_1001, true)
        table.insert(PlayerEquip.posSetting, 1000)
        table.insert(PlayerEquip.posSetting, 1001)
    end 
end

function PlayerEquip.RefreshGuildInfo() -- 在人物装备栏显示行会信息
    local textGuildInfo = PlayerEquip._ui.Text_guildinfo
    local guildData = SL:GetMetaValue("GUILD_INFO") -- 行会数据
    local myGuildName = guildData.guildName  --行会名字
    local myJobName = SL:GetMetaValue("GUILD_OFFICIAL", guildData.rank) --行会职位
    if not myGuildName then
        return
    end
    myJobName = myJobName or ""

    local guildInfo = myGuildName .. " " .. myJobName
    GUI:Text_setString(textGuildInfo, guildInfo)  --设置装备栏显示行会信息

    local color = SL:GetMetaValue("USER_NAME_COLOR") --获取玩家名字颜色值
    if color and color > 0 then
        GUI:Text_setTextColor(textGuildInfo, SL:GetHexColorByStyleId(color))
    end
end

--刷新首饰盒状态,鼠标放上去显示提示
function PlayerEquip.RefreshPlayerBestRingsOpenState(data)
    local activeState = SL:GetMetaValue("BEST_RING_OPENSTATE", PlayerEquip.RoleType.Self)  --首饰盒是否激活
    if activeState then
        GUI:Image_setGrey(PlayerEquip._ui.Image_box, false)
    else
        GUI:Image_setGrey(PlayerEquip._ui.Image_box, true)  -- 没激活显示灰色
    end
    
    local function mouseMoveCallBack(touchPos)  -- 鼠标移动到首饰盒上回调函数
        if not GUI:getVisible(PlayerEquip._ui.Best_ringBox) then 
            return
        end
        local bestRingsName = SL:GetMetaValue("SERVER_OPTION", "SndaItemBoxName") or "饰盒"
        if SL:CheckNodeCanCallBack(PlayerEquip._ui.Best_ringBox, touchPos) and bestRingsName ~= "" then
            local tips = nil
            local activeState = SL:GetMetaValue("BEST_RING_OPENSTATE", PlayerEquip.RoleType.Self)
            if activeState then
                tips = string.format("点击打开%s", bestRingsName)
            else
                tips = string.format("%s未开启", bestRingsName)
            end
            local worldPos = GUI:getWorldPosition(PlayerEquip._ui.Best_ringBox)
            worldPos.x = GUI:getContentSize(PlayerEquip._ui.Best_ringBox).width/2 + worldPos.x
            GUI:ShowWorldTips(tips, worldPos, GUI:p(0.5, 1)) --设置提示文本中心
        end
    end

    local function leaveItem()
        GUI:HideWorldTips() --移走时关闭提示文本
    end

    --绑定鼠标移动事件
    GUI:addMouseMoveEvent(PlayerEquip._ui.Best_ringBox,
        {
            onEnterFunc = mouseMoveCallBack,
            onLeaveFunc = leaveItem
        }
    )
    if data and data.isOpen then
        if activeState then
            SL:OpenBestRingBoxUI(PlayerEquip.RoleType.Self, { param = {} })
        end
    end
end

function PlayerEquip.RefreshBestRingBox()  -- 打开首饰盒,播放首饰盒按钮动画
    SL:scheduleOnce(PlayerEquip._ui.Best_ringBox,function()
        local texture = "btn_jewelry_1_1.png"
        if SL:GetMetaValue("BEST_RING_WIN_ISOPEN", PlayerEquip.RoleType.Self) then -- 首饰盒界面是否打开
            texture = "btn_jewelry_1_0.png"
        end
        GUI:Image_loadTexture(PlayerEquip._ui.Image_box, SLDefine.PATH_RES_PRIVATE .. "player_best_rings_ui/player_best_rings_ui_win32/" .. texture)
        -- 重置尺寸
        GUI:setIgnoreContentAdaptWithSize(PlayerEquip._ui.Image_box, true)
        PlayerEquip.RefreshPlayerBestRingsOpenState()
    end,0.1)
end

-- 获取装备在UI上的实际显示位置
function PlayerEquip.GetShowUIPosByItemWhere(pos)
    -- 获取装备位置类型配置
    local typeConfig = GUIDefine.EquipPosUI
    
    -- 将斗笠和面巾的位置映射到头盔位置
    if pos == typeConfig.Equip_Type_Cap or pos == typeConfig.Equip_Type_Veil then
        pos = typeConfig.Equip_Type_Helmet
    -- 将高级斗笠和高级面巾的位置映射到高级头盔位置    
    elseif pos == typeConfig.Equip_Type_Super_Cap or pos == typeConfig.Equip_Type_Super_Veil then
        pos = typeConfig.Equip_Type_Super_Helmet
    end
    
    return pos
end



-- 更新装备时传递的参数
-- data = {
--      "MakeIndex" = 14225,
--      "Where"     = 1,
--      "opera"     = 2,
-- }
function PlayerEquip.UpdateEquipUI(data) --玩家换装备时,界面更新装备的显示
    
    if not data or not next(data) then
        return
    end
    local operatorType = data.opera
    local MakeIndex = data.MakeIndex
    local pos = data.Where
    if not PlayerEquip._samePosDiff[pos] then
        if not PlayerEquip._pos13Visible or pos ~= 55 then --面巾不处理
            pos = PlayerEquip.GetShowUIPosByItemWhere(pos) --获取显示装备的位置
        end
    end

    local equipPanel = PlayerEquip._ui["Panel_pos" .. pos]  --不存在的装备panel直接退出
    if not equipPanel then
        return
    end
    local isShowItem = false 
    if GUIFunction:CheckCanShowEquipItem(pos) or PlayerEquip._samePosDiff[pos] then
        isShowItem = true
    end

    PlayerEquip._moveItemData = nil
    if operatorType == 1 then -- 增
        if isShowItem then
            local itemNode = PlayerEquip._ui["Node_" .. pos]
            if not PlayerEquip._hideNodePos[pos] then 
                GUI:setVisible(itemNode, true) --不是隐藏节点,则显示出来
            else
                GUI:setVisible(itemNode, false)
            end
            GUI:removeAllChildren(itemNode)  --删除掉子节
            local item = SL:GetMetaValue("EQUIP_DATA_BY_MAKEINDEX", MakeIndex)  --根据MakeIndex获取装备数据
            -- "item" = {
            --     "AddValues" = {
            --     }
            --     "Dura"       = 7000
            --     "DuraMax"    = 7000
            --     "ExAbil" = {
            --         "abil" = *MAX NESTING*
            --         "abilex" = ""
            --         "name"   = ""
            --     }
            --     "ExtendInfo" = {
            --         "ItmSrc" = *MAX NESTING*
            --     }
            --     "Index"      = 50163
            --     "MakeIndex"  = 14227
            --     "OverLap"    = 1
            --     "Values" = {
            --     }
            --     "Where"      = 7
            -- }
            PlayerEquip.CreateEquipItem(itemNode, item, pos) --创建装备显示
            if PlayerEquip._samePosDiff[pos] and PlayerEquip.showModelCapAndHelmet then 
                PlayerEquip.UpdatePlayerView()
                PlayerEquip.ShowEquipItemsUI(pos)
            end
        else
            PlayerEquip.UpdatePlayerView()
            PlayerEquip.ShowEquipItemsUI(pos)
        end
    elseif operatorType == 2 then -- 删
        if isShowItem then
            local itemNode = PlayerEquip._ui["Node_" .. pos]
            GUI:removeAllChildren(itemNode)
            if PlayerEquip._samePosDiff[pos] and PlayerEquip.showModelCapAndHelmet then 
                PlayerEquip.UpdatePlayerView()
                PlayerEquip.HideEquipItemsUI(pos)
            end
        else
            PlayerEquip.UpdatePlayerView()
            PlayerEquip.HideEquipItemsUI(pos)
        end
    elseif operatorType == 3 then -- 改
        -- 如果更新的装备不是更新Look  不进行更新内观的刷新
        if not data.isChangeLook then
            return
        end

        if isShowItem then
            local itemNode = PlayerEquip._ui["Node_" .. pos]
            GUI:removeAllChildren(itemNode)
            local item = SL:GetMetaValue("EQUIP_DATA_BY_MAKEINDEX", MakeIndex)
            PlayerEquip.CreateEquipItem(itemNode, item, pos)
            if PlayerEquip._samePosDiff[pos] and PlayerEquip.showModelCapAndHelmet then 
                PlayerEquip.UpdatePlayerView()
            end
        else
            PlayerEquip.UpdatePlayerView()
        end
    end
end

-- 更新角色模型显示
function PlayerEquip.UpdatePlayerView(noEquipType, init)
    -- 清除现有模型
    GUI:removeAllChildren(PlayerEquip._ui.Node_playerModel)
    -- 获取装备数据和配置
    -- "equipDataByPos" = {
    --     1 = 14225
    --     5 = 14231
    --     7 = 14227
    -- }
    local equipDataByPos = SL:GetMetaValue("EQUIP_POS_DATAS")
    local equipTypeConfig = GUIDefine.EquipPosUI  --获取装备位置信息  "Equip_Type_Weapon"            = 1

    
    noEquipType = noEquipType or {}

    local showNakedMold = true -- 是否显示裸模,默认显示
    local showHelmet = false   -- 是否显示头盔
    
    -- 获取外观文件名和类型
    local function getFileName(looks)
        local fileName = string.format("%06d", looks % 10000)
        return fileName, math.floor(looks / 10000)
    end

    -- 获取装备外观数据
    local function GetLooks(equipType, need)
        -- "equipDataByPos" = {
        --     1 = 14225
        --     5 = 14231
        -- }
        
        local show = {
            look = nil,    -- 外观ID
            effect = nil   -- 特效ID
        }
        -- 时装类型处理
        if equipType > 10000 then
            local fashionShow = {}
            return fashionShow
        end
        
        -- 获取装备数据并处理外观
        if not need and equipType and equipDataByPos[equipType] then
            local MakeIndex = equipDataByPos[equipType]  --1 = 14225
            -- 处理装备移动时的显示
            if init and PlayerEquip._moveItemData and MakeIndex == PlayerEquip._moveItemData.MakeIndex then
                return show
            end
            local equipData = SL:GetMetaValue("EQUIP_DATA_BY_MAKEINDEX", MakeIndex) or {}

            -- 处理衣服显示裸模逻辑
            if equipType == equipTypeConfig.Equip_Type_Dress then
                if showNakedMold and equipData and equipData.shonourSell and tonumber(equipData.shonourSell) == 1 then
                    showNakedMold = false
                end
            end

            -- 设置外观和特效
            if equipData and equipData.Looks then
                show.look = equipData.Looks
            end
            if equipData and equipData.sEffect then
                show.effect = equipData.sEffect
            end

            -- 处理斗笠显示
            if equipType == equipTypeConfig.Equip_Type_Cap and equipData.AniCount == 0 then
                showHelmet = true
            end

            -- 处理特殊位置装备显示
            if PlayerEquip._samePosDiff[equipType] and not PlayerEquip.showModelCapAndHelmet then  --
                return {
                    look = nil,
                    effect = nil
                }
            end

            return show
        end
        return show
    end

    -- 获取角色基础信息
    local hairID        = SL:GetMetaValue("HAIR")
    local clothShow     = GetLooks(equipTypeConfig.Equip_Type_Dress, noEquipType.NoCloth)
    local weaponShow    = GetLooks(equipTypeConfig.Equip_Type_Weapon, noEquipType.NoWeapon)
    local headShow      = GetLooks(equipTypeConfig.Equip_Type_Helmet, noEquipType.NoHead)
    local capShow       = GetLooks(equipTypeConfig.Equip_Type_Cap, noEquipType.NoCap)
    local shieldShow    = GetLooks(equipTypeConfig.Equip_Type_Shield, noEquipType.NoShield)
    local veilShow      = GetLooks(equipTypeConfig.Equip_Type_Veil, noEquipType.NoVeil)
    local tDressShow    = GetLooks(10004)
    local tWeaponShow   = GetLooks(10005)
    local embattle      = SL:GetMetaValue("EMBATTLE")

    local modelData = {
        clothID         = clothShow.look,
        clothEffectID   = clothShow.effect,
        weaponID        = weaponShow.look,
        weaponEffectID  = weaponShow.effect,
        headID          = headShow.look,
        headEffectID    = headShow.effect,
        hairID          = hairID,
        capID           = capShow.look,
        capEffectID     = capShow.effect,
        veilID          = veilShow.look,
        veilEffectID    = veilShow.effect,
        shieldID        = shieldShow.look,
        shieldEffectID  = shieldShow.effect,
        tDressID        = tDressShow.look,
        tDressEffectID  = tDressShow.effect,
        tWeaponID       = tWeaponShow.look,
        tWeaponEffectID = tWeaponShow.effect,
        embattlesID     = embattle,
        notShowMold     = not showNakedMold,
        notShowHair     = not showNakedMold,
    }

    local sex = SL:GetMetaValue("SEX")
    local job = SL:GetMetaValue("JOB")
    local uiModel = GUI:UIModel_Create(PlayerEquip._ui.Node_playerModel, "model", 0, 0, sex, modelData, nil, true, job, {showHelmet = showHelmet})
    GUI:setAnchorPoint(uiModel, 0.5, 0.5)
end

function PlayerEquip.ShowEquipItemsUI(pos)
    
    if not pos then 
        return 
    end 

    if not PlayerEquip.realUIPos or not PlayerEquip.realUIPos[pos] then 
        return 
    end 

    local data = SL:GetMetaValue("EQUIP_DATA", pos)
    if not data then 
        return 
    end 

    local UIPos = PlayerEquip.realUIPos[pos]

    local itemPanel = PlayerEquip._ui["Panel_pos" .. UIPos]
    local bShow = GUI:getVisible(itemPanel)
    if not bShow then 
        return 
    end 
    local itemNode = PlayerEquip._ui["Node_" .. UIPos]
    if not itemNode then   
        return 
    end 
    

    GUI:setVisible(itemNode, true)
    GUI:removeAllChildren(itemNode)

    PlayerEquip.CreateEquipItem(itemNode, data, UIPos)
end

function PlayerEquip.HideEquipItemsUI(pos)
    if not pos then 
        return 
    end 

    if not PlayerEquip.realUIPos or not PlayerEquip.realUIPos[pos] then 
        return 
    end 

    local UIPos = PlayerEquip.realUIPos[pos] 

    local itemPanel = PlayerEquip._ui["Panel_pos" .. UIPos]
    local bShow = GUI:getVisible(itemPanel)
    if not bShow then 
        return 
    end 

    local itemNode = PlayerEquip._ui["Node_"..UIPos]
    if not itemNode then   
        return 
    end 

    GUI:setVisible(itemNode, false)
    GUI:removeAllChildren(itemNode)
end

function PlayerEquip.OnOpenOrCloseWin(data)
    if data == "PlayerBestRingGUI" then
        PlayerEquip.RefreshBestRingBox()
    end
end

--[[    
    界面关闭回调
]]
function PlayerEquip.CloseCallback()
    PlayerEquip.UnRegisterEvent()
end

function PlayerEquip.RegisterEvent()
    --刷新行会信息
    SL:RegisterLUAEvent(LUA_EVENT_PLAYER_GUILD_INFO_CHANGE, "PlayerEquip", PlayerEquip.RefreshGuildInfo)
    -- 刷新装备信息
    SL:RegisterLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, "PlayerEquip", PlayerEquip.UpdateEquipUI)
    -- 刷新法阵
    SL:RegisterLUAEvent(LUA_EVENT_PLAYER_EMBATTLE_CHANGE, "PlayerEquip", PlayerEquip.UpdatePlayerView)
    -- 刷新性别
    SL:RegisterLUAEvent(LUA_EVENT_PLAYER_SEX_CHANGE, "PlayerEquip", PlayerEquip.UpdatePlayerView)
    -- 打开/关闭界面
    SL:RegisterLUAEvent(LUA_EVENT_OPENWIN, "PlayerEquip", PlayerEquip.OnOpenOrCloseWin)
    SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, "PlayerEquip", PlayerEquip.OnOpenOrCloseWin)
    -- 首饰盒状态改变
    SL:RegisterLUAEvent(LUA_EVENT_BESTRINGBOX_STATE, "PlayerEquip", PlayerEquip.RefreshPlayerBestRingsOpenState)
end

function PlayerEquip.UnRegisterEvent()
    SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_GUILD_INFO_CHANGE, "PlayerEquip")
    SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, "PlayerEquip")
    SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_EMBATTLE_CHANGE, "PlayerEquip")
    SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_SEX_CHANGE, "PlayerEquip")
    SL:UnRegisterLUAEvent(LUA_EVENT_OPENWIN, "PlayerEquip")
    SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, "PlayerEquip")
    SL:UnRegisterLUAEvent(LUA_EVENT_BESTRINGBOX_STATE, "PlayerEquip")
end
    6 天后
    -- 角色面板 装备
    PlayerEquip = {}
    
    PlayerEquip._ui = nil
    
    -- 13 斗笠位置比较特殊 属于和头盔位置同部位
    -- 要斗笠和头盔分开 需要设置Panel_pos13为显示 
    PlayerEquip.showModelCapAndHelmet = false -- 斗笠和头盔分开情况下  模型是否显示 斗笠头盔
    PlayerEquip.posSetting = {}
    PlayerEquip._hideNodePos = {}
    PlayerEquip.RoleType = {
        Self = 1 -- 自己
    }
    
    -- 剑甲分离出格子 需要对应相应装备位置
    PlayerEquip.realUIPos = {
        [GUIDefine.EquipPosUI.Equip_Type_Dress] = 1000, 
        [GUIDefine.EquipPosUI.Equip_Type_Weapon] = 1001,
    }
    
    PlayerEquip.fictionalUIPos = {
        [1000] = GUIDefine.EquipPosUI.Equip_Type_Dress,
        [1001] = GUIDefine.EquipPosUI.Equip_Type_Weapon, 
    }
    
    function PlayerEquip.main(data)
        PlayerEquip.posSetting = {
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 71, 72 --1000, 1001 如有分离装备 需要添加
        }
        local parent = GUI:Attach_Parent()
        GUI:LoadExport(parent, "player/player_equip_node_win32")
    
        PlayerEquip._ui = GUI:ui_delegate(parent)
        -- if not PlayerEquip._ui then
        --     return false
        -- end
    
        -- 检查UI是否正确加载
        if not PlayerEquip._ui then
            SL:Print("[ERROR] Failed to load player equip UI!")
            return false
        end
        
        -- 检查71号位置的面板是否存在
        if not PlayerEquip._ui["Panel_pos71"] then
            SL:Print("[ERROR] Panel_pos71 not found in UI!")
        end
    
        PlayerEquip._parent = parent
    
        
        -- 用于保存某个装备位置是否是特殊处理位置 ,影响装备的显示逻辑和模型更新
        PlayerEquip._samePosDiff = {}
    
        -- 初始化装备槽
        PlayerEquip.InitEquipCells()  --6格和剑甲分离装备框,初始化,决定其是否显示。
        -- 角色性别
        PlayerEquip.playerSex = SL:GetMetaValue("SEX")
        -- 发型
        PlayerEquip.playerHairID = SL:GetMetaValue("HAIR")
        -- 职业
        PlayerEquip.playerJob = SL:GetMetaValue("JOB")
        
    
        -- 首饰盒
        local ringBoxShow = SL:GetMetaValue("SERVER_OPTION", SW_KEY_SNDAITEMBOX) == 1 -- 首饰盒功能是否开启
        GUI:setVisible(PlayerEquip._ui.Best_ringBox, ringBoxShow)
        GUI:addOnClickEvent(PlayerEquip._ui.Best_ringBox,function()
            -- 请求玩家首饰盒状态
            SL:RequestOpenPlayerBestRings()
    
            GUI:delayTouchEnabled(PlayerEquip._ui.Best_ringBox, 0.3) -- 0.3秒后启用触摸事件
        end)
        
        --刷新首饰盒状态
        PlayerEquip.RefreshPlayerBestRingsOpenState()
        PlayerEquip.RefreshBestRingBox()
        ----------------------
        --刷新行会信息
        PlayerEquip.RefreshGuildInfo()
        ----------------------
        PlayerEquip.RegisterEvent()
    end
    
    -- 初始化隐藏位置
    function PlayerEquip.InitHideNodePos()
        PlayerEquip._hideNodePos = {}
        local posList = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 71, 72}
        for _, i in ipairs(posList) do
            if PlayerEquip._ui[string.format("Node_%s", i)] then
                local visible = GUI:getVisible(PlayerEquip._ui[string.format("Node_%s", i)])
                if not visible then
                    PlayerEquip._hideNodePos[i] = true   --根据UI节点决定是否显示装备
                end
            end
        end
        --     "_hideNodePos" = {
        --     71 = true
        -- }
        SL:Dump(PlayerEquip._hideNodePos, "_hideNodePos", 1)
    end
    
    
    function PlayerEquip.InitSamePosDiff(isAfterF10Load)
        -- 获取斗笠装备槽(位置13)的显示状态
        PlayerEquip._pos13Visible = GUI:getVisible(PlayerEquip._ui.Panel_pos13)
        
        if PlayerEquip._pos13Visible then  -- 如果斗笠槽可见
            -- 将斗笠(13)和面巾(55)位置添加到装备位置设置中
            table.insert(PlayerEquip.posSetting, 13)
            table.insert(PlayerEquip.posSetting, 55)
            
            -- 设置特殊位置映射关系
            PlayerEquip._samePosDiff = {
                [4] = 4,   -- 头盔位置
                [13] = 13  -- 斗笠位置
            }
        end
    
        -- "PlayerEquip.posSetting" = {
        --     1  = 0
        --     2  = 1
        --     3  = 2
        --     4  = 3
        --     5  = 4
        --     6  = 5
        --     7  = 6
        --     8  = 7
        --     9  = 8
        --     10 = 9
        --     11 = 10
        --     12 = 11
        --     13 = 12
        --     14 = 16
        --     15 = 71
        --     16 = 72
        --     17 = 14
        --     18 = 15
        -- }
        -- 根据斗笠槽的显示状态来决定是否显示面巾相关UI元素
        GUI:setVisible(PlayerEquip._ui.Panel_pos55, PlayerEquip._pos13Visible)
        GUI:setVisible(PlayerEquip._ui.Node_55, PlayerEquip._pos13Visible)
    
        --F10加载后的初始化,打开装备面板初始化
        if isAfterF10Load then
            PlayerEquip.InitEquipEvent()    -- 初始化装备移动事件
            PlayerEquip.InitEquipUI()       -- 初始化装备UI
            PlayerEquip.UpdatePlayerView(nil, true)  -- 更新角色模型显示
        end
    end
    
    function PlayerEquip.InitEquipEvent()  --初始化每件装备移动事件
        local posSetting = PlayerEquip.posSetting
        for _, pos in ipairs(posSetting) do
            local equipPanel = PlayerEquip._ui["Panel_pos" .. pos]
            PlayerEquip.InitPanelMoveEvent(equipPanel, pos)
        end
    end
    
    -- 注册装备移动时的事件
    function PlayerEquip.InitPanelMoveEvent(equipPanel, pos)
    
        -- 添加检查
        if not equipPanel then
            SL:Print("[ERROR] Equipment panel for position " .. pos .. " not found!")
            return
        end
    
        -- 根据装备位置获取装备数据
        local function GetEquipDataByPos(equipPos, equipList)
            local beginOnMoving = true
            -- 如果是特殊位置(如头盔/斗笠共用位置),特殊处理
            --     "PlayerEquip._samePosDiff-----" = {
            --  }
            if PlayerEquip._samePosDiff[equipPos] then
                equipList = false
                beginOnMoving = false
            end
    
            local equipItems = nil
            local posData = nil
            -- 根据是否需要列表来获取装备数据
            if equipList then
                equipItems = SL:GetMetaValue("EQUIP_DATA_LIST", equipPos)  --
            else
                posData = SL:GetMetaValue("EQUIP_DATA", equipPos, beginOnMoving)  --获取玩家某一装备数据
            end
    
            
            -- 处理装备数据的格式转换
            if not equipItems and posData then
                if not beginOnMoving then
                    -- 如果不是开始移动状态,创建新数组并将posData作为单个元素插入
                    equipItems = {}
                    table.insert(equipItems, posData)
                else
                    -- 如果是开始移动状态,直接使用posData作为装备数据
                    equipItems = posData
                end
            end
    
            -- "equipItems-----" = {
            --     1 = {
            --         "AddValues" = {
            --         }
            --         "Article"        = ""
            --         "Color"          = 251
            --         "Desc"           = ""
            --         "Dura"           = 7000
            --         "DuraMax"        = 7000
            --         "ExAbil" = {
            --             "abil" = *MAX NESTING*
            --             "abilex" = ""
            --             "name"   = ""
            --         }
            --         "ExtendInfo" = {
            --             "ItmSrc" = *MAX NESTING*
            --         }
            --         "Index"          = 50163
            --         "Looks"          = 147
            --         "MakeIndex"      = 14227
            --         "Name"           = "圣战戒指"
            --         "Need"           = 1
            --         "NeedLevel"      = 40
            --         "NeedLevelParam" = 24
            --         "OverLap"        = 1
            --         "Shape"          = 0
            --         "Source"         = 0
            --         "StdMode"        = 22
            --         "Values" = {
            --             1 = *MAX NESTING*
            --         }
            --         "Weight"         = 2
            --         "Where"          = 7
            --         "attribute"      = "3#12#1|3#4#7"
            --         "bEffect"        = ""
            --         "sEffect"        = ""
            --     }
            -- }
    
            return equipItems
        end
    
        -- 检查同位置装备的当前选择 4, 还是 1
        local function checkSamePosCurSelect(equipPos)
            SL:Dump(PlayerEquip._samePosDiff, "PlayerEquip._samePosDiff-----", 3)
            if not PlayerEquip._samePosDiff[equipPos] then
                local itemData = SL:GetMetaValue("EQUIP_DATA", equipPos, true)
                if itemData and itemData.Where then
                    SL:Print("itemData.Where-----", tostring(itemData.Where))
                    return itemData.Where
                end
            end
            SL:Print("equipPos-2----", tostring(equipPos))
            return equipPos
        end
    
        -- 获取实际的装备位置(处理虚拟位置到实际位置的映射)
        local equipPos = PlayerEquip.fictionalUIPos and PlayerEquip.fictionalUIPos[pos] or pos
        
        -- 刷新装备移动状态的回调函数
        local function refreshMoveState(_, bool)
            -- 获取装备位置
            local setPos = equipPos
            
    
            -- 处理可显示装备的位置
            -- 检查是否为可显示的装备位置或特殊位置(如头盔/斗笠共用位置)
            -- "PlayerEquip._samePosDiff" = {
            -- }
            
            if GUIFunction:CheckCanShowEquipItem(setPos) or PlayerEquip._samePosDiff[setPos] then
                -- 获取对应位置的装备节点
                local itemNode = PlayerEquip._ui["Node_" .. setPos]
                
                -- 根据hideNodePos配置决定是否显示节点
                if PlayerEquip._hideNodePos[setPos] then
                    GUI:setVisible(itemNode, false)
                else
                    -- bool为true表示开始移动,false表示结束移动
                    -- 移动时隐藏原位置的装备显示
                    GUI:setVisible(itemNode, not bool)
                end
            else
                -- 处理UI模型装备位置的显示/隐藏
                local noEquip = nil
                if bool then -- 当开始移动装备时
                    -- 如果是头盔位置,获取实际的装备位置(处理头盔/斗笠共用位置的情况)
                    if setPos == GUIDefine.EquipPosUI.Equip_Type_Helmet then
                        setPos = checkSamePosCurSelect(GUIDefine.EquipPosUI.Equip_Type_Helmet)
                    end
                    
                    SL:Print("setPos-----", tostring(setPos))
                    -- 根据不同装备类型设置对应的显示标记
                    noEquip = {}
                    if setPos == GUIDefine.EquipPosUI.Equip_Type_Dress then
                        noEquip.NoCloth = true        -- 衣服
                    elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Weapon then
                        noEquip.NoWeapon = true       -- 武器
                    elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Helmet then
                        noEquip.NoHead = true         -- 头盔
                    elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Cap then
                        noEquip.NoCap = true          -- 斗笠
                    elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Shield then
                        noEquip.NoShield = true       -- 盾牌
                    elseif setPos == GUIDefine.EquipPosUI.Equip_Type_Veil then
                        noEquip.NoVeil = true         -- 面巾
                    end
                end
                -- 更新角色模型显示
                PlayerEquip.UpdatePlayerView(noEquip)
            end
    
            -- 处理实际UI位置的显示/隐藏(用于处理剑甲分离等特殊情况)
            if PlayerEquip.realUIPos and PlayerEquip.realUIPos[setPos] then 
                if bool then 
                    PlayerEquip.HideEquipItemsUI(setPos)   -- 开始移动时隐藏UI
                else 
                    PlayerEquip.ShowEquipItemsUI(setPos)   -- 结束移动时显示UI
                end 
            end
    
            -- 记录/清除移动中的装备数据
            if bool then
                -- 开始移动时记录装备数据
                PlayerEquip._moveItemData = SL:GetMetaValue("EQUIP_DATA", equipPos)
            else
                -- 结束移动时清除记录
                PlayerEquip._moveItemData = nil
            end
        end
    
        -- 移动结束回调,清理移动数据
        local function endMoveCallBack()
            PlayerEquip._moveItemData = nil
        end
    
        -- 双击卸下装备的回调函数
        local function doubleCallBack()
            -- 调试输出
            SL:Print("doubleCallBack-----")
    
            -- 如果有装备正在移动中,则不处理双击事件
            if PlayerEquip._moveItemData then
                return
            end
    
            -- 初始化是否需要获取装备列表的标志
            local isList = false
    
            -- 检查是否为特殊位置装备(如头盔/斗笠共用位置)
            -- "PlayerEquip._samePosDiff" = {
            -- }
            if not PlayerEquip._samePosDiff[equipPos] then
                -- 如果是头盔或高级头盔位置,需要获取装备列表
                isList = equipPos == GUIDefine.EquipPosUI.Equip_Type_Helmet or 
                        equipPos == GUIDefine.EquipPosUI.Equip_Type_Super_Helmet
            end
    
            -- 获取该位置的装备数据
            -- 参数说明:
            -- equipPos: 装备位置
            -- isList: 是否需要获取装备列表(用于处理同位置多件装备的情况)
            SL:Print("doubleCallBack-----", tostring(equipPos), tostring(isList))
            local itemData = SL:GetMetaValue("EQUIP_DATA", equipPos, isList)
            SL:Dump(itemData, "itemData-----", 3)
    
            -- 如果该位置有装备,则执行卸下操作
            if itemData then
                SL:TakeOffPlayerEquip(itemData)
            end
        end
    
        -- 鼠标滚动
        local function scrollCallBack(data)
            SL:onLUAEvent(LUA_EVENT_ITEMTIPS_MOUSE_SCROLL, data)
        end
    
        -- 创建可移动组件
        local panelSize = GUI:getContentSize(equipPanel)
        local equipWidget = GUI:MoveWidget_Create(equipPanel, "move_equip_" .. pos, panelSize.width / 2 , panelSize.height / 2, panelSize.width, panelSize.height, SL:GetMetaValue("ITEMFROMUI_ENUM").PALYER_EQUIP, {
            equipPos = equipPos,
            equipList = not PlayerEquip._samePosDiff[equipPos] and true or false,
            beginMoveCB = refreshMoveState,
            cancelMoveCB = refreshMoveState,
            endMoveCB = endMoveCallBack,
            pcDoubleCB = doubleCallBack,
            mouseScrollCB = scrollCallBack,
        })
    
        -- 鼠标移入延迟计时器
        local enterDelayTimer = nil
        -- 清理计时器函数
        local function CleanupTimer()
            if enterDelayTimer then
                GUI:stopAllActions(equipPanel)  --取消定时器
                enterDelayTimer = nil
            end
        end
    
        -- 鼠标移动显示装备信息的回调
        local function mouseMoveCallBack()
            SL:Print("mouseMoveCallBack-----", tostring(equipPos))
            local itemData = GetEquipDataByPos(equipPos, true)
            
            if not itemData or PlayerEquip._moveItemData then
                return
            end
            local panelPos = GUI:getWorldPosition(equipPanel)
            local data = {}
            data.itemData = itemData[#itemData] 
            data.itemData2 = itemData[#itemData - 1] --记录前面装备的信息
            data.itemData3 = itemData[#itemData - 2]
            data.pos = panelPos
            data.lookPlayer = false
            data.from = SL:GetMetaValue("ITEMFROMUI_ENUM").PALYER_EQUIP
            -- SL:Dump(data, "data-----", 3)
            -- SL:Print("data-#itemData--2--" .. tostring(#itemData))
            
            -- "data-----" = {
            --     "from"       = 2
            --     "itemData" = {
            --         "AddValues" = {
            --         }
            --         "Article"        = ""
            --         "Color"          = 251
            --         "Desc"           = ""
            --         "Dura"           = 7000
            --         "DuraMax"        = 7000
            --         "ExAbil" = {
            --             "abil" = *MAX NESTING*
            --             "abilex" = ""
            --             "name"   = ""
            --         }
            --         "ExtendInfo" = {
            --             "ItmSrc" = *MAX NESTING*
            --         }
            --         "Index"          = 50163
            --         "Looks"          = 147
            --         "MakeIndex"      = 14317
            --         "Name"           = "圣战戒指"
            --         "Need"           = 1
            --         "NeedLevel"      = 40
            --         "NeedLevelParam" = 24
            --         "OverLap"        = 1
            --         "Shape"          = 0
            --         "Source"         = 0
            --         "StdMode"        = 22
            --         "Values" = {
            --             1 = *MAX NESTING*
            --         }
            --         "Weight"         = 2
            --         "Where"          = 7
            --         "attribute"      = "3#12#1|3#4#7"
            --         "bEffect"        = ""
            --         "sEffect"        = ""
            --     }
            --     "lookPlayer" = false
            --     "pos" = {
            --         "x" = 917
            --         "y" = 328
            --     }
            -- }
            SL:OpenItemTips(data)
            CleanupTimer()
        end
    
        -- 鼠标进入回调
        local function onEnterFunc()
            if enterDelayTimer then
                return
            end
            -- 延迟显示装备信息提示
            enterDelayTimer = SL:scheduleOnce(equipPanel, function()
                mouseMoveCallBack()
            end, 0.05)
        end
    
        -- 鼠标离开回调
        local function onLeaveFunc()
            SL:CloseItemTips()
            CleanupTimer()
        end
    
        -- 添加鼠标移动事件监听
        GUI:addMouseMoveEvent(equipPanel, {
            onEnterFunc = onEnterFunc,
            onLeaveFunc = onLeaveFunc,
            checkIsVisible = true
        })
    end
    
    -- 初始化装备UI显示
    function PlayerEquip.InitEquipUI()
        -- 获取所有装备位置的数据
        local equipDataByPos = SL:GetMetaValue("EQUIP_POS_DATAS")  
        SL:Dump(equipDataByPos, "-----equipDataByPos-----", 3)
        
        -- "-----equipDataByPos-----" = {
        --     4  = 14334
        --     7  = 14317
        --     13 = 14323
        --     71 = 14354
        -- }
        -- 遍历每个装备位置
        for pos, data in pairs(equipDataByPos) do
            -- 获取对应位置的装备面板
            local equipPanel = PlayerEquip._ui["Panel_pos" .. pos]
            
            -- 检查该位置是否可以显示装备(普通位置或特殊位置如头盔/斗笠)
            if equipPanel and (GUIFunction:CheckCanShowEquipItem(pos) or PlayerEquip._samePosDiff[pos]) then
                -- 根据MakeIndex获取装备数据
                local item = SL:GetMetaValue("EQUIP_DATA_BY_MAKEINDEX", data)
                if item then 
                    -- 获取装备显示节点
                    local itemNode = PlayerEquip._ui["Node_"..pos]
                    -- 清除节点上的所有子节点
                    GUI:removeAllChildren(itemNode)
                    -- 创建单个并显示装备
                    PlayerEquip.CreateEquipItem(itemNode, item, pos)
                end
            end
            -- 显示该位置的装备UI
            PlayerEquip.ShowEquipItemsUI(pos)
        end
    end
    
    -- --创建装备显示
    function PlayerEquip.CreateEquipItem(parent, data, uiPos)
        
        local function checkPos(uiPos)
            if PlayerEquip.fictionalUIPos and PlayerEquip.fictionalUIPos[uiPos] then 
                local pos = PlayerEquip.fictionalUIPos[uiPos]
                if pos == GUIDefine.EquipPosUI.Equip_Type_Dress or pos == GUIDefine.EquipPosUI.Equip_Type_Weapon then
                    return false
                end
            end
            return true
        end
    
        local info = {}
        info.itemData = data
        info.index = data.Index
        info.noMouseTips = true  --鼠标移入不显示tips
        info.showModelEffect = checkPos(uiPos)
        info.from = SL:GetMetaValue("ITEMFROMUI_ENUM").PALYER_EQUIP  --物品来自玩家身上
        local item = GUI:ItemShow_Create(parent, "item_" .. uiPos, 0, 0, info) -- 创建物品框  --- 最核心的一步
        -- "info-----" = {
        -- "from"            = 2
        -- "index"           = 51098
        -- "itemData" = {
        --         "AddValues" = {
        --         }
        --         "Article"    = ""
        --         "Dura"       = 5000
        --         "DuraMax"    = 5000
        --         "ExAbil" = {
        --             "abil" = *MAX NESTING*
        --             "abilex" = ""
        --             "name"   = ""
        --         }
        --         "ExtendInfo" = {
        --             "ItmSrc" = *MAX NESTING*
        --         }
        --         "Index"      = 51098
        --         "Looks"      = 1782
        --         "MakeIndex"  = 14354
        --         "OverLap"    = 1
        --         "StdMode"    = 10001
        --         "Values" = {
        --         }
        --         "Where"      = 71
        --         "bEffect"    = ""
        --         "sEffect"    = ""
        --     }
        --     "noMouseTips"     = true
        --     "showModelEffect" = true
        -- }
        GUI:setAnchorPoint(item, 0.5, 0.5)
    end
    
    function PlayerEquip.InitEquipCells() 
        local uid = SL:GetMetaValue("USER_ID")
        -- 请求通知脚本查看uid的珍宝
        SL:RequestLookZhenBao(uid)
        -- 额外的装备位置
        local equipPosSet = SL:GetMetaValue("SERVER_OPTION", SW_KEY_EQUIP_EXTRA_POS) or 0 --是否开启6格
        local showExtra = equipPosSet == 1
        if showExtra then --开启6格后,把装备位置设置到PlayerEquip.posSetting中
            
            table.insert(PlayerEquip.posSetting, 14)
            table.insert(PlayerEquip.posSetting, 15)
        else
            GUI:setVisible(PlayerEquip._ui.Panel_pos14, false)
            GUI:setVisible(PlayerEquip._ui.Panel_pos15, false)
            GUI:setVisible(PlayerEquip._ui.Node_14, false)
            GUI:setVisible(PlayerEquip._ui.Node_15, false)
        end
    
        -- 剑甲分离配置
        if SL:GetMetaValue("GAME_DATA", "DivideWeaponAndClothes") == 1 then 
            GUI:setVisible(PlayerEquip._ui.Panel_pos1000, true)
            GUI:setVisible(PlayerEquip._ui.Panel_pos1001, true)
            GUI:setVisible(PlayerEquip._ui.Node_1000, true)
            GUI:setVisible(PlayerEquip._ui.Node_1001, true)
            table.insert(PlayerEquip.posSetting, 1000)
            table.insert(PlayerEquip.posSetting, 1001)
        end 
    end
    
    function PlayerEquip.RefreshGuildInfo() -- 在人物装备栏显示行会信息
        local textGuildInfo = PlayerEquip._ui.Text_guildinfo
        local guildData = SL:GetMetaValue("GUILD_INFO") -- 行会数据
        local myGuildName = guildData.guildName  --行会名字
        local myJobName = SL:GetMetaValue("GUILD_OFFICIAL", guildData.rank) --行会职位
        if not myGuildName then
            return
        end
        myJobName = myJobName or ""
    
        local guildInfo = myGuildName .. " " .. myJobName
        GUI:Text_setString(textGuildInfo, guildInfo)  --设置装备栏显示行会信息
    
        local color = SL:GetMetaValue("USER_NAME_COLOR") --获取玩家名字颜色值
        if color and color > 0 then
            GUI:Text_setTextColor(textGuildInfo, SL:GetHexColorByStyleId(color))
        end
    end
    
    --刷新首饰盒状态,鼠标放上去显示提示
    function PlayerEquip.RefreshPlayerBestRingsOpenState(data)
        local activeState = SL:GetMetaValue("BEST_RING_OPENSTATE", PlayerEquip.RoleType.Self)  --首饰盒是否激活
        if activeState then
            GUI:Image_setGrey(PlayerEquip._ui.Image_box, false)
        else
            GUI:Image_setGrey(PlayerEquip._ui.Image_box, true)  -- 没激活显示灰色
        end
        
        local function mouseMoveCallBack(touchPos)  -- 鼠标移动到首饰盒上回调函数
            if not GUI:getVisible(PlayerEquip._ui.Best_ringBox) then 
                return
            end
            local bestRingsName = SL:GetMetaValue("SERVER_OPTION", "SndaItemBoxName") or "饰盒"
            if SL:CheckNodeCanCallBack(PlayerEquip._ui.Best_ringBox, touchPos) and bestRingsName ~= "" then
                local tips = nil
                local activeState = SL:GetMetaValue("BEST_RING_OPENSTATE", PlayerEquip.RoleType.Self)
                if activeState then
                    tips = string.format("点击打开%s", bestRingsName)
                else
                    tips = string.format("%s未开启", bestRingsName)
                end
                local worldPos = GUI:getWorldPosition(PlayerEquip._ui.Best_ringBox)
                worldPos.x = GUI:getContentSize(PlayerEquip._ui.Best_ringBox).width/2 + worldPos.x
                GUI:ShowWorldTips(tips, worldPos, GUI:p(0.5, 1)) --设置提示文本中心
            end
        end
    
        local function leaveItem()
            GUI:HideWorldTips() --移走时关闭提示文本
        end
    
        --绑定鼠标移动事件
        GUI:addMouseMoveEvent(PlayerEquip._ui.Best_ringBox,
            {
                onEnterFunc = mouseMoveCallBack,
                onLeaveFunc = leaveItem
            }
        )
        if data and data.isOpen then
            if activeState then
                SL:OpenBestRingBoxUI(PlayerEquip.RoleType.Self, { param = {} })
            end
        end
    end
    
    function PlayerEquip.RefreshBestRingBox()  -- 打开首饰盒,播放首饰盒按钮动画
        SL:scheduleOnce(PlayerEquip._ui.Best_ringBox,function()
            local texture = "btn_jewelry_1_1.png"
            if SL:GetMetaValue("BEST_RING_WIN_ISOPEN", PlayerEquip.RoleType.Self) then -- 首饰盒界面是否打开
                texture = "btn_jewelry_1_0.png"
            end
            GUI:Image_loadTexture(PlayerEquip._ui.Image_box, SLDefine.PATH_RES_PRIVATE .. "player_best_rings_ui/player_best_rings_ui_win32/" .. texture)
            -- 重置尺寸
            GUI:setIgnoreContentAdaptWithSize(PlayerEquip._ui.Image_box, true)
            PlayerEquip.RefreshPlayerBestRingsOpenState()
        end,0.1)
    end
    
    -- 获取装备在UI上的实际显示位置
    function PlayerEquip.GetShowUIPosByItemWhere(pos)
        -- 获取装备位置类型配置
        local typeConfig = GUIDefine.EquipPosUI
        
        -- 将斗笠和面巾的位置映射到头盔位置
        if pos == typeConfig.Equip_Type_Cap or pos == typeConfig.Equip_Type_Veil then
            SL:Print("pos1---GetShowUIPosByItemWhere--", tostring(pos))
            pos = typeConfig.Equip_Type_Helmet
            SL:Print("pos--2-GetShowUIPosByItemWhere--", tostring(pos))
        -- 将高级斗笠和高级面巾的位置映射到高级头盔位置    
        elseif pos == typeConfig.Equip_Type_Super_Cap or pos == typeConfig.Equip_Type_Super_Veil then
            pos = typeConfig.Equip_Type_Super_Helmet
        end
        
        return pos
    end
    
    
    
    -- 更新装备时传递的参数
    -- data = {
    --      "MakeIndex" = 14225,
    --      "Where"     = 1,
    --      "opera"     = 2,
    -- }
    function PlayerEquip.UpdateEquipUI(data) --玩家换装备时,界面更新装备的显示
        
        if not data or not next(data) then
            return
        end
        local operatorType = data.opera
        local MakeIndex = data.MakeIndex
        local pos = data.Where
        if not PlayerEquip._samePosDiff[pos] then
            if not PlayerEquip._pos13Visible or pos ~= 55 then --面巾不处理
                pos = PlayerEquip.GetShowUIPosByItemWhere(pos) --获取显示装备的位置
                SL:Dump(pos, "pos-----", 3)
            end
        end
    
        local equipPanel = PlayerEquip._ui["Panel_pos" .. pos]  --不存在的装备panel直接退出
        if not equipPanel then
            return
        end
        local isShowItem = false 
        if GUIFunction:CheckCanShowEquipItem(pos) or PlayerEquip._samePosDiff[pos] then
            isShowItem = true  -- 可以显示装备
        end
    
        PlayerEquip._moveItemData = nil
        if operatorType == 1 then -- 增
            if isShowItem then
                local itemNode = PlayerEquip._ui["Node_" .. pos]
                if not PlayerEquip._hideNodePos[pos] then 
                    GUI:setVisible(itemNode, true) --不是隐藏节点,则显示出来
                else
                    GUI:setVisible(itemNode, false)
                end
                GUI:removeAllChildren(itemNode)  --删除掉子节
                local item = SL:GetMetaValue("EQUIP_DATA_BY_MAKEINDEX", MakeIndex)  --根据MakeIndex获取装备数据
                -- "item" = {
                --     "AddValues" = {
                --     }
                --     "Dura"       = 7000
                --     "DuraMax"    = 7000
                --     "ExAbil" = {
                --         "abil" = *MAX NESTING*
                --         "abilex" = ""
                --         "name"   = ""
                --     }
                --     "ExtendInfo" = {
                --         "ItmSrc" = *MAX NESTING*
                --     }
                --     "Index"      = 50163
                --     "MakeIndex"  = 14227
                --     "OverLap"    = 1
                --     "Values" = {
                --     }
                --     "Where"      = 7
                -- }
                PlayerEquip.CreateEquipItem(itemNode, item, pos) --创建装备显示
                if PlayerEquip._samePosDiff[pos] and PlayerEquip.showModelCapAndHelmet then 
                    
                    PlayerEquip.UpdatePlayerView()
                    PlayerEquip.ShowEquipItemsUI(pos)
                end
            else
                PlayerEquip.UpdatePlayerView()
                PlayerEquip.ShowEquipItemsUI(pos)
            end
        elseif operatorType == 2 then -- 删
            if isShowItem then
                local itemNode = PlayerEquip._ui["Node_" .. pos]
                GUI:removeAllChildren(itemNode)
                if PlayerEquip._samePosDiff[pos] and PlayerEquip.showModelCapAndHelmet then 
                    PlayerEquip.UpdatePlayerView()
                    PlayerEquip.HideEquipItemsUI(pos)
                end
            else
                PlayerEquip.UpdatePlayerView()
                PlayerEquip.HideEquipItemsUI(pos)
            end
        elseif operatorType == 3 then -- 改
            -- 如果更新的装备不是更新Look  不进行更新内观的刷新
            if not data.isChangeLook then
                return
            end
    
            if isShowItem then
                local itemNode = PlayerEquip._ui["Node_" .. pos]
                GUI:removeAllChildren(itemNode)
                local item = SL:GetMetaValue("EQUIP_DATA_BY_MAKEINDEX", MakeIndex)
                PlayerEquip.CreateEquipItem(itemNode, item, pos)
                if PlayerEquip._samePosDiff[pos] and PlayerEquip.showModelCapAndHelmet then 
                    PlayerEquip.UpdatePlayerView()
                end
            else
                PlayerEquip.UpdatePlayerView()
            end
        end
    end
    
    -- 更新色模型显示
    function PlayerEquip.UpdatePlayerView(noEquipType, init)
        -- 清除现有模型
        GUI:removeAllChildren(PlayerEquip._ui.Node_playerModel)
        -- 获取装备数据和配置
        -- "equipDataByPos" = {
        --     1 = 14225
        --     5 = 14231
        --     7 = 14227
        -- }
        local equipDataByPos = SL:GetMetaValue("EQUIP_POS_DATAS")
        local equipTypeConfig = GUIDefine.EquipPosUI  --获取装备位置信息  "Equip_Type_Weapon"            = 1
    
        
        noEquipType = noEquipType or {}
    
        local showNakedMold = true -- 是否显示裸模,默认显示
        local showHelmet = false   -- 是否显示头盔
        
        -- 获取外观文件名和类型
        local function getFileName(looks)
            local fileName = string.format("%06d", looks % 10000)
            return fileName, math.floor(looks / 10000)
        end
    
        -- 获取装备外观数据
        -- @param equipType - 装备类型ID
        -- @param need - 是否需要强制不显示该装备
        -- @return table - 包含外观ID和特效ID的数据表
        local function GetLooks(equipType, need)
            -- 初始化返回的外观数据结构
            local show = {
                look = nil,    -- 外观ID
                effect = nil   -- 特效ID
            }
            
            -- 如果是时装类型(ID > 10000),返回空的时装数据
            if equipType > 10000 then
                local fashionShow = {}
                return fashionShow
            end
            
            -- 只有在不强制隐藏且装备类型存在时才处理
            if not need and equipType and equipDataByPos[equipType] then
                -- 获取装备数据和配置
                -- "equipDataByPos" = {
                --     1 = 14225
                --     5 = 14231
                --     7 = 14227
                -- }
                local MakeIndex = equipDataByPos[equipType]
                
                -- 如果是初始化且装备正在移动中,不显示该装备
                if init and PlayerEquip._moveItemData and MakeIndex == PlayerEquip._moveItemData.MakeIndex then
                    return show
                end
                
                -- 获取装备详细数据
                local equipData = SL:GetMetaValue("EQUIP_DATA_BY_MAKEINDEX", MakeIndex) or {}
    
                -- 处理衣服的裸模显示逻辑
                -- 如果是衣服且有荣誉出售标记,则不显示裸模
                if equipType == equipTypeConfig.Equip_Type_Dress then
                    if showNakedMold and equipData and equipData.shonourSell and tonumber(equipData.shonourSell) == 1 then
                        showNakedMold = false
                    end
                end
    
                -- 设置装备的外观ID和特效ID
                if equipData and equipData.Looks then
                    show.look = equipData.Looks
                end
                if equipData and equipData.sEffect then
                    show.effect = equipData.sEffect
                end
    
                -- 处理斗笠的特殊显示逻辑
                -- 如果是斗笠且没有动画,则显示头盔
                if equipType == equipTypeConfig.Equip_Type_Cap and equipData.AniCount == 0 then
                    showHelmet = true
                end
    
                -- 处理特殊位置装备的显示逻辑
                -- 如果是特殊位置且不显示斗笠和头盔,则返回空外观
                if PlayerEquip._samePosDiff[equipType] and not PlayerEquip.showModelCapAndHelmet then
                    return {
                        look = nil,
                        effect = nil
                    }
                end
    
                return show
            end
            
            return show
        end
    
        -- 获取角色基础信息
        local hairID        = SL:GetMetaValue("HAIR")
        local clothShow     = GetLooks(equipTypeConfig.Equip_Type_Dress, noEquipType.NoCloth)
        local weaponShow    = GetLooks(equipTypeConfig.Equip_Type_Weapon, noEquipType.NoWeapon)
        local headShow      = GetLooks(equipTypeConfig.Equip_Type_Helmet, noEquipType.NoHead)
        local capShow       = GetLooks(equipTypeConfig.Equip_Type_Cap, noEquipType.NoCap)
        local shieldShow    = GetLooks(equipTypeConfig.Equip_Type_Shield, noEquipType.NoShield)
        local veilShow      = GetLooks(equipTypeConfig.Equip_Type_Veil, noEquipType.NoVeil)
        local tDressShow    = GetLooks(10004)
        local tWeaponShow   = GetLooks(10005)
        local embattle      = SL:GetMetaValue("EMBATTLE")  -- 法阵ID
    
        local modelData = {
            clothID         = clothShow.look,
            clothEffectID   = clothShow.effect,
            weaponID        = weaponShow.look,
            weaponEffectID  = weaponShow.effect,
            headID          = headShow.look,
            headEffectID    = headShow.effect,
            hairID          = hairID,
            capID           = capShow.look,
            capEffectID     = capShow.effect,
            veilID          = veilShow.look,
            veilEffectID    = veilShow.effect,
            shieldID        = shieldShow.look,
            shieldEffectID  = shieldShow.effect,
            tDressID        = tDressShow.look,
            tDressEffectID  = tDressShow.effect,
            tWeaponID       = tWeaponShow.look,
            tWeaponEffectID = tWeaponShow.effect,
            embattlesID     = embattle,
            notShowMold     = not showNakedMold,
            notShowHair     = not showNakedMold,
        }
    
        local sex = SL:GetMetaValue("SEX")
        local job = SL:GetMetaValue("JOB")
        local uiModel = GUI:UIModel_Create(PlayerEquip._ui.Node_playerModel, "model", 0, 0, sex, modelData, nil, true, job, {showHelmet = showHelmet})
        GUI:setAnchorPoint(uiModel, 0.5, 0.5)
    end
    
    -- 显示装备物品的UI界面
    -- @param pos - 装备位置ID
    function PlayerEquip.ShowEquipItemsUI(pos)
        -- 检查参数是否有效
        if not pos then 
            return 
        end 
    
        -- 检查是否存在实际UI位置的映射关系
        -- realUIPos用于处理剑甲分离等特殊装备位置的显示
        if not PlayerEquip.realUIPos or not PlayerEquip.realUIPos[pos] then 
            
            return 
        end 
    
        -- 获取该位置的装备数据
        local data = SL:GetMetaValue("EQUIP_DATA", pos)
        SL:Dump(data, "data-----", 3)
        if not data then 
            return 
        end 
    
        -- 获取实际的UI显示位置
        local UIPos = PlayerEquip.realUIPos[pos]
    
        -- 获取装备面板并检查其可见性
        local itemPanel = PlayerEquip._ui["Panel_pos" .. UIPos]
        local bShow = GUI:getVisible(itemPanel)
        if not bShow then 
            return 
        end 
    
        -- 获取装备显示节点
        local itemNode = PlayerEquip._ui["Node_" .. UIPos]
        if not itemNode then   
            return 
        end 
        
        -- 显示装备节点并清除其所有子节点
        GUI:setVisible(itemNode, true)
        GUI:removeAllChildren(itemNode)
    
        -- 创建并显示装备物品
        PlayerEquip.CreateEquipItem(itemNode, data, UIPos)
    end
    
    -- 隐藏装备物品的UI界面
    -- @param pos - 装备���置ID
    function PlayerEquip.HideEquipItemsUI(pos)
        SL:Dump(pos, "pos-----", 3)
        SL:Dump(PlayerEquip.realUIPos, "PlayerEquip.realUIPos-----", 3)
        -- 检查参数是否有效
        if not pos then 
            return 
        end 
    
        -- 检查是否存在实际UI位置的映射关系
        -- realUIPos用于处理剑甲分离等特殊装备位置的显示
        if not PlayerEquip.realUIPos or not PlayerEquip.realUIPos[pos] then 
            return 
        end 
    
        -- 获取实际的UI显示位置
        local UIPos = PlayerEquip.realUIPos[pos] 
    
        -- 获取装备面板并检查其可见性
        local itemPanel = PlayerEquip._ui["Panel_pos" .. UIPos]
        local bShow = GUI:getVisible(itemPanel)
        if not bShow then 
            return 
        end 
    
        -- 获取装备显示节点
        local itemNode = PlayerEquip._ui["Node_"..UIPos]
        if not itemNode then   
            return 
        end 
    
        -- 隐藏装备节点并清除其所有子节点
        GUI:setVisible(itemNode, false)
        GUI:removeAllChildren(itemNode)
    end
    
    -- 处理打开或关闭窗口的事件
    -- @param data - 窗口名称
    function PlayerEquip.OnOpenOrCloseWin(data)
        -- 如果是首饰盒界面,刷新首饰盒显示
        if data == "PlayerBestRingGUI" then
            PlayerEquip.RefreshBestRingBox()
        end
    end
    
    --[[    
        界面关闭回调
    ]]
    function PlayerEquip.CloseCallback()
        PlayerEquip.UnRegisterEvent()
    end
    
    function PlayerEquip.RegisterEvent()
        --刷新行会信息
        SL:RegisterLUAEvent(LUA_EVENT_PLAYER_GUILD_INFO_CHANGE, "PlayerEquip", PlayerEquip.RefreshGuildInfo)
        -- 刷新装备信息
        SL:RegisterLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, "PlayerEquip", PlayerEquip.UpdateEquipUI)
        -- 刷新法阵
        SL:RegisterLUAEvent(LUA_EVENT_PLAYER_EMBATTLE_CHANGE, "PlayerEquip", PlayerEquip.UpdatePlayerView)
        -- 刷新性别
        SL:RegisterLUAEvent(LUA_EVENT_PLAYER_SEX_CHANGE, "PlayerEquip", PlayerEquip.UpdatePlayerView)
        -- 打开/关闭界面
        SL:RegisterLUAEvent(LUA_EVENT_OPENWIN, "PlayerEquip", PlayerEquip.OnOpenOrCloseWin)
        SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, "PlayerEquip", PlayerEquip.OnOpenOrCloseWin)
        -- 首饰盒状态改变
        SL:RegisterLUAEvent(LUA_EVENT_BESTRINGBOX_STATE, "PlayerEquip", PlayerEquip.RefreshPlayerBestRingsOpenState)
    end
    
    function PlayerEquip.UnRegisterEvent()
        SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_GUILD_INFO_CHANGE, "PlayerEquip")
        SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, "PlayerEquip")
        SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_EMBATTLE_CHANGE, "PlayerEquip")
        SL:UnRegisterLUAEvent(LUA_EVENT_PLAYER_SEX_CHANGE, "PlayerEquip")
        SL:UnRegisterLUAEvent(LUA_EVENT_OPENWIN, "PlayerEquip")
        SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, "PlayerEquip")
        SL:UnRegisterLUAEvent(LUA_EVENT_BESTRINGBOX_STATE, "PlayerEquip")
    end
      撰写回复...