Подведи собственные итоги года совместно с YOUGAME и забери ценные призы! Перейти

Вопрос Legendware buttons

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
28 Авг 2019
Сообщения
120
Реакции
8
how can i add these button types to legendware?
2021-01-03 22_04_03-(2) Исходник - Neverpivo v2 (ImGui) _ Игровой форум YouGame.Biz.png
 
C++:
Expand Collapse Copy
bool ImGui::Checkbox(const char* label, bool* v)
{
    ImVec2 p = ImGui::GetCursorScreenPos() + ImVec2(0, 0);
    ImDrawList* draw_list = ImGui::GetWindowDrawList();

    float height = ImGui::GetFrameHeight();
    float width = height * 1.50f;
    float radius = height * 0.50f;

    ImGuiContext& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    ImGuiWindow* window = ImGui::GetCurrentWindow();
    const ImGuiID id = window->GetID(label);
    const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true);

    const float square_sz = GetFrameHeight();
    const ImVec2 pos = window->DC.CursorPos;
    const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
    if (!ItemAdd(total_bb, id))
        return false;


    ImGui::InvisibleButton(label, ImVec2(190 + width, height));
    if (ImGui::IsItemClicked())
        *v = !*v;

    float t = *v ? 1.0f : 0.0f;

    if (customize == true)
    {
    }
    else
    {
        animspeed = 0.30f;
    }
    if (g.LastActiveId == g.CurrentWindow->GetID(label))
    {
        float t_anim = ImSaturate(g.LastActiveIdTimer / animspeed);
        t = *v ? (t_anim) : (1.f - t_anim);
    }

    ImU32 col_bg;
    ImU32 col_bg2;
    if (ImGui::IsItemHovered())
    {
        col_bg = ImGui::GetColorU32(ImLerp(ImColor(0,0,0), ImVec4(0.01f, 0.09f, 0.17f, 1.f), t));
        col_bg2 = ImGui::GetColorU32(ImLerp(ImColor(84, 83, 89, 255), ImVec4(0.3f, 0.6f, 1.f, 1.f), t));
    }
    else
    {
        col_bg = ImGui::GetColorU32(ImLerp(ImColor(0,0,0), ImVec4(0.01f, 0.09f, 0.17f, 1.f), t));
        col_bg2 = ImGui::GetColorU32(ImLerp(ImColor(84, 83, 89, 255), ImVec4(0.3f, 0.6f, 1.f, 1.f), t));
    }

    draw_list->AddRectFilled(ImVec2(p.x + 203, p.y + 4), ImVec2(p.x + 227, p.y + 15), col_bg, height * 0.5f);
    draw_list->AddCircleFilled(ImVec2(200 + p.x + radius + t * (width - radius * 2.0f), p.y + radius), radius - 2.5f, col_bg2);

    if (label_size.x > 0.0f)
    {
        ImGui::PushFont(ne_takoi_tolstiy2);
        ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f));
        RenderText(ImVec2((p.x + width) - 35, (p.y + height) - 16), label);
        ImGui::PopStyleColor(1);
        ImGui::PopFont();
        ImGui::Spacing();
        ImGui::Spacing();
        ImGui::Spacing();
        ImGui::Spacing();
    }

}
UPD: SHITCODE ,парни я это высрал после 2 суток без сна, соре
 

Вложения

  • 1609716389717.png
    1609716389717.png
    5.5 KB · Просмотры: 181
Последнее редактирование:
C++:
Expand Collapse Copy
bool ImGui::Checkbox(const char* label, bool* v)
{
    ImVec2 p = ImGui::GetCursorScreenPos() + ImVec2(0, 0);
    ImDrawList* draw_list = ImGui::GetWindowDrawList();

    float height = ImGui::GetFrameHeight();
    float width = height * 1.50f;
    float radius = height * 0.50f;

    ImGuiContext& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    ImGuiWindow* window = ImGui::GetCurrentWindow();
    const ImGuiID id = window->GetID(label);
    const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true);

    const float square_sz = GetFrameHeight();
    const ImVec2 pos = window->DC.CursorPos;
    const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
    if (!ItemAdd(total_bb, id))
        return false;


    ImGui::InvisibleButton(label, ImVec2(190 + width, height));
    if (ImGui::IsItemClicked())
        *v = !*v;

    float t = *v ? 1.0f : 0.0f;

    if (customize == true)
    {
    }
    else
    {
        animspeed = 0.30f;
    }
    if (g.LastActiveId == g.CurrentWindow->GetID(label))
    {
        float t_anim = ImSaturate(g.LastActiveIdTimer / animspeed);
        t = *v ? (t_anim) : (1.f - t_anim);
    }

    ImU32 col_bg;
    ImU32 col_bg2;
    if (ImGui::IsItemHovered())
    {
        col_bg = ImGui::GetColorU32(ImLerp(ImColor(0,0,0), ImVec4(0.01f, 0.09f, 0.17f, 1.f), t));
        col_bg2 = ImGui::GetColorU32(ImLerp(ImColor(84, 83, 89, 255), ImVec4(0.3f, 0.6f, 1.f, 1.f), t));
    }
    else
    {
        col_bg = ImGui::GetColorU32(ImLerp(ImColor(0,0,0), ImVec4(0.01f, 0.09f, 0.17f, 1.f), t));
        col_bg2 = ImGui::GetColorU32(ImLerp(ImColor(84, 83, 89, 255), ImVec4(0.3f, 0.6f, 1.f, 1.f), t));
    }

    draw_list->AddRectFilled(ImVec2(p.x + 203, p.y + 4), ImVec2(p.x + 227, p.y + 15), col_bg, height * 0.5f);
    draw_list->AddCircleFilled(ImVec2(200 + p.x + radius + t * (width - radius * 2.0f), p.y + radius), radius - 2.5f, col_bg2);

    if (label_size.x > 0.0f)
    {
        ImGui::PushFont(ne_takoi_tolstiy2);
        ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f));
        RenderText(ImVec2((p.x + width) - 35, (p.y + height) - 16), label);
        ImGui::PopStyleColor(1);
        ImGui::PopFont();
        ImGui::Spacing();
        ImGui::Spacing();
        ImGui::Spacing();
        ImGui::Spacing();
    }

}
Посмотреть вложение 123129
customize , animspeed ?
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
1609936799503.png

Все можно сделать
 
Назад
Сверху Снизу