local addonName, ZLAUTO = ...
local ZL = ZLAUTO.mainFrame
local ZLCreateFrame = ZL.ZLCreateFrame
local CreateButton = ZL.CreateButton
local CreateEditBox = ZL.CreateEditBox
local CreateDynamicTable = ZL.CreateDynamicTable
local GameTooltipShow = ZL.GameTooltipShow
local cGetItemInfo = C_Item and C_Item.GetItemInfo or GetItemInfo
local cGetItemIcon = C_Item and C_Item.GetItemIconByID or GetItemIcon

local LibSerialize = LibStub("LibSerialize")
local LibDeflate = LibStub("LibDeflate")

local INVTYPE_LIST = {"头", "项链", "肩膀", "披风", "胸部", "手腕", "手", "腰带", "腿", "脚", "戒指1", "戒指2", "饰品1", "饰品2", "主手", "副手", "远程", "其他"}

local InventoryType = {
    INVTYPE_HEAD = "头", INVTYPE_NECK = "项链", INVTYPE_SHOULDER = "肩膀", INVTYPE_CLOAK = "披风", INVTYPE_CHEST = "胸部", INVTYPE_ROBE = "胸部",
    INVTYPE_WRIST = "手腕", INVTYPE_HAND = "手", INVTYPE_WAIST = "腰带", INVTYPE_LEGS = "腿", INVTYPE_FEET = "脚",
    INVTYPE_FINGER = "戒指", INVTYPE_TRINKET = "饰品", INVTYPE_WEAPON = "主手", INVTYPE_SHIELD = "副手", INVTYPE_RANGED = "远程",
    INVTYPE_2HWEAPON = "主手", INVTYPE_WEAPONMAINHAND = "主手", INVTYPE_WEAPONOFFHAND = "副手", INVTYPE_HOLDABLE = "副手",
    INVTYPE_THROWN = "主手", INVTYPE_RANGEDRIGHT = "远程", INVTYPE_RELIC = "远程",
}
local INVTYPE_BISTOOLTIP = {
    ["头"] = "Head",
    ["项链"] = "Neck",
    ["肩膀"] = "Shoulder",
    ["披风"] = "Back",
    ["胸部"] = "Chest",
    ["手腕"] = "Wrist",
    ["手"] = "Hands",
    ["腰带"] = "Waist",
    ["腿"] = "Legs",
    ["脚"] = "Feet",
    ["戒指"] = "Finger",
    ["饰品"] = "Trinket",
    ["主手"] = "Weapon",
    ["副手"] = "Off hand",
    ["远程"] = "Ranged",
}
local INVTYPETEXTURE_LIST = {
    ["头"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Head.blp",
    ["项链"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Neck.blp",
    ["肩膀"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Shoulder.blp",
    ["披风"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Chest.blp",
    ["胸部"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Chest.blp",
    ["手腕"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Wrists.blp",
    ["手"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Hands.blp",
    ["腰带"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Waist.blp",
    ["腿"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Legs.blp",
    ["脚"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Feet.blp",
    ["戒指"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Finger.blp",
    ["饰品"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Trinket.blp",
    ["主手"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-MainHand.blp",
    ["副手"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-SecondaryHand.blp",
    ["远程"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Ranged.blp",
    ["其他"] = "Interface\\Paperdoll\\UI-PaperDoll-Slot-Ranged.blp",
}

local CLASSNAME_LIST = {
    ["战士"] = "Warrior",
    ["圣骑士"] = "Paladin",
    ["猎人"] = "Hunter",
    ["潜行者"] = "Rogue",
    ["牧师"] = "Priest",
    ["死亡骑士"] = "Death knight",
    ["萨满祭司"] = "Shaman",
    ["法师"] = "Mage",
    ["术士"] = "Warlock",
    ["德鲁伊"] = "Druid",
}
local CLASSICON_LIST = {
    ["战士"] = 626008,
    ["圣骑士"] = 626003,
    ["猎人"] = 626000,
    ["潜行者"] = 626005,
    ["牧师"] = 626004,
    ["死亡骑士"] = 135771,
    ["萨满祭司"] = 626006,
    ["法师"] = 626001,
    ["术士"] = 626007,
    ["德鲁伊"] = 625999,
}
local SPECS_LIST = {
    ["Blood tank"] = "鲜血坦克", ["Frost"] = "冰霜", ["Unholy"] = "邪恶", ["Blood dps"] = "鲜血输出",
    ["Balance"] = "平衡", ["Feral tank"] = "野性坦克", ["Feral dps"] = "野性输出", ["Restoration"] = "恢复",
    ["Beast mastery"] = "野兽控制", ["Marksmanship"] = "射击", ["Survival"] = "生存",
    ["Arcane"] = "奥术", ["Fire"] = "火焰", ["Fire FFB"] = "霜火",
    ["Holy"] = "神圣", ["Protection"] = "防护", ["Retribution"] = "惩戒",
    ["Discipline"] = "戒律", ["Shadow"] = "暗影",
    ["Assassination"] = "刺杀", ["Subtlety"] = "敏锐", ["Combat"] = "战斗",
    ["Elemental"] = "元素", ["Enhancement"] = "增强",
    ["Affliction"] = "痛苦", ["Demonology"] = "恶魔学识", ["Destruction"] = "毁灭",
    ["Arms"] = "武器", ["Fury"] = "狂怒",
}
local SPECSICON_LIST = {
    ["Death knight"] = {
        ["classIcon"] = 135771,
        ["Blood tank"] = 135770,
        ["Frost"] = 135773,
        ["Unholy"] = 135775,
        ["Blood dps"] = 135770,
    },
    ["Druid"] = {
        ["classIcon"] = 625999,
        ["Balance"] = 136096,
        ["Feral tank"] = 132276,
        ["Feral dps"] = 132115,
        ["Restoration"] = 136041,
    },
    ["Hunter"] = {
        ["classIcon"] = 626000,
        ["Beast mastery"] = 132164,
        ["Marksmanship"] = 132222,
        ["Survival"] = 132215,
    },
    ["Mage"] = {
        ["classIcon"] = 626001,
        ["Arcane"] = 135932,
        ["Fire"] = 135810,
        ["Fire FFB"] = 236217,
        ["Frost"] = 135846,
    },
    ["Paladin"] = {
        ["classIcon"] = 626003,
        ["Holy"] = 135920,
        ["Protection"] = 135893,
        ["Retribution"] = 135873,
    },
    ["Priest"] = {
        ["classIcon"] = 626004,
        ["Discipline"] = 135987,
        ["Holy"] = 135953,
        ["Shadow"] = 136207,
    },
    ["Rogue"] = {
        ["classIcon"] = 626005,
        ["Assassination"] = 132292,
        ["Combat"] = 132090,
        ["Subtlety"] = 132320,
    },
    ["Shaman"] = {
        ["classIcon"] = 626006,
        ["Elemental"] = 136048,
        ["Enhancement"] = 136051,
        ["Restoration"] = 136052,
    },
    ["Warlock"] = {
        ["classIcon"] = 626007,
        ["Affliction"] = 136145,
        ["Demonology"] = 136172,
        ["Destruction"] = 136186,
        ["Destruction fire"] = 136186,
    },
    ["Warrior"] = {
        ["classIcon"] = 626008,
        ["Arms"] = 132292,
        ["Fury"] = 132347,
        ["Protection"] = 134952,
    },
}


function ZL:CreateConcernFrame()
    if not ZL.opt.concernList then ZL.opt.concernList = {} end
    local concernList = ZL.opt.concernList
    local realmKey = GetRealmName()
    local charKey = ZL.GetClassColorName(UnitName("player")) .. " - " .. realmKey
    local className = UnitClass("player")
    local classIcon = CLASSICON_LIST[className]
    --更改关注物品戒指和饰品数据库结构
    if ZL.opt.concernList and next(ZL.opt.concernList) then
        for _, data in pairs(ZL.opt.concernList) do
            if data.slotInfo and data.slotInfo["戒指"] then
                data.slotInfo["戒指1"] = data.slotInfo["戒指"]
                data.slotInfo["戒指"] = nil
                data.slotInfo["戒指2"] = {}
            end
            if data.slotInfo and data.slotInfo["饰品"] then
                data.slotInfo["饰品1"] = data.slotInfo["饰品"]
                data.slotInfo["饰品"] = nil
                data.slotInfo["饰品2"] = {}
            end
        end
    end
    for _, data in pairs(ZL.opt.concernList) do
        if data.slotInfo then
            data.peiZhuangList = {}
            local maxPeiZhuang = 0
            for _, invtype in ipairs(INVTYPE_LIST) do
                maxPeiZhuang = max(maxPeiZhuang, #data.slotInfo[invtype])
            end
            for i = 1, maxPeiZhuang do
                local tempList = {}
                for _, invtype in ipairs(INVTYPE_LIST) do
                    tempList[invtype] = data.slotInfo[invtype][i]
                end
                tinsert(data.peiZhuangList, tempList)
            end
            data.slotInfo = nil
        end
    end

    if (not concernList[charKey]) and ((not ZL.opt.concernType) or (not ZL.opt.concernType.deleteList[charKey])) then
        concernList[charKey] = {
            ["classInfo"] = {
                icon = classIcon,
                class = className,
                hasRelic = UnitHasRelicSlot("player"),
            },
            ["peiZhuangList"] = {},
            ["itemList"] = {},
        }
    end
    local function profileDropdownList()
        local tempList = {}
        local tempDownList = {}
        if concernList then
            for _charKey in pairs(concernList) do
                tinsert(tempList, _charKey)
            end
            table.sort(tempList)
            for i, _charKey in ipairs(tempList) do
                if (not ZL.opt.concernType) or (not ZL.opt.concernType.hideList[_charKey]) then
                    tinsert(tempDownList, {
                        text = "|T" .. concernList[_charKey]["classInfo"]["icon"] .. ":0:0:2:0|t " .. _charKey,
                        value = i,
                    })
                end
            end
        end
        wipe(tempList)
        tempList = nil
        return tempDownList
    end

    ZL.ConcernFrame = ZLCreateFrame("ZLConcernFrame", ZL, nil, nil, nil, nil, true, "关注物品")
    local ConcernFrame = ZL.ConcernFrame
    tinsert(UISpecialFrames, ConcernFrame:GetName())
    ConcernFrame:SetScript("OnMouseUp", function (self)
        self:StopMovingOrSizing()
        if not ZL.db.global.ZLConcernFrame then ZL.db.global.ZLConcernFrame = {} end
        ZL.db.global.ZLConcernFrame.point, _, ZL.db.global.ZLConcernFrame.relative, ZL.db.global.ZLConcernFrame.x, ZL.db.global.ZLConcernFrame.y = self:GetPoint()
    end)
    ConcernFrame:SetScript("OnMouseDown", function (self)
        self:StartMoving()
    end)
    ConcernFrame:SetScript("OnShow", function (self)
        ConcernFrame:Update()
    end)
    -- 设置鼠标按下时开始调整大小
    local resizeButton = ConcernFrame.resizeButton
    resizeButton:SetScript("OnMouseDown", function(self, button)
        if button == "LeftButton" then
            ConcernFrame:StartSizing("BOTTOMRIGHT")
        end
    end)
    -- 鼠标松开时停止调整大小
    resizeButton:SetScript("OnMouseUp", function(self, button)
        ConcernFrame:StopMovingOrSizing()
        if not ZL.db.global.ZLConcernFrame then ZL.db.global.ZLConcernFrame = {} end
        ZL.db.global.ZLConcernFrame.Width,  ZL.db.global.ZLConcernFrame.Height= ConcernFrame:GetSize()
    end)
    ConcernFrame:ClearAllPoints()
    if ZL.opt.ZLConcernFrame and ZL.opt.ZLConcernFrame.point then
        ConcernFrame:SetPoint(ZL.opt.ZLConcernFrame.point, UIParent, ZL.opt.ZLConcernFrame.relative, ZL.opt.ZLConcernFrame.x, ZL.opt.ZLConcernFrame.y)
    else
        ConcernFrame:SetPoint("CENTER")
    end
    if ZL.db.global.ZLConcernFrame and ZL.db.global.ZLConcernFrame.Width and ZL.db.global.ZLConcernFrame.Height then
        ConcernFrame:SetSize(ZL.db.global.ZLConcernFrame.Width, ZL.db.global.ZLConcernFrame.Height)
    end

    ConcernFrame.infoBtn = CreateFrame("Button", nil, ConcernFrame)
    ConcernFrame.infoBtn:SetSize(25, 25)
    ConcernFrame.infoBtn:SetPoint("TOPLEFT", 3, 0)
    ConcernFrame.infoBtn:SetNormalTexture(616343)
    ConcernFrame.infoBtn:SetHighlightTexture(616343)
    ConcernFrame.infoBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("添加关注物品5种方式：")
        GameTooltip:AddLine("1、直接输入物品ID添加", 1, 1, 1)
        GameTooltip:AddLine("2、聊天窗口|cff00ff00右键|r点击物品链接，点|cff00ff00关注|r", 1, 1, 1)
        GameTooltip:AddLine("3、打开AtlasLoot插件|cffff0000(需安装)|r，|cff00ff00右键|r点击物品图标", 1, 1, 1)
        GameTooltip:AddLine("4、点击部位按钮，弹出BisTooltip插件|cffff0000(需安装)|r，选择对应物品关注", 1, 1, 1)
        GameTooltip:AddLine("5、拍卖清单、账单总览、拾取记录、对账单窗口|cff00ff00双击|r物品图标关注", 1, 1, 1)
        GameTooltip:Show()
    end)
    ConcernFrame.infoBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)

    ConcernFrame.profileDropdown = CreateFrame("Button", nil, ConcernFrame)
    local profileDropdown = ConcernFrame.profileDropdown
    profileDropdown:SetPoint("TOPLEFT", ConcernFrame.TitleBottom, "BOTTOMLEFT", 5, -5)
    profileDropdown:SetSize(211, 24)
    ZL.GUI:GetClass('Dropdown'):Bind(profileDropdown)
    if (not ZL.opt.concernType) or (not ZL.opt.concernType.deleteList[charKey]) then
        profileDropdown:SetDefaultText("|T" .. classIcon .. ":0:0:2:0|t " .. charKey)
    else
        profileDropdown:SetDefaultText(" ")
    end
    profileDropdown:SetMenuTable(profileDropdownList)
    profileDropdown:SetCallback('OnSelectChanged', function ()
        local selectCharKey = profileDropdown:GetText()
        selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
        if selectCharKey ~= charKey then
            local msgStr = "注意：已切换为非当前账号配置\n添加和删除关注物品将保存到：" .. selectCharKey
            ZL.Print(msgStr)
        end
        ConcernFrame:Update()
    end)

    ConcernFrame.exportBtn = CreateButton(nil, ConcernFrame, "导出", "LEFT", profileDropdown, "RIGHT", 5, 0, 40, 24, 14)
    local exportBtn= ConcernFrame.exportBtn
    exportBtn:SetScript("OnClick", function ()
        local selectCharKey = profileDropdown:GetText()
        selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
        if not selectCharKey then return end
        if concernList and concernList[selectCharKey] and concernList[selectCharKey]["itemList"]
        and next(concernList[selectCharKey]["itemList"]) then
            local data = concernList[selectCharKey]
            local serialized = LibSerialize:Serialize(data)
            local compressed = LibDeflate:CompressDeflate(serialized)
            local encoded = "!AutoAuction:1!" .. LibDeflate:EncodeForPrint(compressed)
            if not ZL.WaStringFrame then ZL:CreateWAStringFrame() end
            local editBox = ZL.WaStringFrame.scrollFrame.editBox
            ZL.WaStringFrame.Title:SetText("【" .. selectCharKey .. "】关注物品数据|cff87CEEB导出|r")
            editBox:SetScript("OnTextChanged", function (self) self:HighlightText() end)
            editBox:SetScript("OnMouseUp", function(self) self:HighlightText() end)
            editBox:SetScript("OnEscapePressed", function() ZL.WaStringFrame:Hide() end)
            editBox:SetText(encoded)
            editBox:HighlightText()
            editBox:SetFocus()
            ZL.WaStringFrame:Show()
            encoded = nil
            compressed = nil
            serialized = nil
        else
            ZL.Print("【" .. selectCharKey .. "】没有关注物品数据！")
        end
    end)

    ConcernFrame.hideBtn = CreateButton(nil, ConcernFrame, "隐藏", "LEFT", exportBtn, "RIGHT", 5, 0, 40, 24, 14)
    local hideBtn= ConcernFrame.hideBtn
    hideBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("隐藏角色")
        GameTooltip:AddLine("不删除数据，只有登录该角色\n时才可以看到关注数据", 1, 1, 1)
        GameTooltip:Show()
    end)
    hideBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    hideBtn:SetScript("OnClick", function (self)
        local function tempfunc()
            local menuList = {{text="隐藏角色", isTitle=true}}
            local charList = {}
            for _charKey in pairs(concernList) do
                tinsert(charList, _charKey)
            end
            table.sort(charList)
            if not ZL.opt.concernType then ZL.opt.concernType = {hideList={}, deleteList={}} end
            local concernType = ZL.opt.concernType
            for _, _charKey in ipairs(charList) do
                tinsert(menuList, {
                    text = "|T" .. concernList[_charKey]["classInfo"]["icon"] .. ":0:0:2:0|t " .. _charKey,
                    checkable = 1,
                    checked = concernType.hideList[_charKey],
                    isNotRadio = 1,
                    keepShownOnClick = 1,
                    func = function (_, data)
                        if data.checked then
                            -- data.checked = 1
                            concernType.hideList[_charKey] = true
                            local selectCharKey = ConcernFrame.profileDropdown:GetText()
                            selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
                            if _charKey == selectCharKey then
                                local tempDownList = profileDropdownList()
                                if #tempDownList > 0 then
                                    ConcernFrame.profileDropdown:SetDefaultText(tempDownList[1].text)
                                else
                                    ConcernFrame.profileDropdown:SetDefaultText(" ")
                                end
                                ConcernFrame:Update()
                            end
                        else
                            -- data.checked = nil
                            concernType.hideList[_charKey] = nil
                        end
                        ConcernFrame.profileDropdown:SetMenuTable(profileDropdownList)
                    end
                })
            end
            tinsert(menuList, {isSeparator = true})
            tinsert(menuList, {text="取消", func = function ()
                ZL.GUI:CloseMenu()
            end})
            return menuList
        end
        ZL.GUI:ToggleMenu(self, tempfunc(), 'TOPLEFT', self, 'TOPRIGHT')
    end)

    ConcernFrame.importBtn = CreateButton(nil, ConcernFrame, "导入", "TOPLEFT", exportBtn, "BOTTOMLEFT", 0, -5, 40, 24, 14)
    local importBtn= ConcernFrame.importBtn
    importBtn:SetScript("OnClick", function ()
        local selectCharKey = profileDropdown:GetText()
        selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
        if not selectCharKey then return end
        if not ZL.WaStringFrame then ZL:CreateWAStringFrame() end
        local editBox = ZL.WaStringFrame.scrollFrame.editBox
        ZL.WaStringFrame.Title:SetText("在下方粘贴字符串文本，关注物品数据将|cffffffff导入|r到【" .. selectCharKey .. "】")
        editBox:SetScript("OnMouseUp", nil)
        editBox:SetScript("OnEscapePressed", function() ZL.WaStringFrame:Hide() end)
        editBox:SetScript("OnTextChanged", function (self)
            local text = self:GetText()
            if text:match("^!AutoAuction:%d+!.+") then
                text = text:gsub("!AutoAuction:%d+!", "", 1)
                local decodedData = LibDeflate:DecodeForPrint(text)
                local decompressedData = LibDeflate:DecompressDeflate(decodedData)
                local success, myReceivedData = LibSerialize:Deserialize(decompressedData)
                if success then
                    if ((not self.time) or (GetTime() - self.time) > 1) then
                        self.time = GetTime()
                        local _selectCharKey = profileDropdown:GetText()
                        _selectCharKey = _selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
                        local receivedClass = myReceivedData.classInfo.class
                        local selectClass = concernList[_selectCharKey].classInfo.class
                        local msgStr
                        if selectClass ~= receivedClass then
                            msgStr = "职业不符，无法导入！当前选择角色职业：|T" .. CLASSICON_LIST[selectClass] .. ":0:0:2:0|t |cffffffff" .. selectClass .. "|r，导入数据职业：|T" .. CLASSICON_LIST[receivedClass] .. ":0:0:2:0|t |cffffffff" .. receivedClass .. "|r"
                            ZL.Print(msgStr, true, nil, 1, 0, 0)
                        else
                            local btnText
                            if next(concernList[_selectCharKey].itemList) then
                                msgStr = "当前选择角色【" .. _selectCharKey .. "】存在关注物品数据，导入后将覆盖原有数据，请选择"
                                btnText = "覆盖导入"
                            else
                                msgStr = "确定将关注物品数据导入到【" .. _selectCharKey .. "】中？"
                                btnText = "导入"
                            end
                            local statisticsData = {
                                data = myReceivedData,
                                selectCharKey = _selectCharKey,
                                btnText = btnText,
                            }
                            StaticPopup_Show("ZL_IMPORTCORCERNSTRING", msgStr, nil, statisticsData)
                            ZL.WaStringFrame:Hide()
                        end
                    end
                else
                    ZL.Print("解析失败！", true, nil, 1, 0, 0)
                end
            end
        end)
        editBox:SetText("")
        editBox:HighlightText()
        editBox:SetFocus()

        ZL.WaStringFrame:Show()
    end)

    ConcernFrame.delBtn = CreateButton(nil, ConcernFrame, "删除", "LEFT", importBtn, "RIGHT", 5, 0, 40, 24, 14)
    local delBtn= ConcernFrame.delBtn
    delBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "BOTTOM", "TOP")
        GameTooltip:AddLine("删除角色")
        GameTooltip:AddLine("删除角色关注数据", 1, 1, 1)
        GameTooltip:Show()
    end)
    delBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    delBtn:SetScript("OnClick", function (self)
        local function tempfunc()
            local menuList = {{text="删除角色", isTitle=true}}
            local charList = {}
            for _charKey in pairs(concernList) do
                tinsert(charList, _charKey)
            end
            table.sort(charList)
            if not ZL.opt.concernType then ZL.opt.concernType = {hideList={}, deleteList={}} end
            local concernType = ZL.opt.concernType
            local tempList = {}
            if next(concernType.deleteList) then
                for key in pairs(concernType.deleteList) do
                    tinsert(tempList, key)
                end
            end
            table.sort(tempList)
            for _, key in ipairs(tempList) do
                tinsert(charList, key)
            end
            for _, _charKey in ipairs(charList) do
                local texture = concernList[_charKey] and concernList[_charKey]["classInfo"]["icon"] or 134400
                tinsert(menuList, {
                    text = "|T" .. texture .. ":0:0:2:0|t " .. _charKey,
                    checkable = 1,
                    checked = concernType.deleteList[_charKey],
                    isNotRadio = 1,
                    keepShownOnClick = 1,
                    func = function (_, data)
                        if data.checked then
                            concernType.deleteList[_charKey] = true
                            concernType.hideList[_charKey] = nil
                            concernList[_charKey] = nil
                            local selectCharKey = ConcernFrame.profileDropdown:GetText()
                            selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
                            if _charKey == selectCharKey then
                                local tempDownList = profileDropdownList()
                                if #tempDownList > 0 then
                                    ConcernFrame.profileDropdown:SetDefaultText(tempDownList[1].text)
                                else
                                    ConcernFrame.profileDropdown:SetDefaultText(" ")
                                end
                                ConcernFrame:Update()
                            end
                        else
                            concernType.deleteList[_charKey] = nil
                            if _charKey == charKey then
                                concernList[charKey] = {
                                    ["classInfo"] = {
                                        icon = classIcon,
                                        class = className,
                                        hasRelic = UnitHasRelicSlot("player"),
                                    },
                                    ["slotInfo"] = {
                                        ["头"] = {},
                                        ["项链"] = {},
                                        ["肩膀"] = {},
                                        ["披风"] = {},
                                        ["胸部"] = {},
                                        ["手腕"] = {},
                                        ["手"] = {},
                                        ["腰带"] = {},
                                        ["腿"] = {},
                                        ["脚"] = {},
                                        ["戒指"] = {},
                                        ["饰品"] = {},
                                        ["主手"] = {},
                                        ["副手"] = {},
                                        ["远程"] = {},
                                        ["其他"] = {},
                                    },
                                    ["itemList"] = {},
                                }
                            end
                        end
                        ConcernFrame.profileDropdown:SetMenuTable(profileDropdownList)
                    end
                })
            end
            tinsert(menuList, {isSeparator = true})
            tinsert(menuList, {text="取消", func = function ()
                ZL.GUI:CloseMenu()
            end})
            return menuList
        end
        ZL.GUI:ToggleMenu(self, tempfunc(), 'TOPLEFT', self, 'TOPRIGHT')
    end)

    ConcernFrame.itemIdFontString = ConcernFrame:CreateFontString(nil, "OVERLAY")
    ConcernFrame.itemIdFontString:SetPoint("TOPLEFT", profileDropdown, "BOTTOMLEFT", 5, -5)
    ConcernFrame.itemIdFontString:SetHeight(24)
    ConcernFrame.itemIdFontString:SetFont(GameFontNormal:GetFont(), 14)
    ConcernFrame.itemIdFontString:SetWordWrap(false)
    ConcernFrame.itemIdFontString:SetJustifyH("CENTER")
    ConcernFrame.itemIdFontString:SetTextColor(1, 0.82, 0, 1)
    ConcernFrame.itemIdFontString:SetText("物品ID：")

    ConcernFrame.itemIdBox = CreateEditBox(ConcernFrame, 105, 24, 14, "RIGHT", true)
    local itemIdBox = ConcernFrame.itemIdBox
    itemIdBox:SetPoint("LEFT", ConcernFrame.itemIdFontString, "RIGHT", 5, 0)
    itemIdBox.Background:SetColorTexture(0, 0, 0, 1)
    --添加关注
    function ZL.addItem(itemId, itemEquipLoc, col)
        local selectCharKey = profileDropdown:GetText()
        selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
        itemId = itemId and tonumber(itemId) or (itemIdBox:GetNumber() or 0)
        if itemId > 0 then
            if itemEquipLoc and col and col <= #concernList[selectCharKey]["peiZhuangList"] and concernList[selectCharKey]["peiZhuangList"][col][itemEquipLoc] == itemId then
                ZL.Print("物品已存在！")
            else
                local item = Item:CreateFromItemID(itemId)
                if item:GetItemID() then
                    item:ContinueOnItemLoad(function()
                        local _, itemLink, _, _, _, _, _, _, _itemEquipLoc = cGetItemInfo(itemId)
                        if not itemEquipLoc then
                            if _itemEquipLoc and InventoryType[_itemEquipLoc] then
                                if InventoryType[_itemEquipLoc] == "戒指" or InventoryType[_itemEquipLoc] == "饰品" then
                                    for index, data in ipairs(concernList[selectCharKey]["peiZhuangList"]) do
                                        if (not data[InventoryType[_itemEquipLoc] .. "1"]) and data[InventoryType[_itemEquipLoc] .. "2"] ~= itemId then
                                            itemEquipLoc = InventoryType[_itemEquipLoc] .. "1"
                                            col = index
                                            break
                                        elseif (not data[InventoryType[_itemEquipLoc] .. "2"]) and data[InventoryType[_itemEquipLoc] .. "1"] ~= itemId  then
                                            itemEquipLoc = InventoryType[_itemEquipLoc] .. "2"
                                            col = index
                                            break
                                        end
                                    end
                                    if not itemEquipLoc then
                                        itemEquipLoc = InventoryType[_itemEquipLoc] .. "1"
                                        col = #concernList[selectCharKey]["peiZhuangList"] + 1
                                    end
                                else
                                    itemEquipLoc = InventoryType[_itemEquipLoc]
                                end
                            else
                                itemEquipLoc = "其他"
                            end
                        end
                        if not col then
                            for index, data in ipairs(concernList[selectCharKey]["peiZhuangList"]) do
                                if not data[itemEquipLoc] then
                                    col = index
                                    break
                                end
                            end
                        end
                        if not col then
                            col = #concernList[selectCharKey]["peiZhuangList"] + 1
                        end
                        if col == #concernList[selectCharKey]["peiZhuangList"] + 1 then
                            tinsert(concernList[selectCharKey]["peiZhuangList"], {})
                        end
                        concernList[selectCharKey]["peiZhuangList"][col][itemEquipLoc] = itemId
                        local title = concernList[selectCharKey]["peiZhuangList"][col].title or ("配装" .. col)
                        if concernList[selectCharKey]["itemList"][itemId] == nil then
                            concernList[selectCharKey]["itemList"][itemId] = true
                        end
                        ZL.Print(itemLink .. "已添加到[" .. selectCharKey .. "][" .. title .. "][|cffff0000" .. itemEquipLoc .. "|r]部位！", true)
                        if ConcernFrame:IsShown() then
                            ConcernFrame:Update()
                        end
                        if ZL.AuctionFrame2:IsShown() then
                            ZL.AuctionFrame2:Update()
                        end
                    end)
                else
                    ZL.Print("物品ID不存在！", true, nil, 1, 0, 0)
                end
            end
        end
        itemIdBox:ClearFocus()
        ZL.miniMapIconAnimation()
    end
    local addItem = ZL.addItem
    --删除关注
    function ZL.deleteItem(itemId)
        itemId = tonumber(itemId)
        if type(itemId) ~= "number" or itemId <= 0 then return end
        local selectCharKey = profileDropdown:GetText()
        selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
        if not selectCharKey then return end
        concernList[selectCharKey]["itemList"][itemId] = nil
        local item = Item:CreateFromItemID(itemId)
        if item:GetItemID() then
            item:ContinueOnItemLoad(function()
                local _, itemLink, _, _, _, _, _, _, itemEquipLoc = cGetItemInfo(itemId)
                local invtype
                if itemEquipLoc and InventoryType[itemEquipLoc] then
                    invtype = InventoryType[itemEquipLoc]
                else
                    invtype = "其他"
                end
                local isExist
                for _, data in ipairs(concernList[selectCharKey]["peiZhuangList"]) do
                    if invtype == "戒指" or invtype == "饰品" then
                        if data[invtype .. "1"] == itemId then
                            data[invtype .. "1"] = nil
                            isExist = true
                        end
                        if data[invtype .. "2"] == itemId then
                            data[invtype .. "2"] = nil
                            isExist = true
                        end
                    else
                        if data[invtype] == itemId then
                            data[invtype] = nil
                            isExist = true
                        end
                    end
                end
                if isExist then
                    ZL.Print(itemLink .. "已取消关注")
                    if ConcernFrame:IsShown() then
                        ConcernFrame:Update()
                    end
                    if ZL.AuctionFrame2:IsShown() then
                        ZL.AuctionFrame2:Update()
                    end
                end
            end)
        else
            ZL.Print("物品ID不存在！", true, nil, 1 , 0, 0)
        end

    end
    local function bisTooltipActivityMenu(self)
        local menuList2 = {}
        if Bistooltip_bislists then
            local selectCharKey = profileDropdown:GetText()
            selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
            if not selectCharKey then return menuList2 end
            local function tempfunc(col)
                local tempMenuList = {}
                local class = concernList[selectCharKey]["classInfo"]["class"]
                local bisClass = CLASSNAME_LIST[class]
                if bisClass then
                    tinsert(tempMenuList, {text="数据来源：BisTooltip", isTitle = true})
                    for spec, specData in pairs(Bistooltip_bislists[bisClass]) do
                        local specList = {}
                        tinsert(specList, {text="天赋：" .. SPECS_LIST[spec], isTitle = true})
                        for _, phase in ipairs(Bistooltip_phases) do
                            if specData[phase] then
                                local phaseList = {}
                                tinsert(phaseList, {text="阶段：" .. phase, isTitle = true})
                                local invtypeTempList = {}
                                if self.row then
                                    invtypeTempList[1] = INVTYPE_LIST[self.row]
                                else
                                    invtypeTempList = INVTYPE_LIST
                                end
                                for i, invtype in ipairs(invtypeTempList) do
                                    local invtype2 = invtype:gsub("%d", "")
                                    local bisinvtype = (invtype2 == "远程" and concernList[selectCharKey]["classInfo"]["hasRelic"]) and "Relic" or INVTYPE_BISTOOLTIP[invtype2]
                                    for bisIndex, bisData in ipairs(specData[phase]) do
                                        if bisData.slot_name == bisinvtype then
                                            local invtypeList = {}
                                            local text = (invtype2 == "远程" and concernList[selectCharKey]["classInfo"]["hasRelic"]) and RELICSLOT or invtype
                                            invtypeList[1] = {text="部位：" .. text, isTitle = true}
                                            for index, itemId in ipairs(bisData) do
                                                local item = Item:CreateFromItemID(itemId)
                                                if item:GetItemID() then
                                                    item:ContinueOnItemLoad(function()
                                                        local isExist = (col and col <= #concernList[selectCharKey]["peiZhuangList"] and concernList[selectCharKey]["peiZhuangList"][col][invtype2] == itemId) and true or nil
                                                        local _, itemLink, _, _, _, _, _, _, itemEquipLoc, itemTexture = cGetItemInfo(itemId)
                                                        if itemEquipLoc and InventoryType[itemEquipLoc] then
                                                            invtypeList[index + 1] = {
                                                                text = "Top" .. index .. " |T" .. itemTexture .. ":0:0:2:0|t " .. itemLink,
                                                                checkable = 1,
                                                                checked = isExist,
                                                                tooltipWhileDisabled = 1,
                                                                tooltipMore = function(tip, data, button)
                                                                    tip:SetHyperlink(itemLink)
                                                                    tip:Show()
                                                                    if _G["ShoppingTooltip1"] and _G["ShoppingTooltip1"]:IsShown() then
                                                                        _G["ShoppingTooltip1"]:Hide()
                                                                    end
                                                                    if _G["ShoppingTooltip2"] and _G["ShoppingTooltip2"]:IsShown() then
                                                                        _G["ShoppingTooltip2"]:Hide()
                                                                    end
                                                                end,
                                                                func = function (owner, data)
                                                                    addItem(itemId, invtype, col)
                                                                    ZL.GUI:CloseMenu()
                                                                    itemIdBox:ClearFocus()
                                                                end
                                                            }
                                                        end
                                                    end)
                                                end
                                            end
                                            local texture = (invtype2 == "远程" and concernList[selectCharKey]["classInfo"]["hasRelic"]) and "Interface\\Paperdoll\\UI-PaperDoll-Slot-Relic.blp" or INVTYPETEXTURE_LIST[invtype2]
                                            tinsert(phaseList, {
                                                text = "|T" .. texture .. ":0:0:2:0|t " .. text,
                                                func = function ()
                                                    itemIdBox:ClearFocus()
                                                    ZL.GUI:CloseMenu()
                                                end,
                                                hasArrow = true,
                                                menuTable = invtypeList,
                                            })
                                            break
                                        end
                                    end
                                end
                                tinsert(specList, {
                                    text = phase,
                                    func = function ()
                                        itemIdBox:ClearFocus()
                                        ZL.GUI:CloseMenu()
                                    end,
                                    hasArrow = true,
                                    menuTable = phaseList,
                                })
                            end
                        end
                        tinsert(tempMenuList, {
                            text = "|T" .. SPECSICON_LIST[bisClass][spec] .. ":0:0:2:0|t " .. SPECS_LIST[spec],
                            func = function ()
                                ZL.GUI:CloseMenu()
                                itemIdBox:ClearFocus()
                            end,
                            hasArrow = true,
                            menuTable = specList,
                        })
                    end
                end
                return tempMenuList
            end
            local menuList = tempfunc()
            if #menuList > 0 then
                if self.col then
                    menuList2 = tempfunc(self.col)
                else
                    local col = 1
                    if #concernList[selectCharKey]["peiZhuangList"] > 0 then
                        for index, data in ipairs(concernList[selectCharKey]["peiZhuangList"]) do
                            tinsert(menuList2, {
                                text = data.title or ("配装" .. index),
                                func = function ()
                                    ZL.GUI:CloseMenu()
                                    itemIdBox:ClearFocus()
                                end,
                                hasArrow = true,
                                menuTable = tempfunc(col),
                            })
                            col = col + 1
                        end
                        tinsert(menuList2, {isSeparator = true})
                    end
                    tinsert(menuList2, {
                        text = "|cffabd473新建|r",
                        func = function ()
                            ZL.GUI:CloseMenu()
                            itemIdBox:ClearFocus()
                        end,
                        hasArrow = true,
                        menuTable = tempfunc(col),
                    })
                end
            end
        end
        return menuList2
    end
    itemIdBox:SetScript("OnEnterPressed", function (self)
        itemIdBox:ClearFocus()
        addItem()
    end)
    itemIdBox:SetScript("OnMouseDown", function (self, button)
        if button == "LeftButton" then
            local menuList = bisTooltipActivityMenu(self)
            if #menuList > 0 then
                ZL.GUI:ToggleMenu(self, menuList, 'TOPLEFT', self, 'BOTTOMRIGHT')
            end
        end
    end)
    itemIdBox:SetScript("OnEditFocusGained", function (self)
        self:HighlightText()
    end)
    itemIdBox:SetScript("OnEditFocusLost", function (self)
        self:HighlightText(0, 0)
    end)
    itemIdBox:SetScript("OnEnter", function (self)
        if not self:HasFocus() then
            GameTooltipShow(self, "BOTTOM", "TOP")
            GameTooltip:AddLine("输入物品ID按|cffffffffEnter|r或|cffffffff添加|r\n按钮可添加或新建配装")
            GameTooltip:Show()
        end
    end)
    itemIdBox:SetScript("OnLeave", function (self)
        GameTooltip:Hide()
    end)
    ConcernFrame.addBtn = CreateButton(nil, ConcernFrame, "添加", "LEFT", itemIdBox, "RIGHT", 5, 0, 40, 24, 14)
    local addBtn = ConcernFrame.addBtn
    addBtn:SetScript("OnClick", function ()
        addItem()
    end)
    addBtn:SetScript("OnEnter", function (self)
        GameTooltipShow(self, "LEFT", "RIGHT")
        GameTooltip:AddLine("如需关注套装兑换物品")
        GameTooltip:AddLine("输入兑换物品ID，关注即可", 1, 1, 1)
        GameTooltip:Show()
    end)
    addBtn:SetScript("OnLeave", function ()
        GameTooltip:Hide()
    end)
    --创建滚动条
    ConcernFrame.scrollFrame = CreateFrame("ScrollFrame", nil, ConcernFrame, "UIPanelScrollFrameTemplate")
    ConcernFrame.scrollFrame:SetFrameLevel(ConcernFrame:GetFrameLevel() + 1) -- 设置为比父框架高1级
    ConcernFrame.scrollFrame:SetPoint("TOPLEFT", ConcernFrame.TitleBottom, "BOTTOMLEFT", 0, -10-profileDropdown:GetHeight()-ConcernFrame.itemIdFontString:GetHeight()-29)
    ConcernFrame.scrollFrame:SetPoint("BOTTOMRIGHT", ConcernFrame, "BOTTOMRIGHT", 0, 3)
    ConcernFrame.scrollFrame:SetClipsChildren(true) --必须设置为true，scrollFrame所有的子元素才会被剪切
    ConcernFrame.scrollFrame:SetScript("OnMouseWheel", ZL.ScrollFrame_OnMouseWheel) --重设滑动条鼠标滚轮事件
    --重设ScrollBar位置，放置到scrollFrame内，防止被剪切掉
    ConcernFrame.scrollFrame.ScrollBar:ClearAllPoints()
    ConcernFrame.scrollFrame.ScrollBar:SetPoint("TOPLEFT", ConcernFrame.scrollFrame, "TOPRIGHT", -20, -17)
    ConcernFrame.scrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", ConcernFrame.scrollFrame, "BOTTOMRIGHT", 0, 16)
    ConcernFrame.scrollFrame.content = CreateFrame("Frame", nil, ConcernFrame.scrollFrame)
    local content = ConcernFrame.scrollFrame.content
    content:SetPoint("TOPLEFT", ConcernFrame.scrollFrame, "TOPLEFT", 0, 0)
    content:SetSize(ConcernFrame.scrollFrame:GetWidth()-20, 100)
    ConcernFrame.scrollFrame:SetScrollChild(content)
    ConcernFrame.scrollFrame.ScrollBar:SetFrameLevel(content:GetFrameLevel()+100)
    -- ZL.background(content)

    ConcernFrame.entries = CreateDynamicTable()
    function ConcernFrame:Update()
        for i in ipairs(ConcernFrame.entries) do
            for j in ipairs(ConcernFrame.entries[i]) do
                if j ~= 1 then
                    ConcernFrame.entries[i][j]:Hide()
                end
            end
        end
        local selectCharKey = profileDropdown:GetText()
        if not selectCharKey then return end
        selectCharKey = selectCharKey:match("^|T%d+:0:0:2:0|t (.+)")
        if not selectCharKey then return end
        local w, h = 40, 40
        local wgap, hgap = 15, 15
        local maxWidth = 315
        local highlightTexture = [[Interface\Buttons\ButtonHilight-Square]]
        if not ConcernFrame.entries[1][1] then
            local slotFont = ConcernFrame:CreateFontString(nil, "OVERLAY")
            slotFont:SetPoint("TOPLEFT", ConcernFrame.itemIdFontString, "BOTTOMLEFT", -5, -5)
            slotFont:SetSize(w+10, 24)
            slotFont:SetFont(GameFontNormal:GetFont(), 14)
            slotFont:SetWordWrap(false)
            slotFont:SetJustifyH("CENTER")
            slotFont:SetTextColor(1, 0.82, 0, 1)
            slotFont:SetText("部位")
            ConcernFrame.entries[1][1] = slotFont
        end
        ConcernFrame.entries[1][1]:Show()
        for i, invtype in ipairs(INVTYPE_LIST) do
            local invtype2 = invtype:gsub("%d", "")
            if not ConcernFrame.entries[i+1][1] then
                local btnText = (invtype2 == "远程" and concernList[selectCharKey]["classInfo"]["hasRelic"]) and RELICSLOT or invtype
                local texture = (invtype2 == "远程" and concernList[selectCharKey]["classInfo"]["hasRelic"]) and "Interface\\Paperdoll\\UI-PaperDoll-Slot-Relic.blp" or INVTYPETEXTURE_LIST[invtype2]
                local button = CreateFrame("Button", nil, content)
                -- button:SetNormalTexture(texture)
                button:SetHighlightTexture(highlightTexture)
                button:SetPoint("TOPLEFT", content, "TOPLEFT", 10, -(i-1)*(h+hgap))
                button:SetSize(w, h)
                button:SetNormalFontObject("GameFontHighlight")
                button:SetHighlightFontObject("GameFontHighlight")
                button:SetDisabledFontObject("GameFontDisable")
                button:SetText(btnText)
                local fontString = button:GetFontString()
                fontString:SetFont(GameFontNormal:GetFont(), 15)

                button.invType = invtype
                button.row = i
                button.col = 1
                ConcernFrame.entries[i+1][1] = button
            end
            ConcernFrame.entries[i+1][1]:Show()
        end
        for j, data in ipairs(concernList[selectCharKey]["peiZhuangList"]) do
            if not ConcernFrame.entries[1][j+1] then
                local editBox = CreateEditBox(ConcernFrame, w+30, 24, 12, "CENTER")
                editBox.Background:SetColorTexture(0, 0, 0, 1)
                editBox:SetTextInsets(2, 2, 0, 0)
                editBox:SetPoint("TOPLEFT", ConcernFrame.itemIdFontString, "BOTTOMLEFT", j*(w+wgap)-15, -5)
                editBox.lable = editBox:CreateFontString(nil, "OVERLAY")
                editBox.lable:SetPoint("TOPLEFT", ConcernFrame.itemIdFontString, "BOTTOMLEFT", j*(w+wgap)-7, -5)
                editBox.lable:SetSize(w+14, 24)
                editBox.lable:SetFont(GameFontNormal:GetFont(), 14)
                editBox.lable:SetWordWrap(false)
                editBox.lable:SetJustifyH("CENTER")
                editBox.lable:SetTextColor(1, 0.82, 0, 1)
                ConcernFrame.entries[1][j+1] = editBox
            end
            do
                local editBox= ConcernFrame.entries[1][j+1]
                editBox:Show()
                editBox.Background:Hide()
                editBox.BorderTop:Hide()
                editBox.BorderLeft:Hide()
                editBox.BorderBottom:Hide()
                editBox.BorderRight:Hide()
                editBox:SetText("")
                editBox.lable:Show()
                editBox.lable:SetTextScale(1)
                local title = data.title or ("配装" .. j)
                editBox.title = title
                editBox.lable:SetText(title)
                if j % 2 == 0 then
                    editBox.lable:SetTextColor(0.98, 0.98, 0.98, 1)
                else
                    editBox.lable:SetTextColor(1, 0.82, 0, 1)
                end
                local bili = editBox.lable:GetStringWidth()>0 and editBox.lable:GetWidth()/(editBox.lable:GetUnboundedStringWidth()+5) or 1
                if bili < 1 then
                    editBox.lable:SetTextScale(bili)
                else
                    editBox.lable:SetTextScale(1)
                end
                editBox:SetScript("OnMouseDown", function (self, button)
                    if button == "RightButton" then
                        local menuList ={
                            {
                                text = "删除该配装",
                                func = function ()
                                    for key, value in pairs(data) do
                                        local isExist
                                        for index, _data in ipairs(concernList[selectCharKey]["peiZhuangList"]) do
                                            if index ~= j and _data[key] == value then
                                                isExist = true
                                                break
                                            end
                                        end
                                        if not isExist then
                                            concernList[selectCharKey]["itemList"][value] = nil
                                        end
                                    end
                                    table.remove(concernList[selectCharKey]["peiZhuangList"], j)
                                    ConcernFrame:Update()
                                    if ZL.AuctionFrame2:IsShown() then
                                        ZL.AuctionFrame2:Update()
                                    end
                                end
                            }
                        }
                        ZL.GUI:ToggleMenu(self, menuList, 'cursor2')
                    end
                end)
                editBox:SetScript("OnEditFocusGained", function (self)
                    self.Background:Show()
                    self.BorderTop:Show()
                    self.BorderLeft:Show()
                    self.BorderBottom:Show()
                    self.BorderRight:Show()
                    self:SetText(self.title)
                    self:HighlightText()
                    self.lable:Hide()
                    GameTooltip:Hide()
                end)
                editBox:SetScript("OnEditFocusLost", function (self)
                    self.Background:Hide()
                    self.BorderTop:Hide()
                    self.BorderLeft:Hide()
                    self.BorderBottom:Hide()
                    self.BorderRight:Hide()
                    self:SetText("")
                    self.lable:Show()
                end)
                editBox:SetScript("OnEnterPressed", function (self)
                    local title = self:GetText()
                    if (not title) or #title == 0 then
                        --删除自定义配装名字
                        data.title = nil
                        self.title = "配装" .. j
                    else
                        --保存自定义配装名字
                        data.title = title
                        self.title = title
                    end
                    editBox.lable:SetTextScale(1)
                    editBox.lable:SetText(self.title)
                    local bili = editBox.lable:GetStringWidth()>0 and editBox.lable:GetWidth()/(editBox.lable:GetUnboundedStringWidth()+5) or 1
                    if bili < 1 then
                        editBox.lable:SetTextScale(bili)
                    else
                        editBox.lable:SetTextScale(1)
                    end
                    self:ClearFocus()
                    if GameTooltip:IsShown() then
                        GameTooltip:Hide()
                        GameTooltipShow(self, "BOTTOM", "TOP")
                        GameTooltip:AddLine(self.title)
                        GameTooltip:Show()
                    end
                end)
                editBox:SetScript("OnEnter", function (self)
                    GameTooltipShow(self, "BOTTOM", "TOP")
                    GameTooltip:AddLine(self.title)
                    GameTooltip:AddLine("右键：删除配装", 1, 1, 1)
                    GameTooltip:Show()
                end)
                editBox:SetScript("OnLeave", function (self)
                    GameTooltip:Hide()
                end)
            end
            for i, invtype in ipairs(INVTYPE_LIST) do
                local invtype2 = invtype:gsub("%d", "")
                local texture = (invtype2 == "远程" and concernList[selectCharKey]["classInfo"]["hasRelic"]) and "Interface\\Paperdoll\\UI-PaperDoll-Slot-Relic.blp" or INVTYPETEXTURE_LIST[invtype2]
                if not ConcernFrame.entries[i+1][j+1] then
                    local button = CreateFrame("Button", nil, content)
                    button:SetHighlightTexture(highlightTexture)
                    button:SetPoint("TOPLEFT", content, "TOPLEFT", j*(w+wgap)+10, -(i-1)*(h+hgap))
                    button:SetSize(w, h)
                    button:SetNormalFontObject("GameFontNormal")
                    button:SetHighlightFontObject("GameFontHighlight")
                    button:SetDisabledFontObject("GameFontDisable")
                    button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
                    button:SetScript("OnEnter", function (self)
                        if self:GetCenter() < UIParent:GetCenter() then
                            GameTooltipShow(self, "TOPLEFT", "TOPRIGHT")
                        else
                            GameTooltipShow(self, "TOPRIGHT", "TOPLEFT")
                        end
                        if self.itemLink then
                            button.delBtn:Show()
                            GameTooltip:SetHyperlink(self.itemLink)
                        else
                            GameTooltip:AddLine("添加关注物品")
                        end
                        GameTooltip:Show()
                        if _G["ShoppingTooltip1"] and _G["ShoppingTooltip1"]:IsShown() then
                            _G["ShoppingTooltip1"]:ClearAllPoints()
                            if self:GetCenter() < UIParent:GetCenter() then
                                _G["ShoppingTooltip1"]:SetPoint("TOPLEFT", GameTooltip, "TOPRIGHT", 0, 0)
                            else
                                _G["ShoppingTooltip1"]:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0)
                            end
                        end
                        if _G["ShoppingTooltip2"] and _G["ShoppingTooltip2"]:IsShown() then
                            _G["ShoppingTooltip2"]:ClearAllPoints()
                            if self:GetCenter() < UIParent:GetCenter() then
                                _G["ShoppingTooltip2"]:SetPoint("TOPLEFT", _G["ShoppingTooltip1"], "TOPRIGHT", 0, 0)
                            else
                                _G["ShoppingTooltip2"]:SetPoint("TOPRIGHT", _G["ShoppingTooltip1"], "TOPLEFT", 0, 0)
                            end
                        end
                        if type(self.editBox.targetAmount) ~= "number" then
                            self.editBox.lable:SetText("心理价")
                        end
                    end)
                    button:SetScript("OnLeave", function (self)
                        GameTooltip:Hide()
                        if not self:IsMouseOver() then
                            button.delBtn:Hide()
                        end
                        if type(self.editBox.targetAmount) ~= "number" then
                            self.editBox.lable:SetText("")
                        end
                    end)
                    button:SetScript("OnClick", function (self)
                        if Bistooltip_bislists then
                            local menuList = bisTooltipActivityMenu(self)
                            if #menuList > 0 then
                                ZL.GUI:ToggleMenu(self, menuList, 'cursor2') --  "TOPLEFT", self, "BOTTOMRIGHT", -20, 20
                                button.delBtn:Hide()
                            end
                        else
                            ZL.Print("没有安装BisTooltip插件，请使用物品ID方式添加！")
                        end
                    end)
                    button.delBtn = CreateFrame("Button", nil, button) --, "UIPanelCloseButton"
                    button.delBtn:SetPoint("TOPRIGHT", button, "TOPRIGHT", -2, -3)
                    button.delBtn:SetNormalTexture([[Interface\Buttons\UI-MinusButton-UP]])
                    button.delBtn:SetPushedTexture([[Interface\Buttons\UI-MinusButton-DOWN]])
                    button.delBtn:SetHighlightTexture([[Interface\Buttons\UI-PlusButton-Hilight]])
                    button.delBtn:SetSize(12, 12)
                    button.delBtn:SetScript("OnEnter", function (self)
                        GameTooltipShow(button, "BOTTOM", "TOP")
                        GameTooltip:AddLine("双击移除")
                        GameTooltip:Show()
                    end)
                    button.delBtn:SetScript("OnLeave", function (self)
                        GameTooltip:Hide()
                        if not button:IsMouseOver() then
                            self:Hide()
                        end
                    end)
                    button.delBtn:Hide()
                    button.editBox = CreateEditBox(button, w+6, 15, 12, "CENTER", true)
                    local editBox = button.editBox
                    editBox.Background:SetColorTexture(0, 0, 0, 1)
                    editBox:SetPoint("TOP", button, "BOTTOM", 0, 0)
                    editBox:SetSize(w+20, hgap)
                    editBox:SetScript("OnEditFocusGained", function (self)
                        self.Background:Show()
                        self.BorderTop:Show()
                        self.BorderLeft:Show()
                        self.BorderBottom:Show()
                        self.BorderRight:Show()
                        self:SetText(self.targetAmount or "")
                        self:HighlightText()
                        self.lable:Hide()
                    end)
                    editBox:SetScript("OnEditFocusLost", function (self)
                        self.Background:Hide()
                        self.BorderTop:Hide()
                        self.BorderLeft:Hide()
                        self.BorderBottom:Hide()
                        self.BorderRight:Hide()
                        self:SetText("")
                        self.lable:Show()
                    end)
                    editBox:SetScript("OnEnterPressed", function (self)
                        local targetAmount = self:GetNumber()
                        if targetAmount == 0 and self.targetAmount and self.targetAmount > 0 then
                            --删除心理价
                            concernList[selectCharKey]["itemList"][button.itemId] = true
                            editBox.lable:SetText("心理价")
                            self.targetAmount = nil
                        elseif targetAmount > 0 then
                            --保存心理价
                            concernList[selectCharKey]["itemList"][button.itemId] = targetAmount
                            editBox.lable:SetText(ZL.formatNumber(targetAmount))
                            self.targetAmount = targetAmount
                        end
                        self:ClearFocus()
                        ConcernFrame:Update()
                    end)
                    editBox:SetScript("OnEnter", function (self)
                        if type(self.targetAmount) ~= "number" then
                            self.lable:SetText("心理价")
                        end
                    end)
                    editBox:SetScript("OnLeave", function (self)
                        if type(self.targetAmount) ~= "number" then
                            self.lable:SetText("")
                        end
                    end)

                    editBox.lable = editBox:CreateFontString(nil, "OVERLAY")
                    local lable = editBox.lable
                    lable:SetPoint("TOP", button, "BOTTOM", 0, 0)
                    lable:SetWidth(w+6)
                    lable:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
                    lable:SetWordWrap(false)
                    lable:SetJustifyH("CENTER")
                    lable:SetTextColor(1, 1, 1, 1)
                    
                    button.levelFont = button:CreateFontString(nil, "OVERLAY")
                    button.levelFont:SetPoint("TOPLEFT", button, "TOPLEFT", 3, -3)
                    button.levelFont:SetFont(GameFontNormal:GetFont(), 11, "OUTLINE")
                    button.levelFont:SetWordWrap(false)
                    button.levelFont:SetJustifyH("CENTER")
                    button.levelFont:SetTextColor(1, 1, 1, 1)
                    
                    button.itemNumbersIcon = button:CreateTexture(nil, "OVERLAY")
                    button.itemNumbersIcon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 2)
                    button.itemNumbersIcon:SetSize(25, 25)
                    ConcernFrame.entries[i+1][j+1] = button
                end
                local btn = ConcernFrame.entries[i+1][j+1]
                btn:Show()
                btn.row = i
                btn.col = j
                btn.invType = invtype
                btn.editBox.Background:Hide()
                btn.editBox.BorderTop:Hide()
                btn.editBox.BorderLeft:Hide()
                btn.editBox.BorderBottom:Hide()
                btn.editBox.BorderRight:Hide()
                if data[invtype] then
                    btn.itemId = data[invtype]
                    btn:SetNormalTexture(cGetItemIcon(data[invtype]))
                    btn.delBtn:SetScript("OnDoubleClick", function (self)
                        if data[invtype] then
                            local itemId = data[invtype]
                            data[invtype] = nil
                            local isExist
                            for _, _data in ipairs(concernList[selectCharKey]["peiZhuangList"]) do
                                if _data[invtype] == itemId then
                                    isExist = true
                                    break
                                end
                            end
                            if not isExist then
                                concernList[selectCharKey]["itemList"][itemId] = nil
                                if ZL.AuctionFrame2:IsShown() then
                                    ZL.AuctionFrame2:Update()
                                end
                            end
                            ConcernFrame:Update()
                        end
                        self:Hide()
                    end)
                    local targetAmount = concernList[selectCharKey]["itemList"][data[invtype]]
                    targetAmount = type(targetAmount) == "number" and targetAmount or nil
                    btn.editBox.targetAmount = targetAmount
                    local lable = btn.editBox.lable
                    lable:Show()
                    lable:SetTextScale(1)
                    lable:SetText(targetAmount and ZL.formatNumber(targetAmount) or "")
                    local bili = lable:GetStringWidth()>0 and lable:GetWidth()/(lable:GetUnboundedStringWidth()+5) or 1
                    if bili < 1 then
                        lable:SetTextScale(bili)
                    else
                        lable:SetTextScale(1)
                    end
                    local itemTotalCount = select(4, ZL.GetItemNumbers(data[invtype]))
                    if itemTotalCount > 0 then
                        btn.itemNumbersIcon:SetTexture([[interface/raidframe/readycheck-ready]])
                    else
                        btn.itemNumbersIcon:SetTexture()
                    end
                    local item = Item:CreateFromItemID(data[invtype])
                    if item:GetItemID() then
                        item:ContinueOnItemLoad(function()
                            local _, itemLink, _, itemLevel = cGetItemInfo(data[invtype])
                            btn.itemLink = itemLink
                            btn.levelFont:SetText(itemLevel)
                        end)
                    else
                        btn.itemLink = nil
                        btn.levelFont:SetText("")
                    end
                else
                    btn.itemId = nil
                    btn:SetNormalTexture(texture)
                    btn.editBox.targetAmount = nil
                    local lable = btn.editBox.lable
                    lable:Hide()
                    btn.itemNumbersIcon:SetTexture()
                    btn.itemLink = nil
                    btn.levelFont:SetText("")
                end
            end
        end
        maxWidth = max(maxWidth, (#concernList[selectCharKey]["peiZhuangList"]+1)*(w+15)+20)
        ConcernFrame:SetResizeBounds(maxWidth, 250, maxWidth, GetScreenHeight()-30)
        ConcernFrame:SetWidth(maxWidth)
    end
end