local L = select(2,...).L
U1_NEW_ICON = '|TInterface\\OptionsFrame\\UI-OptionsFrame-NewFeatureIcon:0:0:0:-1|t'

local U1StoreHideCompactRaid = nil
local _b_hideCompactRaid = false;
local function _Hook_HideOnShow(self)
    if _b_hideCompactRaid then
        self:Hide();
    end
end

function U1CfgMakeCVarOption(title, cvar, options)
    local info = options and Mixin({}, options) or {}

    info.text = title
    info.var = "cvar_"..cvar
    local origin_callback = info.callback

    if pcall(GetCVarDefault, cvar) then
        info.getvalue = info.getvalue or function()
            if info.type == "checkbox" or info.type == nil then
                return GetCVarBool(cvar)
            else
                return GetCVar(cvar)
            end
        end
        info.callback = function(cfg, v, loading)
            if loading then return end --加载的时候不根据保存的值设置
            if( false and InCombatLockdown()) then
                U1Message("战斗中无法设置此选项,请结束战斗后重试.")
            else
                if origin_callback then
                    origin_callback(cfg, v, loading)
                else
                    SetCVar(cvar, v)
                end
            end
        end
        info.default = info.default or function()
            return info.getvalue()
        end
    else
        info.disabled = 1
        info.tip = format("已失效``当前版本没有'%s'这个设置变量'", cvar)
        info.getvalue = nil
        info.callback = nil
    end

    return info
end

-- U1RegisterAddon("!!!Libs", { load = "NORMAL", protected = 1, hide = 1 }) EnableAddOn("!!!Libs") --163UI必须第一个加载，不能依赖其他的，只能这样
--U1RegisterAddon("!!!163UI.pics!!!", { title = "插件说明图片", hide = 1, defaultEnable = 0 });
--U1RegisterAddon("!!!163UI.3dcodecmd!!!", { title = "有爱核心", load = "NORMAL", hide = 1, protected = 1, defaultEnable = 1 });


U1RegisterAddon("!!!163UI!!!", {
    title = L["网易有爱"],
    tags = { "TAG_MANAGEMENT", },
    desc = L["网易有爱（163UI）插件是由网易游戏频道官方推出的一款新一代整合插件。其设计理念是兼顾整合插件的易用性和单体插件的灵活性，同时适合普通和高级用户群体。``插件中心控制台是网易有爱团队全力打造的管理界面，整合了'插件加载管理'、'插件选项配置'、'标签式分类'、'实时全文搜索'、'小地图按钮收集'等一系列先进功能。而且任意插件均可'一键启用'，不需重载界面。``网易有爱将依靠强大的技术实力，让插件更少的报错、让问题更快的回复、让建议更快的实现，为您提供更新更快更强大的新一代整合插件。"],
    protected = 1,
    icon = "Interface\\AddOns\\!!!163UI!!!\\Textures\\UI2-logo",

    nopic = 1,

    author = L["|cffcd1a1c[网易原创]|r"],

    {
        text = "额外设置",
        callback = function(cfg, v, loading)
            U1SelectAddon("163UI_MoreOptions") UUI.Right.TabChange(1)
        end
    },
    {
        text = "小功能集合",
        callback = function(cfg, v, loading)
            U1SelectAddon("163UI_Plugins") UUI.Right.TabChange(1)
        end
    },
    --[[text = L["有爱客户端相关"], type = "text",
        {
            var = "displayLinkageStatusAsBuff",
            default = false,
            text = "有爱连接状态显示为Buff",
            tip = "说明`关闭此选项*不会*导致有爱连接断开，以及影响签到的时间积累",
            callback = function(cfg, v, loading)
                if Toggle3DCodeCmdBuff  then
                    Toggle3DCodeCmdBuff()
                end
            end
        },]]
    --[[
        {
            var = "displayScrshotEmoticonBtn",
            default = false,
            text = "显示有爱截图和表情按钮",
            tip = "说明`在聊天条里显示爱有截图和自定义表情按钮",
            callback = function(cfg, v, loading)
                U1DB.configs["!!!163ui!!!/displayLinkageStatusAsBuff"] = false
                if Toggle3DCodeCmdChatFrameBtnShown  then
                    Toggle3DCodeCmdChatFrameBtnShown()
                end
            end
        },]]
    {
        var = "autoStand",
        default = '1',
        text = "坐下时施法自动起立",
        tip = "说明`怀旧服喝水的时候施法不会自动站起",
        callback = function(cfg, v, loading)
        end
    },
    {
        var = "autoDismount",
        default = '1',
        text = "施法自动下坐骑",
        tip = "说明`怀旧服施法不会自动下坐骑",
        callback = function(cfg, v, loading)
        end
    },
    -- {
    --     var = "charmingCastBar",
    --     default = 1,
    --     text = "施法条特殊纹理",
    --     tip = "为施法条增加一些额外的小彩蛋",
    --     callback = function(cfg, v, loading)
    --         if v then
    --             __163_HookCastingBarFrame(nil, 1);
    --         else
    --             __163_UnhookCastingBarFrame();
    --         end
    --     end
    -- },
    {
        var = "charmingCastBar",
        default = 0,
        text = "为施法条加点料！",
        tip = "为施法条增加一些额外的小彩蛋",
        type = "radio",
        options = {
            "无", 0, "有爱", 1, "极光", 5, "火焰", 6, "雷光", 7,
        },
        cols = 5,
        callback = function(cfg, v, loading)
            if v ~= 0 then
                __163_HookCastingBarFrame(nil, v);
            else
                __163_UnhookCastingBarFrame();
            end
        end
    },
    {
        var = "colorFriend",
        default = true,
        text = "好友列表染色",
        callback = function(cfg, v, loading)
            _163UI_TOGGLE_FRIEND_COLOR(v, loading);
        end
    },
    {
        var = "enhanceFriendTip",
        default = true,
        text = "增强好友列表鼠标提示",
        callback = function(cfg, v, loading)
            _163UI_TOGGLE_FRIEND_COLOR_TIP(v, loading);
        end
    },
    {
        var = "auto_quest",
        default = false,
        text = "\124cffffffff自动交接任务\124r",
        tip = "支持Questie ClassicCodex Leatrix_Plus。`如果使用其他单体插件，请在单体插件的设置里自行寻找。",
        callback = function(cfg, v, loading)
            if loading then return; end
            U1ChangeCfg("!!!163ui!!!/auto_quest_accept", v)
            U1ChangeCfg("!!!163ui!!!/auto_quest_complete", v)
        end,
        -- getvalue = function()
        --     return Questie and Questie.db and Questie.db.char and (Questie.db.char.autocomplete or Questie.db.char.autoaccept) or CodexConfig and (CodexConfig.autoTurnin or CodexConfig.autoAccept) or _163_Leatrix_Plus_LeaPlusLC and (_163_Leatrix_Plus_LeaPlusLC["AutomateQuests"] == "On");
        -- end,
    },
    {
        var = "auto_quest_accept",
        default = false,
        text = "\124cffffafaf自动接受任务\124r",
        tip = "支持Questie ClassicCodex Leatrix_Plus。`Leatrix_Plus无法单独设置接或者交任务`如果使用其他单体插件，请在单体插件的设置里自行寻找。",
        callback = function(cfg, v, loading)
            if loading then return; end
            if v then
                quest_auto_quest_accept_Toggle_on();
            else
                quest_auto_quest_accpet_Toggle_off();
            end
        end,
        getvalue = function()
            return Questie and Questie.db and Questie.db.char and Questie.db.char.autoaccept or CodexConfig and CodexConfig.autoAccept or _163_Leatrix_Plus_LeaPlusLC and (_163_Leatrix_Plus_LeaPlusLC["AutomateQuests"] == "On");
            -- return Questie and Questie.db and Questie.db.char and (Questie.db.char.autocomplete or Questie.db.char.autoaccept) or CodexConfig and (CodexConfig.autoTurnin or CodexConfig.autoAccept) or _163_Leatrix_Plus_LeaPlusLC and (_163_Leatrix_Plus_LeaPlusLC["AutomateQuests"] == "On");
        end,
    },
    {
        var = "auto_quest_complete",
        default = false,
        text = "\124cffffafaf自动交还任务\124r",
        tip = "支持Questie ClassicCodex Leatrix_Plus。`Leatrix_Plus无法单独设置接或者交任务`如果使用其他单体插件，请在单体插件的设置里自行寻找。",
        callback = function(cfg, v, loading)
            if loading then return; end
            if v then
                quest_auto_quest_complete_Toggle_on();
            else
                quest_auto_quest_complete_Toggle_off();
            end
        end,
        getvalue = function()
            return Questie and Questie.db and Questie.db.char and Questie.db.char.autocomplete or CodexConfig and CodexConfig.autoTurnin or _163_Leatrix_Plus_LeaPlusLC and (_163_Leatrix_Plus_LeaPlusLC["AutomateQuests"] == "On");
        end,
    },
    {
        var = "ann_interrupt",
        default = true,
        text = "通报打断",
        tip = "在团队/小队/喊（单人时）通报打断成功信息。",
    },
    {
        var = "ann_missed",
        default = true,
        text = "通报关键技能未命中",
        tip = "在团队/小队/喊（单人时）通报关键技能未命中信息（嘲讽）。",
    },
    {
        var = "nameplateNotSelectedAlpha",
        text = "非当前目标的姓名版透明度",
        tip = "当选择一个目标时，其它姓名版的透明度",
        type = "spin",
        range = { 0.0, 1.0, 0.05 },
        default = 0.25,
        getvalue = function() return GetCVar("nameplateNotSelectedAlpha"); end,
        callback = function(cfg, v, loading) SetCVar("nameplateNotSelectedAlpha", min(1.0, max(0.0, tonumber(v)))); end,
    },
    U1CfgMakeCVarOption("按下按键时开始动作", "ActionButtonUseKeyDown"),
    {
        var = "ffxDeath",
        text = "关闭灵魂状态下的泛光效果",
        --tip = L["说明`这个值是修改"],
        default = true,
        getvalue = function() return GetCVar("ffxDeath") == "0"; end,
        callback = function(cfg, v, loading) SetCVar("ffxDeath", v and "0" or "1"); end,
    },
    {
        var = "cameraDistanceMaxZoomFactor",
        text = L["设置最远镜头距离"],
        tip = L["说明`这个值是修改\"界面-镜头-最大镜头距离\"绝对值, 比如, 系统默认为15, 界面设置里调到最大是15，调到中间是7.5。当设置此选项为25时，调到最大是25，调到中间是12.5"],
        type = "spin",
        range = {1, 2.6, 0.1},
        cols = 3,
        default = "2.6",
        getvalue = function() return ceil(GetCVar("cameraDistanceMaxZoomFactor")*10)/10 end,
        callback = function(cfg, v, loading) if loading then C_Timer.After(0.25, function() SetCVar("cameraDistanceMaxZoomFactor", v) end) else SetCVar("cameraDistanceMaxZoomFactor", v) end end,
    },
    {
        var = "num_empty_bag_slots",
        text = "显示背包空格数量",
        --tip = L["说明`这个值是修改"],
        default = true,
        callback = function(cfg, v, loading) _163_BagNum:Toggle(v) end,
        {
            var = "fontSize",
            text = "字体大小",
            default = 20,
            type = "spin",
            range = { 4, 40, 2 },
            callback = function(cfg, v, loading)
                _163_BagNum:Size(v);
            end,
        },
    },
    {
        var = "violenceLevel",
        text = "暴力等级",
        --tip = L["说明`这个值是修改"],
        type = "spin",
        range = {1, 5, 1},
        cols = 3,
        default = "5",
        getvalue = function() return GetCVar("violenceLevel") end,
        callback = function(cfg, v, loading) SetCVar("violenceLevel", v) end,
    },
    {
        var = "playerResource",
        text = "个人资源",
        --tip = L["说明`这个值是修改"],
        default = false,
        callback = function(cfg, v, loading) _163_PlayerStatus:TogglePlayerResource(v) end,
        {
            var = "colorHP",
            text = "生命条根据血量染色",
            --tip = L["说明`这个值是修改"],
            default = false,
            callback = function(cfg, v, loading) _163_PlayerStatus:TogglecolorHP(v) end,
        },
        {
            var = "power",
            text = "能量条",
            --tip = L["说明`这个值是修改"],
            default = false,
            callback = function(cfg, v, loading) _163_PlayerStatus:TogglePlayerResourcePower(v) end,
        },
        {
            var = "text",
            text = "个人资源数值",
            --tip = L["说明`这个值是修改"],
            default = false,
            callback = function(cfg, v, loading) _163_PlayerStatus:TogglePlayerResourceText(v) end,
        },
        {
            var = "width",
            text = "宽度",
            default = 190,
            type = "spin",
            range = { 50, 500, 5 },
            callback = function(cfg, v, loading)
                _163_PlayerStatus:SetBarW(v);
            end,
        },
        {
            var = "height",
            text = "高度",
            default = 15,
            type = "spin",
            range = { 5, 50, 1 },
            callback = function(cfg, v, loading)
                _163_PlayerStatus:SetBarH(v);
            end,
        },
        {
            var = "alpha",
            text = "透明度",
            default = 1.0,
            type = "spin",
            range = { 0.0, 1.0, 0.05 },
            callback = function(cfg, v, loading)
                _163_PlayerStatus:Set_Alpha(v);
            end,
        },
        {
            var = "posx",
            text = "横向位置X",
            default = 0,
            type = "spin",
            range = { - math.floor(GetScreenWidth() * 0.5), math.floor(GetScreenWidth() * 0.5), 5 },
            callback = function(cfg, v, loading)
                _163_PlayerStatus:SetBarPosX(v);
            end,
        },
        {
            var = "posy",
            text = "纵向位置Y",
            default = -120,
            type = "spin",
            range = { - math.floor(GetScreenHeight() * 0.5), math.floor(GetScreenHeight() * 0.5), 5 },
            callback = function(cfg, v, loading)
                _163_PlayerStatus:SetBarPosY(v);
            end,
        },
    },
    --[[U1CfgMakeCVarOption("姓名板的最大显示距离", "nameplateMaxDistance", {
        tip = "说明`怀旧服默认最高40，不建议将数值设置过大。",
        type = "spin",
        range = {20, 200, 10},
        callback = function(cfg, v, loading)
            if v / 10 < 10 then
                v = (v / 10) .. "e1";
            else
                v = (v / 100) .. "e2";
            end
            SetCVar("nameplateMaxDistance", v);
        end,
    }),]]
    -- {
    --     var = 'profanityFilter',
    --     text = '强制关闭语言过滤器',
    --     tip = '说明`4.3版本后出现的BUG，玩家即使不开启过滤器，系统有时也会强制过滤，而且在界面选项里无法修改。开启此选项后，网易有爱会强制关闭语言过滤器选项。',
    --     default = true,
    --     --getvalue = function() return GetCVar'profanityFilter' == '1' end,
    --     callback = function(cfg, v, loading)
    --         if(U1GetCfgValue("!!!163UI!!!", 'profanityFilter')) then
    --             SetCVar('profanityFilter', '0')
    --             --if BNConnected() then
    --             pcall(BNSetMatureLanguageFilter, false)
    --         end
    --             --return setProfanityFilter()
    --     end
    -- },
    {
        text = "新物品优先放入右边的行囊",
        var = "SetInsertItemsLeftToRight",
        tip = "说明`拾取/购买新物品时，优先放入靠右的背包。",
        default = false,
        getvalue = function() return GetInsertItemsLeftToRight() end,
        callback = function(cfg, v, loading)
            if loading then return end
            SetInsertItemsLeftToRight(v)
        end,
    },

    {
        var = "alwaysCompareItems",
        default = '1',
        text = "鼠标对比装备",
        tip = "说明`鼠标指向装备图标或装备链接时，显示身上对应部位的装备",
        callback = function(cfg, v, loading)
            if v  then
                SetCVar("alwaysCompareItems",'1')
            else
                SetCVar("alwaysCompareItems",'0')
            end -- alwaysCompareItems
        end
    },
    {
        var = "showLevelOnSlot",
        text = "装备栏左上角显示物品等级",
        default = 0,
    },
    {
        var = "showLevelOnBag",
        text = "背包物品左上角显示物品等级",
        default = true,
        callback = function(cfg, v, loading) _163UI_BagItemLevel_Toggle(v) end,
    },
    --[[ 7.0 以后无法显示详细信息，只能取消了
    {
        var = "lootenh",
        text = "启用ROLL点界面增强",
        tip = "说明`在物品等待分配的界面上显示已选择'贪婪'、'需求'、'放弃'的队员人数及职业。并可以在获胜时生成Roll点结果链接供点击查看。|cff00ff00开启此选项后，界面-显示-详细拾取信息将保持开启。|r",
        default = 1,
        reload = 1,
        callback = function(cfg, v, loading)
            if loading and v then
                CoreCall("U1GroupLootRoll");
            end
            U1GroupLootRoll = nil;
        end,
        {
            var = "filter",
            text = "屏蔽ROLL点时的详细信息",
            tip = "说明`Roll点界面增强要求始终显示详细的拾取信息，如果觉得太乱可以开启此选项屏蔽这些信息，可以通过物品选择界面看到需求选择情况，最后结果中的链接可以点击查看详情。",
            default = false,
            callback = function(cfg, v, loading)
                U1_GROUP_LOOT_FILTER = v
            end,
        },
    },
    --]]
    {
        var = "hideCompactRaid",
        text = L["完全屏蔽默认的团队框架"],
        tip = L["说明`完全屏蔽暴雪团队框架及屏幕左侧的控制条，在使用Grid等团队框架时可以减少占用。` `注意此选项不能在战斗中设置"],
        default = nil,
        secure = 1,
        callback = function(cfg, v, loading)
            _b_hideCompactRaid = v;
            if loading and not v then return end
            if not GetDisplayedAllyFrames or not CompactRaidFrameManager or not CompactRaidFrameContainer then
                U1Message(L["此选项不适合此游戏版本"])
                return
            end
            if InCombatLockdown() then U1Message(L["此选项无法在战斗中设置，请脱战后重试"]) return end

            if not U1StoreHideCompactRaid then
                U1StoreHideCompactRaid = { onUpdateFrames = {} } --first time --CompactUnitFrame.lua:142 --if show target then there will be tainting
                for i=1, 100 do
                    local frame = _G["CompactRaidFrame"..i]
                    if frame and frame.onUpdateFrame then U1StoreHideCompactRaid.onUpdateFrames[frame.onUpdateFrame] = true end
                end
                hooksecurefunc("CompactUnitFrame_SetUpdateAllOnUpdate", function(frame)
                    if frame and frame.onUpdateFrame then U1StoreHideCompactRaid.onUpdateFrames[frame.onUpdateFrame] = true end
                end)
            end

            -- CompactRaidFrameManager:HookScript("OnShow", _Hook_HideOnShow)
            CompactRaidFrameContainer:HookScript("OnShow", _Hook_HideOnShow)
            if v then
                CompactRaidFrameManager:SetAlpha(0) --CompactRaidFrameManager 不能Hide，会污染
                CompactRaidFrameManager:UnregisterAllEvents();
                CompactRaidFrameContainer:Hide()
                CompactRaidFrameContainer:UnregisterAllEvents();
                for frame, _ in pairs(U1StoreHideCompactRaid.onUpdateFrames) do frame:Hide() end
            else
                for frame, _ in pairs(U1StoreHideCompactRaid.onUpdateFrames) do frame:Show() end
                CompactRaidFrameManager:RegisterEvent("DISPLAY_SIZE_CHANGED");
                CompactRaidFrameManager:RegisterEvent("UI_SCALE_CHANGED");
                CompactRaidFrameManager:RegisterEvent("GROUP_ROSTER_UPDATE");
                CompactRaidFrameManager:RegisterEvent("UNIT_FLAGS");
                CompactRaidFrameManager:RegisterEvent("PLAYER_FLAGS_CHANGED");
                CompactRaidFrameManager:RegisterEvent("PLAYER_ENTERING_WORLD");
                CompactRaidFrameManager:RegisterEvent("PARTY_LEADER_CHANGED");
                CompactRaidFrameManager:RegisterEvent("RAID_TARGET_UPDATE");
                CompactRaidFrameManager:RegisterEvent("PLAYER_TARGET_CHANGED");

                CompactRaidFrameContainer:RegisterEvent("GROUP_ROSTER_UPDATE");
                CompactRaidFrameContainer:RegisterEvent("UNIT_PET");
                --local sub = U1CfgFindChild(cfg, "always")
                if GetDisplayedAllyFrames()=="raid" or true then --(sub and U1LoadDBValue(sub)) then
                    CompactRaidFrameContainer:Show()
                    CompactRaidFrameManager:SetAlpha(1)
                end
            end
        end,
        --[[{
            var = "always",
            default = nil,
            text = "无条件显示团队框架",
            tip = "说明`无论单人还是小队，只要解除屏蔽，就总是显示默认的团队框架。`修改此选项后必须切换次上一选项。",
        }]]
    },
    {
        var = "disableLaterLoading",
        text = L["延迟加载插件"],
        tip = L["说明`网易有爱独家支持，可以先读完蓝条然后再逐一加载插件。会大大加快读条速度，但是加载大型插件时会有卡顿。如果不喜欢这种方式，请取消勾选即可，下次进游戏时就会采用新设置。` `对比测试：`未开启时，在第7.5秒后读完蓝条同时加载完全部插件`开启后，在第3.8秒读完蓝条，第8.0秒加载完全部插件"],
        default = 1,
        getvalue = function() return not U1DB.disableLaterLoading end,
        callback = function(cfg, v, loading)
            U1DB.disableLaterLoading = not v;
        end,
        {
            var = "speed",
            text = L["插件加载速度（个/秒）"],
            tip = L["说明`　控制进入游戏时插件加载的速度，如果数值大，则单次卡顿的时间长，但总的加载时间会短，比如设置成100就会大卡一下后插件就全部加载好了。而设置成5则是每秒只会小卡一下，但要很久才能加载完全部插件。` `　另外可以使用/rl2命令来强制最慢速度加载，适合副本战斗中界面出错后（比如上载具没出动作条）迅速重载界面。"],
            default = 2,
            reload = 1,
            type = "spin",
            range = {1, 10, 1},
            getvalue = function() return U1DB.loadSpeed end,
            callback = function(cfg, v, loading)
                U1DB.loadSpeed = v
            end,
        }
    },
    {
        var = "checkAddonVersion",
        text = L["允许加载过期插件"],
        tip = L["说明`和人物选择功能插件界面上的选项一致"],
        default = "0",
        getvalue = function() return GetCVar("checkAddonVersion")=="0" end,
        callback = function(cfg, v, loading)
            SetCVar("checkAddonVersion", v and "0" or "1")
        end,
    },

    {
        var = "soundRedirect",
        text = "插件声音通过主声道播放",
        tip = "说明`开启此选项后，第三方的插件音效会从主声道播放，而不是默认的'声音效果'声道。这样就可以把所有的音效都关掉，但不会错过插件提示的声音。`注意，'系统-声音'设置里最上面的'开启声效'不能管, 要关的是'声音效果'和'环境音效'",
        default = nil,
        callback = function(cfg, v, loading)
            if loading then
                local config = cfg._path
                local playS, playSF = PlaySound, PlaySoundFile
                local function shouldRedirect(channel)
                    if(not U1GetCfgValue(config)) then return end
                    channel = channel and channel:upper() or "SFX"
                    if(channel == "MASTER") then return end
                    if(GetCVarBool("Sound_EnableSFX") and channel~="MUSIC" and channel~="MASTER" and channel~="AMBIENCE") then return end
                    return true
                end
                hooksecurefunc("PlaySound", function(sound, channel) if shouldRedirect(channel) then playS(sound, "Master") end end)
                hooksecurefunc("PlaySoundFile", function(sound, channel) if shouldRedirect(channel) then playSF(sound, "Master") end end)
            else
                if v then
                    if GetCVarBool("Sound_EnableSFX") then
                        U1Message("已关闭游戏音效，现在只会听到插件的声音")
                    end
                    SetCVar("Sound_EnableSFX", "0")
                    SetCVar("Sound_EnableAmbience", "0")
                end
            end
        end
    },
    {
        var = "ahkeep",
        text = "保持拍卖行界面开启",
        tip = "说明`打开交易技能等界面时保持拍卖行界面开启，适用于屏幕分辨率不高的玩家。如果遇到拍卖行无法打开的情况，请尝试关闭此选项。",
        default = false,
        callback = function(cfg, v, loading)
            if loading and not v then return end
            --- 拍卖行不会自动关闭
            CoreDependCall("Blizzard_AuctionUI", function()
                if v then
                    AuctionFrame:SetAttribute("UIPanelLayout-area", false);
                    tinsertdata(UISpecialFrames, "AuctionFrame")
                else
                    AuctionFrame:SetAttribute("UIPanelLayout-area", "doublewide");
                    tremovedata(UISpecialFrames, "AuctionFrame")
                end
                if not AuctionFrame._hooked163 then
                    AuctionFrame._hooked163 = true
                    hooksecurefunc(AuctionFrame, "SetAttribute", function(self, arg1, value)
                        if (arg1 == "UIPanelLayout-area" and value and U1GetCfgValue(cfg._path)) then
                            self:SetAttribute(arg1, false);
                        end
                    end)
                end
            end)
        end,
    },
    {
        var = "fixhot",
        text = "临时修复动作条热键乱码",
        tip = "说明`暴雪给动作条热键设置的默认字体不支持中文，所以遇到'鼠标滚轮'之类的就会显示????，这个选项是用来临时修复的，如果自己修改了字体，请关闭。",
        default = nil,
        callback = function(cfg, v, loading)
            U1NumberFontNormalSmallGray = U1NumberFontNormalSmallGray or WW:Font("U1NumberFontNormalSmallGray", ChatFontNormal, 11, .6, .6, .6, 1):SetFontFlags("OUTLINE, MONOCHROME"):un()
            if loading then
                CoreDependCall("ExtraActionBar", function()
                    hooksecurefunc("U1BAR_CreateBar", function(name)
                        local font, height, flags
                        if U1GetCfgValue(cfg._path) then
                            font, height, flags = U1NumberFontNormalSmallGray:GetFont()
                        else
                            font, height, flags = NumberFontNormalSmallGray:GetFont()
                        end
                        for i=1, 12 do _G[name.."AB"..i.."HotKey"]:SetFont(font, height, flags) end
                    end)
                end)
            end
            if loading and not v then return end

            local font, height, flags
            if v then
                font, height, flags = U1NumberFontNormalSmallGray:GetFont()
            else
                font, height, flags = NumberFontNormalSmallGray:GetFont()
            end
            for _, btn in next, ActionBarButtonEventsFrame.frames do
                if btn:GetName() then
                    local hotkey = _G[btn:GetName().."HotKey"]
                    if hotkey then
                        hotkey:SetSize(37, 10)
                        --载具的会看不到
                        --hotkey:ClearAllPoints();
                        --hotkey:SetPoint("TOPRIGHT", 1, -2);
                        hotkey:SetFont(font, height, flags)
                    end
                end
            end
            for i=1, 10 do
                if _G["U1BAR"..i] then
                    for j =1, 12 do _G["U1BAR"..i.."AB"..j.."HotKey"]:SetFont(font, height, flags) end
                end
            end
        end,
    },
    {
        text = "重置界面框体顺序",
        confirm = "此操作需要重载界面，您是否确定？",
        tip = "说明`经过网易有爱团队的测试，暴雪目前的界面存在一个BUG，当打开过多界面时，框体层次顺序可能会出错，使得某些按钮被遮挡无法看到，或者无法点击。` `当出现类似问题的时候，尝试点击此按钮，会重置所有框体的层次并重载界面，问题一般就会修复。",
        callback = function(cfg, v, loading)
            local f = EnumerateFrames()
            while f do
                if f:IsUserPlaced() then
                    f:SetFrameLevel(1)
                end
                f = EnumerateFrames(f)
            end
            ReloadUI()
        end
    },
    {
        text = L["小地图相关"], type = "text",
        --[[
        {
            var = "changeClip",
            default = false,
            text = "修改小地图目标标记",
            tip = "说明`默认的小地图目标标记太大，容易遮挡周围图标，选中此项可简化一下。",
            callback = function(cfg, v, loading)
                CoreCall("ToggleMinimapBlips", v)
            end
        },
        ]]
        {
            lower = true,
            text = L["收集全部小地图图标"],
            callback = function(cfg, v, loading)
                CoreCall("U1_MMBCollectAll");
                CoreCall("U1_MMBUpdateUI");
            end
        },
        {
            text = L["还原全部小地图图标"],
            callback = function(cfg, v, loading)
                CoreCall("U1_MMBRestoreAll");
                CoreCall("U1_MMBUpdateUI");
            end
        },
        {
            var = "coord",
            default = 1,
            text = "显示坐标小窗",
            callback = function(cfg, v, loading) if not MinimapCoordsButton then return end if v then MinimapCoordsButton:Show() else MinimapCoordsButton:Hide() end end,
        },
        {
            var = "zoom",
            default = 0,
            text = L["隐藏缩小放大按钮"],
            tip = L["说明`隐藏后用鼠标滚轮缩放小地图"],
            callback = function(cfg, v, loading) CoreCall("U1MMB_MinimapZoom_Toggle", v) end,
        },

    },
    {
        text = L["控制台设置"], type = "text",
        {
            var = "scale",
            text = "缩放比例",
            default = 1,
            type = "spin",
            range = { 0.5, 1.5, 0.1 },
            callback = function(cfg, v, loading)
                UUI():SetScale(v)
            end,
        },
        {
            var = "alpha",
            text = "透明度",
            default = 1,
            type = "spin",
            range = { 0.3, 1, 0.1 },
            callback = function(cfg, v, loading)
                UUI():SetAlpha(v)
            end,
        },
        {
            var = "english",
            text = L["显示插件英文名"],
            default = false,
            tip = L["说明`选中显示插件目录的名字，适合中高级用户快速选择所需插件。"],
            getvalue = function() return U1GetShowOrigin() end,
            callback = function(cfg, v, loading)
                U1SetShowOrigin(v);
                if not loading then
                    U1SortAddons();
                    UUI.Right.ADDON_SELECTED();
                end
            end,
        },
        {
            var = "sortmem",
            text = L["按插件所用内存排序"],
            default = false,
            tip = L["说明`选中则按插件(包括子模块)所占内存大小进行排序，否则按插件名称排序。"],
            getvalue = function() return not U1DB.sortByName end,
            callback = function(cfg, v, loading)
                U1DB.sortByName = not v;
                if not loading then
                    UpdateAddOnMemoryUsage();
                    U1SortAddons()
                end
            end,
        },
        {
            text = "清理自动保存方案",
            tip = "说明`一些小号长久运行生成的方案比较占内存，一键清理",
            confirm = "即将清理方案管理里所有自动保存的方案，以及橙装闪换的数据，会自动重载，请确定",
            callback = function(cfg, v, loading)
                U1DBG.profiles.auto = nil
                U1DB.LS = nil
                ReloadUI()
            end,
        },
    },
});