баг с fawesome6_solid и шрифтом

fsrxvdd

Активный
Автор темы
286
70
Версия MoonLoader
.026-beta
имеется вот такой скрипт:

lua:
local imgui = require('mimgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8
local fa = require('fAwesome6_solid')

local renderWindow = imgui.new.bool()

local fontPath = "E:\\Arizona Games Launcher\\bin\\arizona\\moonloader\\Arizona Tools\\files\\EagleSans-Reg.ttf"
local font = {}

local tabs = {
    fa.SPINNER..u8' Основное',
    fa.USER_GEAR .. u8' Настройки',
    fa.ROTATE_LEFT .. u8' В разработке',
    fa.ROTATE_LEFT .. u8' В разработке'
}
local selectedp = imgui.new.int(1)

function main()
    while not isSampAvailable() do wait(0) end

    sampRegisterChatCommand('mmmm', function()
        renderWindow[0] = not renderWindow[0]
    end)

    while true do
        wait(0)
    end
end

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    fa.Init()
    local io = imgui.GetIO()
    for Size = 10, 25 do
        font[Size] = io.Fonts:AddFontFromFileTTF(fontPath, Size, nil, io.Fonts:GetGlyphRangesCyrillic())
    end
end)

local window = imgui.OnFrame(function() return renderWindow[0] end, function(self)
    local resX, resY = getScreenResolution()
    local sizeX, sizeY = 700, 400
    imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Основное меню', renderWindow, imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoResize)

    imgui.SetCursorPos(imgui.ImVec2(0, 130))
    if font then imgui.PushFont(font[17]) end
    imgui.CustomMenu(tabs, selectedp, imgui.ImVec2(135, 30), 0.2, true)
   
    imgui.SetCursorPos(imgui.ImVec2(150, 35))
    imgui.BeginChild('##main', imgui.ImVec2(500, 300), true)
       
        if selectedp[0] == 1 then

            imgui.Text(fa.HOUSE_CHIMNEY)

        elseif selectedp[0] == 2 then

            if imgui.Button(u8'Камера 1') then
                setCameraZoom(0)
            end
            if imgui.Button(u8'Камера 2') then
                setCameraZoom(1)
            end
            if imgui.Button(u8'Камера 3') then
                setCameraZoom(2)
            end

        elseif selectedp[0] == 3 then

           

        elseif selectedp[0] == 4 then

            imgui.Text('123')

        end

    imgui.EndChild()

    imgui.End()

    if font then imgui.PopFont() end

end)

---@param labels array: Названия элементов меню
---@param selected number: Выбранный пункт меню
---@param size string: Размер элементов
---@param speed number: Скорость анимации выбора элемента (необязательно, по стандарту - 0.2)
---@param centering bool: Центрирование текста в элементе (необязательно, по стандарту - false)
function imgui.CustomMenu(labels, selected, size, speed, centering)
    local changed = false
    speed = speed or 0.2
    centering = centering or false
    local radius = size.y * 0.5

    if LastActiveTime == nil then LastActiveTime = {} end
    if LastActive == nil then LastActive = {} end

    local draw_list = imgui.GetWindowDrawList()
    local style = imgui.GetStyle()

    local function ImSaturate(f)
        return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end

    for i, label in ipairs(labels) do
        local cursorPos = imgui.GetCursorPos()
        local screenPos = imgui.GetCursorScreenPos()

        if imgui.InvisibleButton(label .. '##' .. i, size) then
            selected[0] = i
            LastActiveTime[label] = os.clock()
            LastActive[label] = true
            changed = true
        end

        imgui.SetCursorPos(cursorPos)

        local t = selected[0] == i and 1.0 or 0.0
        if LastActive[label] then
            local time = os.clock() - (LastActiveTime[label] or 0)
            if time <= 0.3 then
                local t_anim = ImSaturate(time / speed)
                t = selected[0] == i and t_anim or 1.0 - t_anim
            else
                LastActive[label] = false
            end
        end

        local col_active = style.Colors[imgui.Col.ButtonActive]
        local col_button = style.Colors[imgui.Col.Button]
        local col_hovered = style.Colors[imgui.Col.ButtonHovered]

        local bg_color = selected[0] == i
            and imgui.ColorConvertFloat4ToU32(col_active)
            or imgui.ColorConvertFloat4ToU32(imgui.ImVec4(0, 0, 0, 0))

        local box_color = selected[0] == i
            and imgui.ColorConvertFloat4ToU32(col_button)
            or imgui.ColorConvertFloat4ToU32(imgui.ImVec4(0, 0, 0, 0))

        local hover_overlay = imgui.ColorConvertFloat4ToU32(
            imgui.ImVec4(col_hovered.x, col_hovered.y, col_hovered.z, imgui.IsItemHovered() and 0.2 or 0.0)
        )

        draw_list:AddRectFilled(
            imgui.ImVec2(screenPos.x - size.x / 6, screenPos.y),
            imgui.ImVec2(screenPos.x + (radius * 0.65) + t * size.x, screenPos.y + size.y),
            bg_color, 10.0
        )

        draw_list:AddRectFilled(
            imgui.ImVec2(screenPos.x - size.x / 6, screenPos.y),
            imgui.ImVec2(screenPos.x + (radius * 0.65) + size.x, screenPos.y + size.y),
            hover_overlay, 10.0
        )

        draw_list:AddRectFilled(
            imgui.ImVec2(screenPos.x, screenPos.y),
            imgui.ImVec2(screenPos.x + 5, screenPos.y + size.y),
            box_color
        )

        local text_size = imgui.CalcTextSize(label)
        local text_x = cursorPos.x + (centering and (size.x - text_size.x) / 2 or 15)
        local text_y = cursorPos.y + (size.y - text_size.y) / 2
        imgui.SetCursorPos(imgui.ImVec2(text_x, text_y))
        imgui.Text(label)

        imgui.SetCursorPos(imgui.ImVec2(cursorPos.x, cursorPos.y + size.y))
    end

    return changed
end
при использовании шрифта и иконок, они выводятся в виде " ? ", можно ли как либо пофиксить это дело?
как только убираю шрифт, иконки отображаются нормально