-
Notifications
You must be signed in to change notification settings - Fork 41
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
Implement units cycling #2474
Implement units cycling #2474
Conversation
Since the new Units Report was introduced in 3.1, there was no longer a way to cycle all units of a given unit type on the map. With this commit scrolling the mouse wheel on the selected unit icon in the "Unit Controls" widget, cycles through idle or sentried units of the same unit type.
This is something I was missing in Sim06. To be honest the UX is obscure, but it is similar to the way it worked in the units report pre-3.1. And it is easier than working with the advanced unit selection for this use case. |
CodeFactor is not happy, although I don't think the method it is complaining about is overly complex. Will check later. |
I had an idea to change the units view to allow for expanding the table to show rows for each unit type and you could double-click to got to the specific unit. This is a nice side idea too. I'll have a look for review. |
I can't seem to get this to work. If I select a unit on the map, hover my mouse over it and scroll the wheel, the map moves up/down. |
Screencast_20241230_102942.mp4 |
The new function names share the prefix `cycle_units`. This is an effort to reduce complexity and pet CodeFactor.
Fixed the CodeFactor warning. |
As requested by code review. No functional changes.
As requested by code review. No functional changes.
Reported by clangd.
This check is used in the logic to find the nearest unit in `view_units.cpp` and the code to cycle units in `hudwidget.cpp`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let @jwrober check that it works but I'm happy from the code perspective :)
Since the new Units Report was introduced in 3.1, there was no longer a way to cycle all units of a given unit type on the map.
With this commit scrolling the mouse wheel on the selected unit icon in the "Unit Controls" widget, cycles through idle or sentried units of the same unit type.