-
Notifications
You must be signed in to change notification settings - Fork 172
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
base: master
Are you sure you want to change the base?
Comms menu controls #6736
Conversation
…rnate communication menu control scheme
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.
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.
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.
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 |
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.
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 |
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.
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 |
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.
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?
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.
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; |
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.
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.
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.
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 |
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.
Thank you for the candid message and reasoning here.
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.