修改难度标示

--[[ Instance Difficulty icon
MiniMapInstanceDifficulty:SetParent(Minimap)
MiniMapInstanceDifficulty:ClearAllPoints()
MiniMapInstanceDifficulty:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", 3, 2)
MiniMapInstanceDifficulty:SetScale(0.75)]]
MiniMapInstanceDifficulty:Hide() -- 隐藏难度图标
MiniMapInstanceDifficulty.Show = function() return end

--[[ Guild Instance Difficulty icon
GuildInstanceDifficulty:SetParent(Minimap)
GuildInstanceDifficulty:ClearAllPoints()
GuildInstanceDifficulty:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", -2, 2)
GuildInstanceDifficulty:SetScale(0.75)]]
GuildInstanceDifficulty:Hide()    -- 隐藏难度图标
GuildInstanceDifficulty.Show = function() return end

--[[ Challenge Mode icon
MiniMapChallengeMode:SetParent(Minimap)
MiniMapChallengeMode:ClearAllPoints()
MiniMapChallengeMode:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", -2, -2)
MiniMapChallengeMode:SetScale(0.75)]]
MiniMapChallengeMode:Hide()
MiniMapChallengeMode.Show = function() return end

-- 难度标示
local function CreateFS(parent, size, justify)
    local f = parent:CreateFontString(nil, "OVERLAY")
    f:SetFont(C.font.filger_font, 15, "OUTLINE")
    f:SetShadowColor(0, 0, 0, 0)
    if(justify) then f:SetJustifyH(justify) end
    return f
end

local rd = CreateFrame("Frame", nil, Minimap)
rd:SetSize(24, 8)
--rd:SetScale(0.86)
rd:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", -1, 1)
rd:RegisterEvent("PLAYER_ENTERING_WORLD")
rd:RegisterEvent("PLAYER_DIFFICULTY_CHANGED")
rd:RegisterEvent("GUILD_PARTY_STATE_UPDATED")

local rdt = CreateFS(rd, 10, "RIGHT")
rdt:SetPoint("TOPRIGHT")

rd:SetScript("OnEvent", function()
    local inInstance, instanceType = IsInInstance() 
    local _, _, difficulty, _, maxPlayers = GetInstanceInfo()
    
    if inInstance and instanceType == "raid" then
        if difficulty == 3 then
            rdt:SetText("10")
        elseif difficulty == 4 then
            rdt:SetText("25")
        elseif difficulty == 5 then
            rdt:SetText("10H")
        elseif difficulty == 6 then
            rdt:SetText("25H")
        elseif difficulty == 7 then
            rdt:SetText("L")
        elseif difficulty == 9 then
            rdt:SetText("40")
        end
    elseif inInstance and instanceType == "party" then
        if difficulty == 1 then
            rdt:SetText("5")
        elseif difficulty == 2 then
            rdt:SetText("5H")
        elseif GetChallengeMode() then
            rdt:SetText("C")
        end
    elseif inInstance and maxPlayers == 3 then
        rdt:SetText("N")
    else
        rdt:SetText("")
    end
    
    if GuildInstanceDifficulty:IsShown() then
        rdt:SetTextColor(0, .9, 0)
    else
        rdt:SetTextColor(1, 1, 1)
    end
end)
原文地址:https://www.cnblogs.com/sakaras/p/2608705.html