Как сделать такую кнопку в имгуи?

ARMOR

Я будто попал в другое измерение
Автор темы
Модератор
5,020
7,105
Версия MoonLoader
.026-beta
sa-mp-074.png

Как та слева там где пишет "Основное меню" "Рынок" "Авто базар" и т.д
 
  • Нравится
Реакции: M0rtelli
Решение

Lua:
function imgui.Selector(labels, size, selected, pos, speed)
    local rBool = false
    if not speed then speed = 10 end
    if (pos.v < (selected.v * size.y)) then
        pos.v = pos.v + speed
    elseif (pos.v > (selected.v * size.y)) then
        pos.v = pos.v - speed
    end
    imgui.SetCursorPos(imgui.ImVec2(0.00, pos.v))
    local draw_list = imgui.GetWindowDrawList()
    local p = imgui.GetCursorScreenPos()
    local radius = size.y * 0.50
    draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/2, p.y), imgui.ImVec2(p.x + radius + 1 * (size.x - radius * 2.0), p.y + radius*2), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ButtonActive]))...

Tol4ek

Активный
216
56

Lua:
function imgui.Selector(labels, size, selected, pos, speed)
    local rBool = false
    if not speed then speed = 10 end
    if (pos.v < (selected.v * size.y)) then
        pos.v = pos.v + speed
    elseif (pos.v > (selected.v * size.y)) then
        pos.v = pos.v - speed
    end
    imgui.SetCursorPos(imgui.ImVec2(0.00, pos.v))
    local draw_list = imgui.GetWindowDrawList()
    local p = imgui.GetCursorScreenPos()
    local radius = size.y * 0.50
    draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/2, p.y), imgui.ImVec2(p.x + radius + 1 * (size.x - radius * 2.0), p.y + radius*2), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ButtonActive]))
    draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/2, p.y), imgui.ImVec2(p.x + 5, p.y + size.y), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.Button]), 0)
    draw_list:AddCircleFilled(imgui.ImVec2(p.x + radius + 1 * (size.x - radius * 2.0), p.y + radius), radius, imgui.GetColorU32(imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.ButtonActive])), radius/10*12)
    for i = 1, #labels do
        imgui.SetCursorPos(imgui.ImVec2(0, (i * size.y)))
        local p = imgui.GetCursorScreenPos()
        if imgui.InvisibleButton(labels[i], size) then selected.v = i rBool = true end
        if imgui.IsItemHovered() then
            draw_list:AddRectFilled(imgui.ImVec2(p.x-size.x/2, p.y), imgui.ImVec2(p.x + size.x, p.y + size.y), imgui.GetColorU32(imgui.ImVec4(0.58, 0.34, 0.46, 0.20)), radius/10*12)
        end
        imgui.SetCursorPos(imgui.ImVec2(20, (i * size.y + (size.y-imgui.CalcTextSize(labels[i]).y)/2)))
        imgui.Text(labels[i])
    end
    return rBool
end
 
  • Нравится
Реакции: ARMOR