Skocz do zawartości

ComboBox fix [Ayyware]


HyperSonic
# CSH External VIP Project

Masz dosyć problemów z czynnikiem zaufania w CS2 lub notorycznymi banami?

Sprawdź CSH External VIP Project.


Więcej informacji  

Rekomendowane odpowiedzi

gui.cpp

void CGUI::Update()
{

    static int bWasntHolding = false;
    static int bGrabbing = false;
    static int iOffsetX = 0, iOffsetY = 0;
    //Key Array
    std::copy(keys, keys + 255, oldKeys);
    for (int x = 0; x < 255; x++)
    {
        //oldKeys[x] = oldKeys[x] & keys[x];
        keys[x] = (GetAsyncKeyState(x));
    }

    POINT mp; GetCursorPos(&mp);
    ScreenToClient(GetForegroundWindow(), &mp);
    Mouse.x = mp.x; Mouse.y = mp.y;

    RECT Screen = Render::GetViewport();

    // Window Binds
    for (auto& bind : WindowBinds)
    {
        if (GetKeyPress(bind.first))
        {
            bind.second->Toggle();
        }
    }

    // Stop dragging
    if (IsDraggingWindow && !GetKeyState(VK_LBUTTON))
    {
        IsDraggingWindow = false;
        DraggingWindow = nullptr;

    }

    // If we are in the proccess of dragging a window
    if (IsDraggingWindow && GetKeyState(VK_LBUTTON) && !GetKeyPress(VK_LBUTTON))
    {
        if (DraggingWindow)
        {
            DraggingWindow->m_x = Mouse.x - DragOffsetX;
            DraggingWindow->m_y = Mouse.y - DragOffsetY;
        }

    }


    //bWasntHolding = Input->Hovering(x, y, width, 28) && !GetAsyncKeyState(VK_LBUTTON);

    // Process some windows
    for (auto window : Windows)
    {
        if (window->m_bIsOpen)
        {
            // Used to tell the widget processing that there could be a click
            bool bCheckWidgetClicks = false;

            // If the user clicks inside the window
            if (GetKeyPress(VK_LBUTTON) || GetKeyPress(VK_RETURN))
            {
                //if (IsMouseInRegion(window->m_x, window->m_y, window->m_x + window->m_iWidth, window->m_y + window->m_iHeight))
                //{
                // Is it inside the client area?
                if (IsMouseInRegion(window->GetClientArea1()))
                {
                    // User is selecting a new tab
                    if (IsMouseInRegion(window->GetTabArea()))
                    {
                        // Loose focus on the control
                        window->IsFocusingControl = false;
                        window->FocusedControl = nullptr;

                        int iTab = 0;
                        int TabCount = window->Tabs.size();
                        if (TabCount) // If there are some tabs
                        {
                            int TabSize = (window->m_iWidth - 4 - 12) / TabCount;
                            int Dist = Mouse.x - (window->m_x + 8);
                            while (Dist > TabSize)
                            {
                                if (Dist > TabSize)
                                {
                                    iTab++;
                                    Dist -= TabSize;
                                }
                            }
                            window->SelectedTab = window->Tabs[iTab];
                        }

                    }
                    else
                        bCheckWidgetClicks = true;
                }
                else if (IsMouseInRegion(window->m_x, window->m_y, window->m_x + window->m_iWidth, window->m_y + window->m_iHeight))
                {
                    // Must be in the around the title or side of the window
                    // So we assume the user is trying to drag the window
                    IsDraggingWindow = true;

                    DraggingWindow = window;

                    DragOffsetX = Mouse.x - window->m_x;
                    DragOffsetY = Mouse.y - window->m_y;

                    // Loose focus on the control
                    window->IsFocusingControl = false;
                    window->FocusedControl = nullptr;
                }

                //else
                //{
                //    // Loose focus on the control
                //    window->IsFocusingControl = false;
                //    window->FocusedControl = nullptr;
                //}
            }


            // Controls
            if (window->SelectedTab != nullptr)
            {
                // Focused widget
                bool SkipWidget = false;
                CControl* SkipMe = nullptr;

                // this window is focusing on a widget??
                if (window->IsFocusingControl)
                {
                    if (window->FocusedControl != nullptr)
                    {
                        // We've processed it once, skip it later
                        SkipWidget = true;
                        SkipMe = window->FocusedControl;

                        POINT cAbs = window->FocusedControl->GetAbsolutePos();
                        RECT controlRect = { cAbs.x, cAbs.y, window->FocusedControl->m_iWidth, window->FocusedControl->m_iHeight };
                        window->FocusedControl->OnUpdate();

                        if (window->FocusedControl->Flag(UIFlags::UI_Clickable) && IsMouseInRegion(controlRect) && bCheckWidgetClicks)
                        {
                            window->FocusedControl->OnClick();

                            // If it gets clicked we loose focus
                            window->IsFocusingControl = false;
                            window->FocusedControl = nullptr;
                            bCheckWidgetClicks = false;
                        }
                    }
                }

                // Itterate over the rest of the control
                for (auto control : window->SelectedTab->Controls)
                {
                    if (control != nullptr)
                    {
                        if (SkipWidget && SkipMe == control)
                            continue;

                        POINT cAbs = control->GetAbsolutePos();
                        RECT controlRect = { cAbs.x, cAbs.y, control->m_iWidth, control->m_iHeight };
                        control->OnUpdate();

                        if (control->Flag(UIFlags::UI_Clickable) && IsMouseInRegion(controlRect) && bCheckWidgetClicks)
                        {
                            control->OnClick();
                            bCheckWidgetClicks = false;

                            // Change of focus
                            if (control->Flag(UIFlags::UI_Focusable))
                            {
                                window->IsFocusingControl = true;
                                window->FocusedControl = control;
                            }
                            else
                            {
                                window->IsFocusingControl = false;
                                window->FocusedControl = nullptr;
                            }

                        }
                    }
                }

                // We must have clicked whitespace
                if (bCheckWidgetClicks)
                {
                    // Loose focus on the control
                    window->IsFocusingControl = false;
                    window->FocusedControl = nullptr;
                }
            }
        }
    }
}

window.cpp

RECT CWindow::GetClientArea()
{
    RECT client;
    client.left = m_x + 8;
    client.top = m_y + 1 + 27;
    client.right = m_iWidth - 4 - 12;
    client.bottom = m_iHeight - 2 - 8 - 26 + 500;
    return client;
}

Miłego fixowania ComboBoxów ;)

Odnośnik do komentarza

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.

Gość
Dodaj odpowiedź do tematu...

×   Wklejono zawartość z formatowaniem.   Usuń formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

  Tagi

×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę. Regulamin. Polityka prywatności