Вопрос Imgui::tab crash

Забаненный
Статус
Оффлайн
Регистрация
9 Фев 2023
Сообщения
6
Реакции[?]
0
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Пожалуйста, авторизуйтесь для просмотра ссылки.
C++:
#include <string>
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
bool ImGui::tab(const char* icon, const char* label, bool selected, int last)
{
    ImGuiWindow* window = ImGui::GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiContext& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(icon);
    ImVec2 label_size[2];
    label_size[1] = { CalcTextSize(icon) }; PushFont(GetIO().Font);  label_size[2] = { CalcTextSize(label) }; PopFont();
    ImVec2 pos = window->DC.CursorPos;
    ImVec2 size = { 50,50 };

    const ImRect bb(pos, ImVec2(pos.x + size.x, pos.y + size.y));
    ImGui::ItemSize(size, 0);
    if (!ImGui::ItemAdd(bb, id))
        return false;

    bool hovered, held;
    bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, NULL);

    if (hovered || held)
        ImGui::SetMouseCursor(7);

    float deltatime = 1.5f * ImGui::GetIO().DeltaTime;
    static std::map<ImGuiID, float> hover_animation;
    auto it_hover = hover_animation.find(id);
    if (it_hover == hover_animation.end())
    {
        hover_animation.insert({ id, 0.f });
        it_hover = hover_animation.find(id);
    }
    it_hover->second = ImClamp(it_hover->second + (1.15f * ImGui::GetIO().DeltaTime * (hovered ? 1.f : -1.f)), 0.0f, 0.4f);
    it_hover->second *= GetStyle().Alpha;
    static std::map<ImGuiID, float> filled_animation;
    auto it_filled = filled_animation.find(id);
    if (it_filled == filled_animation.end())
    {
        filled_animation.insert({ id, 0.f });
        it_filled = filled_animation.find(id);
    }
    it_filled->second = ImClamp(it_filled->second + (2.15f * ImGui::GetIO().DeltaTime * (selected ? 1.f : -1.5f)), it_hover->second, 1.f);
    it_filled->second *= GetStyle().Alpha;

    static std::map<ImGuiID, float> alpha_animation;
    auto this_alpha = alpha_animation.find(id);
    if (this_alpha == alpha_animation.end())
    {
        alpha_animation.insert({ id, 0.f });
        this_alpha = alpha_animation.find(id);
    }
    this_alpha->second = ImClamp(it_filled->second + (2.15f * ImGui::GetIO().DeltaTime * (GetStyle().Alpha > 0.5f ? 1.f : -1.5f)), 0.3f, 1.f);
    this_alpha->second *= GetStyle().Alpha;

    auto ga = ImGui::GetStyle().Alpha;
    //37, 37, 40
    ImVec4 col = ImLerp(ImVec4{ 170 / 255.f, 170 / 255.f, 170 / 255.f, this_alpha->second }, ImVec4{ 130 / 255.f, 132 / 255.f, 170 / 255.f, this_alpha->second }, it_filled->second);
    ImVec4 col2 = ImLerp(ImVec4{ 190 / 255.f, 190 / 255.f, 190 / 255.f, this_alpha->second }, ImVec4{ 220 / 255.f, 220 / 255.f, 220 / 255.f, min(this_alpha->second, 1.0f) }, it_filled->second);
  

    //ImGui::GetWindowDrawList()->AddRectFilledMultiColor(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Max.x, bb.Max.y), ImColor(col2), ImColor(144 / 255.f, 144 / 255.f, 147 / 255.f, 1.f), ImColor(44 / 255.f, 44 / 255.f, 47 / 255.f, ga), ImColor(col2));


    ImGui::PushStyleColor(ImGuiCol_Text, col);
    if (last == 1)
        ImGui::RenderText(ImVec2(bb.Min.x + (50 / 2 - label_size[1].x / 2) - 5, bb.Min.y + (50 / 2 - label_size[1].y / 2)), icon);
    else if (last == 2)
        ImGui::RenderText(ImVec2(bb.Min.x + (50 / 2 - label_size[1].x / 2) - 1, bb.Min.y + (50 / 2 - label_size[1].y / 2)), icon);
    else
        ImGui::RenderText(ImVec2(bb.Min.x + (50 / 2 - label_size[1].x / 2), bb.Min.y + (50 / 2 - label_size[1].y / 2)), icon);
    
    ImGui::PopStyleColor();

    return pressed;
}
 
get good get legendware
Участник
Статус
Оффлайн
Регистрация
22 Сен 2020
Сообщения
435
Реакции[?]
200
Поинты[?]
47K
you have 80 lines of code, go thought each 10 lines and press f9 and put a break point and debug and keep pressing continue till you see which line crashes you
 
Забаненный
Статус
Оффлайн
Регистрация
9 Фев 2023
Сообщения
6
Реакции[?]
0
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Забаненный
Статус
Оффлайн
Регистрация
9 Фев 2023
Сообщения
6
Реакции[?]
0
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Похожие темы
Сверху Снизу