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

Вопрос Как пофиксить этот ебучий слайдер?

iq abuser
Пользователь
Пользователь
Статус
Оффлайн
Регистрация
16 Апр 2021
Сообщения
662
Реакции
140
У меня в сурсе(unisense) слайдер с самого начала был прозрачный, была только обводка и какой-то мелкий хуй посредине, как фикситб?)))
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
мне что ради слайдеров бегать по форуму и искать юнисекс.....
Почему бы и нет? Ты вот когда-нибудь видел тса который сам скамит Авито? Нет? Мораль думайте сами :seemsgood:
Камазииик ну за шо, ты же добрый :FeelsBadMan:
 

Почему бы и нет? Ты вот когда-нибудь видел тса который сам скамит Авито? Нет? Мораль думайте сами :seemsgood:
Камазииик ну за шо, ты же добрый :FeelsBadMan:
Так ты хочеш что бы тебе помогли. Тебе тяжело скинуть код? Зачем человеку качать вечь(ВЕСЬ) сурс только для того, что бы помочь тебе
 

Вложения

  • изображение_2021-07-10_223200.png
    изображение_2021-07-10_223200.png
    33.4 KB · Просмотры: 10
C++:
Expand Collapse Copy
bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, bool minimum_damage, float power)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    if (window->DC.CurrLineTextBaseOffset != window->DC.PrevLineTextBaseOffset)
        SetCursorPosY(GetCursorPosY() + c_menu::get().dpi_scale * 8.f);

    SetCursorPosX(GetCursorPosX() + c_menu::get().dpi_scale * 3.f);

    ImGuiContext& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(label);
    const float w = CalcItemWidth() - c_menu::get().dpi_scale * 3.f;

    const ImVec2 label_size = CalcTextSize(label, NULL, true);
    const ImRect frame_bb(window->DC.CursorPos + ImVec2(0, 11 * c_menu::get().dpi_scale), window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f * 0.5f));
    const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));

    ItemSize(ImRect(total_bb.Min - ImVec2(0, 22 * c_menu::get().dpi_scale), total_bb.Max), style.FramePadding.y);
    if (!ItemAdd(ImRect(total_bb.Min - ImVec2(0, 22 * c_menu::get().dpi_scale), total_bb.Max), id, &frame_bb))
        return false;

    // Default format string when passing NULL
    if (format == NULL)
        format = DataTypeGetInfo(data_type)->PrintFmt;
    else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.)
        format = PatchFormatStringFloatToInt(format);

    // Tabbing or CTRL-clicking on Slider turns it into an input box

    const bool hovered = ItemHoverable(frame_bb, id);
    bool temp_input_is_active = TempInputIsActive(id);
    bool temp_input_start = false;
    if (!temp_input_is_active)
    {
        const bool focus_requested = FocusableItemRegister(window, id);
        const bool clicked = (hovered && g.IO.MouseClicked[0]);
        if (focus_requested || clicked || g.NavActivateId == id || g.NavInputId == id)
        {
            SetActiveID(id, window);
            SetFocusID(id, window);
            FocusWindow(window);
            g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right);
        }
    }

    // Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that..
    if (temp_input_is_active || temp_input_start)
        return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);


    // Draw frame

    const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
    const ImVec4 hover_act = ImVec4(g_cfg.menu.color.r() / 255.f, g_cfg.menu.color.g() / 255.f, g_cfg.menu.color.b() / 255.f, 1.f);
    const ImVec4 hover_dis = ImVec4(g_cfg.menu.color.r() / 255.f, g_cfg.menu.color.g() / 255.f, g_cfg.menu.color.b() / 255.f, 1.f);
    const ImVec4 hover_off = ImVec4(32 / 255.f, 32 / 255.f, 32 / 255.f, 0.4f);


    float deltatime = 1.5f * ImGui::GetIO().DeltaTime;

    static std::map<ImGuiID, ImVec4> hover_animation;
    auto it_hover = hover_animation.find(id);
    if (it_hover == hover_animation.end())
    {
        hover_animation.insert({ id, hover_off });
        it_hover = hover_animation.find(id);
    }
    if (hovered || g.ActiveId == id)
    {
        ImVec4 to = hover_act;
        if (it_hover->second.x != to.x)
        {
            if (it_hover->second.x < to.x)
                it_hover->second.x = ImMin(it_hover->second.x + deltatime, to.x);
            else if (it_hover->second.x > to.x)
                it_hover->second.x = ImMax(to.x, it_hover->second.x - deltatime);
        }

        if (it_hover->second.y != to.y)
        {
            if (it_hover->second.y < to.y)
                it_hover->second.y = ImMin(it_hover->second.y + deltatime, to.y);
            else if (it_hover->second.y > to.y)
                it_hover->second.y = ImMax(to.y, it_hover->second.y - deltatime);
        }

        if (it_hover->second.z != to.z)
        {
            if (it_hover->second.z < to.z)
                it_hover->second.z = ImMin(it_hover->second.z + deltatime, to.z);
            else if (it_hover->second.z > to.z)
                it_hover->second.z = ImMax(to.z, it_hover->second.z - deltatime);
        }

        if (it_hover->second.w != to.w)
        {
            if (it_hover->second.w < to.w)
                it_hover->second.w = ImMin(it_hover->second.w + deltatime, to.w);
            else if (it_hover->second.w > to.w)
                it_hover->second.w = ImMax(to.w, it_hover->second.w - deltatime);
        }
    }
    else
    {
        ImVec4 to = hover_off;
        if (it_hover->second.x != to.x)
        {
            if (it_hover->second.x < to.x)
                it_hover->second.x = ImMin(it_hover->second.x + deltatime, to.x);
            else if (it_hover->second.x > to.x)
                it_hover->second.x = ImMax(to.x, it_hover->second.x - deltatime);
        }

        if (it_hover->second.y != to.y)
        {
            if (it_hover->second.y < to.y)
                it_hover->second.y = ImMin(it_hover->second.y + deltatime, to.y);
            else if (it_hover->second.y > to.y)
                it_hover->second.y = ImMax(to.y, it_hover->second.y - deltatime);
        }

        if (it_hover->second.z != to.z)
        {
            if (it_hover->second.z < to.z)
                it_hover->second.z = ImMin(it_hover->second.z + deltatime, to.z);
            else if (it_hover->second.z > to.z)
                it_hover->second.z = ImMax(to.z, it_hover->second.z - deltatime);
        }

        if (it_hover->second.w != to.w)
        {
            if (it_hover->second.w < to.w)
                it_hover->second.w = ImMin(it_hover->second.w + deltatime, to.w);
            else if (it_hover->second.w > to.w)
                it_hover->second.w = ImMax(to.w, it_hover->second.w - deltatime);
        }
    }


    static std::map<ImGuiID, ImVec4> grab_animation;
    auto it_grab = grab_animation.find(id);
    if (it_grab == grab_animation.end())
    {
        grab_animation.insert({ id, hover_dis });
        it_grab = grab_animation.find(id);
    }
    if (g.ActiveId == id)
    {
        ImVec4 to = hover_act;
        if (it_grab->second.x != to.x)
        {
            if (it_grab->second.x < to.x)
                it_grab->second.x = ImMin(it_grab->second.x + deltatime, to.x);
            else if (it_grab->second.x > to.x)
                it_grab->second.x = ImMax(to.x, it_grab->second.x - deltatime);
        }

        if (it_grab->second.y != to.y)
        {
            if (it_grab->second.y < to.y)
                it_grab->second.y = ImMin(it_grab->second.y + deltatime, to.y);
            else if (it_grab->second.y > to.y)
                it_grab->second.y = ImMax(to.y, it_grab->second.y - deltatime);
        }

        if (it_grab->second.z != to.z)
        {
            if (it_grab->second.z < to.z)
                it_grab->second.z = ImMin(it_grab->second.z + deltatime, to.z);
            else if (it_grab->second.z > to.z)
                it_grab->second.z = ImMax(to.z, it_grab->second.z - deltatime);
        }
    }
    else
    {
        ImVec4 to = hover_dis;
        if (it_grab->second.x != to.x)
        {
            if (it_grab->second.x < to.x)
                it_grab->second.x = ImMin(it_grab->second.x + deltatime, to.x);
            else if (it_grab->second.x > to.x)
                it_grab->second.x = ImMax(to.x, it_grab->second.x - deltatime);
        }

        if (it_grab->second.y != to.y)
        {
            if (it_grab->second.y < to.y)
                it_grab->second.y = ImMin(it_grab->second.y + deltatime, to.y);
            else if (it_grab->second.y > to.y)
                it_grab->second.y = ImMax(to.y, it_grab->second.y - deltatime);
        }

        if (it_grab->second.z != to.z)
        {
            if (it_grab->second.z < to.z)
                it_grab->second.z = ImMin(it_grab->second.z + deltatime, to.z);
            else if (it_grab->second.z > to.z)
                it_grab->second.z = ImMax(to.z, it_grab->second.z - deltatime);
        }
    }

    RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding);
    window->DrawList->AddRect(frame_bb.Min, frame_bb.Max, ImGui::GetColorU32(it_hover->second), g.Style.FrameRounding);

    // Slider behavior
    ImRect grab_bb;
    const bool value_changed = SliderBehavior(frame_bb, id, data_type, p_data, p_min, p_max, format, power, ImGuiSliderFlags_None, &grab_bb);
    if (value_changed)
        MarkItemEdited(id);

    // Render grab
    if (grab_bb.Max.x > grab_bb.Min.x)
        window->DrawList->AddCircleFilled(ImVec2(math::clamp(grab_bb.Min.x + ((grab_bb.Max.x - grab_bb.Min.x) / 2), frame_bb.Min.x + ((grab_bb.Max.x - grab_bb.Min.x)), frame_bb.Max.x - ((grab_bb.Max.x - grab_bb.Min.x))), (grab_bb.Min.y + ((grab_bb.Max.y - grab_bb.Min.y) / 2))), (grab_bb.Max.y - grab_bb.Min.y) * (1.35f / min(c_menu::get().dpi_scale, 1.55f)), GetColorU32(it_grab->second), 40);

    // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
    char value_buf[64];
    const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format);

    if (minimum_damage && *(int*)p_data > 100)
    {
        auto value_damage = crypt_str("HP + ") + std::to_string(*(int*)p_data - 100);
        value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), "%s", value_damage.c_str());
    }

    RenderTextClipped(ImVec2(frame_bb.Max.x - CalcTextSize(value_buf).x, frame_bb.Min.y - CalcTextSize(value_buf).y - (4 * c_menu::get().dpi_scale)), frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.0f, 0.0f));

    if (label_size.x > 0.0f)
        RenderText(ImVec2(frame_bb.Min.x, frame_bb.Min.y - CalcTextSize(label).y - (4 * c_menu::get().dpi_scale)), label);

    if (g_cfg.scripts.developer_mode && ImGui::IsItemHovered())
    {
        for (auto& item : cfg_manager->items)
        {
            if (p_data == item->pointer)
            {
                ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0f, 6.0f));
                ImGui::SetTooltip(item->name.c_str());
                ImGui::PopStyleVar();
                break;
            }
        }
    }

    IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags);
    return value_changed;
}

// Add multiple sliders on 1 line for compact edition of multiple components
bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format, float power)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiContext& g = *GImGui;
    bool value_changed = false;
    BeginGroup();
    PushID(label);
    PushMultiItemsWidths(components, CalcItemWidth());
    size_t type_size = GDataTypeInfo[data_type].Size;
    for (int i = 0; i < components; i++)
    {
        PushID(i);
        if (i > 0)
            SameLine(0, g.Style.ItemInnerSpacing.x);
        value_changed |= SliderScalar("", data_type, v, v_min, v_max, false, format, power);
        PopID();
        PopItemWidth();
        v = (void*)((char*)v + type_size);
    }
    PopID();

    const char* label_end = FindRenderedTextEnd(label);
    if (label != label_end)
    {
        SameLine(0, g.Style.ItemInnerSpacing.x);
        TextEx(label, label_end);
    }

    EndGroup();
    return value_changed;
}
 
Назад
Сверху Снизу