Skip to content

Improving the problems menu #2261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

darkfated
Copy link
Contributor

  • Combined duplicate problem and error list refresh functions into a single shared RefreshList function to improve code maintainability and reduce code duplication
  • The changes improve sorting performance in ReceivedError() function by implementing a single-pass array sorting with numeric indices instead of multiple iterations. This optimization reduces memory allocations and improves efficiency when handling large numbers of error panels
  • Added menu closing functionality using the ESCAPE key. (Implementation uses input.IsKeyDown() in the Think() method since the standard OnKeyCodePressed handler doesn't capture the ESCAPE key in Garry's Mod menu system). This improves UX by allowing users to close the menu using the standard game key

@darkfated
Copy link
Contributor Author

Let me briefly explain my optimization 🙃

Both algorithms (the existing one and mine) have the same O(n log n) complexity, but my version has fewer operations and a better constant factor. At low error counts, the difference is negligible, but at scale, mine will be faster. I also use an array instead of a hash table, which is more efficient, and perform fewer sorting passes

@robotboy655 robotboy655 added the Enhancement The pull request enhances current functionality. label Apr 3, 2025
Copy link
Collaborator

@robotboy655 robotboy655 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please actually test your changes before making a Pull Request. How many times do I have to encounter PRs that do not work?

@darkfated
Copy link
Contributor Author

I made the problem menu close on ESP only in the main menu. I also rolled back the changes related to the list refresh processing function. The mistake was that I carelessly passed the table that I made a copy of in the argument and cleaned it up locally. I decided to return the old version

@darkfated darkfated requested a review from robotboy655 April 3, 2025 22:39
@darkfated
Copy link
Contributor Author

I would suggest the idea of closing the menu also by clicking in a free area of the screen

{2D1C0D69-CF46-47DB-A812-C19A829E06CD}

@darkfated
Copy link
Contributor Author

cls_background.mp4

@robotboy655
Copy link
Collaborator

You should not be removing the default close button.

@darkfated
Copy link
Contributor Author

You should not be removing the default close button.

All done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement The pull request enhances current functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants