Skip to content

Comms menu controls #6736

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 8 commits into
base: master
Choose a base branch
from

Conversation

Wielkimati
Copy link

This feature adds new controls for comms menu, allowing the user to select given commands using simple up/down/select keybinds.

I'm not familiar with C++, so I hope I'm not doing any obvious blunders here.

@Wielkimati Wielkimati requested a review from z64555 as a code owner May 28, 2025 12:08
@wookieejedi wookieejedi added enhancement A new feature or upgrade of an existing feature to add additional functionality. controls A feature or issue related to input devices or actions controlled/triggered by them labels May 28, 2025
Copy link
Member

@z64555 z64555 left a comment

Choose a reason for hiding this comment

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

Please link a video demonstrating the operation of the feature. I think I've seen it before on discord, but for accounting purposes it is good to link it here on github, as well.

Copy link
Member

@z64555 z64555 May 28, 2025

Choose a reason for hiding this comment

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

Explicit values assigned to control enums are no longer required for new control entries (old entries must still have them) and are recommended to be defined by name only. Reason: maintenance QOL.

...or at least they should be. I'm sure I added that feature in Controls6...

@@ -108,6 +108,7 @@ mmode_item MsgItems[MAX_MENU_ITEMS];
int Num_menu_items = -1; // number of items for a message menu

int First_menu_item= -1; // index of first item in the menu
int Selected_menu_item = First_menu_item; // index of selected item in the menu
Copy link
Member

Choose a reason for hiding this comment

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

What is the valid range of values for this index? Our codebase uses negative values (especially -1) in many places to signal an error code or uninitialized state. Please add this info to the line's comment doxy, and use the //!< sequence to have doxygen pick up on it.

//Check if comms menu is up
if (Player->flags & PLAYER_FLAGS_MSG_MODE)
{
//move down
Copy link
Member

Choose a reason for hiding this comment

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

Typo. This is the move up method.

@@ -108,6 +108,7 @@ mmode_item MsgItems[MAX_MENU_ITEMS];
int Num_menu_items = -1; // number of items for a message menu

int First_menu_item= -1; // index of first item in the menu
Copy link
Member

Choose a reason for hiding this comment

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

This index seems odd. Probably outside the scope of this review, but why would we need to track the first menu item? Why can we not assume the first menu item index is 0? Should this be a constant expression intead?

Copy link
Contributor

Choose a reason for hiding this comment

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

My memory is a bit fuzzy because it's been a few months but IIRC it's valid for submenus to have 0 items.

//Select the last menu item if we went outside items range, so we can loop around
else if (Selected_menu_item < 0)
{
First_menu_item = ((Num_menu_items - 1) / 10) * 10;
Copy link
Member

Choose a reason for hiding this comment

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

Caution: integer arithmetic. Possible abuse of hardcoded magic numbers. What are the assumptions made here? Please document either here or at the declaration of First_menu_item.

Copy link
Contributor

Choose a reason for hiding this comment

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

10 probably needs to be MAX_MENU_DISPLAY define is my guess.

}
}

//function that tricks hud_squadmsg_get_key() into thinking player selected a menu item with a num key press
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for the candid message and reasoning here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controls A feature or issue related to input devices or actions controlled/triggered by them enhancement A new feature or upgrade of an existing feature to add additional functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants